Skip to content

Commit

Permalink
made some improvements to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindm711 committed Jul 2, 2021
1 parent 943216b commit 1f72361
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 147 deletions.
65 changes: 30 additions & 35 deletions mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from mslib.msui import mscolab_project as mp
from mslib.msui import mscolab_admin_window as maw
from mslib.msui import mscolab_version_history as mvh
from mslib.msui import sideview, tableview, topview, linearview
# from mslib.msui import sideview, tableview, topview, linearview
from mslib.msui import socket_control as sc

from PyQt5 import QtCore, QtGui, QtWidgets
Expand Down Expand Up @@ -371,17 +371,20 @@ def __init__(self, parent=None, data_dir=None):
# hide mscolab related widgets
self.ui.usernameLabel.hide()
self.ui.userOptionsTb.hide()
self.ui.addProjectBtn.hide()
self.ui.actionAddProject.setEnabled(False)
self.hide_project_options()
self.ui.actionShareProject.setVisible(False)

# connect project options menu actions
self.ui.actionAddProject.triggered.connect(self.add_project_handler)
self.ui.actionChat.triggered.connect(self.project_options_handler)
self.ui.actionVersionHistory.triggered.connect(self.project_options_handler)
self.ui.actionManageUsers.triggered.connect(self.project_options_handler)
self.ui.actionShareProject.triggered.connect(self.project_options_handler)
self.ui.actionDeleteProject.triggered.connect(self.project_options_handler)

# connect slot for handling project options combobox
self.ui.workLocallyCheckbox.stateChanged.connect(self.handle_work_locally_toggle)
self.ui.serverOptionsCb.currentIndexChanged.connect(self.server_options_handler)

# if token is None, not authorized, else authorized
self.token = None
# int to store active pid
Expand Down Expand Up @@ -472,12 +475,8 @@ def after_login(self, emailid, url, r):
# self.icon = QtGui.QIcon()
# self.icon.addPixmap(self.pixmap, QtGui.QIcon.Normal, QtGui.QIcon.Off)
# self.userOptionsTb.setIcon(self.icon)
# show add project button here
self.ui.addProjectBtn.show()
self.ui.addProjectBtn.clicked.connect(self.add_project_handler)
# connect slot for handling project options combobox
self.ui.workLocallyCheckbox.stateChanged.connect(self.handle_work_locally_toggle)
self.ui.serverOptionsCb.currentIndexChanged.connect(self.server_options_handler)
# enable add project menu action
self.ui.actionAddProject.setEnabled(True)

# Populate open projects list
self.add_projects_to_ui()
Expand Down Expand Up @@ -597,8 +596,6 @@ def project_options_handler(self):
self.open_version_history_window()
elif self.sender() == self.ui.actionManageUsers:
self.open_admin_window()
elif self.sender() == self.ui.actionShareProject:
pass
elif self.sender() == self.ui.actionDeleteProject:
self.handle_delete_project()

