commotion_client.GUI.main_window.MainWindow Class Reference
Inheritance diagram for commotion_client.GUI.main_window.MainWindow:

Public Member Functions

def __init__
 
def toggle_menu_bar
 
def setup_menu_bar
 
def init_crash_reporter
 
def set_viewport
 
def apply_viewport
 
def init_viewport_signals
 
def change_viewport
 
def init_toolbar
 
def purge
 
def closeEvent
 
def exitEvent
 
def cleanup
 
def bring_front
 
def load_settings
 
def save_settings
 
def crash
 
def is_dirty
 

Public Attributes

 log
 
 translate
 
 ext_manager
 
 viewport
 
 exitOnClose
 
 remove_on_close
 
 menu_bar
 
 menu_dock
 
 crash_report
 
 central_widget
 
 toolbar
 
 scroll_area
 
 next_extension
 

Static Public Attributes

tuple clean_up = QtCore.pyqtSignal()
 
tuple app_message = QtCore.pyqtSignal(str)
 

Detailed Description

The central widget for the commotion client. This widget initalizes all other sub-widgets and extensions as well as defines the paramiters of the main GUI container.

Member Function Documentation

def commotion_client.GUI.main_window.MainWindow.apply_viewport (   self,
  viewport,
  toolbar = None 
)
Apply current viewport to the central widget and set up proper signal's for communication. 

References commotion_client.GUI.main_window.MainWindow.central_widget, commotion_client.GUI.main_window.MainWindow.init_toolbar(), commotion_client.GUI.main_window.MainWindow.init_viewport_signals(), commotion_client.GUI.main_window.MainWindow.scroll_area, commotion_client.GUI.main_window.MainWindow.toolbar, commotion_client.GUI.extension_toolbar.ExtensionToolBar.viewport, commotion_client.GUI.main_window.MainWindow.viewport, and commotion_client.GUI.extension_toolbar.MenuItem.viewport.

Referenced by commotion_client.GUI.main_window.MainWindow.set_viewport().

114  def apply_viewport(self, viewport, toolbar=None):
115  """Apply current viewport to the central widget and set up proper signal's for communication. """
116  #Create central widget (replaced due to splitter)
117  # self.central_widget = QtGui.QWidget(self)
118  self.central_widget = QtGui.QSplitter(QtCore.Qt.Vertical, self)
119  self.viewport = viewport(self.central_widget)
120  if not toolbar:
121  toolbar = False
122  self.toolbar = self.init_toolbar(toolbar)
123 
124  #Set up central layout (Replaced due to splitter)
125  #self.central_layout = QtGui.QVBoxLayout(self.central_widget)
126 
127  self.scroll_area = QtGui.QScrollArea(self.central_widget)
128  self.scroll_area.setWidgetResizable(True)
129  self.scroll_area.setWidget(self.viewport)
130 
131  #add scroll area to central layout (replaced due to splitter)
132  #self.central_layout.addWidget(self.scroll_area)
133 
134  self.central_widget.addWidget(self.scroll_area)
135  self.central_widget.addWidget(self.toolbar)
136 
137  self.setCentralWidget(self.central_widget)
138  self.init_viewport_signals()
139  self.central_widget.show()
140  self.viewport.show()
def init_toolbar
Definition: main_window.py:162
viewport
Definition: main_window.py:50
central_widget
Definition: main_window.py:117
scroll_area
Definition: main_window.py:126
def init_viewport_signals
Definition: main_window.py:141
def apply_viewport
Definition: main_window.py:113
toolbar
Definition: main_window.py:121
def commotion_client.GUI.main_window.MainWindow.bring_front (   self)
Brings the main window to the front of the screen.
210  def bring_front(self):
211  """
212  Brings the main window to the front of the screen.
213  """
214  self.show()
215  self.raise_()
def bring_front
Definition: main_window.py:209
def commotion_client.GUI.main_window.MainWindow.change_viewport (   self,
  viewport 
)
Prepare next viewport for loading and start loading process when ready.

References commotion_client.GUI.main_window.MainWindow.next_extension, commotion_client.GUI.main_window.MainWindow.set_viewport(), commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, and commotion_client.commotion_client.CommotionClientApplication.translate.

153  def change_viewport(self, viewport):
154  """Prepare next viewport for loading and start loading process when ready."""
155  self.log.debug(self.translate("logs", "Request to change viewport received."))
156  self.next_extension = viewport
157  if self.viewport.is_dirty:
158  self.viewport.on_stop.connect(self.set_viewport)
159  self.clean_up.emit()
160  else:
161  self.set_viewport()
next_extension
Definition: main_window.py:155
def change_viewport
Definition: main_window.py:152
def set_viewport
Definition: main_window.py:105
translate
Definition: main_window.py:44
def commotion_client.GUI.main_window.MainWindow.closeEvent (   self,
  event 
)
Captures the close event for the main window. When called from exitEvent removes a trayIcon and accepts its demise. When called otherwise will simply hide the main window and ignore the event.

