def saveOrReloadSize(self,key) : if key & (QtCore.Qt.SHIFT|QtCore.Qt.CTRL) : key &= ~(QtCore.Qt.SHIFT|QtCore.Qt.CTRL) keyname = 'F%d' % ((key - qt.Qt.Key_F9) + 9) self.saveSize('_%d' % key) QtGui.QMessageBox.information(self,'Position and size', 'This configuration is saved on key %s' % keyname, QtGui.QMessageBox.Default) else: for display in self.windows: window = self.configuration.windows[str(display.name())] Qt4_GUIDisplay.restoreSizes(self.configuration,window,display,configurationSuffix = '_%d' % key,moveWindowFlag = False)
def display(self): self.windows = [] for window in self.configuration.windows_list: display = Qt4_GUIDisplay.WindowDisplayWidget(\ None, window["name"], execution_mode=True, no_border=self.no_border) self.windows.append(display) display.set_caption(window["properties"]["caption"]) display.draw_preview(window, id(display)) display.close_on_exit = window["properties"]["closeOnExit"] display.set_font_size(window["properties"]["fontSize"]) if window["properties"]["show"]: display._show = True else: display._show = False display.hide() for item in self.user_settings: if item["name"] == window["name"]: display.move(item["posx"], item["posy"]) display.resize(item["width"], item["height"]) for window in self.windows: window.append_windows_links(self.windows)
def saveOrReloadSize(self, key): if key & (QtCore.Qt.SHIFT | QtCore.Qt.CTRL): key &= ~(QtCore.Qt.SHIFT | QtCore.Qt.CTRL) keyname = 'F%d' % ((key - qt.Qt.Key_F9) + 9) self.saveSize('_%d' % key) QtGui.QMessageBox.information( self, 'Position and size', 'This configuration is saved on key %s' % keyname, QtGui.QMessageBox.Default) else: for display in self.windows: window = self.configuration.windows[str(display.name())] Qt4_GUIDisplay.restoreSizes(self.configuration, window, display, configurationSuffix='_%d' % key, moveWindowFlag=False)
def execute(self, config): # # start in execution mode # self.windows = Qt4_GUIDisplay.display(config, noBorder=self.noBorder) main_window = None if len(self.windows) > 0: main_window = self.windows[0] main_window.configuration = config QtGui.QApplication.setActiveWindow(main_window) if self.noBorder: main_window.move(0, 0) w = QtGui.QApplication.desktop().width() h = QtGui.QApplicaitoj.desktop().height() main_window.resize(QtCore.QSize(w,h)) # # make connections # widgets_dict = dict([(callable(w.objectName) and str(w.objectName()) or None, w) for w in QtGui.QApplication.allWidgets()]) def make_connections(items_list): for item in items_list: try: sender = widgets_dict[item["name"]] except KeyError: logging.getLogger().error("Could not find receiver widget %s", item["name"]) else: for connection in item["connections"]: _receiver = connection["receiver"] or connection["receiverWindow"] try: receiver = widgets_dict[_receiver] except KeyError: logging.getLogger().error("Could not find receiver widget %s", _receiver) else: try: slot = getattr(receiver, connection["slot"]) except AttributeError: logging.getLogger().error("No slot '%s' in receiver %s", connection["slot"], _receiver) else: sender.connect(sender, QtCore.SIGNAL(connection["signal"]), slot) make_connections(item["children"]) make_connections(config.windows_list) # # set run mode for every brick # BlissWidget.setRunMode(True) if self.showMaximized: main_window.showMaximized() else: main_window.show() for window in self.windows: """window._fontSizeMinusKey = QtGui.QShortcut(window) window._fontSizeMinusKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.Key_Minus) window._fontSizePlusKey = QtGui.QShortcut(window) window._fontSizePlusKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.Key_Plus) window._fontSizeAsteriskKey = QtGui.QShortcut(window) window._fontSizeAsteriskKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.Key_Asterisk) window._whatsThisKey = QtGui.QShortcut(window) window._whatsThisKey.setKey(QtCore.Qt.Key_F1) window._reloadKey = QtGui.QShortcut(window) window._reloadKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_F5) window._splitterPositionAccel = QtGui.QShortcut(window) for key in [QtCore.Qt.Key_F9, QtCore.Qt.Key_F10, QtCore.Qt.Key_F11, QtCore.Qt.Key_F12] : window._splitterPositionAccel.setKey(QtCore.Qt.SHIFT+key) window._splitterPositionAccel.setKey(QtCore.Qt.CTRL+key) window._splitterPositionAccel.setKey(key) QtCore.QObject.connect(window._splitterPositionAccel, QtCore.SIGNAL('activated()'),self.saveOrReloadSize) QtCore.QObject.connect(window._fontSizeMinusKey, QtCore.SIGNAL('activated()'), self.changeFontSize) QtCore.QObject.connect(window._whatsThisAccel, QtCore.SIGNAL('activated()'), BlissWidget.updateWhatsThis) QtCore.QObject.connect(window._reloadAccel, QtCore.SIGNAL('activated()'), self.reloadGUI)""" if window._show: window.show() if BlissWidget._menuBar: BlissWidget._menuBar.set_exp_mode(False) return main_window
def execute(self, config): """Start in execution mode""" self.windows = Qt4_GUIDisplay.display(config, no_border=self.no_border) main_window = None if len(self.windows) > 0: main_window = self.windows[0] main_window.configuration = config QtGui.QApplication.setActiveWindow(main_window) if self.no_border: main_window.move(0, 0) width = QtGui.QApplication.desktop().width() height = QtGui.QApplication.desktop().height() main_window.resize(QtCore.QSize(width, height)) # make connections widgets_dict = dict([(isinstance(w.objectName, \ collections.Callable) and str(w.objectName()) or None, w) \ for w in QtGui.QApplication.allWidgets()]) def make_connections(items_list): """Creates connections""" for item in items_list: try: sender = widgets_dict[item["name"]] except KeyError: logging.getLogger().error(\ "Could not find receiver widget %s" % \ item["name"]) else: for connection in item["connections"]: _receiver = connection["receiver"] or \ connection["receiverWindow"] try: receiver = widgets_dict[_receiver] except KeyError: logging.getLogger().error("Could not find " + \ "receiver widget %s", _receiver) else: try: slot = getattr(receiver, connection["slot"]) except AttributeError: logging.getLogger().error(\ "No slot '%s' " % connection["slot"] + \ "in receiver %s" % _receiver) else: sender.connect(sender, QtCore.SIGNAL(connection["signal"]), slot) make_connections(item["children"]) make_connections(config.windows_list) # set run mode for every brick BlissWidget.setRunMode(True) if self.show_maximized: main_window.showMaximized() else: main_window.show() for window in self.windows: if window._show: window.show() if BlissWidget._menuBar: BlissWidget._menuBar.set_exp_mode(False) return main_window
def execute(self, config): # # start in execution mode # self.windows = Qt4_GUIDisplay.display(config, noBorder=self.noBorder) main_window = None if len(self.windows) > 0: main_window = self.windows[0] main_window.configuration = config QtGui.QApplication.setActiveWindow(main_window) if self.noBorder: main_window.move(0, 0) w = QtGui.QApplication.desktop().width() h = QtGui.QApplicaitoj.desktop().height() main_window.resize(QtCore.QSize(w, h)) # # make connections # widgets_dict = dict([ (isinstance(w.objectName, collections.Callable) and str(w.objectName()) or None, w) for w in QtGui.QApplication.allWidgets() ]) def make_connections(items_list): for item in items_list: try: sender = widgets_dict[item["name"]] except KeyError: logging.getLogger().error( "Could not find receiver widget %s", item["name"]) else: for connection in item["connections"]: _receiver = connection["receiver"] or connection[ "receiverWindow"] try: receiver = widgets_dict[_receiver] except KeyError: logging.getLogger().error( "Could not find receiver widget %s", _receiver) else: try: slot = getattr(receiver, connection["slot"]) except AttributeError: logging.getLogger().error( "No slot '%s' in receiver %s", connection["slot"], _receiver) else: sender.connect( sender, QtCore.SIGNAL(connection["signal"]), slot) make_connections(item["children"]) make_connections(config.windows_list) # # set run mode for every brick # BlissWidget.setRunMode(True) if self.showMaximized: main_window.showMaximized() else: main_window.show() for window in self.windows: """window._fontSizeMinusKey = QtGui.QShortcut(window) window._fontSizeMinusKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.Key_Minus) window._fontSizePlusKey = QtGui.QShortcut(window) window._fontSizePlusKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.Key_Plus) window._fontSizeAsteriskKey = QtGui.QShortcut(window) window._fontSizeAsteriskKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.Key_Asterisk) window._whatsThisKey = QtGui.QShortcut(window) window._whatsThisKey.setKey(QtCore.Qt.Key_F1) window._reloadKey = QtGui.QShortcut(window) window._reloadKey.setKey(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_F5) window._splitterPositionAccel = QtGui.QShortcut(window) for key in [QtCore.Qt.Key_F9, QtCore.Qt.Key_F10, QtCore.Qt.Key_F11, QtCore.Qt.Key_F12] : window._splitterPositionAccel.setKey(QtCore.Qt.SHIFT+key) window._splitterPositionAccel.setKey(QtCore.Qt.CTRL+key) window._splitterPositionAccel.setKey(key) QtCore.QObject.connect(window._splitterPositionAccel, QtCore.SIGNAL('activated()'),self.saveOrReloadSize) QtCore.QObject.connect(window._fontSizeMinusKey, QtCore.SIGNAL('activated()'), self.changeFontSize) QtCore.QObject.connect(window._whatsThisAccel, QtCore.SIGNAL('activated()'), BlissWidget.updateWhatsThis) QtCore.QObject.connect(window._reloadAccel, QtCore.SIGNAL('activated()'), self.reloadGUI)""" if window._show: window.show() if BlissWidget._menuBar: BlissWidget._menuBar.set_exp_mode(False) return main_window