def test_aboutdialog(): app = QtWidgets.QApplication(sys.argv) d = AboutDialog() d.show() app.exec_()
def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0), **kwargs): loglevel = kwargs.pop('loglevel', logging.NOTSET) _log.debug('Main window base classes initialization ...') QtWidgets.QApplication.setWindowIcon( qtsupport.geticon('GSDView.png', __name__)) super(GSDView, self).__init__(parent, flags, **kwargs) title = self.tr('GSDView Open Source Edition v. %s') % info.version self.setWindowTitle(title) self.setObjectName('gsdview-mainwin') # Dialogs _log.debug('Setting up file dialog ...') #: application global file dialog instance self.filedialog = QtWidgets.QFileDialog(self) self.filedialog.setFileMode(QtWidgets.QFileDialog.ExistingFile) self.filedialog.setViewMode(QtWidgets.QFileDialog.Detail) _log.debug('Setting up the about dialog ...') #: application global about dialog instance self.aboutdialog = AboutDialog(self) _log.debug('Setting up the preferences dialog ...') #: prefernces dialog instance self.preferencesdialog = PreferencesDialog(self, apply=self.applySettings) # Stop button _log.debug('Setting up the stop button ...') qstyle = QtWidgets.QApplication.style() icon = qstyle.standardIcon(QtWidgets.QStyle.SP_BrowserStop) #: stop button for external tools self.stopbutton = QtWidgets.QPushButton(icon, self.tr('Stop'), self) self.statusBar().addPermanentWidget(self.stopbutton) self.stopbutton.hide() # Progressbar _log.debug('Setting up the progress bar ...') #: application progress bar self.progressbar = QtWidgets.QProgressBar(self) self.progressbar.setTextVisible(True) self.statusBar().addPermanentWidget(self.progressbar) self.progressbar.hide() # Miscellanea _log.debug('Miscellanea setup ...') #: cache directory path self.cachedir = None # GraphicsViewMonitor and mouse manager _log.debug('Setting up "monitor" components ...') #: graphics scenes/views monitor self.monitor = graphicsview.GraphicsViewMonitor() #: mouse manager for graphics scenes/views self.mousemanager = mousemanager.MouseManager(self) self.mousemanager.mode = 'hand' # Plugin Manager #: backends list self.backends = [] #: plugin manager instance self.pluginmanager = pluginmanager.PluginManager(self, SYSPLUGINSDIR) self.preferencesdialog.addPage( pluginmanager.PluginManagerGui(self.pluginmanager, self), qtsupport.geticon('plugin.svg', __name__), label='Plugins') # Settings if not os.path.isdir(USERCONFIGDIR): os.makedirs(USERCONFIGDIR) # @TODO: fix filename _log.debug('Read application settings ...') #self.settings = QtCore.QSettings('gsdview-soft', 'gsdview', self) #self.settings = QtCore.QSettings(QtCore.QSettings.IniFormat, # QtCore.QSettings.UserScope, # 'gsdview', 'gsdview', self) cfgfile = os.path.join(USERCONFIGDIR, 'gsdview.ini') _log.info('Configuration file: "%s".', cfgfile) #: application settings self.settings = QtCore.QSettings(cfgfile, QtCore.QSettings.IniFormat, self) # Setup the log system and the external tools controller _log.debug('Complete logging setup...') # @TODO: logevel could be set from command line #: application standard logger self.logger = self.setupLogging(loglevel=loglevel) _log.debug('Setting up external tool controller ...') #: external tool controller self.controller = self.setupController(self.logger, self.statusBar(), self.progressbar) # Actions _log.debug('Setting up actions ...') #: actions associated to file menu self.fileActions = None #: settings actions self.settingsActions = None #: help actions self.helpActions = None self.setupActions() # File menu end toolbar self._addMenuFromActions(self.fileActions, self.tr('&File')) self._addToolBarFromActions(self.fileActions, self.tr('File toolbar')) # Image menu and toolbar self.imagemenu = self._addMenuFromActions(self.mousemanager.actions, self.tr('&Image')) self._addToolBarFromActions(self.mousemanager.actions, self.tr('Mouse toolbar')) # Tools menu self.toolsmenu = QtWidgets.QMenu(self.tr('&Tools'), self) self.menuBar().addMenu(self.toolsmenu) self.toolsmenu.hide() # Setup plugins _log.debug(self.tr('Setup plugins ...')) self.setupPlugins() # Settings menu end toolbar _log.debug(self.tr('Settings menu setup ...')) menu = self._addMenuFromActions(self.settingsActions, self.tr('&Settings')) self._addToolBarFromActions(self.settingsActions, self.tr('Settings toolbar')) #: settings sub-menu self.settings_submenu = QtWidgets.QMenu( self.tr('&View'), aboutToShow=self.updateSettingsMenu) menu.addSeparator() menu.addMenu(self.settings_submenu) _log.debug(self.tr('Window menu setup ...')) self.menuBar().addMenu(self.windowmenu) # Help menu end toolbar _log.debug('Help menu setup ...') self._addMenuFromActions(self.helpActions, self.tr('&Help')) self._addToolBarFromActions(self.helpActions, self.tr('Help toolbar')) # @NOTE: the window state setup must happen after the plugins loading _log.info('Load settings ...') self.loadSettings(loglevel=loglevel) # @TODO: pass cachedir self.treeview.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.treeview.customContextMenuRequested.connect(self.itemContextMenu) self.statusBar().showMessage('Ready')