Expand Down Expand Up @@ -716,14 +713,14 @@ def handle_work_locally_toggle(self):
self.user['username'], self.active_project_name,
'mscolab_project.ftml'))
self.ui.workingStatusLabel.setText(
self.ui.tr("Working On: Local File. Your changes are only available to you."
self.ui.tr("Working On: Local File.\nYour changes are only available to you."
"To save your changes with everyone, use the \"Save to Server\" button."))
self.ui.serverOptionsCb.show()
self.reload_local_wp()
else:
self.local_ftml_file = None
self.ui.workingStatusLabel.setText(
self.ui.tr("Working On: Shared File. All your changes will be shared with everyone."
self.ui.tr("Working On: Shared File.\nAll your changes will be shared with everyone."
"Turn on work locally to work on local flight track file"))
self.ui.serverOptionsCb.hide()
self.waypoints_model = None
Expand Down Expand Up @@ -906,7 +903,7 @@ def delete_project_from_list(self, p_id):
self.active_pid = None
self.access_level = None
self.active_project_name = None
self.ui.workingStatusLabel.hide()
# self.ui.workingStatusLabel.setEnabled(False)
self.force_close_view_windows()
self.close_external_windows()
self.hide_project_options()
Expand Down Expand Up @@ -969,8 +966,9 @@ def add_projects_to_ui(self):

def set_active_pid(self, item):
if self.verify_user_token():
if item.p_id == self.active_pid:
return
if not self.ui.local_active:
if item.p_id == self.active_pid:
return

# close all hanging window
self.close_external_windows()
Expand All @@ -990,10 +988,10 @@ def set_active_pid(self, item):
# set active flightpath here
self.load_wps_from_server()
# display working status
self.ui.workingStatusLabel.setText(self.ui.tr("Working On: Shared File."
self.ui.workingStatusLabel.setText(self.ui.tr("Working On: Shared File.\n"
"All your changes will be shared with everyone."
"Turn on work locally to work on local flight track file"))
self.ui.workingStatusLabel.show()
# self.ui.workingStatusLabel.show()
# enable access level specific widgets
self.show_project_options()

Expand All @@ -1014,8 +1012,8 @@ def set_active_pid(self, item):
self.logout()

def switch_to_local(self):
self.ui.local_active = True
if self.active_pid is not None:
self.ui.local_active = True
if self.verify_user_token():
# change font style for selected
font = QtGui.QFont()
Expand All @@ -1034,26 +1032,24 @@ def show_project_options(self):
self.ui.actionChat.setEnabled(False)
self.ui.actionVersionHistory.setEnabled(False)
self.ui.actionManageUsers.setEnabled(False)
self.ui.actionShareProject.setEnabled(False)
self.ui.actionDeleteProject.setEnabled(False)
self.ui.menuProjectProperties.setEnabled(False)
if self.access_level == "viewer":
self.ui.menuImportFlightTrack.setEnabled(False)
return

project_opt_list = ['Project Options']
if self.access_level in ["creator", "admin", "collaborator"]:
if self.ui.workLocallyCheckbox.isChecked():
self.ui.actionChat.setEnabled(True)
else:
self.ui.actionChat.setEnabled(True)
self.ui.actionVersionHistory.setEnabled(True)
self.ui.workLocallyCheckbox.show()
self.ui.workLocallyCheckbox.setEnabled(True)
else:
if self.version_window is not None:
self.version_window.close()
if self.chat_window is not None:
self.chat_window.close()
self.ui.workLocallyCheckbox.hide()
self.ui.workLocallyCheckbox.setEnabled(False)
self.ui.serverOptionsCb.hide()

if self.access_level in ["creator", "admin"]:
Expand All @@ -1063,22 +1059,19 @@ def show_project_options(self):
self.admin_window.close()

if self.access_level in ["creator"]:
project_opt_list.extend(['Share Project', 'Delete Project'])
self.ui.actionShareProject.setEnabled(True)
self.ui.actionDeleteProject.setEnabled(True)
self.ui.menuProjectProperties.setEnabled(True)

self.ui.menuImportFlightTrack.setEnabled(True)

def hide_project_options(self):
self.ui.actionChat.setEnabled(False)
self.ui.actionVersionHistory.setEnabled(False)
self.ui.actionManageUsers.setEnabled(False)
self.ui.actionShareProject.setEnabled(False)
self.ui.actionDeleteProject.setEnabled(False)
# self.ui.projectOptionsCb.hide()
self.ui.workingStatusLabel.hide()
self.ui.workLocallyCheckbox.hide()
self.ui.menuProjectProperties.setEnabled(False)
self.ui.workLocallyCheckbox.setEnabled(False)
self.ui.serverOptionsCb.hide()
# change working status label
self.ui.workingStatusLabel.setText(self.ui.tr("No Project Selected"))

def request_wps_from_server(self):
if self.verify_user_token():
Expand Down Expand Up @@ -1263,7 +1256,8 @@ def enable_navbar_action_buttons(self, _type, view_window):
view_window.tableWayPoints.setEnabled(True)

def logout(self):
self.switch_to_local()
self.ui.local_active = True
self.ui.menu_handler()
# delete token and show login widget-items
self.token = None
# delete active-project-id
Expand All @@ -1281,7 +1275,8 @@ def logout(self):
self.ui.usernameLabel.hide()
self.ui.userOptionsTb.hide()
self.ui.connectBtn.show()
self.ui.addProjectBtn.hide()
# self.ui.addProjectBtn.hide()
self.ui.actionAddProject.setEnabled(False)
# disconnect socket
if self.conn is not None:
self.conn.disconnect()
Expand Down
27 changes: 15 additions & 12 deletions mslib/msui/mss_pyui.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,13 @@ def menu_handler(self):
self.actionImportFlightTrackFTML.setVisible(not self.local_active)
self.actionExportFlightTrackFTML.setVisible(not self.local_active)

# enable/disable flight track menus
self.actionNewFlightTrack.setEnabled(self.local_active)
self.actionOpenFlightTrack.setEnabled(self.local_active)
self.actionActivateSelectedFlightTrack.setEnabled(self.local_active)
self.actionSaveActiveFlightTrack.setEnabled(self.local_active)
self.actionSaveActiveFlightTrackAs.setEnabled(self.local_active)
self.actionCloseSelectedFlightTrack.setEnabled(self.local_active)
# # enable/disable flight track menus
# self.actionNewFlightTrack.setEnabled(self.local_active)
# self.actionOpenFlightTrack.setEnabled(self.local_active)
# self.actionActivateSelectedFlightTrack.setEnabled(self.local_active)
# self.actionSaveActiveFlightTrack.setEnabled(self.local_active)
# self.actionSaveActiveFlightTrackAs.setEnabled(self.local_active)
# self.actionCloseSelectedFlightTrack.setEnabled(self.local_active)

def add_plugin_submenu(self, name, extension, plugin_type="Import"):
if plugin_type == "Import":
Expand Down Expand Up @@ -507,8 +507,8 @@ def create_new_flight_track(self, template=None, filename=None):
listitem = QFlightTrackListWidgetItem(waypoints_model, self.listFlightTracks)
listitem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)

# Activate new item
self.activate_flight_track(listitem)
# # Activate new item
# self.activate_flight_track(listitem)

def open_flight_track(self):
"""Slot for the 'Open Flight Track' menu entry. Opens a QFileDialog and
Expand Down Expand Up @@ -770,15 +770,16 @@ def closeEvent(self, event):
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No)

if ret == QtWidgets.QMessageBox.Yes:
# cleanup mscolab widgets
if self.mscolab.token is not None:
self.mscolab.logout()
# Table View stick around after MainWindow closes - maybe some dangling reference?
# This removes them for sure!
while self.listViews.count() > 0:
self.listViews.item(0).window.handle_force_close()
self.listViews.clear()
self.listFlightTracks.clear()
# cleanup mscolab widgets
if self.mscolab.token is not None:
self.mscolab.logout()
# close configuration editor
if self.config_editor is not None:
self.config_editor.close()
event.accept()
Expand Down Expand Up @@ -874,6 +875,8 @@ def main():
mainwindow = MSSMainWindow()
mainwindow.setStyleSheet("QListWidget { border: 1px solid grey; }")
mainwindow.create_new_flight_track()
mainwindow.listFlightTracks.setCurrentRow(0)
mainwindow.activate_selected_flight_track()
mainwindow.show()
sys.exit(application.exec_())

Expand Down
Loading

0 comments on commit 1f72361

Please sign in to comment.