Ejemplo n.º 1
0
 def do(self):
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(Meta.documentationUrl()))
Ejemplo n.º 2
0
    def __init__(self):  # pylint: disable=R0915
        super().__init__()

        self._manager = QtNetwork.QNetworkAccessManager(self)

        self._workspace = Workspace()
        self.setCentralWidget(
            WorkspaceView(self, mainWindow=self, workspace=self._workspace))
        self._workspace.load()
        self._devenum = DeviceEnumerator()

        self.setWindowTitle(
            _('{appName} v{appVersion}').format(appName=Meta.appName(),
                                                appVersion=str(
                                                    Meta.appVersion())))
        self.statusBar()

        filemenu = QtWidgets.QMenu(_('File'), self)
        filemenu.addAction(
            uicommands.ExportConfigurationUICommand(
                self, mainWindow=self, container=self.centralWidget()))
        filemenu.addAction(
            uicommands.ImportConfigurationUICommand(self,
                                                    mainWindow=self,
                                                    workspace=self._workspace))
        filemenu.addAction(
            uicommands.ExportBytecodeUICommand(self,
                                               mainWindow=self,
                                               workspace=self._workspace,
                                               container=self.centralWidget()))
        self.menuBar().addMenu(filemenu)

        editmenu = QtWidgets.QMenu(_('Edit'), self)
        editmenu.addAction(uicommands.UndoUICommand(self, mainWindow=self))
        editmenu.addAction(uicommands.RedoUICommand(self, mainWindow=self))
        editmenu.addAction(
            uicommands.ShowSettingsDialogUICommand(self, mainWindow=self))
        self.menuBar().addMenu(editmenu)

        devmenu = uicommands.DeviceMenu(self,
                                        mainWindow=self,
                                        workspace=self._workspace,
                                        enumerator=self._devenum)
        self.menuBar().addMenu(devmenu)

        uploadmenu = uicommands.UploadMenu(self,
                                           mainWindow=self,
                                           container=self.centralWidget(),
                                           workspace=self._workspace,
                                           enumerator=self._devenum)
        self.menuBar().addMenu(uploadmenu)

        helpmenu = QtWidgets.QMenu(_('Help'), self)
        helpmenu.addAction(
            uicommands.ShowAboutDialogUICommand(self, mainWindow=self))
        helpmenu.addAction(uicommands.OpenDocsUICommand(self, mainWindow=self))
        self.menuBar().addMenu(helpmenu)

        with Settings().grouped('UIState') as settings:
            if settings.contains('WindowGeometry'):
                self.restoreGeometry(settings.value('WindowGeometry'))
            else:
                self.resize(1280, 600)
            self.centralWidget().loadState(settings)

        self.raise_()
        self.show()

        settings = Settings()
        if settings.isFirstVersionLaunch():
            QtGui.QDesktopServices.openUrl(QtCore.QUrl(
                Meta.documentationUrl()))

        self.check()

        def gotChangelog(downloader):
            self._changelogDl = None
            try:
                _unused, text = downloader.result()
            except AbortedError:
                self.logger.info('Changelog download aborted')
                return
            except (DownloadError, SSLError) as exc:
                self.logger.exception('Cannot download changelog: %s', exc)
                return

            changelog = Changelog(text)
            if changelog.changesSince(Meta.appVersion()):
                win = ChangelogView(self, changelog)
                win.show()
                win.raise_()

        self._changelogDl = StringDownloader(self,
                                             self.manager(),
                                             callback=gotChangelog)
        self._changelogDl.get(Meta.changelogUrl())