Skip to content

Commit

Permalink
Improve tutorials (#2540)
Browse files Browse the repository at this point in the history
* join for recording

* fixes #2539

* spelling
  • Loading branch information
ReimarBauer authored Sep 30, 2024
1 parent 22aa853 commit b39536e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 30 deletions.
3 changes: 2 additions & 1 deletion mslib/msui/linearview.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ class MSUILinearViewWindow(MSUIMplViewWindow, ui.Ui_LinearWindow):
"""
name = "Linear View"

def __init__(self, parent=None, model=None, _id=None):
def __init__(self, parent=None, model=None, _id=None, tutorial_mode=False):
"""
Set up user interface, connect signal/slots.
"""
super().__init__(parent, model, _id)
self.settings_tag = "linearview"
self.tutorial_mode = tutorial_mode

self.setupUi(self)
self.setWindowIcon(QtGui.QIcon(icons('64x64')))
Expand Down
8 changes: 4 additions & 4 deletions mslib/msui/msui_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,23 +920,23 @@ def create_view(self, _type, model):
view_window = topview.MSUITopViewWindow(mainwindow=self, model=model,
active_flighttrack=self.active_flight_track,
mscolab_server_url=self.mscolab.mscolab_server_url,
token=self.mscolab.token)
token=self.mscolab.token, tutorial_mode=self.tutorial_mode)
view_window.mpl.resize(layout['topview'][0], layout['topview'][1])
if layout["immutable"]:
view_window.mpl.setFixedSize(layout['topview'][0], layout['topview'][1])
elif _type == "sideview":
# Side view.
view_window = sideview.MSUISideViewWindow(model=model)
view_window = sideview.MSUISideViewWindow(model=model, tutorial_mode=self.tutorial_mode)
view_window.mpl.resize(layout['sideview'][0], layout['sideview'][1])
if layout["immutable"]:
view_window.mpl.setFixedSize(layout['sideview'][0], layout['sideview'][1])
elif _type == "tableview":
# Table view.
view_window = tableview.MSUITableViewWindow(model=model)
view_window = tableview.MSUITableViewWindow(model=model, tutorial_mode=self.tutorial_mode)
view_window.centralwidget.resize(layout['tableview'][0], layout['tableview'][1])
elif _type == "linearview":
# Linear view.
view_window = linearview.MSUILinearViewWindow(model=model)
view_window = linearview.MSUILinearViewWindow(model=model, tutorial_mode=self.tutorial_mode)
view_window.mpl.resize(layout['linearview'][0], layout['linearview'][1])
if layout["immutable"]:
view_window.mpl.setFixedSize(layout['linearview'][0], layout['linearview'][1])
Expand Down
3 changes: 2 additions & 1 deletion mslib/msui/sideview.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ class MSUISideViewWindow(MSUIMplViewWindow, ui.Ui_SideViewWindow):
"""
name = "Side View"

def __init__(self, parent=None, model=None, _id=None):
def __init__(self, parent=None, model=None, _id=None, tutorial_mode=False):
"""
Set up user interface, connect signal/slots.
"""
super().__init__(parent, model, _id)
self.tutorial_mode = tutorial_mode
self.setupUi(self)
self.setWindowIcon(QtGui.QIcon(icons('64x64')))
self.settings_tag = "sideview"
Expand Down
4 changes: 2 additions & 2 deletions mslib/msui/tableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class MSUITableViewWindow(MSUIViewWindow, ui.Ui_TableViewWindow):

name = "Table View"

def __init__(self, parent=None, model=None, _id=None):
def __init__(self, parent=None, model=None, _id=None, tutorial_mode=False):
"""
"""
super().__init__(parent, model, _id)

self.tutorial_mode = tutorial_mode
self.setupUi(self)
self.setWindowIcon(QtGui.QIcon(icons('64x64')))
self.settings_tag = "tableview"
Expand Down
3 changes: 2 additions & 1 deletion mslib/msui/topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ class MSUITopViewWindow(MSUIMplViewWindow, ui.Ui_TopViewWindow):
signal_render_new_permission = QtCore.pyqtSignal(int, str)

def __init__(self, parent=None, mainwindow=None, model=None, _id=None,
active_flighttrack=None, mscolab_server_url=None, token=None):
active_flighttrack=None, mscolab_server_url=None, token=None, tutorial_mode=False):
"""
Set up user interface, connect signal/slots.
"""
super().__init__(parent, model, _id)
logging.debug(_id)
self.settings_tag = "topview"
self.tutorial_mode = tutorial_mode
self.mainwindow_signal_login_mscolab = mainwindow.signal_login_mscolab
self.mainwindow_signal_logout_mscolab = mainwindow.signal_logout_mscolab
self.mainwindow_signal_listFlighttrack_doubleClicked = mainwindow.signal_listFlighttrack_doubleClicked
Expand Down
48 changes: 34 additions & 14 deletions mslib/msui/viewwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,42 @@ def disable_navbar_action_buttons(self):
self.tableWayPoints.setEnabled(False)

