def show_about(self): message = '<h2>{} {}</h2>'.format(QApplication.applicationName(), QApplication.applicationVersion()) message += '<h3>A digital image forensic toolkit</h3>' message += '<p>author: <a href="{}">{}</a></p>'.format( QApplication.organizationDomain(), QApplication.organizationName()) message += '<p>source: <a href="https://github.com/GuidoBartoli/sherloq">GitHub repository</a></p>' QMessageBox.about(self, self.tr('About'), message)
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) backAction.triggered.connect(self.tbackward) homeAction.triggered.connect(self.thome) self.textBrowser.sourceChanged.connect(self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
def __init__(self, parent=None): super().__init__(parent) logo = QSvgWidget() logo.load(":/icons/apps/22/tabulator.svg") name = QLabel( self.tr( "<strong style=\"font-size:large;\">{0}</strong> v{1}").format( QApplication.applicationName(), QApplication.applicationVersion())) description = QLabel( self. tr("An editor tool for documents with character-separated values")) labels = QVBoxLayout() labels.addWidget(name) labels.addWidget(description) # Main layout self._layout = QHBoxLayout(self) self._layout.addWidget(logo) self._layout.addLayout(labels) # Set logo size height = name.sizeHint().height() + labels.layout().spacing( ) + description.sizeHint().height() logo.setFixedSize(height, height)
def __init__(self, parent=None): super().__init__(parent) self.setMinimumSize(480, 320) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowTitle( self.tr("About {0}").format(QApplication.applicationName())) # Title box titleBox = DialogTitleBox() # Content aboutPage = ColophonAboutPage() aboutPage.setZeroMargins() # Button box buttonBox = QDialogButtonBox(QDialogButtonBox.Close) buttonBox.rejected.connect(self.close) # Main layout layout = QVBoxLayout(self) layout.addWidget(titleBox) layout.addWidget(aboutPage) layout.addWidget(buttonBox)
def load(self, fileName): image = QImage(fileName) if image.isNull(): QMessageBox.information(self, QApplication.applicationName(), "Cannot load " + fileName) self.setWindowTitle("Image viewer") self.setPixmap(QPixmap()) self.imageLabel.setPixmap(QPixmap.fromImage(image)) self.setWindowTitle(fileName)
def __init__(self, parent=None): super().__init__(parent) textBox = QTextBrowser() textBox.setFrameStyle(QFrame.NoFrame) textBox.setStyleSheet("background-color:transparent;") textBox.setOpenExternalLinks(True) textBox.setHtml(self.tr("<html><body>" "<p>{0} is an open source editor tool written in Qt for Python and designed for easy creation and editing of documents with character-separated values.</p>" "<p>Copyright © 2020-2021 <a href=\"{1}\" title=\"Visit organization's homepage\">{2}</a>.</p>" "<p>This application is licensed under the terms of the <a href=\"https://www.gnu.org/licenses/gpl-3.0.en.html\" title=\"Visit license's homepage\">GNU General Public License, version 3</a>.</p>" "</body></html>").format(QApplication.applicationName(), QApplication.organizationDomain(), QApplication.organizationName())) # Main layout self._layout = QVBoxLayout(self) self._layout.addWidget(textBox)
def load_file(self): self.filename, basename, self.image = load_image(self) if self.filename is None: return self.findChild(ToolTree, 'tree_widget').setEnabled(True) self.findChild(QAction, 'prev_action').setEnabled(True) self.findChild(QAction, 'next_action').setEnabled(True) self.findChild(QAction, 'tile_action').setEnabled(True) self.findChild(QAction, 'cascade_action').setEnabled(True) self.findChild(QAction, 'close_action').setEnabled(True) self.findChild(QAction, 'tabbed_action').setEnabled(True) self.setWindowTitle('[{}] - {} {}'.format( basename, QApplication.applicationName(), QApplication.applicationVersion())) self.show_message(self.tr('Image "{}" successfully loaded'.format(basename))) # FIXME: disable_bold della chiusura viene chiamato DOPO open_tool e nell'albero la voce NON diventa neretto self.mdi_area.closeAllSubWindows() self.open_tool(self.tree_widget.topLevelItem(0).child(0), None)
def __init__(self, parent=None): super().__init__(parent) textBox = QTextBrowser() textBox.setFrameStyle(QFrame.NoFrame) textBox.setStyleSheet("background-color:transparent;") textBox.setOpenExternalLinks(True) textBox.setHtml(self.tr("<html><body>" "<p>{0} is free software: you can redistribute it and/or modify it under the terms of the " "GNU General Public License as published by the Free Software Foundation, either version 3 of the License, " "or (at your option) any later version.</p>" "<p>{0} is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; " "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " "See the GNU General Public License for more details.</p>" "<p>You should have received a copy of the GNU General Public License along with {0}. " "If not, see <a href=\"https://www.gnu.org/licenses/\" title=\"Visit license's homepage\">https://www.gnu.org/licenses/</a>.</p>" "</body></html>").format(QApplication.applicationName())) # Main layout self._layout = QVBoxLayout(self) self._layout.addWidget(textBox)
def initialize(self, filename, basename, image): self.filename = filename self.image = image self.findChild(ToolTree, 'tree_widget').setEnabled(True) self.findChild(QAction, 'prev_action').setEnabled(True) self.findChild(QAction, 'next_action').setEnabled(True) self.findChild(QAction, 'tile_action').setEnabled(True) self.findChild(QAction, 'cascade_action').setEnabled(True) self.findChild(QAction, 'close_action').setEnabled(True) self.findChild(QAction, 'tabbed_action').setEnabled(True) self.setWindowTitle('({}) - {} {}'.format( basename, QApplication.applicationName(), QApplication.applicationVersion())) if filename not in self.recent_files: self.recent_files.insert(0, filename) if len(self.recent_files) > self.max_recent: self.recent_files = self.recent_files[:self.max_recent] self.update_recent() self.show_message(self.tr('Image "{}" successfully loaded'.format(basename))) # FIXME: disable_bold della chiusura viene chiamato DOPO open_tool e nell'albero la voce NON diventa neretto self.mdi_area.closeAllSubWindows() self.open_tool(self.tree_widget.topLevelItem(0).child(0), None)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) QApplication.setApplicationName('Sherloq') QApplication.setOrganizationName('Guido Bartoli') QApplication.setOrganizationDomain('www.guidobartoli.com') QApplication.setApplicationVersion(ToolTree().version) QApplication.setWindowIcon(QIcon('icons/sherloq_white.png')) self.setWindowTitle('{} {}'.format(QApplication.applicationName(), QApplication.applicationVersion())) self.mdi_area = QMdiArea() self.setCentralWidget(self.mdi_area) self.filename = None self.image = None modify_font(self.statusBar(), bold=True) tree_dock = QDockWidget(self.tr('TOOLS'), self) tree_dock.setObjectName('tree_dock') tree_dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.addDockWidget(Qt.LeftDockWidgetArea, tree_dock) self.tree_widget = ToolTree() self.tree_widget.setObjectName('tree_widget') self.tree_widget.itemDoubleClicked.connect(self.open_tool) tree_dock.setWidget(self.tree_widget) tools_action = tree_dock.toggleViewAction() tools_action.setText(self.tr('Show tools')) tools_action.setToolTip(self.tr('Toggle toolset visibility')) tools_action.setShortcut(QKeySequence(Qt.Key_Tab)) tools_action.setObjectName('tools_action') tools_action.setIcon(QIcon('icons/tools.svg')) help_action = QAction(self.tr('Show help'), self) help_action.setToolTip(self.tr('Toggle online help')) help_action.setShortcut(QKeySequence.HelpContents) help_action.setObjectName('help_action') help_action.setIcon(QIcon('icons/help.svg')) help_action.setCheckable(True) help_action.setEnabled(False) load_action = QAction(self.tr('&Load image...'), self) load_action.setToolTip(self.tr('Load an image to analyze')) load_action.setShortcut(QKeySequence.Open) load_action.triggered.connect(self.load_file) load_action.setObjectName('load_action') load_action.setIcon(QIcon('icons/load.svg')) quit_action = QAction(self.tr('&Quit'), self) quit_action.setToolTip(self.tr('Exit from Sherloq')) quit_action.setShortcut(QKeySequence.Quit) quit_action.triggered.connect(self.close) quit_action.setObjectName('quit_action') quit_action.setIcon(QIcon('icons/quit.svg')) tabbed_action = QAction(self.tr('&Tabbed'), self) tabbed_action.setToolTip(self.tr('Toggle tabbed view for window area')) tabbed_action.setShortcut(QKeySequence(Qt.Key_F10)) tabbed_action.setCheckable(True) tabbed_action.triggered.connect(self.toggle_view) tabbed_action.setObjectName('tabbed_action') tabbed_action.setIcon(QIcon('icons/tabbed.svg')) prev_action = QAction(self.tr('&Previous'), self) prev_action.setToolTip(self.tr('Select the previous tool window')) prev_action.setShortcut(QKeySequence.PreviousChild) prev_action.triggered.connect(self.mdi_area.activatePreviousSubWindow) prev_action.setObjectName('prev_action') prev_action.setIcon(QIcon('icons/previous.svg')) next_action = QAction(self.tr('&Next'), self) next_action.setToolTip(self.tr('Select the next tool window')) next_action.setShortcut(QKeySequence.NextChild) next_action.triggered.connect(self.mdi_area.activateNextSubWindow) next_action.setObjectName('next_action') next_action.setIcon(QIcon('icons/next.svg')) tile_action = QAction(self.tr('&Tile'), self) tile_action.setToolTip( self.tr('Arrange windows into non-overlapping views')) tile_action.setShortcut(QKeySequence(Qt.Key_F11)) tile_action.triggered.connect(self.mdi_area.tileSubWindows) tile_action.setObjectName('tile_action') tile_action.setIcon(QIcon('icons/tile.svg')) cascade_action = QAction(self.tr('&Cascade'), self) cascade_action.setToolTip( self.tr('Arrange windows into overlapping views')) cascade_action.setShortcut(QKeySequence(Qt.Key_F12)) cascade_action.triggered.connect(self.mdi_area.cascadeSubWindows) cascade_action.setObjectName('cascade_action') cascade_action.setIcon(QIcon('icons/cascade.svg')) close_action = QAction(self.tr('Close &All'), self) close_action.setToolTip(self.tr('Close all open tool windows')) close_action.setShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_W)) close_action.triggered.connect(self.mdi_area.closeAllSubWindows) close_action.setObjectName('close_action') close_action.setIcon(QIcon('icons/close.svg')) self.full_action = QAction(self.tr('Full screen'), self) self.full_action.setToolTip(self.tr('Switch to full screen mode')) self.full_action.setShortcut(QKeySequence.FullScreen) self.full_action.triggered.connect(self.change_view) self.full_action.setObjectName('full_action') self.full_action.setIcon(QIcon('icons/full.svg')) self.normal_action = QAction(self.tr('Normal view'), self) self.normal_action.setToolTip(self.tr('Back to normal view mode')) self.normal_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_F12)) self.normal_action.triggered.connect(self.change_view) self.normal_action.setObjectName('normal_action') self.normal_action.setIcon(QIcon('icons/normal.svg')) about_action = QAction(self.tr('&About...'), self) about_action.setToolTip(self.tr('Information about this program')) about_action.triggered.connect(self.show_about) about_action.setObjectName('about_action') about_action.setIcon(QIcon('icons/sherloq_alpha.png')) about_qt_action = QAction(self.tr('About &Qt'), self) about_qt_action.setToolTip( self.tr('Information about the Qt Framework')) about_qt_action.triggered.connect(QApplication.aboutQt) about_qt_action.setIcon(QIcon('icons/Qt.svg')) file_menu = self.menuBar().addMenu(self.tr('&File')) file_menu.addAction(load_action) file_menu.addSeparator() self.recent_actions = [None] * self.max_recent for i in range(len(self.recent_actions)): self.recent_actions[i] = QAction(self) self.recent_actions[i].setVisible(False) self.recent_actions[i].triggered.connect(self.open_recent) file_menu.addAction(self.recent_actions[i]) file_menu.addSeparator() file_menu.addAction(quit_action) view_menu = self.menuBar().addMenu(self.tr('&View')) view_menu.addAction(tools_action) view_menu.addAction(help_action) view_menu.addSeparator() view_menu.addAction(self.full_action) view_menu.addAction(self.normal_action) window_menu = self.menuBar().addMenu(self.tr('&Window')) window_menu.addAction(prev_action) window_menu.addAction(next_action) window_menu.addSeparator() window_menu.addAction(tile_action) window_menu.addAction(cascade_action) window_menu.addAction(tabbed_action) window_menu.addSeparator() window_menu.addAction(close_action) help_menu = self.menuBar().addMenu(self.tr('&Help')) help_menu.addAction(help_action) help_menu.addSeparator() help_menu.addAction(about_action) help_menu.addAction(about_qt_action) main_toolbar = self.addToolBar(self.tr('&Toolbar')) main_toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) main_toolbar.addAction(load_action) main_toolbar.addSeparator() main_toolbar.addAction(tools_action) main_toolbar.addAction(help_action) main_toolbar.addSeparator() main_toolbar.addAction(prev_action) main_toolbar.addAction(next_action) main_toolbar.addSeparator() main_toolbar.addAction(tile_action) main_toolbar.addAction(cascade_action) main_toolbar.addAction(tabbed_action) main_toolbar.addAction(close_action) # main_toolbar.addSeparator() # main_toolbar.addAction(self.normal_action) # main_toolbar.addAction(self.full_action) main_toolbar.setAllowedAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea) main_toolbar.setObjectName('main_toolbar') settings = QSettings() settings.beginGroup('main_window') self.restoreGeometry(settings.value('geometry')) self.restoreState(settings.value('state')) self.recent_files = settings.value('recent_files') if self.recent_files is None: self.recent_files = [] elif not isinstance(self.recent_files, list): self.recent_files = [self.recent_files] self.update_recent() settings.endGroup() prev_action.setEnabled(False) next_action.setEnabled(False) tile_action.setEnabled(False) cascade_action.setEnabled(False) close_action.setEnabled(False) tabbed_action.setEnabled(False) self.tree_widget.setEnabled(False) self.showNormal() self.normal_action.setEnabled(False) self.show_message(self.tr('Ready'))
def _createActions(self): # # Actions: Application self._actionAbout = QAction(self.tr("About {0}").format(QApplication.applicationName()), self) self._actionAbout.setObjectName("actionAbout") self._actionAbout.setIcon(QIcon(":/icons/apps/16/tabulator.svg")) self._actionAbout.setIconText(self.tr("About")) self._actionAbout.setToolTip(self.tr("Brief description of the application")) self._actionAbout.triggered.connect(self._onActionAboutTriggered) self._actionColophon = QAction(self.tr("Colophon"), self) self._actionColophon.setObjectName("actionColophon") self._actionColophon.setToolTip(self.tr("Lengthy description of the application")) self._actionColophon.triggered.connect(self._onActionColophonTriggered) self._actionPreferences = QAction(self.tr("Preferences…"), self) self._actionPreferences.setObjectName("actionPreferences") self._actionPreferences.setIcon(QIcon.fromTheme("configure", QIcon(":/icons/actions/16/application-configure.svg"))) self._actionPreferences.setToolTip(self.tr("Customize the appearance and behavior of the application")) self._actionPreferences.triggered.connect(self._onActionPreferencesTriggered) self._actionQuit = QAction(self.tr("Quit"), self) self._actionQuit.setObjectName("actionQuit") self._actionQuit.setIcon(QIcon.fromTheme("application-exit", QIcon(":/icons/actions/16/application-exit.svg"))) self._actionQuit.setShortcut(QKeySequence.Quit) self._actionQuit.setToolTip(self.tr("Quit the application")) self._actionQuit.triggered.connect(self.close) # # Actions: Document self._actionNew = QAction(self.tr("New"), self) self._actionNew.setObjectName("actionNew") self._actionNew.setIcon(QIcon.fromTheme("document-new", QIcon(":/icons/actions/16/document-new.svg"))) self._actionNew.setShortcut(QKeySequence.New) self._actionNew.setToolTip(self.tr("Create new document")) self._actionNew.triggered.connect(self._onActionNewTriggered) self._actionOpen = QAction(self.tr("Open…"), self) self._actionOpen.setObjectName("actionOpen") self._actionOpen.setIcon(QIcon.fromTheme("document-open", QIcon(":/icons/actions/16/document-open.svg"))) self._actionOpen.setShortcut(QKeySequence.Open) self._actionOpen.setToolTip(self.tr("Open an existing document")) self._actionOpen.triggered.connect(self._onActionOpenTriggered) self._actionOpenRecentClear = QAction(self.tr("Clear List"), self) self._actionOpenRecentClear.setObjectName("actionOpenRecentClear") self._actionOpenRecentClear.setToolTip(self.tr("Clear document list")) self._actionOpenRecentClear.triggered.connect(self._onActionOpenRecentClearTriggered) self._actionSave = QAction(self.tr("Save"), self) self._actionSave.setObjectName("actionSave") self._actionSave.setIcon(QIcon.fromTheme("document-save", QIcon(":/icons/actions/16/document-save.svg"))) self._actionSave.setShortcut(QKeySequence.Save) self._actionSave.setToolTip(self.tr("Save document")) self._actionSave.triggered.connect(self._onActionSaveTriggered) self._actionSaveAs = QAction(self.tr("Save As…"), self) self._actionSaveAs.setObjectName("actionSaveAs") self._actionSaveAs.setIcon(QIcon.fromTheme("document-save-as", QIcon(":/icons/actions/16/document-save-as.svg"))) self._actionSaveAs.setShortcut(QKeySequence.SaveAs) self._actionSaveAs.setToolTip(self.tr("Save document under a new name")) self._actionSaveAs.triggered.connect(self._onActionSaveAsTriggered) self._actionSaveAsDelimiterColon = QAction(self.tr("Colon"), self) self._actionSaveAsDelimiterColon.setObjectName("actionSaveAsDelimiterColon") self._actionSaveAsDelimiterColon.setCheckable(True) self._actionSaveAsDelimiterColon.setToolTip(self.tr("Save document with colon as delimiter under a new name")) self._actionSaveAsDelimiterColon.setData("colon") self._actionSaveAsDelimiterColon.triggered.connect(lambda: self._onActionSaveAsDelimiterTriggered("colon") ) self._actionSaveAsDelimiterComma = QAction(self.tr("Comma"), self) self._actionSaveAsDelimiterComma.setObjectName("actionSaveAsDelimiterComma") self._actionSaveAsDelimiterComma.setCheckable(True) self._actionSaveAsDelimiterComma.setToolTip(self.tr("Save document with comma as delimiter under a new name")) self._actionSaveAsDelimiterComma.setData("comma") self._actionSaveAsDelimiterComma.triggered.connect(lambda: self._onActionSaveAsDelimiterTriggered("comma") ) self._actionSaveAsDelimiterSemicolon = QAction(self.tr("Semicolon"), self) self._actionSaveAsDelimiterSemicolon.setObjectName("actionSaveAsDelimiterSemicolon") self._actionSaveAsDelimiterSemicolon.setCheckable(True) self._actionSaveAsDelimiterSemicolon.setToolTip(self.tr("Save document with semicolon as delimiter under a new name")) self._actionSaveAsDelimiterSemicolon.setData("semicolon") self._actionSaveAsDelimiterSemicolon.triggered.connect(lambda: self._onActionSaveAsDelimiterTriggered("semicolon") ) self._actionSaveAsDelimiterTab = QAction(self.tr("Tab"), self) self._actionSaveAsDelimiterTab.setObjectName("actionSaveAsDelimiterTab") self._actionSaveAsDelimiterTab.setCheckable(True) self._actionSaveAsDelimiterTab.setToolTip(self.tr("Save document with tab as delimiter under a new name")) self._actionSaveAsDelimiterTab.setData("tab") self._actionSaveAsDelimiterTab.triggered.connect(lambda: self._onActionSaveAsDelimiterTriggered("tab") ) self._actionSaveAsDelimiter = QActionGroup(self) self._actionSaveAsDelimiter.setObjectName("actionSaveAsDelimiter") self._actionSaveAsDelimiter.addAction(self._actionSaveAsDelimiterColon) self._actionSaveAsDelimiter.addAction(self._actionSaveAsDelimiterComma) self._actionSaveAsDelimiter.addAction(self._actionSaveAsDelimiterSemicolon) self._actionSaveAsDelimiter.addAction(self._actionSaveAsDelimiterTab) self._actionSaveCopyAs = QAction(self.tr("Save Copy As…"), self) self._actionSaveCopyAs.setObjectName("actionSaveCopyAs") self._actionSaveCopyAs.setIcon(QIcon.fromTheme("document-save-as", QIcon(":/icons/actions/16/document-save-as.svg"))) self._actionSaveCopyAs.setToolTip(self.tr("Save copy of document under a new name")) self._actionSaveCopyAs.triggered.connect(self._onActionSaveCopyAsTriggered) self._actionSaveAll = QAction(self.tr("Save All"), self) self._actionSaveAll.setObjectName("actionSaveAll") self._actionSaveAll.setIcon(QIcon.fromTheme("document-save-all", QIcon(":/icons/actions/16/document-save-all.svg"))) self._actionSaveAll.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_L)) self._actionSaveAll.setToolTip(self.tr("Save all documents")) self._actionSaveAll.triggered.connect(self._onActionSaveAllTriggered) self._actionClose = QAction(self.tr("Close"), self) self._actionClose.setObjectName("actionClose") self._actionClose.setIcon(QIcon.fromTheme("document-close", QIcon(":/icons/actions/16/document-close.svg"))) self._actionClose.setShortcut(QKeySequence.Close) self._actionClose.setToolTip(self.tr("Close document")) self._actionClose.triggered.connect(self._onActionCloseTriggered) self._actionCloseOther = QAction(self.tr("Close Other"), self) self._actionCloseOther.setObjectName("actionCloseOther") self._actionCloseOther.setToolTip(self.tr("Close all other documents")) self._actionCloseOther.triggered.connect(self._onActionCloseOtherTriggered) self._actionCloseAll = QAction(self.tr("Close All"), self) self._actionCloseAll.setObjectName("actionCloseAll") self._actionCloseAll.setShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_W)) self._actionCloseAll.setToolTip(self.tr("Close all documents")) self._actionCloseAll.triggered.connect(self._onActionCloseAllTriggered) # # Actions: View self._actionFullScreen = QAction(self) self._actionFullScreen.setObjectName("actionFullScreen") self._actionFullScreen.setIconText(self.tr("Full Screen")) self._actionFullScreen.setCheckable(True) self._actionFullScreen.setShortcuts([QKeySequence(Qt.Key_F11), QKeySequence.FullScreen]) self._actionFullScreen.triggered.connect(self._onActionFullScreenTriggered) self._actionTitlebarFullPath = QAction(self.tr("Show Path in Titlebar"), self) self._actionTitlebarFullPath.setObjectName("actionTitlebarFullPath") self._actionTitlebarFullPath.setCheckable(True) self._actionTitlebarFullPath.setChecked(True) self._actionTitlebarFullPath.setToolTip(self.tr("Display the full path of the document in the titlebar")) self._actionTitlebarFullPath.triggered.connect(self._onActionTitlebarFullPathTriggered) self._actionToolbarApplication = QAction(self.tr("Show Application Toolbar"), self) self._actionToolbarApplication.setObjectName("actionToolbarApplication") self._actionToolbarApplication.setCheckable(True) self._actionToolbarApplication.setToolTip(self.tr("Display the Application toolbar")) self._actionToolbarApplication.toggled.connect(lambda checked: self._toolbarApplication.setVisible(checked)) self._actionToolbarDocument = QAction(self.tr("Show Document Toolbar"), self) self._actionToolbarDocument.setObjectName("actionToolbarDocument") self._actionToolbarDocument.setCheckable(True) self._actionToolbarDocument.setToolTip(self.tr("Display the Document toolbar")) self._actionToolbarDocument.toggled.connect(lambda checked: self._toolbarDocument.setVisible(checked)) self._actionToolbarEdit = QAction(self.tr("Show Edit Toolbar"), self) self._actionToolbarEdit.setObjectName("actionToolbarEdit") self._actionToolbarEdit.setCheckable(True) self._actionToolbarEdit.setToolTip(self.tr("Display the Edit toolbar")) self._actionToolbarEdit.toggled.connect(lambda checked: self._toolbarEdit.setVisible(checked)) self._actionToolbarTools = QAction(self.tr("Show Tools Toolbar"), self) self._actionToolbarTools.setObjectName("actionToolbarTools") self._actionToolbarTools.setCheckable(True) self._actionToolbarTools.setToolTip(self.tr("Display the Tools toolbar")) self._actionToolbarTools.toggled.connect(lambda checked: self._toolbarTools.setVisible(checked)) self._actionToolbarView = QAction(self.tr("Show View Toolbar"), self) self._actionToolbarView.setObjectName("actionToolbarView") self._actionToolbarView.setCheckable(True) self._actionToolbarView.setToolTip(self.tr("Display the View toolbar")) self._actionToolbarView.toggled.connect(lambda checked: self._toolbarView.setVisible(checked)) self._actionToolbarHelp = QAction(self.tr("Show Help Toolbar"), self) self._actionToolbarHelp.setObjectName("actionToolbarHelp") self._actionToolbarHelp.setCheckable(True) self._actionToolbarHelp.setToolTip(self.tr("Display the Help toolbar")) self._actionToolbarHelp.toggled.connect(lambda checked: self._toolbarHelp.setVisible(checked)) # # Actions: Help self._actionKeyboardShortcuts = QAction(self.tr("Keyboard Shortcuts"), self) self._actionKeyboardShortcuts.setObjectName("actionKeyboardShortcuts") self._actionKeyboardShortcuts.setIcon(QIcon.fromTheme("help-keyboard-shortcuts", QIcon(":/icons/actions/16/help-keyboard-shortcuts.svg"))) self._actionKeyboardShortcuts.setIconText(self.tr("Shortcuts")) self._actionKeyboardShortcuts.setToolTip(self.tr("List of all keyboard shortcuts")) self._actionKeyboardShortcuts.triggered.connect(self._onActionKeyboardShortcutsTriggered)
def load(self, fileName): image = QImage(fileName) if image.isNull(): QMessageBox.information(self, QApplication.applicationName(), "Cannot load " + fileName)
languageListOption = QCommandLineOption( ["language-list"], QCoreApplication.translate("main", "Lists available application languages.")) languageOption = QCommandLineOption( ["language"], QCoreApplication.translate("main", "Adjusts application language."), QCoreApplication.translate("main", "language code")) parser = QCommandLineParser() parser.setApplicationDescription( QCoreApplication.translate( "main", "{0} - An editor tool for documents with character-separated values" ).format(app.applicationName())) parser.addHelpOption() parser.addVersionOption() parser.addOption(languageListOption) parser.addOption(languageOption) parser.addPositionalArgument("files", "Documents to open.", "[files...]") parser.process(app) # Command line: Language list if parser.isSet(languageListOption): sys.exit(showLanguageList()) # Command line: Language language = parser.value(languageOption) #