References commotion_client.GUI.main_window.MainWindow.exitOnClose, commotion_client.GUI.main_window.MainWindow.remove_on_close, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, and commotion_client.commotion_client.CommotionClientApplication.translate.

178  def closeEvent(self, event):
179  """
180  Captures the close event for the main window. When called from exitEvent removes a trayIcon and accepts its demise. When called otherwise will simply hide the main window and ignore the event.
181  """
182 
183  if self.exitOnClose:
184  self.log.debug(self.translate("logs", "Application has received a EXIT close event and will shutdown completely."))
185  event.accept()
186  elif self.remove_on_close:
187  self.log.debug(self.translate("logs", "Application has received a GUI closing close event and will close its main window."))
188  self.deleteLater()
189  event.accept()
190  else:
191  self.log.debug(self.translate("logs", "Application has received a non-exit close event and will hide its main window."))
192  self.hide()
193  event.setAccepted(True)
194  event.ignore()
def closeEvent
Definition: main_window.py:177
exitOnClose
Definition: main_window.py:62
remove_on_close
Definition: main_window.py:63
translate
Definition: main_window.py:44
def commotion_client.GUI.main_window.MainWindow.crash (   self,
  crash_type 
)
Emits a closing signal to allow other windows who need to clean up to clean up and then exits the application.

References commotion_client.GUI.main_window.MainWindow.exitOnClose.

Referenced by commotion_client.GUI.main_window.MainWindow.init_crash_reporter().

254  def crash(self, crash_type):
255  """
256  Emits a closing signal to allow other windows who need to clean up to clean up and then exits the application.
257  """
258  self.clean_up.emit() #send signal for others to clean up if they need to
259  if crash_type == "restart":
260  self.app_message.emit("restart")
261  else:
262  self.exitOnClose = True
263  self.close()
exitOnClose
Definition: main_window.py:62
def crash
Definition: main_window.py:253
def commotion_client.GUI.main_window.MainWindow.exitEvent (   self)
Closes and exits the entire commotion program.

References commotion_client.GUI.main_window.MainWindow.cleanup(), commotion_client.GUI.main_window.MainWindow.exitOnClose, commotion_client.extensions.config_editor.main.ViewPort.is_dirty(), commotion_client.GUI.main_window.MainWindow.is_dirty(), and commotion_client.GUI.main_window.MainWindow.save_settings().

196  def exitEvent(self):
197  """
198  Closes and exits the entire commotion program.
199  """
200  self.cleanup()
201  self.exitOnClose = True
202  self.close()
exitOnClose
Definition: main_window.py:62
def cleanup
Definition: main_window.py:203
def exitEvent
Definition: main_window.py:195
def commotion_client.GUI.main_window.MainWindow.init_crash_reporter (   self)
 

References commotion_client.GUI.crash_report.CrashReport.crash, commotion_client.GUI.main_window.MainWindow.crash(), commotion_client.GUI.main_window.MainWindow.crash_report, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, and commotion_client.commotion_client.CommotionClientApplication.translate.

94 
95  def init_crash_reporter(self):
96  """ """
97  try:
98  self.crash_report = CrashReport()
99  except Exception as _excp:
100  self.log.critical(self.translate("logs", "Failed to load crash reporter. Ironically, this means that the application must be halted."))
101  self.log.exception(_excp)
102  raise
103  else:
104  self.crash_report.crash.connect(self.crash)
Definition: crash_report.py:28
def crash
Definition: main_window.py:253
crash_report
Definition: main_window.py:97
def init_crash_reporter
Definition: main_window.py:94
translate
Definition: main_window.py:44
def commotion_client.GUI.main_window.MainWindow.init_toolbar (   self,
  ext_toolbar 
)
 

References commotion_client.GUI.main_window.MainWindow.central_widget, commotion_client.GUI.extension_toolbar.ExtensionToolBar.viewport, commotion_client.GUI.main_window.MainWindow.viewport, and commotion_client.GUI.extension_toolbar.MenuItem.viewport.

Referenced by commotion_client.GUI.main_window.MainWindow.apply_viewport().

163  def init_toolbar(self, ext_toolbar):
164  """ """
165  toolbar = toolbar_builder.ToolBar(self.central_widget, self.viewport, ext_toolbar,)
166  return toolbar
167 
def init_toolbar
Definition: main_window.py:162
viewport
Definition: main_window.py:50
Definition: toolbar_builder.py:24
central_widget
Definition: main_window.py:117
def commotion_client.GUI.main_window.MainWindow.is_dirty (   self)
Get the current state of the main window

References commotion_client.GUI.main_window.MainWindow._dirty, commotion_client.GUI.extension_toolbar.ExtensionToolBar._dirty, commotion_client.extensions.config_editor.main.ViewPort._dirty, and commotion_client.GUI.extension_toolbar.MenuItem._dirty.

