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, 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) pythonVersion = sys.version pysideVersion = PySide2.__version__ qtVersion = PySide2.QtCore.qVersion() # Qt version used to run Qt for Python qtBuildVersion = PySide2.QtCore.__version__ # Qt version used to compile PySide2 osName = QSysInfo.prettyProductName() osKernelVersion = QSysInfo.kernelVersion() osCpuArchitecture = QSysInfo.currentCpuArchitecture() textBox = QTextBrowser() textBox.setFrameStyle(QFrame.NoFrame) textBox.setStyleSheet("background-color:transparent;") textBox.setOpenExternalLinks(True) textBox.setHtml(self.tr("<html><body>" "<dl><dt><strong>Application version</strong></dt>" "<dd>{0}</dd></dl>" "<dl><dt><strong>Qt for Python version</strong></dt>" "<dd>{1} runs on Qt {2} (Built against {3})</dd></dl>" "<dl><dt><strong>Python version</strong></dt>" "<dd>{4}</dd></dl>" "<dl><dt><strong>Operation System</strong></dt>" "<dd>{5} (Kernel {6} on {7})</dd></dl>" "</body></html>").format(QApplication.applicationVersion(), pysideVersion, qtVersion, qtBuildVersion, pythonVersion, osName, osKernelVersion, osCpuArchitecture)) # 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 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'))