def changeEvent(self, event):
top_left = self.mapToGlobal(QtCore.QPoint(0, 0))
if top_left.x() != 0:
os_screen_region = (top_left.x(), top_left.y(), self.width(), self.height())
settings = {'os_screen_region': os_screen_region}
# we have to save this to reuse it by the tutorials
save_settings_qsettings(self.settings_tag, settings)
QtWidgets.QWidget.changeEvent(self, event)
"""
Change event method
This method is called when a change event is triggered for the linearview, tableview, topview, sideview widget.
It is an overridden method of the QWidget class.
Parameters:
:event: The QEvent object representing the change event.
"""
if self.tutorial_mode:
top_left = self.mapToGlobal(QtCore.QPoint(0, 0))
if top_left.x() != 0:
os_screen_region = (top_left.x(), top_left.y(), self.width(), self.height())
settings = {'os_screen_region': os_screen_region}
# we have to save this to reuse it by the tutorials
save_settings_qsettings(self.settings_tag, settings)
QtWidgets.QWidget.changeEvent(self, event)

def moveEvent(self, event):
top_left = self.mapToGlobal(QtCore.QPoint(0, 0))
if top_left.x() != 0:
os_screen_region = (top_left.x(), top_left.y(), self.width(), self.height())
settings = {'os_screen_region': os_screen_region}
# we have to save this to reuse it by the tutorials
save_settings_qsettings(self.settings_tag, settings)
QtWidgets.QWidget.moveEvent(self, event)
"""
Move event method
This method is called when a move event is triggered for the linearview, tableview, topview, sideview widget.
It is an overridden method of the QWidget class.
Parameters:
:event: The QEvent object representing the move event.
"""
if self.tutorial_mode:
top_left = self.mapToGlobal(QtCore.QPoint(0, 0))
if top_left.x() != 0:
os_screen_region = (top_left.x(), top_left.y(), self.width(), self.height())
settings = {'os_screen_region': os_screen_region}
# we have to save this to reuse it by the tutorials
save_settings_qsettings(self.settings_tag, settings)
QtWidgets.QWidget.moveEvent(self, event)


class MSUIMplViewWindow(MSUIViewWindow):
Expand Down
11 changes: 4 additions & 7 deletions tutorials/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,10 @@ def start(target=None, duration=120, dry_run=False, mscolab=False):
p1.start()
p2.start()

# unclear for what the join was needed
# p2.join()
# p1.join()
# if not dry_run:
# p3.join()
# if mscolab:
# p4.join()
# recording process needs to become joined
if not dry_run:
p3.join()

print("\n\nINFO : Automation Completes Successfully!")

# pag.press('q') # In some cases, recording windows does not closes. So it needs to ne there.
Expand Down

0 comments on commit b39536e

Please sign in to comment.