Referenced by commotion_client.GUI.main_window.MainWindow.exitEvent().

266  def is_dirty(self):
267  """Get the current state of the main window"""
268  return self._dirty
269 
270 
_dirty
Definition: main_window.py:42
def is_dirty
Definition: main_window.py:265
def commotion_client.GUI.main_window.MainWindow.load_settings (   self)
Loads window geometry from saved settings and sets window to those settings.

References commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, and commotion_client.commotion_client.CommotionClientApplication.translate.

Referenced by commotion_client.GUI.toolbar.ToolBar.init_settings(), and commotion_client.GUI.toolbar_builder.ToolBar.init_settings().

217  def load_settings(self):
218  """
219  Loads window geometry from saved settings and sets window to those settings.
220  """
221  defaults = {
222  #QRect(posX, posY, width, height)
223  "geometry":QtCore.QRect(300, 300, 640, 480), #TODO set sane defaults and catalogue in HIG
224  }
225 
226  _settings = QtCore.QSettings()
227  _settings.beginGroup("MainWindow")
228 
229  #Load settings from saved, or use defaults
230  geometry = _settings.value("geometry", defaults['geometry'])
231  if geometry.isNull() == True:
232  _error = self.translate("logs", "Could not load window geometry from settings file or defaults.")
233  self.log.critical(_error)
234  raise EnvironmentError(_error)
235  _settings.endGroup()
236  self.setGeometry(geometry)
def load_settings
Definition: main_window.py:216
translate
Definition: main_window.py:44
def commotion_client.GUI.main_window.MainWindow.purge (   self)
Closes the menu and sets its data up for immediate removal.

References commotion_client.GUI.main_window.MainWindow.cleanup().

169  def purge(self):
170  """
171  Closes the menu and sets its data up for immediate removal.
172  """
173  self.cleanup()
174  self.main.remove_on_close = True
175  self.close()
176 
def purge
Definition: main_window.py:168
def cleanup
Definition: main_window.py:203
def commotion_client.GUI.main_window.MainWindow.save_settings (   self)
Saves current window geometry

References commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, and commotion_client.commotion_client.CommotionClientApplication.translate.

Referenced by commotion_client.GUI.main_window.MainWindow.exitEvent(), and commotion_client.utils.extension_manager.ExtensionManager.install_loaded().

238  def save_settings(self):
239  """
240  Saves current window geometry
241  """
242 
243  _settings = QtCore.QSettings()
244  _settings.beginGroup("MainWindow")
245  #Save settings
246  try:
247  _settings.setValue("geometry", self.geometry())
248  except Exception as _excp:
249  self.log.warn(self.translate("logs", "Could not save window geometry. Will continue without saving window geometry."))
250  self.log.exception(_excp)
251  _settings.endGroup()
252 
def save_settings
Definition: main_window.py:237
translate
Definition: main_window.py:44
def commotion_client.GUI.main_window.MainWindow.set_viewport (   self)
Load and set viewport to next viewport and load viewport 

References commotion_client.GUI.main_window.MainWindow.apply_viewport(), and commotion_client.GUI.main_window.MainWindow.next_extension.

Referenced by commotion_client.GUI.main_window.MainWindow.change_viewport().

106  def set_viewport(self):
107  """Load and set viewport to next viewport and load viewport """
108  self.log.info(self.next_extension)
109  next_view = self.next_extension
110  ext_viewport = self.ext_manager.load_user_interface(str(next_view), "main")
111  ext_toolbar = self.ext_manager.load_user_interface(str(next_view), "toolbar")
112  self.apply_viewport(ext_viewport, ext_toolbar)
next_extension
Definition: main_window.py:155
def apply_viewport
Definition: main_window.py:113
def set_viewport
Definition: main_window.py:105
def commotion_client.GUI.main_window.MainWindow.setup_menu_bar (   self)
Set up menu bar. 
75 
76  def setup_menu_bar(self):
77  """ Set up menu bar. """
78  self.menu_bar = MenuBar(self)
79  #Create dock for menu-bar TEST
80  self.menu_dock = QtGui.QDockWidget(self)
81  #turn off title bar
82  #TODO create a vertical title bar that is the "dock handle"
83  self.menu_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
84  #Set Name of dock so we can hide and show it.
85  self.menu_dock.setObjectName("MenuBarDock")
86  #force bar to the left side
87  self.menu_dock.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea)
88  #apply menu bar to dock and dock to the main window
89  self.menu_dock.setWidget(self.menu_bar)
90  self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.menu_dock)
91 
92  #Create slot to monitor when menu-bar wants the main window to change the main-viewport
93  self.menu_bar.viewport_requested.connect(self.change_viewport)
menu_dock
Definition: main_window.py:79
def change_viewport
Definition: main_window.py:152
menu_bar
Definition: main_window.py:77
Definition: menu_bar.py:26
def setup_menu_bar
Definition: main_window.py:75

The documentation for this class was generated from the following file: