def __init__(self, model): """Initialize MNELAB main window. Parameters ---------- model : mnelab.model.Model instance The main window needs to connect to a model containing all data sets. This decouples the GUI from the data (model/view). """ super().__init__() self.model = model # data model self.setWindowTitle("MNELAB") # restore settings settings = read_settings() self.recent = settings["recent"] # list of recent files self.resize(settings["size"]) self.move(settings["pos"]) # remove None entries from self.recent self.recent = [recent for recent in self.recent if recent is not None] # trigger theme setting QIcon.setThemeSearchPaths([str(Path(__file__).parent / "icons")]) self.event(QEvent(QEvent.PaletteChange)) self.actions = {} # contains all actions # initialize menus file_menu = self.menuBar().addMenu("&File") icon = QIcon.fromTheme("open-file") self.actions["open_file"] = file_menu.addAction( icon, "&Open...", self.open_data, QKeySequence.Open) self.recent_menu = file_menu.addMenu("Open recent") self.recent_menu.aboutToShow.connect(self._update_recent_menu) self.recent_menu.triggered.connect(self._load_recent) if not self.recent: self.recent_menu.setEnabled(False) self.actions["close_file"] = file_menu.addAction( "&Close", self.model.remove_data, QKeySequence.Close) self.actions["close_all"] = file_menu.addAction( "Close all", self.close_all) file_menu.addSeparator() icon = QIcon.fromTheme("meta-info") self.actions["meta_info"] = file_menu.addAction( icon, "Show information...", self.meta_info) file_menu.addSeparator() self.actions["import_bads"] = file_menu.addAction( "Import bad channels...", lambda: self.import_file( model.import_bads, "Import bad channels", "*.csv")) self.actions["import_events"] = file_menu.addAction( "Import events...", lambda: self.import_file( model.import_events, "Import events", "*.csv")) self.actions["import_annotations"] = file_menu.addAction( "Import annotations...", lambda: self.import_file( model.import_annotations, "Import annotations", "*.csv")) self.actions["import_ica"] = file_menu.addAction( "Import &ICA...", lambda: self.open_file( model.import_ica, "Import ICA", "*.fif *.fif.gz")) file_menu.addSeparator() self.export_menu = file_menu.addMenu("Export data") for ext, description in writers.items(): action = "export_data" + ext.replace(".", "_") self.actions[action] = self.export_menu.addAction( f"{ext[1:].upper()} ({description[1]})...", partial(self.export_file, model.export_data, "Export data", "*" + ext)) self.actions["export_bads"] = file_menu.addAction( "Export &bad channels...", lambda: self.export_file( model.export_bads, "Export bad channels", "*.csv")) self.actions["export_events"] = file_menu.addAction( "Export &events...", lambda: self.export_file( model.export_events, "Export events", "*.csv")) self.actions["export_annotations"] = file_menu.addAction( "Export &annotations...", lambda: self.export_file( model.export_annotations, "Export annotations", "*.csv")) self.actions["export_ica"] = file_menu.addAction( "Export ICA...", lambda: self.export_file( model.export_ica, "Export ICA", "*.fif *.fif.gz")) file_menu.addSeparator() self.actions["xdf_chunks"] = file_menu.addAction( "Show XDF chunks...", self.xdf_chunks) file_menu.addSeparator() self.actions["quit"] = file_menu.addAction("&Quit", self.close, QKeySequence.Quit) edit_menu = self.menuBar().addMenu("&Edit") self.actions["pick_chans"] = edit_menu.addAction( "P&ick channels...", self.pick_channels) icon = QIcon.fromTheme("chan-props") self.actions["chan_props"] = edit_menu.addAction( icon, "Channel &properties...", self.channel_properties) self.actions["set_montage"] = edit_menu.addAction( "Set &montage...", self.set_montage) edit_menu.addSeparator() self.actions["set_ref"] = edit_menu.addAction("Set &reference...", self.set_reference) edit_menu.addSeparator() self.actions["annotations"] = edit_menu.addAction( "&Annotations...", self.edit_annotations) self.actions["events"] = edit_menu.addAction("&Events...", self.edit_events) edit_menu.addSeparator() self.actions["crop"] = edit_menu.addAction("&Crop data...", self.crop) self.actions["append_data"] = edit_menu.addAction( "Appen&d data...", self.append_data) plot_menu = self.menuBar().addMenu("&Plot") icon = QIcon.fromTheme("plot-data") self.actions["plot_data"] = plot_menu.addAction( icon, "&Data", self.plot_data) icon = QIcon.fromTheme("plot-psd") self.actions["plot_psd"] = plot_menu.addAction( icon, "&Power spectral density", self.plot_psd) icon = QIcon.fromTheme("plot-locations") self.actions["plot_locations"] = plot_menu.addAction( icon, "&Channel locations", self.plot_locations) self.actions["plot_erds"] = plot_menu.addAction( "&ERDS maps...", self.plot_erds) plot_menu.addSeparator() self.actions["plot_ica_components"] = plot_menu.addAction( "ICA &components...", self.plot_ica_components) self.actions["plot_ica_sources"] = plot_menu.addAction( "ICA &sources...", self.plot_ica_sources) tools_menu = self.menuBar().addMenu("&Tools") icon = QIcon.fromTheme("filter-data") self.actions["filter"] = tools_menu.addAction(icon, "&Filter data...", self.filter_data) icon = QIcon.fromTheme("find-events") self.actions["find_events"] = tools_menu.addAction( icon, "Find &events...", self.find_events) self.actions["events_from_annotations"] = tools_menu.addAction( "Create events from annotations", self.events_from_annotations) self.actions["annotations_from_events"] = tools_menu.addAction( "Create annotations from events", self.annotations_from_events) tools_menu.addSeparator() nirs_menu = tools_menu.addMenu("NIRS") self.actions["convert_od"] = nirs_menu.addAction( "Convert to &optical density", self.convert_od) self.actions["convert_bl"] = nirs_menu.addAction( "Convert to &haemoglobin", self.convert_bl) tools_menu.addSeparator() icon = QIcon.fromTheme("run-ica") self.actions["run_ica"] = tools_menu.addAction(icon, "Run &ICA...", self.run_ica) self.actions["apply_ica"] = tools_menu.addAction( "Apply &ICA", self.apply_ica) tools_menu.addSeparator() self.actions["interpolate_bads"] = tools_menu.addAction( "Interpolate bad channels...", self.interpolate_bads) tools_menu.addSeparator() icon = QIcon.fromTheme("epoch-data") self.actions["epoch_data"] = tools_menu.addAction( icon, "Create epochs...", self.epoch_data) view_menu = self.menuBar().addMenu("&View") self.actions["history"] = view_menu.addAction("&History...", self.show_history) self.actions["toolbar"] = view_menu.addAction("&Toolbar", self._toggle_toolbar) self.actions["toolbar"].setCheckable(True) self.actions["statusbar"] = view_menu.addAction( "&Statusbar", self._toggle_statusbar) self.actions["statusbar"].setCheckable(True) help_menu = self.menuBar().addMenu("&Help") self.actions["about"] = help_menu.addAction("&About", self.show_about) self.actions["about_qt"] = help_menu.addAction("About &Qt", self.show_about_qt) # actions that are always enabled self.always_enabled = [ "open_file", "about", "about_qt", "quit", "xdf_chunks", "toolbar", "statusbar" ] # set up toolbar self.toolbar = self.addToolBar("toolbar") self.toolbar.setObjectName("toolbar") self.toolbar.addAction(self.actions["open_file"]) self.toolbar.addAction(self.actions["meta_info"]) self.toolbar.addSeparator() self.toolbar.addAction(self.actions["chan_props"]) self.toolbar.addSeparator() self.toolbar.addAction(self.actions["plot_data"]) self.toolbar.addAction(self.actions["plot_psd"]) self.toolbar.addAction(self.actions["plot_locations"]) self.toolbar.addSeparator() self.toolbar.addAction(self.actions["filter"]) self.toolbar.addAction(self.actions["find_events"]) self.toolbar.addAction(self.actions["epoch_data"]) self.toolbar.addAction(self.actions["run_ica"]) self.toolbar.setMovable(False) self.setUnifiedTitleAndToolBarOnMac(True) if settings["toolbar"]: self.toolbar.show() self.actions["toolbar"].setChecked(True) else: self.toolbar.hide() self.actions["toolbar"].setChecked(False) # set up data model for sidebar (list of open files) self.names = QStringListModel() self.names.dataChanged.connect(self._update_names) splitter = QSplitter() self.sidebar = QListView() self.sidebar.setFrameStyle(QFrame.NoFrame) self.sidebar.setFocusPolicy(Qt.NoFocus) self.sidebar.setModel(self.names) self.sidebar.clicked.connect(self._update_data) splitter.addWidget(self.sidebar) self.infowidget = InfoWidget() splitter.addWidget(self.infowidget) width = splitter.size().width() splitter.setSizes((int(width * 0.3), int(width * 0.7))) self.setCentralWidget(splitter) self.status_label = QLabel() self.statusBar().addPermanentWidget(self.status_label) if settings["statusbar"]: self.statusBar().show() self.actions["statusbar"].setChecked(True) else: self.statusBar().hide() self.actions["statusbar"].setChecked(False) self.setAcceptDrops(True) self.data_changed()
class KaitaiView(QScrollArea, View): def __init__(self, parent, binaryView): QScrollArea.__init__(self, parent) View.__init__(self) View.setBinaryDataNavigable(self, True) self.setupView(self) # BinaryViewType self.binaryView = binaryView self.rootSelectionStart = 0 self.rootSelectionEnd = 1 self.ioRoot = None self.ioCurrent = None # top half = treeWidget + structPath self.treeWidget = MyQTreeWidget() self.treeWidget.setColumnCount(4) self.treeWidget.setHeaderLabels(['label', 'value', 'start', 'end']) self.treeWidget.itemSelectionChanged.connect(self.onTreeSelect) self.structPath = QLineEdit("root") self.structPath.setReadOnly(True) topHalf = QWidget(self) layout = QVBoxLayout() layout.addWidget(self.treeWidget) layout.addWidget(self.structPath) topHalf.setLayout(layout) # bottom half = hexWidget self.hexWidget = HexEditor(binaryView, ViewFrame.viewFrameForWidget(self), 0) # splitter = top half, bottom half self.splitter = QSplitter(self) self.splitter.setOrientation(Qt.Vertical) self.splitter.addWidget(topHalf) self.splitter.addWidget(self.hexWidget) self.setWidgetResizable(True) self.setWidget(self.splitter) self.kaitaiParse() # parse the file using Kaitai, construct the TreeWidget def kaitaiParse(self, ksModuleName=None): log.log_debug('kaitaiParse() with len(bv)=%d and bv.file.filename=%s' % (len(self.binaryView), self.binaryView.file.filename)) if len(self.binaryView) == 0: return kaitaiIO = kshelpers.KaitaiBinaryViewIO(self.binaryView) parsed = kshelpers.parseIo(kaitaiIO, ksModuleName) if not parsed: return # it SEEMS as if parsing is finished at this moment, but some parsing # is postponed until attributes are accessed, so we must try/catch here tree = None if True: try: tree = kshelpers.buildQtree(parsed) except Exception as e: log.log_error( 'kaitai module %s threw exception, check file type' % ksModuleName) tree = None else: tree = kshelpers.buildQtree(parsed) if not tree: return self.ioRoot = tree.ksobj._io self.ioCurrent = tree.ksobj._io self.treeWidget.clear() self.treeWidget.setSortingEnabled(False) # temporarily, for efficiency # two options with how we create the hierarchy if False: # treat root as top level "file" container tree.setLabel('file') tree.setValue(None) tree.setStart(0) tree.setEnd(0) self.treeWidget.insertTopLevelItem(0, tree) else: # add root's children as top level items self.treeWidget.insertTopLevelItems(0, tree.takeChildren()) # enable sorting self.treeWidget.setSortingEnabled(True) self.treeWidget.sortByColumn(2, Qt.AscendingOrder) # TODO: select first item, maybe expand a few things self.rootSelectionStart = 0 self.rootSelectionEnd = 1 self.treeWidget.setUniformRowHeights(True) self.treeWidget.queueInitialPresentation = True # binja callbacks def getData(self): return self.binaryView def getStart(self): result = self.binaryView.start #log.log_debug('getStart() returning '+str(result)) return result def getEnd(self): result = self.binaryView.end #log.log_debug('getEnd() returning '+str(result)) return result def getLength(self): result = len(self.binaryView) #log.log_debug('getLength() returning '+str(result)) return result def getCurrentOffset(self): result = self.rootSelectionStart + int( (self.rootSelectionEnd - self.rootSelectionStart) / 2) #result = self.rootSelectionStart #log.log_debug('getCurrentOffset() returning '+str(result)) return result def getSelectionOffsets(self): result = None if self.hexWidget: result = self.hexWidget.getSelectionOffsets() else: result = (self.rootSelectionStart, self.rootSelectionStart) #log.log_debug('getSelectionOffsets() returning '+str(result)) return result def setCurrentOffset(self, offset): #log.log_debug('setCurrentOffset(0x%X)' % offset) self.rootSelectionStart = offset UIContext.updateStatus(True) def getFont(self): return binaryninjaui.getMonospaceFont(self) def navigate(self, addr): self.rootSelectionStart = addr self.rootSelectionEnd = addr + 1 self.hexWidget.setSelectionRange(addr, addr + 1) return True def navigateToFileOffset(self, offset): #log.log_debug('navigateToFileOffset()') return False def onTreeSelect(self, wtf=None): # get KaitaiTreeWidgetItem items = self.treeWidget.selectedItems() if not items or len(items) < 1: return item = items[0] # build path, inform user structPath = item.label itemTmp = item while itemTmp.parent(): itemTmp = itemTmp.parent() label = itemTmp.label if label.startswith('_m_'): label = label[3:] structPath = label + '.' + structPath self.structPath.setText('root.' + structPath) # (start, end) = (item.start, item.end) if start == None or end == None: return # determine current IO we're in (the Kaitai input/output abstraction) _io = None # if the tree item is linked to a KaitaiNode, simply read the IO if item.ksobj: _io = item.ksobj._parent._io else: # else we're a leaf parent = item.parent() if parent: # a leaf with a parent -> read parent's IO _io = parent.ksobj._io else: # a leaf without a parent -> we must be at root -> use root IO _io = self.ioRoot # if the selection is in the root view, store the interval so that upon # getCurrentOffset() callback, we return the middle and feature map is # updated if _io == self.ioRoot: self.rootSelectionStart = start self.rootSelectionEnd = end # current kaitai object is on a different io? then swap HexEditor if _io != self.ioCurrent: # delete old view self.hexWidget.hide() self.hexWidget.setParent(None) self.hexWidget.deleteLater() self.hexWidget = None # if it's the original file IO, wrap the already-open file binary view if _io == self.ioRoot: self.hexWidget = HexEditor(self.binaryView, ViewFrame.viewFrameForWidget(self), 0) # otherwise delete old view, create a temporary view else: # create new view length = _io.size() _io.seek(0) data = _io.read_bytes(length) bv = binaryview.BinaryView.new(data) self.hexWidget = HexEditor(bv, ViewFrame.viewFrameForWidget(self), 0) self.splitter.addWidget(self.hexWidget) self.ioCurrent = _io # now position selection in whatever HexEditor is current #log.log_debug('selecting to [0x%X, 0x%X)' % (start, end)) self.hexWidget.setSelectionRange(start, end) # set hex group title to reflect current selection #self.hexGroup.setTitle('Hex View @ [0x%X, 0x%X)' % (start, end)) def getStatusBarWidget(self): return menu.KaitaiStatusBarWidget(self)
class MainWidget(QWidget): def __init__(self, parent: QWidget, model: Model) -> None: super().__init__(parent) logger.add(self.log) settings = QSettings() self.mainlayout = QVBoxLayout() self.mainlayout.setContentsMargins(5, 5, 5, 5) self.setLayout(self.mainlayout) # summary summarylayout = FlowLayout() summarylayout.setContentsMargins(0, 0, 0, 0) self.summary = QWidget() self.summary.setLayout(summarylayout) self.mainlayout.addWidget(self.summary) self.summary.setVisible( settings.value('showSummary', 'True') == 'True') detailslayout = QHBoxLayout() detailslayout.setContentsMargins(1, 0, 0, 0) detailslayout.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) detailslayout.setSpacing(15) details = QWidget() details.setLayout(detailslayout) summarylayout.addWidget(details) self.modstotal = QLabel() detailslayout.addWidget(self.modstotal) self.modsenabled = QLabel() detailslayout.addWidget(self.modsenabled) self.overridden = QLabel() detailslayout.addWidget(self.overridden) self.conflicts = QLabel() detailslayout.addWidget(self.conflicts) buttonslayout = QHBoxLayout() buttonslayout.setContentsMargins(0, 0, 0, 0) buttonslayout.setAlignment(Qt.AlignRight | Qt.AlignVCenter) buttons = QWidget() buttons.setLayout(buttonslayout) summarylayout.addWidget(buttons) self.startscriptmerger = QPushButton('Start Script Merger') self.startscriptmerger.setContentsMargins(0, 0, 0, 0) self.startscriptmerger.setMinimumWidth(140) self.startscriptmerger.setIcon( QIcon(str(getRuntimePath('resources/icons/script.ico')))) self.startscriptmerger.clicked.connect(lambda: [ openExecutable(Path(str(settings.value('scriptMergerPath'))), True) ]) self.startscriptmerger.setEnabled( verifyScriptMergerPath( Path(str(settings.value('scriptMergerPath')))) is not None) buttonslayout.addWidget(self.startscriptmerger) self.startgame = QPushButton('Start Game') self.startgame.setContentsMargins(0, 0, 0, 0) self.startgame.setMinimumWidth(100) self.startgame.setIcon( QIcon(str(getRuntimePath('resources/icons/w3b.ico')))) buttonslayout.addWidget(self.startgame) # splitter self.splitter = QSplitter(Qt.Vertical) self.stack = QStackedWidget() self.splitter.addWidget(self.stack) # mod list widget self.modlistwidget = QWidget() self.modlistlayout = QVBoxLayout() self.modlistlayout.setContentsMargins(0, 0, 0, 0) self.modlistwidget.setLayout(self.modlistlayout) self.stack.addWidget(self.modlistwidget) # search bar self.searchbar = QLineEdit() self.searchbar.setPlaceholderText('Search...') self.modlistlayout.addWidget(self.searchbar) # mod list self.modlist = ModList(self, model) self.modlistlayout.addWidget(self.modlist) self.searchbar.textChanged.connect(lambda e: self.modlist.setFilter(e)) # welcome message welcomelayout = QVBoxLayout() welcomelayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) welcomewidget = QWidget() welcomewidget.setLayout(welcomelayout) welcomewidget.dragEnterEvent = self.modlist.dragEnterEvent # type: ignore welcomewidget.dragMoveEvent = self.modlist.dragMoveEvent # type: ignore welcomewidget.dragLeaveEvent = self.modlist.dragLeaveEvent # type: ignore welcomewidget.dropEvent = self.modlist.dropEvent # type: ignore welcomewidget.setAcceptDrops(True) icon = QIcon(str(getRuntimePath('resources/icons/open-folder.ico'))) iconpixmap = icon.pixmap(32, 32) icon = QLabel() icon.setPixmap(iconpixmap) icon.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) icon.setContentsMargins(4, 4, 4, 4) welcomelayout.addWidget(icon) welcome = QLabel('''<p><font> No mod installed yet. Drag a mod into this area to get started! </font></p>''') welcome.setAttribute(Qt.WA_TransparentForMouseEvents) welcome.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) welcomelayout.addWidget(welcome) self.stack.addWidget(welcomewidget) # output log self.output = QTextEdit(self) self.output.setTextInteractionFlags(Qt.NoTextInteraction) self.output.setReadOnly(True) self.output.setContextMenuPolicy(Qt.NoContextMenu) self.output.setPlaceholderText('Program output...') self.splitter.addWidget(self.output) # TODO: enhancement: show indicator if scripts have to be merged self.splitter.setStretchFactor(0, 1) self.splitter.setStretchFactor(1, 0) self.mainlayout.addWidget(self.splitter) # TODO: incomplete: make start game button functional if len(model): self.stack.setCurrentIndex(0) self.splitter.setSizes([self.splitter.size().height(), 50]) else: self.stack.setCurrentIndex(1) self.splitter.setSizes([self.splitter.size().height(), 0]) model.updateCallbacks.append(self.modelUpdateEvent) asyncio.create_task(model.loadInstalled()) def keyPressEvent(self, event: QKeyEvent) -> None: if event.key() == Qt.Key_Escape: self.modlist.setFocus() self.searchbar.setText('') elif event.matches(QKeySequence.Find): self.searchbar.setFocus() elif event.matches(QKeySequence.Paste): self.pasteEvent() # TODO: enhancement: add start game / start script merger shortcuts else: super().keyPressEvent(event) def pasteEvent(self) -> None: clipboard = QApplication.clipboard().text().splitlines() if len(clipboard) == 1 and isValidNexusModsUrl(clipboard[0]): self.parentWidget().showDownloadModDialog() else: urls = [ url for url in QApplication.clipboard().text().splitlines() if len(str(url.strip())) ] if all( isValidModDownloadUrl(url) or isValidFileUrl(url) for url in urls): asyncio.create_task(self.modlist.checkInstallFromURLs(urls)) def modelUpdateEvent(self, model: Model) -> None: total = len(model) enabled = len([mod for mod in model if model[mod].enabled]) overridden = sum( len(file) for file in model.conflicts.bundled.values()) conflicts = sum(len(file) for file in model.conflicts.scripts.values()) self.modstotal.setText( f'<font color="#73b500" size="4">{total}</font> \ <font color="#888" text-align="center">Installed Mod{"" if total == 1 else "s"}</font>' ) self.modsenabled.setText( f'<font color="#73b500" size="4">{enabled}</font> \ <font color="#888">Enabled Mod{"" if enabled == 1 else "s"}</font>' ) self.overridden.setText( f'<font color="{"#b08968" if overridden > 0 else "#84C318"}" size="4">{overridden}</font> \ <font color="#888">Overridden File{"" if overridden == 1 else "s"}</font> ' ) self.conflicts.setText( f'<font color="{"#E55934" if conflicts > 0 else "#aad576"}" size="4">{conflicts}</font> \ <font color="#888">Unresolved Conflict{"" if conflicts == 1 else "s"}</font> ' ) if len(model) > 0: if self.stack.currentIndex() != 0: self.stack.setCurrentIndex(0) self.repaint() else: if self.stack.currentIndex() != 1: self.stack.setCurrentIndex(1) self.repaint() def unhideOutput(self) -> None: if self.splitter.sizes()[1] < 10: self.splitter.setSizes([self.splitter.size().height(), 50]) def unhideModList(self) -> None: if self.splitter.sizes()[0] < 10: self.splitter.setSizes([50, self.splitter.size().height()]) def log(self, message: Any) -> None: # format log messages to user readable output settings = QSettings() record = message.record message = record['message'] extra = record['extra'] level = record['level'].name.lower() name = str(extra['name'] ) if 'name' in extra and extra['name'] is not None else '' path = str(extra['path'] ) if 'path' in extra and extra['path'] is not None else '' dots = bool( extra['dots'] ) if 'dots' in extra and extra['dots'] is not None else False newline = bool( extra['newline'] ) if 'newline' in extra and extra['newline'] is not None else False output = bool( extra['output'] ) if 'output' in extra and extra['output'] is not None else bool( message) modlist = bool( extra['modlist'] ) if 'modlist' in extra and extra['modlist'] is not None else False if level in ['debug' ] and settings.value('debugOutput', 'False') != 'True': if newline: self.output.append(f'') return n = '<br>' if newline else '' d = '...' if dots else '' if len(name) and len(path): path = f' ({path})' if output: message = html.escape(message, quote=True) if level in ['success', 'error', 'warning']: message = f'<strong>{message}</strong>' if level in ['success']: message = f'<font color="#04c45e">{message}</font>' if level in ['error', 'critical']: message = f'<font color="#ee3b3b">{message}</font>' if level in ['warning']: message = f'<font color="#ff6500">{message}</font>' if level in ['debug', 'trace']: message = f'<font color="#aaa">{message}</font>' path = f'<font color="#aaa">{path}</font>' if path else '' d = f'<font color="#aaa">{d}</font>' if d else '' time = record['time'].astimezone( tz=None).strftime('%Y-%m-%d %H:%M:%S') message = f'<font color="#aaa">{time}</font> {message}' self.output.append( f'{n}{message.strip()}{" " if name or path else ""}{name}{path}{d}' ) else: self.output.append(f'') self.output.verticalScrollBar().setValue( self.output.verticalScrollBar().maximum()) self.output.repaint() if modlist: self.unhideModList() if settings.value('unhideOutput', 'True') == 'True' and output: self.unhideOutput()
def __init__(self, persepolis_setting): super().__init__() # MainWindow self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) # enable drag and drop self.setAcceptDrops(True) # frame self.frame = QFrame(self.centralwidget) # download_table_horizontalLayout download_table_horizontalLayout = QHBoxLayout() horizontal_splitter = QSplitter(Qt.Horizontal) vertical_splitter = QSplitter(Qt.Vertical) # category_tree self.category_tree_qwidget = QWidget(self) category_tree_verticalLayout = QVBoxLayout() self.category_tree = CategoryTreeView(self) category_tree_verticalLayout.addWidget(self.category_tree) self.category_tree_model = QStandardItemModel() self.category_tree.setModel(self.category_tree_model) category_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.category_tree_model.setHorizontalHeaderLabels( category_table_header) self.category_tree.header().setStretchLastSection(True) self.category_tree.header().setDefaultAlignment(Qt.AlignCenter) # queue_panel self.queue_panel_widget = QWidget(self) queue_panel_verticalLayout_main = QVBoxLayout(self.queue_panel_widget) # queue_panel_show_button self.queue_panel_show_button = QPushButton(self) queue_panel_verticalLayout_main.addWidget(self.queue_panel_show_button) # queue_panel_widget_frame self.queue_panel_widget_frame = QFrame(self) self.queue_panel_widget_frame.setFrameShape(QFrame.StyledPanel) self.queue_panel_widget_frame.setFrameShadow(QFrame.Raised) queue_panel_verticalLayout_main.addWidget( self.queue_panel_widget_frame) queue_panel_verticalLayout = QVBoxLayout(self.queue_panel_widget_frame) queue_panel_verticalLayout_main.setContentsMargins(50, -1, 50, -1) # start_end_frame self.start_end_frame = QFrame(self) # start time start_verticalLayout = QVBoxLayout(self.start_end_frame) self.start_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.start_checkBox) self.start_frame = QFrame(self) self.start_frame.setFrameShape(QFrame.StyledPanel) self.start_frame.setFrameShadow(QFrame.Raised) start_frame_verticalLayout = QVBoxLayout(self.start_frame) self.start_time_qDataTimeEdit = MyQDateTimeEdit(self.start_frame) self.start_time_qDataTimeEdit.setDisplayFormat('H:mm') start_frame_verticalLayout.addWidget(self.start_time_qDataTimeEdit) start_verticalLayout.addWidget(self.start_frame) # end time self.end_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.end_checkBox) self.end_frame = QFrame(self) self.end_frame.setFrameShape(QFrame.StyledPanel) self.end_frame.setFrameShadow(QFrame.Raised) end_frame_verticalLayout = QVBoxLayout(self.end_frame) self.end_time_qDateTimeEdit = MyQDateTimeEdit(self.end_frame) self.end_time_qDateTimeEdit.setDisplayFormat('H:mm') end_frame_verticalLayout.addWidget(self.end_time_qDateTimeEdit) start_verticalLayout.addWidget(self.end_frame) self.reverse_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.reverse_checkBox) queue_panel_verticalLayout.addWidget(self.start_end_frame) # limit_after_frame self.limit_after_frame = QFrame(self) # limit_checkBox limit_verticalLayout = QVBoxLayout(self.limit_after_frame) self.limit_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.limit_checkBox) # limit_frame self.limit_frame = QFrame(self) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.limit_frame) limit_frame_verticalLayout = QVBoxLayout(self.limit_frame) # limit_spinBox limit_frame_horizontalLayout = QHBoxLayout() self.limit_spinBox = QDoubleSpinBox(self) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_frame_horizontalLayout.addWidget(self.limit_spinBox) # limit_comboBox self.limit_comboBox = QComboBox(self) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") limit_frame_horizontalLayout.addWidget(self.limit_comboBox) limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout) # limit_pushButton self.limit_pushButton = QPushButton(self) limit_frame_verticalLayout.addWidget(self.limit_pushButton) # after_checkBox self.after_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.after_checkBox) # after_frame self.after_frame = QFrame(self) self.after_frame.setFrameShape(QFrame.StyledPanel) self.after_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.after_frame) after_frame_verticalLayout = QVBoxLayout(self.after_frame) # after_comboBox self.after_comboBox = QComboBox(self) self.after_comboBox.addItem("") after_frame_verticalLayout.addWidget(self.after_comboBox) # after_pushButton self.after_pushButton = QPushButton(self) after_frame_verticalLayout.addWidget(self.after_pushButton) queue_panel_verticalLayout.addWidget(self.limit_after_frame) category_tree_verticalLayout.addWidget(self.queue_panel_widget) # keep_awake_checkBox self.keep_awake_checkBox = QCheckBox(self) queue_panel_verticalLayout.addWidget(self.keep_awake_checkBox) self.category_tree_qwidget.setLayout(category_tree_verticalLayout) horizontal_splitter.addWidget(self.category_tree_qwidget) # download table widget self.download_table_content_widget = QWidget(self) download_table_content_widget_verticalLayout = QVBoxLayout( self.download_table_content_widget) # download_table self.download_table = DownloadTableWidget(self) vertical_splitter.addWidget(self.download_table) horizontal_splitter.addWidget(self.download_table_content_widget) self.download_table.setColumnCount(13) self.download_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.download_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.download_table.verticalHeader().hide() # hide column of GID and column of link. self.download_table.setColumnHidden(8, True) self.download_table.setColumnHidden(9, True) download_table_header = [ QCoreApplication.translate("mainwindow_ui_tr", 'File Name'), QCoreApplication.translate("mainwindow_ui_tr", 'Status'), QCoreApplication.translate("mainwindow_ui_tr", 'Size'), QCoreApplication.translate("mainwindow_ui_tr", 'Downloaded'), QCoreApplication.translate("mainwindow_ui_tr", 'Percentage'), QCoreApplication.translate("mainwindow_ui_tr", 'Connections'), QCoreApplication.translate("mainwindow_ui_tr", 'Transfer Rate'), QCoreApplication.translate("mainwindow_ui_tr", 'Estimated Time Left'), 'Gid', QCoreApplication.translate("mainwindow_ui_tr", 'Link'), QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'), QCoreApplication.translate("mainwindow_ui_tr", 'Last Try Date'), QCoreApplication.translate("mainwindow_ui_tr", 'Category') ] self.download_table.setHorizontalHeaderLabels(download_table_header) # fixing the size of download_table when window is Maximized! self.download_table.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeMode.Interactive) self.download_table.horizontalHeader().setStretchLastSection(True) horizontal_splitter.setStretchFactor(0, 3) # category_tree width horizontal_splitter.setStretchFactor(1, 10) # ratio of tables's width # video_finder_widget self.video_finder_widget = QWidget(self) video_finder_horizontalLayout = QHBoxLayout(self.video_finder_widget) self.muxing_pushButton = QPushButton(self) self.muxing_pushButton.setIcon(QIcon(icons + 'video_finder')) video_finder_horizontalLayout.addWidget(self.muxing_pushButton) video_finder_horizontalLayout.addSpacing(20) video_audio_verticalLayout = QVBoxLayout() self.video_label = QLabel(self) video_audio_verticalLayout.addWidget(self.video_label) self.audio_label = QLabel(self) video_audio_verticalLayout.addWidget(self.audio_label) video_finder_horizontalLayout.addLayout(video_audio_verticalLayout) status_muxing_verticalLayout = QVBoxLayout() self.video_finder_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.video_finder_status_label) self.muxing_status_label = QLabel(self) status_muxing_verticalLayout.addWidget(self.muxing_status_label) video_finder_horizontalLayout.addLayout(status_muxing_verticalLayout) vertical_splitter.addWidget(self.video_finder_widget) download_table_content_widget_verticalLayout.addWidget( vertical_splitter) download_table_horizontalLayout.addWidget(horizontal_splitter) self.frame.setLayout(download_table_horizontalLayout) self.verticalLayout.addWidget(self.frame) self.setCentralWidget(self.centralwidget) # menubar self.menubar = QMenuBar(self) self.menubar.setGeometry(QRect(0, 0, 600, 24)) self.setMenuBar(self.menubar) fileMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&File')) editMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Edit')) viewMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&View')) downloadMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Download')) queueMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Queue')) videoFinderMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'V&ideo Finder')) helpMenu = self.menubar.addMenu( QCoreApplication.translate("mainwindow_ui_tr", '&Help')) # viewMenu submenus sortMenu = viewMenu.addMenu( QCoreApplication.translate("mainwindow_ui_tr", 'Sort by')) # statusbar self.statusbar = QStatusBar(self) self.setStatusBar(self.statusbar) self.statusbar.showMessage( QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) # toolBar self.toolBar2 = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar2) self.toolBar2.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Menu')) self.toolBar2.setFloatable(False) self.toolBar2.setMovable(False) self.toolBar = QToolBar(self) self.addToolBar(Qt.TopToolBarArea, self.toolBar) self.toolBar.setWindowTitle( QCoreApplication.translate("mainwindow_ui_tr", 'Toolbar')) self.toolBar.setFloatable(False) self.toolBar.setMovable(False) #toolBar and menubar and actions self.persepolis_setting.beginGroup('settings/shortcuts') # videoFinderAddLinkAction self.videoFinderAddLinkAction = QAction( QIcon(icons + 'video_finder'), QCoreApplication.translate("mainwindow_ui_tr", 'Find Video Links...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Download video or audio from Youtube, Vimeo, etc.'), triggered=self.showVideoFinderAddLinkWindow) self.videoFinderAddLinkAction_shortcut = QShortcut( self.persepolis_setting.value('video_finder_shortcut'), self, self.showVideoFinderAddLinkWindow) videoFinderMenu.addAction(self.videoFinderAddLinkAction) # stopAllAction self.stopAllAction = QAction(QIcon(icons + 'stop_all'), QCoreApplication.translate( "mainwindow_ui_tr", 'Stop All Active Downloads'), self, statusTip='Stop All Active Downloads', triggered=self.stopAllDownloads) downloadMenu.addAction(self.stopAllAction) # sort_file_name_Action self.sort_file_name_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File Name'), self, triggered=self.sortByName) sortMenu.addAction(self.sort_file_name_Action) # sort_file_size_Action self.sort_file_size_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'File Size'), self, triggered=self.sortBySize) sortMenu.addAction(self.sort_file_size_Action) # sort_first_try_date_Action self.sort_first_try_date_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'First Try Date'), self, triggered=self.sortByFirstTry) sortMenu.addAction(self.sort_first_try_date_Action) # sort_last_try_date_Action self.sort_last_try_date_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Last Try Date'), self, triggered=self.sortByLastTry) sortMenu.addAction(self.sort_last_try_date_Action) # sort_download_status_Action self.sort_download_status_Action = QAction(QCoreApplication.translate( "mainwindow_ui_tr", 'Download Status'), self, triggered=self.sortByStatus) sortMenu.addAction(self.sort_download_status_Action) # trayAction self.trayAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show System Tray Icon'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Show/Hide system tray icon"), triggered=self.showTray) self.trayAction.setCheckable(True) viewMenu.addAction(self.trayAction) # showMenuBarAction self.showMenuBarAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show Menubar'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show Menubar'), triggered=self.showMenuBar) self.showMenuBarAction.setCheckable(True) viewMenu.addAction(self.showMenuBarAction) # showSidePanelAction self.showSidePanelAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show Side Panel'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show Side Panel'), triggered=self.showSidePanel) self.showSidePanelAction.setCheckable(True) viewMenu.addAction(self.showSidePanelAction) # minimizeAction self.minimizeAction = QAction( QIcon(icons + 'minimize'), QCoreApplication.translate("mainwindow_ui_tr", 'Minimize to System Tray'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Minimize to System Tray"), triggered=self.minMaxTray) self.minimizeAction_shortcut = QShortcut( self.persepolis_setting.value('hide_window_shortcut'), self, self.minMaxTray) viewMenu.addAction(self.minimizeAction) # addlinkAction self.addlinkAction = QAction( QIcon(icons + 'add'), QCoreApplication.translate("mainwindow_ui_tr", 'Add New Download Link...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Add New Download Link"), triggered=self.addLinkButtonPressed) self.addlinkAction_shortcut = QShortcut( self.persepolis_setting.value('add_new_download_shortcut'), self, self.addLinkButtonPressed) fileMenu.addAction(self.addlinkAction) # importText self.addtextfileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Import Links from Text File...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Create a text file and put links in it, line by line!'), triggered=self.importText) self.addtextfileAction_shortcut = QShortcut( self.persepolis_setting.value('import_text_shortcut'), self, self.importText) fileMenu.addAction(self.addtextfileAction) # resumeAction self.resumeAction = QAction( QIcon(icons + 'play'), QCoreApplication.translate("mainwindow_ui_tr", 'Resume Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Resume Download"), triggered=self.resumeButtonPressed) downloadMenu.addAction(self.resumeAction) # pauseAction self.pauseAction = QAction( QIcon(icons + 'pause'), QCoreApplication.translate("mainwindow_ui_tr", 'Pause Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Pause Download"), triggered=self.pauseButtonPressed) downloadMenu.addAction(self.pauseAction) # stopAction self.stopAction = QAction( QIcon(icons + 'stop'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Stop/Cancel Download"), triggered=self.stopButtonPressed) downloadMenu.addAction(self.stopAction) # propertiesAction self.propertiesAction = QAction( QIcon(icons + 'setting'), QCoreApplication.translate("mainwindow_ui_tr", 'Properties'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Properties"), triggered=self.propertiesButtonPressed) downloadMenu.addAction(self.propertiesAction) # progressAction self.progressAction = QAction( QIcon(icons + 'window'), QCoreApplication.translate("mainwindow_ui_tr", 'Progress'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Progress"), triggered=self.progressButtonPressed) downloadMenu.addAction(self.progressAction) # openFileAction self.openFileAction = QAction( QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Open File...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open File...'), triggered=self.openFile) fileMenu.addAction(self.openFileAction) # openDownloadFolderAction self.openDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open Download Folder'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open Download Folder'), triggered=self.openDownloadFolder) fileMenu.addAction(self.openDownloadFolderAction) # openDefaultDownloadFolderAction self.openDefaultDownloadFolderAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open Default Download Folder'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Open Default Download Folder'), triggered=self.openDefaultDownloadFolder) fileMenu.addAction(self.openDefaultDownloadFolderAction) # exitAction self.exitAction = QAction( QIcon(icons + 'exit'), QCoreApplication.translate("mainwindow_ui_tr", 'Exit'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Exit"), triggered=self.closeAction) self.exitAction_shortcut = QShortcut( self.persepolis_setting.value('quit_shortcut'), self, self.closeAction) fileMenu.addAction(self.exitAction) # clearAction self.clearAction = QAction(QIcon(icons + 'multi_remove'), QCoreApplication.translate( "mainwindow_ui_tr", 'Clear Download List'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Clear all items in download list'), triggered=self.clearDownloadList) editMenu.addAction(self.clearAction) # removeSelectedAction self.removeSelectedAction = QAction( QIcon(icons + 'remove'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove Selected Downloads from List'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Remove Selected Downloads from List'), triggered=self.removeSelected) self.removeSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('remove_shortcut'), self, self.removeSelected) editMenu.addAction(self.removeSelectedAction) self.removeSelectedAction.setEnabled(False) # deleteSelectedAction self.deleteSelectedAction = QAction( QIcon(icons + 'trash'), QCoreApplication.translate("mainwindow_ui_tr", 'Delete Selected Download Files'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Delete Selected Download Files'), triggered=self.deleteSelected) self.deleteSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('delete_shortcut'), self, self.deleteSelected) editMenu.addAction(self.deleteSelectedAction) self.deleteSelectedAction.setEnabled(False) # moveSelectedDownloadsAction self.moveSelectedDownloadsAction = QAction( QIcon(icons + 'folder'), QCoreApplication.translate( "mainwindow_ui_tr", 'Move Selected Download Files to Another Folder...'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move Selected Download Files to Another Folder'), triggered=self.moveSelectedDownloads) editMenu.addAction(self.moveSelectedDownloadsAction) self.moveSelectedDownloadsAction.setEnabled(False) # createQueueAction self.createQueueAction = QAction( QIcon(icons + 'add_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Create New Queue...'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Create new download queue'), triggered=self.createQueue) queueMenu.addAction(self.createQueueAction) # removeQueueAction self.removeQueueAction = QAction( QIcon(icons + 'remove_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove Queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Remove this queue'), triggered=self.removeQueue) queueMenu.addAction(self.removeQueueAction) # startQueueAction self.startQueueAction = QAction( QIcon(icons + 'start_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Start Queue'), triggered=self.startQueue) queueMenu.addAction(self.startQueueAction) # stopQueueAction self.stopQueueAction = QAction( QIcon(icons + 'stop_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Stop Queue'), triggered=self.stopQueue) queueMenu.addAction(self.stopQueueAction) # moveUpSelectedAction self.moveUpSelectedAction = QAction( QIcon(icons + 'multi_up'), QCoreApplication.translate("mainwindow_ui_tr", 'Move Selected Items Up'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items up by one row'), triggered=self.moveUpSelected) self.moveUpSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_up_selection_shortcut'), self, self.moveUpSelected) queueMenu.addAction(self.moveUpSelectedAction) # moveDownSelectedAction self.moveDownSelectedAction = QAction( QIcon(icons + 'multi_down'), QCoreApplication.translate("mainwindow_ui_tr", 'Move Selected Items Down'), self, statusTip=QCoreApplication.translate( "mainwindow_ui_tr", 'Move currently selected items down by one row'), triggered=self.moveDownSelected) self.moveDownSelectedAction_shortcut = QShortcut( self.persepolis_setting.value('move_down_selection_shortcut'), self, self.moveDownSelected) queueMenu.addAction(self.moveDownSelectedAction) # preferencesAction self.preferencesAction = QAction( QIcon(icons + 'preferences'), QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), triggered=self.openPreferences, menuRole=QAction.MenuRole.PreferencesRole) editMenu.addAction(self.preferencesAction) # aboutAction self.aboutAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'About'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'About'), triggered=self.openAbout, menuRole=QAction.MenuRole.AboutRole) helpMenu.addAction(self.aboutAction) # issueAction self.issueAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Report an Issue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Report an issue'), triggered=self.reportIssue) helpMenu.addAction(self.issueAction) # updateAction self.updateAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Check for Newer Version'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Check for newer release'), triggered=self.newUpdate) helpMenu.addAction(self.updateAction) # logAction self.logAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Show Log File'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.showLog) helpMenu.addAction(self.logAction) # helpAction self.helpAction = QAction( QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Help'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.persepolisHelp) helpMenu.addAction(self.helpAction) self.persepolis_setting.endGroup() self.qmenu = MenuWidget(self) self.toolBar2.addWidget(self.qmenu) # labels self.queue_panel_show_button.setText( QCoreApplication.translate("mainwindow_ui_tr", "Hide Options")) self.start_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Start Time")) self.end_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "End Time")) self.reverse_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Download bottom of\n the list first")) self.limit_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Limit Speed")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.limit_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.after_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "After download")) self.after_comboBox.setItemText( 0, QCoreApplication.translate("mainwindow_ui_tr", "Shut Down")) self.keep_awake_checkBox.setText( QCoreApplication.translate("mainwindow_ui_tr", "Keep System Awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate( "mainwindow_ui_tr", "<html><head/><body><p>This option will prevent the system from going to sleep.\ It is necessary if your power manager is suspending the system automatically. </p></body></html>" )) self.after_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.muxing_pushButton.setText( QCoreApplication.translate("mainwindow_ui_tr", "Start Mixing")) self.video_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Video File Status: </b>")) self.audio_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Audio File Status: </b>")) self.video_finder_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Status: </b>")) self.muxing_status_label.setText( QCoreApplication.translate("mainwindow_ui_tr", "<b>Mixing status: </b>"))
def __init__(self, context, parent=None): super(Snippets, self).__init__(parent) # Create widgets self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.title = QLabel(self.tr("Snippet Editor")) self.saveButton = QPushButton(self.tr("&Save")) self.saveButton.setShortcut(QKeySequence(self.tr("Ctrl+S"))) self.runButton = QPushButton(self.tr("&Run")) self.runButton.setShortcut(QKeySequence(self.tr("Ctrl+R"))) self.closeButton = QPushButton(self.tr("Close")) self.clearHotkeyButton = QPushButton(self.tr("Clear Hotkey")) self.setWindowTitle(self.title.text()) #self.newFolderButton = QPushButton("New Folder") self.browseButton = QPushButton("Browse Snippets") self.browseButton.setIcon(QIcon.fromTheme("edit-undo")) self.deleteSnippetButton = QPushButton("Delete") self.newSnippetButton = QPushButton("New Snippet") indentation = Settings().get_string("snippets.indentation") if Settings().get_bool("snippets.syntaxHighlight"): self.edit = QCodeEditor(SyntaxHighlighter=Pylighter, delimeter=indentation) else: self.edit = QCodeEditor(SyntaxHighlighter=None, delimeter=indentation) self.edit.setPlaceholderText("python code") self.resetting = False self.columns = 3 self.context = context self.keySequenceEdit = QKeySequenceEdit(self) self.currentHotkey = QKeySequence() self.currentHotkeyLabel = QLabel("") self.currentFileLabel = QLabel() self.currentFile = "" self.snippetDescription = QLineEdit() self.snippetDescription.setPlaceholderText("optional description") #Set Editbox Size font = getMonospaceFont(self) self.edit.setFont(font) font = QFontMetrics(font) self.edit.setTabStopDistance( 4 * font.horizontalAdvance(' ')) #TODO, replace with settings API #Files self.files = QFileSystemModel() self.files.setRootPath(snippetPath) self.files.setNameFilters(["*.py"]) #Tree self.tree = QTreeView() self.tree.setModel(self.files) self.tree.setSortingEnabled(True) self.tree.hideColumn(2) self.tree.sortByColumn(0, Qt.AscendingOrder) self.tree.setRootIndex(self.files.index(snippetPath)) for x in range(self.columns): #self.tree.resizeColumnToContents(x) self.tree.header().setSectionResizeMode( x, QHeaderView.ResizeToContents) treeLayout = QVBoxLayout() treeLayout.addWidget(self.tree) treeButtons = QHBoxLayout() #treeButtons.addWidget(self.newFolderButton) treeButtons.addWidget(self.browseButton) treeButtons.addWidget(self.newSnippetButton) treeButtons.addWidget(self.deleteSnippetButton) treeLayout.addLayout(treeButtons) treeWidget = QWidget() treeWidget.setLayout(treeLayout) # Create layout and add widgets buttons = QHBoxLayout() buttons.addWidget(self.clearHotkeyButton) buttons.addWidget(self.keySequenceEdit) buttons.addWidget(self.currentHotkeyLabel) buttons.addWidget(self.closeButton) buttons.addWidget(self.runButton) buttons.addWidget(self.saveButton) description = QHBoxLayout() description.addWidget(QLabel(self.tr("Description: "))) description.addWidget(self.snippetDescription) vlayoutWidget = QWidget() vlayout = QVBoxLayout() vlayout.addLayout(description) vlayout.addWidget(self.edit) vlayout.addLayout(buttons) vlayoutWidget.setLayout(vlayout) hsplitter = QSplitter() hsplitter.addWidget(treeWidget) hsplitter.addWidget(vlayoutWidget) hlayout = QHBoxLayout() hlayout.addWidget(hsplitter) self.showNormal() #Fixes bug that maximized windows are "stuck" #Because you can't trust QT to do the right thing here if (sys.platform == "darwin"): self.settings = QSettings("Vector35", "Snippet Editor") else: self.settings = QSettings("Vector 35", "Snippet Editor") if self.settings.contains("ui/snippeteditor/geometry"): self.restoreGeometry( self.settings.value("ui/snippeteditor/geometry")) else: self.edit.setMinimumWidth(80 * font.averageCharWidth()) self.edit.setMinimumHeight(30 * font.lineSpacing()) # Set dialog layout self.setLayout(hlayout) # Add signals self.saveButton.clicked.connect(self.save) self.closeButton.clicked.connect(self.close) self.runButton.clicked.connect(self.run) self.clearHotkeyButton.clicked.connect(self.clearHotkey) self.tree.selectionModel().selectionChanged.connect(self.selectFile) self.newSnippetButton.clicked.connect(self.newFileDialog) self.deleteSnippetButton.clicked.connect(self.deleteSnippet) #self.newFolderButton.clicked.connect(self.newFolder) self.browseButton.clicked.connect(self.browseSnippets) if self.settings.contains("ui/snippeteditor/selected"): selectedName = self.settings.value("ui/snippeteditor/selected") self.tree.selectionModel().select( self.files.index(selectedName), QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) if self.tree.selectionModel().hasSelection(): self.selectFile(self.tree.selectionModel().selection(), None) self.edit.setFocus() cursor = self.edit.textCursor() cursor.setPosition(self.edit.document().characterCount() - 1) self.edit.setTextCursor(cursor) else: self.readOnly(True) else: self.readOnly(True)
class Ui_testGlWindow(object): def setupUi(self, testGlWindow): if not testGlWindow.objectName(): testGlWindow.setObjectName(u"testGlWindow") testGlWindow.resize(952, 847) testGlWindow.setAcceptDrops(True) icon = QIcon() icon.addFile(u":/images/candle_256.png", QSize(), QIcon.Normal, QIcon.Off) testGlWindow.setWindowIcon(icon) testGlWindow.setStyleSheet(u"") self.centralWidget = QWidget(testGlWindow) self.centralWidget.setObjectName(u"centralWidget") self.horizontalLayout_5 = QHBoxLayout(self.centralWidget) self.horizontalLayout_5.setSpacing(9) self.horizontalLayout_5.setContentsMargins(11, 11, 11, 11) self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.horizontalLayout_5.setContentsMargins(9, 9, 5, 9) self.grpProgram = QGroupBox(self.centralWidget) self.grpProgram.setObjectName(u"grpProgram") self.grpProgram.setFlat(False) self.verticalLayout_17 = QVBoxLayout(self.grpProgram) self.verticalLayout_17.setSpacing(7) self.verticalLayout_17.setContentsMargins(11, 11, 11, 11) self.verticalLayout_17.setObjectName(u"verticalLayout_17") self.verticalLayout_17.setContentsMargins(8, 8, 8, 8) self.splitter = QSplitter(self.grpProgram) self.splitter.setObjectName(u"splitter") self.splitter.setOrientation(Qt.Vertical) self.splitter.setHandleWidth(12) self.frame = QWidget(self.splitter) self.frame.setObjectName(u"frame") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frame.sizePolicy().hasHeightForWidth()) self.frame.setSizePolicy(sizePolicy) self.frame.setMinimumSize(QSize(0, 600)) self.frame.setStyleSheet(u"border: 1px solid gray;") self.verticalLayout_8 = QVBoxLayout(self.frame) self.verticalLayout_8.setSpacing(6) self.verticalLayout_8.setContentsMargins(11, 11, 11, 11) self.verticalLayout_8.setObjectName(u"verticalLayout_8") self.verticalLayout_8.setContentsMargins(1, 1, 1, 1) self.splitter.addWidget(self.frame) self.layoutWidget = QWidget(self.splitter) self.layoutWidget.setObjectName(u"layoutWidget") self.verticalLayout_7 = QVBoxLayout(self.layoutWidget) self.verticalLayout_7.setSpacing(9) self.verticalLayout_7.setContentsMargins(11, 11, 11, 11) self.verticalLayout_7.setObjectName(u"verticalLayout_7") self.verticalLayout_7.setContentsMargins(0, 0, 0, 0) self.tblProgram = QTableView(self.layoutWidget) self.tblProgram.setObjectName(u"tblProgram") font = QFont() font.setPointSize(9) self.tblProgram.setFont(font) self.tblProgram.setContextMenuPolicy(Qt.CustomContextMenu) self.tblProgram.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.tblProgram.setSelectionMode(QAbstractItemView.ContiguousSelection) self.tblProgram.setSelectionBehavior(QAbstractItemView.SelectRows) self.tblProgram.setGridStyle(Qt.DashLine) self.tblProgram.horizontalHeader().setMinimumSectionSize(50) self.tblProgram.horizontalHeader().setHighlightSections(False) self.tblProgram.verticalHeader().setVisible(False) self.verticalLayout_7.addWidget(self.tblProgram) self.splitter.addWidget(self.layoutWidget) self.verticalLayout_17.addWidget(self.splitter) self.verticalLayout_17.setStretch(0, 1) self.horizontalLayout_5.addWidget(self.grpProgram) self.horizontalLayout_5.setStretch(0, 100) testGlWindow.setCentralWidget(self.centralWidget) self.menuBar = QMenuBar(testGlWindow) self.menuBar.setObjectName(u"menuBar") self.menuBar.setGeometry(QRect(0, 0, 952, 21)) testGlWindow.setMenuBar(self.menuBar) self.retranslateUi(testGlWindow) QMetaObject.connectSlotsByName(testGlWindow) # setupUi def retranslateUi(self, testGlWindow): testGlWindow.setWindowTitle( QCoreApplication.translate("testGlWindow", u"Candle", None)) self.grpProgram.setTitle( QCoreApplication.translate("testGlWindow", u"G-code program", None))
class Ui_tfm(object): def setupUi(self, tfm): if not tfm.objectName(): tfm.setObjectName(u"tfm") tfm.resize(800, 600) tfm.setContextMenuPolicy(Qt.NoContextMenu) tfm.setLocale(QLocale(QLocale.English, QLocale.UnitedStates)) self.action_menu = QAction(tfm) self.action_menu.setObjectName(u"action_menu") self.action_new_dir = QAction(tfm) self.action_new_dir.setObjectName(u"action_new_dir") self.action_new_file = QAction(tfm) self.action_new_file.setObjectName(u"action_new_file") self.action_back = QAction(tfm) self.action_back.setObjectName(u"action_back") self.action_up = QAction(tfm) self.action_up.setObjectName(u"action_up") self.action_home = QAction(tfm) self.action_home.setObjectName(u"action_home") self.action_go = QAction(tfm) self.action_go.setObjectName(u"action_go") self.action_forward = QAction(tfm) self.action_forward.setObjectName(u"action_forward") self.action_copy = QAction(tfm) self.action_copy.setObjectName(u"action_copy") self.action_paste = QAction(tfm) self.action_paste.setObjectName(u"action_paste") self.action_cut = QAction(tfm) self.action_cut.setObjectName(u"action_cut") self.action_show_hidden = QAction(tfm) self.action_show_hidden.setObjectName(u"action_show_hidden") self.action_show_hidden.setCheckable(True) self.action_delete = QAction(tfm) self.action_delete.setObjectName(u"action_delete") self.action_rename = QAction(tfm) self.action_rename.setObjectName(u"action_rename") self.action_add_to_bookmarks = QAction(tfm) self.action_add_to_bookmarks.setObjectName(u"action_add_to_bookmarks") self.action_remove_bookmark = QAction(tfm) self.action_remove_bookmark.setObjectName(u"action_remove_bookmark") self.action_copy_path = QAction(tfm) self.action_copy_path.setObjectName(u"action_copy_path") self.action_extract_here = QAction(tfm) self.action_extract_here.setObjectName(u"action_extract_here") self.action_mount_iso = QAction(tfm) self.action_mount_iso.setObjectName(u"action_mount_iso") self.centralwidget = QWidget(tfm) self.centralwidget.setObjectName(u"centralwidget") self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setObjectName(u"horizontalLayout") self.vsplit = QSplitter(self.centralwidget) self.vsplit.setObjectName(u"vsplit") self.vsplit.setOrientation(Qt.Horizontal) self.hsplit = QSplitter(self.vsplit) self.hsplit.setObjectName(u"hsplit") self.hsplit.setOrientation(Qt.Vertical) self.fs_tree = QTreeView(self.hsplit) self.fs_tree.setObjectName(u"fs_tree") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.fs_tree.sizePolicy().hasHeightForWidth()) self.fs_tree.setSizePolicy(sizePolicy) self.fs_tree.setTabKeyNavigation(True) self.fs_tree.setProperty("showDropIndicator", True) self.fs_tree.setDragEnabled(False) self.fs_tree.setDragDropMode(QAbstractItemView.DropOnly) self.fs_tree.setDefaultDropAction(Qt.MoveAction) self.fs_tree.setRootIsDecorated(False) self.hsplit.addWidget(self.fs_tree) self.fs_tree.header().setVisible(False) self.bookmark_view = QListView(self.hsplit) self.bookmark_view.setObjectName(u"bookmark_view") self.bookmark_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.bookmark_view.setEditTriggers(QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.bookmark_view.setTabKeyNavigation(True) self.bookmark_view.setDragDropOverwriteMode(True) self.bookmark_view.setDragDropMode(QAbstractItemView.DropOnly) self.bookmark_view.setDefaultDropAction(Qt.CopyAction) self.bookmark_view.setAlternatingRowColors(True) self.hsplit.addWidget(self.bookmark_view) self.mounts_view = QListView(self.hsplit) self.mounts_view.setObjectName(u"mounts_view") self.mounts_view.setTabKeyNavigation(True) self.mounts_view.setAlternatingRowColors(True) self.hsplit.addWidget(self.mounts_view) self.vsplit.addWidget(self.hsplit) self.table_view = QTableView(self.vsplit) self.table_view.setObjectName(u"table_view") sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy1.setHorizontalStretch(1) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.table_view.sizePolicy().hasHeightForWidth()) self.table_view.setSizePolicy(sizePolicy1) self.table_view.viewport().setProperty("cursor", QCursor(Qt.ArrowCursor)) self.table_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.table_view.setAcceptDrops(True) self.table_view.setToolTipDuration(-3) self.table_view.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.table_view.setDragEnabled(True) self.table_view.setDragDropMode(QAbstractItemView.DragDrop) self.table_view.setDefaultDropAction(Qt.MoveAction) self.table_view.setAlternatingRowColors(True) self.table_view.setSelectionMode(QAbstractItemView.ExtendedSelection) self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.table_view.setTextElideMode(Qt.ElideMiddle) self.table_view.setShowGrid(False) self.table_view.setSortingEnabled(True) self.table_view.setWordWrap(False) self.vsplit.addWidget(self.table_view) self.table_view.horizontalHeader().setDefaultSectionSize(150) self.table_view.horizontalHeader().setHighlightSections(False) self.table_view.horizontalHeader().setStretchLastSection(True) self.table_view.verticalHeader().setVisible(False) self.horizontalLayout.addWidget(self.vsplit) tfm.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(tfm) self.statusbar.setObjectName(u"statusbar") self.statusbar.setContextMenuPolicy(Qt.NoContextMenu) self.statusbar.setSizeGripEnabled(False) tfm.setStatusBar(self.statusbar) self.toolbar = QToolBar(tfm) self.toolbar.setObjectName(u"toolbar") self.toolbar.setContextMenuPolicy(Qt.PreventContextMenu) self.toolbar.setMovable(False) tfm.addToolBar(Qt.TopToolBarArea, self.toolbar) self.toolbar.addAction(self.action_back) self.toolbar.addAction(self.action_forward) self.toolbar.addAction(self.action_up) self.toolbar.addAction(self.action_home) self.toolbar.addAction(self.action_go) self.retranslateUi(tfm) QMetaObject.connectSlotsByName(tfm) # setupUi def retranslateUi(self, tfm): tfm.setWindowTitle(QCoreApplication.translate("tfm", u"tfm", None)) self.action_menu.setText( QCoreApplication.translate("tfm", u"Menu", None)) self.action_new_dir.setText( QCoreApplication.translate("tfm", u"New Directory", None)) self.action_new_file.setText( QCoreApplication.translate("tfm", u"New File", None)) self.action_back.setText( QCoreApplication.translate("tfm", u"Back", None)) self.action_up.setText(QCoreApplication.translate("tfm", u"Up", None)) self.action_home.setText( QCoreApplication.translate("tfm", u"Home", None)) self.action_go.setText(QCoreApplication.translate("tfm", u"Go", None)) #if QT_CONFIG(tooltip) self.action_go.setToolTip( QCoreApplication.translate("tfm", u"Go or Reload", None)) #endif // QT_CONFIG(tooltip) self.action_forward.setText( QCoreApplication.translate("tfm", u"Forward", None)) self.action_copy.setText( QCoreApplication.translate("tfm", u"Copy", None)) self.action_paste.setText( QCoreApplication.translate("tfm", u"Paste", None)) self.action_cut.setText(QCoreApplication.translate( "tfm", u"Cut", None)) self.action_show_hidden.setText( QCoreApplication.translate("tfm", u"Show hidden files", None)) #if QT_CONFIG(shortcut) self.action_show_hidden.setShortcut( QCoreApplication.translate("tfm", u"Ctrl+H", None)) #endif // QT_CONFIG(shortcut) self.action_delete.setText( QCoreApplication.translate("tfm", u"Delete", None)) self.action_rename.setText( QCoreApplication.translate("tfm", u"Rename", None)) self.action_add_to_bookmarks.setText( QCoreApplication.translate("tfm", u"Add to bookmarks", None)) self.action_remove_bookmark.setText( QCoreApplication.translate("tfm", u"Remove bookmark", None)) #if QT_CONFIG(tooltip) self.action_remove_bookmark.setToolTip( QCoreApplication.translate("tfm", u"Remove bookmark", None)) #endif // QT_CONFIG(tooltip) self.action_copy_path.setText( QCoreApplication.translate("tfm", u"Copy path", None)) self.action_extract_here.setText( QCoreApplication.translate("tfm", u"Extract here", None)) #if QT_CONFIG(tooltip) self.action_extract_here.setToolTip( QCoreApplication.translate("tfm", u"Extract here", None)) #endif // QT_CONFIG(tooltip) self.action_mount_iso.setText( QCoreApplication.translate("tfm", u"Mount ISO", None)) #if QT_CONFIG(tooltip) self.action_mount_iso.setToolTip( QCoreApplication.translate("tfm", u"Mount ISO", None))
class DebugView(QWidget, View): class DebugViewHistoryEntry(HistoryEntry): def __init__(self, memory_addr, address, is_raw): HistoryEntry.__init__(self) self.memory_addr = memory_addr self.address = address self.is_raw = is_raw def __repr__(self): if self.is_raw: return "<raw history: {}+{:0x} (memory: {:0x})>".format(self.address['module'], self.address['offset'], self.memory_addr) return "<code history: {:0x} (memory: {:0x})>".format(self.address, self.memory_addr) def __init__(self, parent, data): if not type(data) == BinaryView: raise Exception('expected widget data to be a BinaryView') self.bv = data self.debug_state = binjaplug.get_state(data) memory_view = self.debug_state.memory_view self.debug_state.ui.debug_view = self QWidget.__init__(self, parent) self.controls = ControlsWidget.DebugControlsWidget(self, "Controls", data, self.debug_state) View.__init__(self) self.setupView(self) self.current_offset = 0 self.splitter = QSplitter(Qt.Orientation.Horizontal, self) frame = ViewFrame.viewFrameForWidget(self) self.memory_editor = LinearView(memory_view, frame) self.binary_editor = DisassemblyContainer(frame, data, frame) self.binary_text = TokenizedTextView(self, memory_view) self.is_raw_disassembly = False self.raw_address = 0 self.is_navigating_history = False self.memory_history_addr = 0 # TODO: Handle these and change views accordingly # Currently they are just disabled as the DisassemblyContainer gets confused # about where to go and just shows a bad view self.binary_editor.getDisassembly().actionHandler().bindAction("View in Hex Editor", UIAction()) self.binary_editor.getDisassembly().actionHandler().bindAction("View in Linear Disassembly", UIAction()) self.binary_editor.getDisassembly().actionHandler().bindAction("View in Types View", UIAction()) self.memory_editor.actionHandler().bindAction("View in Hex Editor", UIAction()) self.memory_editor.actionHandler().bindAction("View in Disassembly Graph", UIAction()) self.memory_editor.actionHandler().bindAction("View in Types View", UIAction()) small_font = QApplication.font() small_font.setPointSize(11) bv_layout = QVBoxLayout() bv_layout.setSpacing(0) bv_layout.setContentsMargins(0, 0, 0, 0) bv_label = QLabel("Loaded File") bv_label.setFont(small_font) bv_layout.addWidget(bv_label) bv_layout.addWidget(self.binary_editor) self.bv_widget = QWidget() self.bv_widget.setLayout(bv_layout) disasm_layout = QVBoxLayout() disasm_layout.setSpacing(0) disasm_layout.setContentsMargins(0, 0, 0, 0) disasm_label = QLabel("Raw Disassembly at PC") disasm_label.setFont(small_font) disasm_layout.addWidget(disasm_label) disasm_layout.addWidget(self.binary_text) self.disasm_widget = QWidget() self.disasm_widget.setLayout(disasm_layout) memory_layout = QVBoxLayout() memory_layout.setSpacing(0) memory_layout.setContentsMargins(0, 0, 0, 0) memory_label = QLabel("Debugged Process") memory_label.setFont(small_font) memory_layout.addWidget(memory_label) memory_layout.addWidget(self.memory_editor) self.memory_widget = QWidget() self.memory_widget.setLayout(memory_layout) self.splitter.addWidget(self.bv_widget) self.splitter.addWidget(self.memory_widget) # Equally sized self.splitter.setSizes([0x7fffffff, 0x7fffffff]) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.controls) layout.addWidget(self.splitter, 100) self.setLayout(layout) self.needs_update = True self.update_timer = QTimer(self) self.update_timer.setInterval(200) self.update_timer.setSingleShot(False) self.update_timer.timeout.connect(lambda: self.updateTimerEvent()) self.add_scripting_ref() # set initial breakpoint when view is switched if self.debug_state.bv and self.debug_state.bv.entry_point: local_entry_offset = self.debug_state.bv.entry_point - self.debug_state.bv.start if not self.debug_state.breakpoints.contains_offset(self.debug_state.bv.file.original_filename, local_entry_offset): self.debug_state.breakpoints.add_offset(self.debug_state.bv.file.original_filename, local_entry_offset) if self.debug_state.ui is not None: self.debug_state.ui.breakpoint_tag_add(self.debug_state.bv.entry_point) self.debug_state.ui.update_highlights() self.debug_state.ui.update_breakpoints() def add_scripting_ref(self): # Hack: The interpreter is just a thread, so look through all threads # and assign our state to the interpreter's locals for thread in threading.enumerate(): if type(thread) == PythonScriptingInstance.InterpreterThread: thread.locals["dbg"] = self.debug_state def getData(self): return self.bv def getFont(self): return binaryninjaui.getMonospaceFont(self) def getCurrentOffset(self): if not self.is_raw_disassembly: return self.binary_editor.getDisassembly().getCurrentOffset() return self.raw_address def getSelectionOffsets(self): if not self.is_raw_disassembly: return self.binary_editor.getDisassembly().getSelectionOffsets() return (self.raw_address, self.raw_address) def getCurrentFunction(self): if not self.is_raw_disassembly: return self.binary_editor.getDisassembly().getCurrentFunction() return None def getCurrentBasicBlock(self): if not self.is_raw_disassembly: return self.binary_editor.getDisassembly().getCurrentBasicBlock() return None def getCurrentArchitecture(self): if not self.is_raw_disassembly: return self.binary_editor.getDisassembly().getCurrentArchitecture() return None def getCurrentLowLevelILFunction(self): if not self.is_raw_disassembly: return self.binary_editor.getDisassembly().getCurrentLowLevelILFunction() return None def getCurrentMediumLevelILFunction(self): if not self.is_raw_disassembly: return self.binary_editor.getDisassembly().getCurrentMediumLevelILFunction() return None def getHistoryEntry(self): if self.is_navigating_history: return None memory_addr = self.memory_editor.getCurrentOffset() if memory_addr != self.memory_history_addr: self.memory_history_addr = memory_addr if self.is_raw_disassembly and self.debug_state.connected: rel_addr = self.debug_state.modules.absolute_addr_to_relative(self.raw_address) return DebugView.DebugViewHistoryEntry(memory_addr, rel_addr, True) else: address = self.binary_editor.getDisassembly().getCurrentOffset() return DebugView.DebugViewHistoryEntry(memory_addr, address, False) def navigateToFunction(self, func, offset): return self.navigate(offset) def navigateToHistoryEntry(self, entry): self.is_navigating_history = True if hasattr(entry, 'is_raw'): self.memory_editor.navigate(entry.memory_addr) if entry.is_raw: if self.debug_state.connected: address = self.debug_state.modules.relative_addr_to_absolute(entry.address) self.navigate_raw(address) else: self.navigate_live(entry.address) View.navigateToHistoryEntry(self, entry) self.is_navigating_history = False def navigate(self, addr): # If we're not connected we cannot even check if the address is remote if not self.debug_state.connected: return self.navigate_live(addr) if self.debug_state.memory_view.is_local_addr(addr): local_addr = self.debug_state.memory_view.remote_addr_to_local(addr) if self.debug_state.bv.read(local_addr, 1) and len(self.debug_state.bv.get_functions_containing(local_addr)) > 0: return self.navigate_live(local_addr) # This runs into conflicts if some other address space is mapped over # where the local BV is currently loaded, but this is was less likely # than the user navigating to a function from the UI if self.debug_state.bv.read(addr, 1) and len(self.debug_state.bv.get_functions_containing(addr)) > 0: return self.navigate_live(addr) return self.navigate_raw(addr) def navigate_live(self, addr): self.show_raw_disassembly(False) return self.binary_editor.getDisassembly().navigate(addr) def navigate_raw(self, addr): if not self.debug_state.connected: # Can't navigate to remote addr when disconnected return False self.raw_address = addr self.show_raw_disassembly(True) self.load_raw_disassembly(addr) return True def notifyMemoryChanged(self): self.needs_update = True def updateTimerEvent(self): if self.needs_update: self.needs_update = False # Refresh the editor if not self.debug_state.connected: self.memory_editor.navigate(0) return # self.memory_editor.navigate(self.debug_state.stack_pointer) def showEvent(self, event): if not event.spontaneous(): self.update_timer.start() self.add_scripting_ref() def hideEvent(self, event): if not event.spontaneous(): self.update_timer.stop() def shouldBeVisible(self, view_frame): if view_frame is None: return False else: return True def load_raw_disassembly(self, start_ip): # Read a few instructions from rip and disassemble them inst_count = 50 arch_dis = self.debug_state.remote_arch rip = self.debug_state.ip # Assume the worst, just in case read_length = arch_dis.max_instr_length * inst_count data = self.debug_state.memory_view.read(start_ip, read_length) lines = [] # Append header line tokens = [InstructionTextToken(InstructionTextTokenType.TextToken, "(Code not backed by loaded file, showing only raw disassembly)")] contents = DisassemblyTextLine(tokens, start_ip) line = LinearDisassemblyLine(LinearDisassemblyLineType.BasicLineType, None, None, contents) lines.append(line) total_read = 0 for i in range(inst_count): line_addr = start_ip + total_read (insn_tokens, length) = arch_dis.get_instruction_text(data[total_read:], line_addr) if insn_tokens is None: insn_tokens = [InstructionTextToken(InstructionTextTokenType.TextToken, "??")] length = arch_dis.instr_alignment if length == 0: length = 1 # terrible libshiboken workaround, see #101 for tok in insn_tokens: if tok.value.bit_length() == 64: tok.value ^= 0x8000000000000000 tokens = [] color = HighlightStandardColor.NoHighlightColor if line_addr == rip: if self.debug_state.breakpoints.contains_absolute(start_ip + total_read): # Breakpoint & pc tokens.append(InstructionTextToken(InstructionTextTokenType.TagToken, self.debug_state.ui.get_breakpoint_tag_type().icon + ">", width=5)) color = HighlightStandardColor.RedHighlightColor else: # PC tokens.append(InstructionTextToken(InstructionTextTokenType.TextToken, " ==> ")) color = HighlightStandardColor.BlueHighlightColor else: if self.debug_state.breakpoints.contains_absolute(start_ip + total_read): # Breakpoint tokens.append(InstructionTextToken(InstructionTextTokenType.TagToken, self.debug_state.ui.get_breakpoint_tag_type().icon, width=5)) color = HighlightStandardColor.RedHighlightColor else: # Regular line tokens.append(InstructionTextToken(InstructionTextTokenType.TextToken, " ")) # Address tokens.append(InstructionTextToken(InstructionTextTokenType.AddressDisplayToken, hex(line_addr)[2:], line_addr)) tokens.append(InstructionTextToken(InstructionTextTokenType.TextToken, " ")) tokens.extend(insn_tokens) # Convert to linear disassembly line contents = DisassemblyTextLine(tokens, line_addr, color=color) line = LinearDisassemblyLine(LinearDisassemblyLineType.CodeDisassemblyLineType, None, None, contents) lines.append(line) total_read += length self.binary_text.setLines(lines) def show_raw_disassembly(self, raw): if raw != self.is_raw_disassembly: self.splitter.replaceWidget(0, self.disasm_widget if raw else self.bv_widget) self.is_raw_disassembly = raw def refresh_raw_disassembly(self): if not self.debug_state.connected: # Can't navigate to remote addr when disconnected return if self.is_raw_disassembly: self.load_raw_disassembly(self.getCurrentOffset())
class BuilderWidget(QWidget): def __init__(self, parent=None) -> None: super().__init__(parent) self.verticalLayout = QVBoxLayout(self) self.compileButton = QPushButton('Compile', self) self.compileButton.setMinimumSize(QSize(200, 50)) self.verticalLayout.addWidget(self.compileButton, 0, Qt.AlignHCenter) self.tidyButton = QPushButton('Tidy', self) self.verticalLayout.addWidget(self.tidyButton, 0, Qt.AlignHCenter) self.splitter = QSplitter(self) self.splitter.setOrientation(Qt.Vertical) self.widget = QWidget(self.splitter) self.widget.setObjectName(u"widget") self.verticalLayout2 = QVBoxLayout(self.widget) self.stdoutLabel = QLabel(self.widget) self.stdoutLabel.setText('stdout:') self.verticalLayout2.addWidget(self.stdoutLabel) self.stdoutText = QTextEdit(self.widget) self.stdoutText.setEnabled(False) self.stdoutText.setReadOnly(True) self.stdoutText.setPlainText("Output will appear here") self.verticalLayout2.addWidget(self.stdoutText) self.splitter.addWidget(self.widget) self.widget1 = QWidget(self.splitter) self.verticalLayout3 = QVBoxLayout(self.widget1) self.stderrLabel = QLabel(self.widget1) self.stderrLabel.setText('stderr:') self.verticalLayout3.addWidget(self.stderrLabel) self.stderrText = QTextEdit(self.widget1) self.stderrText.setEnabled(False) self.stderrText.setReadOnly(True) self.stderrText.setPlainText('Errors will appear here') self.verticalLayout3.addWidget(self.stderrText) self.splitter.addWidget(self.widget1) self.verticalLayout.addWidget(self.splitter) # Logic # Use QProcess to start a program and get its outputs https://stackoverflow.com/a/22110924 self.process = QProcess(self) self.process.readyReadStandardOutput.connect(self.readStdout) self.process.readyReadStandardError.connect(self.readStderr) self.process.started.connect(self.processStarted) self.process.finished.connect(self.processFinished) self.process.errorOccurred.connect(self.errorOccurred) self.compileButton.clicked.connect(self.doCompile) self.tidyButton.clicked.connect(self.doTidy) def doCompile(self): self.cleanupUI() self.process.setWorkingDirectory(settings.get_repo_location()) self.process.startCommand(settings.get_build_command()) def doTidy(self): self.cleanupUI() self.process.setWorkingDirectory(settings.get_repo_location()) self.process.startCommand(settings.get_tidy_command()) def cleanupUI(self): self.stdoutText.setEnabled(True) self.stderrText.setEnabled(True) self.stdoutText.setPlainText('') self.stderrText.setPlainText('') def readStdout(self): lines = self.process.readAllStandardOutput().data().decode( )[:-1].split('\n') for line in lines: if line == 'tmc.gba: FAILED': line = 'tmc.gba: <b style="color:red">FAILED</b>' elif line == 'tmc.gba: OK': line = 'tmc.gba: <b style="color:lime">OK</b>' self.stdoutText.append(line) def readStderr(self): lines = self.process.readAllStandardError().data().decode()[:-1].split( '\n') for line in lines: if 'error' in line.lower(): line = f'<span style="color:red">{line}</span>' elif 'warning' in line.lower(): line = f'<span style="color:orange">{line}</span>' self.stderrText.append(line) def processStarted(self): self.compileButton.setEnabled(False) self.tidyButton.setEnabled(False) def processFinished(self): self.compileButton.setEnabled(True) self.tidyButton.setEnabled(True) def errorOccurred(self): self.stderrText.insertPlainText(self.process.errorString())
class Ui_AssetDialog(object): def setupUi(self, AssetDialog): if not AssetDialog.objectName(): AssetDialog.setObjectName(u"AssetDialog") AssetDialog.setWindowModality(Qt.ApplicationModal) AssetDialog.resize(927, 323) AssetDialog.setModal(False) self.gridLayout = QGridLayout(AssetDialog) self.gridLayout.setSpacing(2) self.gridLayout.setObjectName(u"gridLayout") self.gridLayout.setContentsMargins(2, 2, 2, 2) self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(self.horizontalSpacer_4, 1, 2, 1, 1) self.frame = QFrame(AssetDialog) self.frame.setObjectName(u"frame") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) self.frame.setSizePolicy(sizePolicy) self.frame.setFrameShape(QFrame.NoFrame) self.frame.setFrameShadow(QFrame.Raised) self.horizontalLayout_3 = QHBoxLayout(self.frame) self.horizontalLayout_3.setSpacing(2) self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.splitter = QSplitter(self.frame) self.splitter.setObjectName(u"splitter") sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth()) self.splitter.setSizePolicy(sizePolicy1) self.splitter.setOrientation(Qt.Horizontal) self.SymbolsFrame = QFrame(self.splitter) self.SymbolsFrame.setObjectName(u"SymbolsFrame") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy2.setHorizontalStretch(5) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth(self.SymbolsFrame.sizePolicy().hasHeightForWidth()) self.SymbolsFrame.setSizePolicy(sizePolicy2) self.SymbolsFrame.setFrameShape(QFrame.NoFrame) self.SymbolsFrame.setFrameShadow(QFrame.Raised) self.verticalLayout = QVBoxLayout(self.SymbolsFrame) self.verticalLayout.setSpacing(2) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.SymbolsCaptionFrame = QFrame(self.SymbolsFrame) self.SymbolsCaptionFrame.setObjectName(u"SymbolsCaptionFrame") self.SymbolsCaptionFrame.setFrameShape(QFrame.NoFrame) self.SymbolsCaptionFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout_5 = QHBoxLayout(self.SymbolsCaptionFrame) self.horizontalLayout_5.setSpacing(2) self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.SymbolsLabel = QLabel(self.SymbolsCaptionFrame) self.SymbolsLabel.setObjectName(u"SymbolsLabel") self.horizontalLayout_5.addWidget(self.SymbolsLabel) self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_5.addItem(self.horizontalSpacer_2) self.AddSymbolButton = QPushButton(self.SymbolsCaptionFrame) self.AddSymbolButton.setObjectName(u"AddSymbolButton") self.horizontalLayout_5.addWidget(self.AddSymbolButton) self.RemoveSymbolButton = QPushButton(self.SymbolsCaptionFrame) self.RemoveSymbolButton.setObjectName(u"RemoveSymbolButton") self.horizontalLayout_5.addWidget(self.RemoveSymbolButton) self.verticalLayout.addWidget(self.SymbolsCaptionFrame) self.SymbolsTable = QTableView(self.SymbolsFrame) self.SymbolsTable.setObjectName(u"SymbolsTable") self.SymbolsTable.setEditTriggers(QAbstractItemView.AnyKeyPressed|QAbstractItemView.EditKeyPressed|QAbstractItemView.SelectedClicked) self.SymbolsTable.setAlternatingRowColors(True) self.SymbolsTable.setSelectionBehavior(QAbstractItemView.SelectRows) self.SymbolsTable.verticalHeader().setVisible(False) self.SymbolsTable.verticalHeader().setMinimumSectionSize(20) self.SymbolsTable.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.SymbolsTable) self.splitter.addWidget(self.SymbolsFrame) self.DataFrame = QFrame(self.splitter) self.DataFrame.setObjectName(u"DataFrame") sizePolicy3 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy3.setHorizontalStretch(2) sizePolicy3.setVerticalStretch(0) sizePolicy3.setHeightForWidth(self.DataFrame.sizePolicy().hasHeightForWidth()) self.DataFrame.setSizePolicy(sizePolicy3) self.DataFrame.setFrameShape(QFrame.NoFrame) self.DataFrame.setFrameShadow(QFrame.Raised) self.verticalLayout_2 = QVBoxLayout(self.DataFrame) self.verticalLayout_2.setSpacing(2) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.DataCaptionFrame = QFrame(self.DataFrame) self.DataCaptionFrame.setObjectName(u"DataCaptionFrame") self.DataCaptionFrame.setFrameShape(QFrame.NoFrame) self.DataCaptionFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout_2 = QHBoxLayout(self.DataCaptionFrame) self.horizontalLayout_2.setSpacing(2) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.DataLbl = QLabel(self.DataCaptionFrame) self.DataLbl.setObjectName(u"DataLbl") self.horizontalLayout_2.addWidget(self.DataLbl) self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(self.horizontalSpacer_3) self.AddDataButton = QPushButton(self.DataCaptionFrame) self.AddDataButton.setObjectName(u"AddDataButton") self.horizontalLayout_2.addWidget(self.AddDataButton) self.RemoveDataButton = QPushButton(self.DataCaptionFrame) self.RemoveDataButton.setObjectName(u"RemoveDataButton") self.horizontalLayout_2.addWidget(self.RemoveDataButton) self.verticalLayout_2.addWidget(self.DataCaptionFrame) self.DataTable = QTableView(self.DataFrame) self.DataTable.setObjectName(u"DataTable") self.DataTable.setEditTriggers(QAbstractItemView.AnyKeyPressed|QAbstractItemView.EditKeyPressed|QAbstractItemView.SelectedClicked) self.DataTable.setAlternatingRowColors(True) self.DataTable.setSelectionBehavior(QAbstractItemView.SelectRows) self.DataTable.verticalHeader().setVisible(False) self.DataTable.verticalHeader().setMinimumSectionSize(20) self.DataTable.verticalHeader().setDefaultSectionSize(20) self.verticalLayout_2.addWidget(self.DataTable) self.splitter.addWidget(self.DataFrame) self.horizontalLayout_3.addWidget(self.splitter) self.gridLayout.addWidget(self.frame, 3, 0, 1, 5) self.NameLbl = QLabel(AssetDialog) self.NameLbl.setObjectName(u"NameLbl") self.gridLayout.addWidget(self.NameLbl, 0, 0, 1, 1) self.isinLbl = QLabel(AssetDialog) self.isinLbl.setObjectName(u"isinLbl") self.gridLayout.addWidget(self.isinLbl, 1, 0, 1, 1) self.BaseAssetSelector = AssetSelector(AssetDialog) self.BaseAssetSelector.setObjectName(u"BaseAssetSelector") self.gridLayout.addWidget(self.BaseAssetSelector, 2, 1, 1, 1) self.ButtonsFrame = QFrame(AssetDialog) self.ButtonsFrame.setObjectName(u"ButtonsFrame") self.ButtonsFrame.setFrameShape(QFrame.NoFrame) self.ButtonsFrame.setFrameShadow(QFrame.Raised) self.horizontalLayout = QHBoxLayout(self.ButtonsFrame) self.horizontalLayout.setSpacing(2) self.horizontalLayout.setObjectName(u"horizontalLayout") self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(self.horizontalSpacer) self.CancelButton = QPushButton(self.ButtonsFrame) self.CancelButton.setObjectName(u"CancelButton") self.horizontalLayout.addWidget(self.CancelButton) self.OkButton = QPushButton(self.ButtonsFrame) self.OkButton.setObjectName(u"OkButton") self.horizontalLayout.addWidget(self.OkButton) self.gridLayout.addWidget(self.ButtonsFrame, 10, 0, 1, 5) self.BaseLbl = QLabel(AssetDialog) self.BaseLbl.setObjectName(u"BaseLbl") self.gridLayout.addWidget(self.BaseLbl, 2, 0, 1, 1) self.TypeLbl = QLabel(AssetDialog) self.TypeLbl.setObjectName(u"TypeLbl") self.gridLayout.addWidget(self.TypeLbl, 1, 3, 1, 1) self.isinEdit = QLineEdit(AssetDialog) self.isinEdit.setObjectName(u"isinEdit") self.gridLayout.addWidget(self.isinEdit, 1, 1, 1, 1) self.CountryLbl = QLabel(AssetDialog) self.CountryLbl.setObjectName(u"CountryLbl") self.gridLayout.addWidget(self.CountryLbl, 2, 3, 1, 1) self.CountryCombo = CountryCombo(AssetDialog) self.CountryCombo.setObjectName(u"CountryCombo") self.gridLayout.addWidget(self.CountryCombo, 2, 4, 1, 1) self.TypeCombo = AssetTypeCombo(AssetDialog) self.TypeCombo.setObjectName(u"TypeCombo") self.gridLayout.addWidget(self.TypeCombo, 1, 4, 1, 1) self.NameEdit = QLineEdit(AssetDialog) self.NameEdit.setObjectName(u"NameEdit") self.gridLayout.addWidget(self.NameEdit, 0, 1, 1, 4) self.retranslateUi(AssetDialog) self.OkButton.clicked.connect(AssetDialog.accept) self.CancelButton.clicked.connect(AssetDialog.reject) QMetaObject.connectSlotsByName(AssetDialog) # setupUi def retranslateUi(self, AssetDialog): AssetDialog.setWindowTitle(QCoreApplication.translate("AssetDialog", u"Asset", None)) self.SymbolsLabel.setText(QCoreApplication.translate("AssetDialog", u"Symbols", None)) self.AddSymbolButton.setText("") self.RemoveSymbolButton.setText("") self.DataLbl.setText(QCoreApplication.translate("AssetDialog", u"Extra data", None)) self.AddDataButton.setText("") self.RemoveDataButton.setText("") self.NameLbl.setText(QCoreApplication.translate("AssetDialog", u"Name:", None)) self.isinLbl.setText(QCoreApplication.translate("AssetDialog", u"ISIN:", None)) self.CancelButton.setText(QCoreApplication.translate("AssetDialog", u"Cancel", None)) self.OkButton.setText(QCoreApplication.translate("AssetDialog", u"OK", None)) self.BaseLbl.setText(QCoreApplication.translate("AssetDialog", u"Base asset:", None)) self.TypeLbl.setText(QCoreApplication.translate("AssetDialog", u"Type: ", None)) self.CountryLbl.setText(QCoreApplication.translate("AssetDialog", u"Country: ", None))
class Ui_OperationsWidget(object): def setupUi(self, OperationsWidget): if not OperationsWidget.objectName(): OperationsWidget.setObjectName(u"OperationsWidget") OperationsWidget.resize(1232, 552) self.verticalLayout_4 = QVBoxLayout(OperationsWidget) self.verticalLayout_4.setSpacing(0) self.verticalLayout_4.setObjectName(u"verticalLayout_4") self.verticalLayout_4.setContentsMargins(0, 0, 0, 0) self.BalanceOperationsSplitter = QSplitter(OperationsWidget) self.BalanceOperationsSplitter.setObjectName( u"BalanceOperationsSplitter") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.BalanceOperationsSplitter.sizePolicy().hasHeightForWidth()) self.BalanceOperationsSplitter.setSizePolicy(sizePolicy) self.BalanceOperationsSplitter.setOrientation(Qt.Horizontal) self.BalanceBox = QGroupBox(self.BalanceOperationsSplitter) self.BalanceBox.setObjectName(u"BalanceBox") sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy1.setHorizontalStretch(1) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.BalanceBox.sizePolicy().hasHeightForWidth()) self.BalanceBox.setSizePolicy(sizePolicy1) self.BalanceBox.setMaximumSize(QSize(16777215, 16777215)) self.verticalLayout = QVBoxLayout(self.BalanceBox) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.BalanceConfigFrame = QFrame(self.BalanceBox) self.BalanceConfigFrame.setObjectName(u"BalanceConfigFrame") self.BalanceConfigFrame.setMinimumSize(QSize(408, 0)) self.BalanceConfigFrame.setMaximumSize(QSize(16777215, 44)) self.BalanceConfigFrame.setFrameShape(QFrame.Panel) self.BalanceConfigFrame.setFrameShadow(QFrame.Plain) self.BalanceConfigFrame.setLineWidth(0) self.horizontalLayout_2 = QHBoxLayout(self.BalanceConfigFrame) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.horizontalLayout_2.setContentsMargins(2, 2, 2, 2) self.BalanceDate = QDateEdit(self.BalanceConfigFrame) self.BalanceDate.setObjectName(u"BalanceDate") self.BalanceDate.setDateTime( QDateTime(QDate(2020, 11, 25), QTime(21, 0, 0))) self.BalanceDate.setCalendarPopup(True) self.BalanceDate.setTimeSpec(Qt.UTC) self.horizontalLayout_2.addWidget(self.BalanceDate) self.CurrencyLbl = QLabel(self.BalanceConfigFrame) self.CurrencyLbl.setObjectName(u"CurrencyLbl") self.CurrencyLbl.setLayoutDirection(Qt.LeftToRight) self.CurrencyLbl.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.horizontalLayout_2.addWidget(self.CurrencyLbl) self.BalancesCurrencyCombo = CurrencyComboBox(self.BalanceConfigFrame) self.BalancesCurrencyCombo.setObjectName(u"BalancesCurrencyCombo") self.horizontalLayout_2.addWidget(self.BalancesCurrencyCombo) self.ShowInactiveCheckBox = QCheckBox(self.BalanceConfigFrame) self.ShowInactiveCheckBox.setObjectName(u"ShowInactiveCheckBox") self.horizontalLayout_2.addWidget(self.ShowInactiveCheckBox) self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(self.horizontalSpacer_2) self.verticalLayout.addWidget(self.BalanceConfigFrame) self.BalancesTableView = QTableView(self.BalanceBox) self.BalancesTableView.setObjectName(u"BalancesTableView") self.BalancesTableView.setFrameShape(QFrame.Panel) self.BalancesTableView.setEditTriggers( QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked) self.BalancesTableView.setAlternatingRowColors(True) self.BalancesTableView.setSelectionMode(QAbstractItemView.NoSelection) self.BalancesTableView.setGridStyle(Qt.DotLine) self.BalancesTableView.setWordWrap(False) self.BalancesTableView.verticalHeader().setVisible(False) self.BalancesTableView.verticalHeader().setMinimumSectionSize(20) self.BalancesTableView.verticalHeader().setDefaultSectionSize(20) self.verticalLayout.addWidget(self.BalancesTableView) self.BalanceOperationsSplitter.addWidget(self.BalanceBox) self.OperationsBox = QGroupBox(self.BalanceOperationsSplitter) self.OperationsBox.setObjectName(u"OperationsBox") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy2.setHorizontalStretch(4) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth( self.OperationsBox.sizePolicy().hasHeightForWidth()) self.OperationsBox.setSizePolicy(sizePolicy2) self.OperationsBox.setContextMenuPolicy(Qt.DefaultContextMenu) self.verticalLayout_2 = QVBoxLayout(self.OperationsBox) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.OperationConfigFrame = QFrame(self.OperationsBox) self.OperationConfigFrame.setObjectName(u"OperationConfigFrame") self.OperationConfigFrame.setEnabled(True) self.OperationConfigFrame.setMinimumSize(QSize(0, 0)) self.OperationConfigFrame.setFrameShape(QFrame.Panel) self.OperationConfigFrame.setFrameShadow(QFrame.Plain) self.OperationConfigFrame.setLineWidth(0) self.horizontalLayout_3 = QHBoxLayout(self.OperationConfigFrame) self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.horizontalLayout_3.setContentsMargins(2, 2, 2, 2) self.DateRange = DateRangeSelector(self.OperationConfigFrame) self.DateRange.setObjectName(u"DateRange") self.DateRange.setProperty("ItemsList", u"week;month;quarter;year;all") self.horizontalLayout_3.addWidget(self.DateRange) self.AccountLbl = QLabel(self.OperationConfigFrame) self.AccountLbl.setObjectName(u"AccountLbl") self.horizontalLayout_3.addWidget(self.AccountLbl) self.ChooseAccountBtn = AccountButton(self.OperationConfigFrame) self.ChooseAccountBtn.setObjectName(u"ChooseAccountBtn") self.horizontalLayout_3.addWidget(self.ChooseAccountBtn) self.SearchLbl = QLabel(self.OperationConfigFrame) self.SearchLbl.setObjectName(u"SearchLbl") self.horizontalLayout_3.addWidget(self.SearchLbl) self.SearchString = QLineEdit(self.OperationConfigFrame) self.SearchString.setObjectName(u"SearchString") self.horizontalLayout_3.addWidget(self.SearchString) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_3.addItem(self.horizontalSpacer) self.verticalLayout_2.addWidget(self.OperationConfigFrame) self.OperationsDetailsSplitter = QSplitter(self.OperationsBox) self.OperationsDetailsSplitter.setObjectName( u"OperationsDetailsSplitter") self.OperationsDetailsSplitter.setOrientation(Qt.Vertical) self.OperationsTableView = QTableView(self.OperationsDetailsSplitter) self.OperationsTableView.setObjectName(u"OperationsTableView") sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy3.setHorizontalStretch(0) sizePolicy3.setVerticalStretch(4) sizePolicy3.setHeightForWidth( self.OperationsTableView.sizePolicy().hasHeightForWidth()) self.OperationsTableView.setSizePolicy(sizePolicy3) self.OperationsTableView.setAlternatingRowColors(True) self.OperationsTableView.setSelectionMode( QAbstractItemView.ExtendedSelection) self.OperationsTableView.setSelectionBehavior( QAbstractItemView.SelectRows) self.OperationsTableView.setWordWrap(False) self.OperationsDetailsSplitter.addWidget(self.OperationsTableView) self.OperationsTableView.verticalHeader().setVisible(False) self.OperationsTableView.verticalHeader().setMinimumSectionSize(20) self.OperationsTableView.verticalHeader().setDefaultSectionSize(20) self.OperationDetails = QFrame(self.OperationsDetailsSplitter) self.OperationDetails.setObjectName(u"OperationDetails") sizePolicy4 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy4.setHorizontalStretch(0) sizePolicy4.setVerticalStretch(1) sizePolicy4.setHeightForWidth( self.OperationDetails.sizePolicy().hasHeightForWidth()) self.OperationDetails.setSizePolicy(sizePolicy4) self.OperationDetails.setMinimumSize(QSize(0, 100)) self.OperationDetails.setMaximumSize(QSize(16777215, 300)) self.OperationDetails.setFrameShape(QFrame.Panel) self.OperationDetails.setFrameShadow(QFrame.Sunken) self.OperationDetails.setLineWidth(1) self.horizontalLayout_4 = QHBoxLayout(self.OperationDetails) self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) self.OperationsTabs = QStackedWidget(self.OperationDetails) self.OperationsTabs.setObjectName(u"OperationsTabs") self.NoOperation = QWidget() self.NoOperation.setObjectName(u"NoOperation") self.OperationsTabs.addWidget(self.NoOperation) self.IncomeSpending = IncomeSpendingWidget() self.IncomeSpending.setObjectName(u"IncomeSpending") self.OperationsTabs.addWidget(self.IncomeSpending) self.Dividend = DividendWidget() self.Dividend.setObjectName(u"Dividend") self.OperationsTabs.addWidget(self.Dividend) self.Trade = TradeWidget() self.Trade.setObjectName(u"Trade") self.OperationsTabs.addWidget(self.Trade) self.Transfer = TransferWidget() self.Transfer.setObjectName(u"Transfer") self.OperationsTabs.addWidget(self.Transfer) self.CorporateAction = CorporateActionWidget() self.CorporateAction.setObjectName(u"CorporateAction") self.OperationsTabs.addWidget(self.CorporateAction) self.horizontalLayout_4.addWidget(self.OperationsTabs) self.OperationsButtons = QFrame(self.OperationDetails) self.OperationsButtons.setObjectName(u"OperationsButtons") self.verticalLayout_3 = QVBoxLayout(self.OperationsButtons) self.verticalLayout_3.setSpacing(2) self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.verticalLayout_3.setContentsMargins(2, 2, 2, 2) self.NewOperationBtn = QPushButton(self.OperationsButtons) self.NewOperationBtn.setObjectName(u"NewOperationBtn") self.verticalLayout_3.addWidget(self.NewOperationBtn) self.CopyOperationBtn = QPushButton(self.OperationsButtons) self.CopyOperationBtn.setObjectName(u"CopyOperationBtn") self.verticalLayout_3.addWidget(self.CopyOperationBtn) self.DeleteOperationBtn = QPushButton(self.OperationsButtons) self.DeleteOperationBtn.setObjectName(u"DeleteOperationBtn") self.verticalLayout_3.addWidget(self.DeleteOperationBtn) self.verticalSpacer_4 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_3.addItem(self.verticalSpacer_4) self.horizontalLayout_4.addWidget(self.OperationsButtons) self.OperationsDetailsSplitter.addWidget(self.OperationDetails) self.verticalLayout_2.addWidget(self.OperationsDetailsSplitter) self.BalanceOperationsSplitter.addWidget(self.OperationsBox) self.verticalLayout_4.addWidget(self.BalanceOperationsSplitter) self.retranslateUi(OperationsWidget) self.OperationsTabs.setCurrentIndex(5) QMetaObject.connectSlotsByName(OperationsWidget) # setupUi def retranslateUi(self, OperationsWidget): OperationsWidget.setWindowTitle( QCoreApplication.translate("OperationsWidget", u"Operations & Balances", None)) self.BalanceBox.setTitle( QCoreApplication.translate("OperationsWidget", u"Balances", None)) self.BalanceDate.setDisplayFormat( QCoreApplication.translate("OperationsWidget", u"dd/MM/yyyy", None)) self.CurrencyLbl.setText( QCoreApplication.translate("OperationsWidget", u"Sum Currency:", None)) self.ShowInactiveCheckBox.setText( QCoreApplication.translate("OperationsWidget", u"Show &Inactive", None)) self.OperationsBox.setTitle( QCoreApplication.translate("OperationsWidget", u"Operations", None)) self.AccountLbl.setText( QCoreApplication.translate("OperationsWidget", u"Account:", None)) self.SearchLbl.setText( QCoreApplication.translate("OperationsWidget", u"Search:", None)) #if QT_CONFIG(tooltip) self.NewOperationBtn.setToolTip( QCoreApplication.translate("OperationsWidget", u"New operation", None)) #endif // QT_CONFIG(tooltip) self.NewOperationBtn.setText("") #if QT_CONFIG(tooltip) self.CopyOperationBtn.setToolTip( QCoreApplication.translate("OperationsWidget", u"Copy operation", None)) #endif // QT_CONFIG(tooltip) self.CopyOperationBtn.setText("") #if QT_CONFIG(tooltip) self.DeleteOperationBtn.setToolTip( QCoreApplication.translate("OperationsWidget", u"Delete operation", None)) #endif // QT_CONFIG(tooltip) self.DeleteOperationBtn.setText("")
def __init__(self, parent, data): QScrollArea.__init__(self, parent) View.__init__(self) View.setBinaryDataNavigable(self, True) self.setupView(self) self.data = data self.currentOffset = 0 self.byteView = None self.fullAnalysisButton = None self.importsWidget = None container = QWidget(self) layout = QVBoxLayout() entropyGroup = QGroupBox("Entropy", container) entropyLayout = QVBoxLayout() entropyLayout.addWidget( entropy.EntropyWidget(entropyGroup, self, self.data)) entropyGroup.setLayout(entropyLayout) layout.addWidget(entropyGroup) hdr = None try: if self.data.view_type == "PE": hdr = headers.PEHeaders(self.data) elif self.data.view_type != "Raw": hdr = headers.GenericHeaders(self.data) except: log.log_error(traceback.format_exc()) if hdr is not None: headerGroup = QGroupBox("Headers", container) headerLayout = QVBoxLayout() headerWidget = headers.HeaderWidget(headerGroup, hdr) headerLayout.addWidget(headerWidget) headerGroup.setLayout(headerLayout) layout.addWidget(headerGroup) if self.data.executable: importExportSplitter = QSplitter(Qt.Horizontal) importGroup = QGroupBox("Imports", container) importLayout = QVBoxLayout() self.importsWidget = imports.ImportsWidget(importGroup, self, self.data) importLayout.addWidget(self.importsWidget) importGroup.setLayout(importLayout) importExportSplitter.addWidget(importGroup) exportGroup = QGroupBox("Exports", container) exportLayout = QVBoxLayout() exportLayout.addWidget( exports.ExportsWidget(exportGroup, self, self.data)) exportGroup.setLayout(exportLayout) importExportSplitter.addWidget(exportGroup) layout.addWidget(importExportSplitter) if self.data.view_type != "PE": segmentsGroup = QGroupBox("Segments", container) segmentsLayout = QVBoxLayout() segmentsWidget = sections.SegmentsWidget( segmentsGroup, self.data) segmentsLayout.addWidget(segmentsWidget) segmentsGroup.setLayout(segmentsLayout) layout.addWidget(segmentsGroup) if len(segmentsWidget.segments) == 0: segmentsGroup.hide() sectionsGroup = QGroupBox("Sections", container) sectionsLayout = QVBoxLayout() sectionsWidget = sections.SectionsWidget(sectionsGroup, self.data) sectionsLayout.addWidget(sectionsWidget) sectionsGroup.setLayout(sectionsLayout) layout.addWidget(sectionsGroup) if len(sectionsWidget.sections) == 0: sectionsGroup.hide() buttonLayout = QHBoxLayout() buttonLayout.addStretch(1) self.loadDynamicButton = QPushButton("Load Dynamic Imports") self.loadDynamicButton.clicked.connect( self.importsWidget.scanDynamic) buttonLayout.addWidget(self.loadDynamicButton) self.fullAnalysisButton = QPushButton("Start Full Analysis") self.fullAnalysisButton.clicked.connect(self.startFullAnalysis) buttonLayout.addWidget(self.fullAnalysisButton) layout.addLayout(buttonLayout) layout.addStretch(1) else: self.byteView = byte.ByteView(self, self.data) layout.addWidget(self.byteView, 1) container.setLayout(layout) self.setWidgetResizable(True) self.setWidget(container) if self.fullAnalysisButton is not None and Settings().get_string( "analysis.mode", data) == "full": self.fullAnalysisButton.hide()
class Ui_JAL_MainWindow(object): def setupUi(self, JAL_MainWindow): if not JAL_MainWindow.objectName(): JAL_MainWindow.setObjectName(u"JAL_MainWindow") JAL_MainWindow.resize(835, 436) JAL_MainWindow.setMinimumSize(QSize(0, 0)) self.actionExit = QAction(JAL_MainWindow) self.actionExit.setObjectName(u"actionExit") self.actionExit.setMenuRole(QAction.QuitRole) self.action_Re_build_Ledger = QAction(JAL_MainWindow) self.action_Re_build_Ledger.setObjectName(u"action_Re_build_Ledger") self.action_LoadQuotes = QAction(JAL_MainWindow) self.action_LoadQuotes.setObjectName(u"action_LoadQuotes") self.actionImportStatement = QAction(JAL_MainWindow) self.actionImportStatement.setObjectName(u"actionImportStatement") self.actionAccountTypes = QAction(JAL_MainWindow) self.actionAccountTypes.setObjectName(u"actionAccountTypes") self.actionAccounts = QAction(JAL_MainWindow) self.actionAccounts.setObjectName(u"actionAccounts") self.actionAssets = QAction(JAL_MainWindow) self.actionAssets.setObjectName(u"actionAssets") self.actionPeers = QAction(JAL_MainWindow) self.actionPeers.setObjectName(u"actionPeers") self.actionCategories = QAction(JAL_MainWindow) self.actionCategories.setObjectName(u"actionCategories") self.actionBackup = QAction(JAL_MainWindow) self.actionBackup.setObjectName(u"actionBackup") self.actionRestore = QAction(JAL_MainWindow) self.actionRestore.setObjectName(u"actionRestore") self.PrepareTaxForms = QAction(JAL_MainWindow) self.PrepareTaxForms.setObjectName(u"PrepareTaxForms") self.MakeDealsReport = QAction(JAL_MainWindow) self.MakeDealsReport.setObjectName(u"MakeDealsReport") self.actionTags = QAction(JAL_MainWindow) self.actionTags.setObjectName(u"actionTags") self.MakePLReport = QAction(JAL_MainWindow) self.MakePLReport.setObjectName(u"MakePLReport") self.MakeCategoriesReport = QAction(JAL_MainWindow) self.MakeCategoriesReport.setObjectName(u"MakeCategoriesReport") self.actionImportSlipRU = QAction(JAL_MainWindow) self.actionImportSlipRU.setObjectName(u"actionImportSlipRU") self.actionCountries = QAction(JAL_MainWindow) self.actionCountries.setObjectName(u"actionCountries") self.actionQuotes = QAction(JAL_MainWindow) self.actionQuotes.setObjectName(u"actionQuotes") self.actionOperations = QAction(JAL_MainWindow) self.actionOperations.setObjectName(u"actionOperations") self.centralwidget = QWidget(JAL_MainWindow) self.centralwidget.setObjectName(u"centralwidget") self.centralwidget.setMaximumSize(QSize(16777215, 16777215)) self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setSpacing(0) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.splitter = QSplitter(self.centralwidget) self.splitter.setObjectName(u"splitter") self.splitter.setOrientation(Qt.Vertical) self.mdiArea = TabbedMdiArea(self.splitter) self.mdiArea.setObjectName(u"mdiArea") self.splitter.addWidget(self.mdiArea) self.Logs = LogViewer(self.splitter) self.Logs.setObjectName(u"Logs") self.splitter.addWidget(self.Logs) self.verticalLayout.addWidget(self.splitter) JAL_MainWindow.setCentralWidget(self.centralwidget) self.MainMenu = QMenuBar(JAL_MainWindow) self.MainMenu.setObjectName(u"MainMenu") self.MainMenu.setGeometry(QRect(0, 0, 835, 23)) self.menuMain = QMenu(self.MainMenu) self.menuMain.setObjectName(u"menuMain") self.menu_Data = QMenu(self.MainMenu) self.menu_Data.setObjectName(u"menu_Data") self.menuPredefined_data = QMenu(self.menu_Data) self.menuPredefined_data.setObjectName(u"menuPredefined_data") self.menu_Export = QMenu(self.MainMenu) self.menu_Export.setObjectName(u"menu_Export") self.menuLanguage = QMenu(self.MainMenu) self.menuLanguage.setObjectName(u"menuLanguage") self.menuImport = QMenu(self.MainMenu) self.menuImport.setObjectName(u"menuImport") self.menuStatement = QMenu(self.menuImport) self.menuStatement.setObjectName(u"menuStatement") self.menuReports = QMenu(self.MainMenu) self.menuReports.setObjectName(u"menuReports") JAL_MainWindow.setMenuBar(self.MainMenu) self.StatusBar = QStatusBar(JAL_MainWindow) self.StatusBar.setObjectName(u"StatusBar") JAL_MainWindow.setStatusBar(self.StatusBar) self.MainMenu.addAction(self.menuMain.menuAction()) self.MainMenu.addAction(self.menu_Data.menuAction()) self.MainMenu.addAction(self.menuReports.menuAction()) self.MainMenu.addAction(self.menuImport.menuAction()) self.MainMenu.addAction(self.menu_Export.menuAction()) self.MainMenu.addAction(self.menuLanguage.menuAction()) self.menuMain.addAction(self.actionOperations) self.menuMain.addAction(self.actionExit) self.menu_Data.addSeparator() self.menu_Data.addAction(self.actionAccounts) self.menu_Data.addAction(self.actionAssets) self.menu_Data.addAction(self.actionPeers) self.menu_Data.addAction(self.actionCategories) self.menu_Data.addAction(self.actionTags) self.menu_Data.addAction(self.actionCountries) self.menu_Data.addAction(self.actionQuotes) self.menu_Data.addAction(self.menuPredefined_data.menuAction()) self.menu_Data.addSeparator() self.menu_Data.addAction(self.actionBackup) self.menu_Data.addAction(self.actionRestore) self.menu_Data.addSeparator() self.menu_Data.addAction(self.action_Re_build_Ledger) self.menuPredefined_data.addAction(self.actionAccountTypes) self.menu_Export.addAction(self.PrepareTaxForms) self.menuImport.addAction(self.action_LoadQuotes) self.menuImport.addAction(self.menuStatement.menuAction()) self.menuImport.addAction(self.actionImportSlipRU) self.retranslateUi(JAL_MainWindow) QMetaObject.connectSlotsByName(JAL_MainWindow) # setupUi def retranslateUi(self, JAL_MainWindow): JAL_MainWindow.setWindowTitle( QCoreApplication.translate("JAL_MainWindow", u"jal", None)) self.actionExit.setText( QCoreApplication.translate("JAL_MainWindow", u"&Exit", None)) self.action_Re_build_Ledger.setText( QCoreApplication.translate("JAL_MainWindow", u"Re-build &Ledger...", None)) self.action_LoadQuotes.setText( QCoreApplication.translate("JAL_MainWindow", u"&Quotes...", None)) self.actionImportStatement.setText( QCoreApplication.translate("JAL_MainWindow", u"&Broker statement...", None)) self.actionAccountTypes.setText( QCoreApplication.translate("JAL_MainWindow", u"Account &Types", None)) self.actionAccounts.setText( QCoreApplication.translate("JAL_MainWindow", u"&Accounts", None)) self.actionAssets.setText( QCoreApplication.translate("JAL_MainWindow", u"A&ssets", None)) self.actionPeers.setText( QCoreApplication.translate("JAL_MainWindow", u"&Peers", None)) self.actionCategories.setText( QCoreApplication.translate("JAL_MainWindow", u"&Categories", None)) self.actionBackup.setText( QCoreApplication.translate("JAL_MainWindow", u"&Backup...", None)) self.actionRestore.setText( QCoreApplication.translate("JAL_MainWindow", u"&Restore...", None)) self.PrepareTaxForms.setText( QCoreApplication.translate("JAL_MainWindow", u"&Tax report [RU]", None)) self.MakeDealsReport.setText( QCoreApplication.translate("JAL_MainWindow", u"&Deals report", None)) self.actionTags.setText( QCoreApplication.translate("JAL_MainWindow", u"&Tags", None)) self.MakePLReport.setText( QCoreApplication.translate("JAL_MainWindow", u"&Profit/Loss report", None)) self.MakeCategoriesReport.setText( QCoreApplication.translate("JAL_MainWindow", u"&Income/Spending report", None)) self.actionImportSlipRU.setText( QCoreApplication.translate("JAL_MainWindow", u"Slip [RU]...", None)) self.actionCountries.setText( QCoreApplication.translate("JAL_MainWindow", u"C&ountries", None)) self.actionQuotes.setText( QCoreApplication.translate("JAL_MainWindow", u"&Quotes", None)) self.actionOperations.setText( QCoreApplication.translate("JAL_MainWindow", u"&Operations", None)) self.menuMain.setTitle( QCoreApplication.translate("JAL_MainWindow", u"&Main", None)) self.menu_Data.setTitle( QCoreApplication.translate("JAL_MainWindow", u"&Data", None)) self.menuPredefined_data.setTitle( QCoreApplication.translate("JAL_MainWindow", u"Predefined data", None)) self.menu_Export.setTitle( QCoreApplication.translate("JAL_MainWindow", u"&Export", None)) self.menuLanguage.setTitle( QCoreApplication.translate("JAL_MainWindow", u"L&anguage", None)) self.menuImport.setTitle( QCoreApplication.translate("JAL_MainWindow", u"&Import", None)) self.menuStatement.setTitle( QCoreApplication.translate("JAL_MainWindow", u"&Statement", None)) self.menuReports.setTitle( QCoreApplication.translate("JAL_MainWindow", u"&Reports", None))