Ejemplo n.º 1
0
    def __init__(self, parent=None):
        super().__init__(parent)

        layout_map = [
            [None, None, Symbol.CLEAR, Symbol.ALL_CLEAR],
            [Symbol.SEVEN, Symbol.EIGHT, Symbol.NINE, Symbol.DIVISION],
            [Symbol.FOUR, Symbol.FIVE, Symbol.SIX, Symbol.MULTIPLICATION],
            [Symbol.ONE, Symbol.TWO, Symbol.THREE, Symbol.SUBTRACTION],
            [Symbol.ZERO, Symbol.POINT, Symbol.EQUALS, Symbol.ADDITION]
        ]

        layout = QGridLayout()

        for row, columns in enumerate(layout_map):
            for column, symbol in enumerate(columns):
                if symbol is None:
                    continue
                button = QPushButton(symbol.value)
                button.clicked.connect(partial(self.button_clicked.emit, symbol))
                layout.addWidget(button, row, column)
                shortcut = QShortcut(QKeySequence(symbol.value), self)
                shortcut.activated.connect(button.click)

                alt_shortcut = None

                if symbol == Symbol.MULTIPLICATION:
                    alt_shortcut = QShortcut(QKeySequence('*'), self)
                elif symbol == Symbol.EQUALS:
                    alt_shortcut = QShortcut(QKeySequence.InsertParagraphSeparator, self)

                if alt_shortcut:
                    alt_shortcut.activated.connect(button.click)

        self.setLayout(layout)
Ejemplo n.º 2
0
Archivo: tfm.py Proyecto: tmahlburg/tfm
 def set_shortcuts(self):
     """
     Set shortcuts for actions.
     """
     self.action_copy.setShortcuts(
         QKeySequence.keyBindings(QKeySequence.Copy))
     self.action_paste.setShortcuts(
         QKeySequence.keyBindings(QKeySequence.Paste))
     self.action_cut.setShortcuts(
         QKeySequence.keyBindings(QKeySequence.Cut))
     self.action_delete.setShortcuts(
         QKeySequence.keyBindings(QKeySequence.Delete))
Ejemplo n.º 3
0
def loadSnippetFromFile(snippetPath):
    try:
        with codecs.open(snippetPath, 'r', 'utf-8') as snippetFile:
            snippetText = snippetFile.readlines()
    except:
        return ("", "", "")
    if (len(snippetText) < 3):
        return ("", "", "")
    else:
        qKeySequence = QKeySequence(snippetText[1].strip()[1:])
        if qKeySequence.isEmpty():
            qKeySequence = None
        return (snippetText[0].strip()[1:], qKeySequence,
                ''.join(snippetText[2:]))
Ejemplo n.º 4
0
    def add_shortcuts(self) -> None:
        key = "Alt+Right"
        self.nextTabShortcut = QShortcut(QKeySequence(key), self)
        self.nextTabShortcut.activated.connect(self.next_tab)
        key = "Ctrl+PgDown"
        self.nextTabShortcut2 = QShortcut(QKeySequence(key), self)
        self.nextTabShortcut2.activated.connect(self.next_tab)

        key = "Alt+Left"
        self.prevTabShortcut = QShortcut(QKeySequence(key), self)
        self.prevTabShortcut.activated.connect(self.prev_tab)
        key = "Ctrl+PgUp"
        self.prevTabShortcut2 = QShortcut(QKeySequence(key), self)
        self.prevTabShortcut2.activated.connect(self.prev_tab)
Ejemplo n.º 5
0
    def __init__(self):
        super(FindToolBar, self).__init__()
        self._line_edit = QLineEdit()
        self._line_edit.setClearButtonEnabled(True)
        self._line_edit.setPlaceholderText("Find...")
        self._line_edit.setMaximumWidth(300)
        self._line_edit.returnPressed.connect(self._find_next)
        self.addWidget(self._line_edit)

        self._previous_button = QToolButton()
        style_icons = ':/qt-project.org/styles/commonstyle/images/'
        self._previous_button.setIcon(QIcon(style_icons + 'up-32.png'))
        self._previous_button.clicked.connect(self._find_previous)
        self.addWidget(self._previous_button)

        self._next_button = QToolButton()
        self._next_button.setIcon(QIcon(style_icons + 'down-32.png'))
        self._next_button.clicked.connect(self._find_next)
        self.addWidget(self._next_button)

        self._case_sensitive_checkbox = QCheckBox('Case Sensitive')
        self.addWidget(self._case_sensitive_checkbox)

        self._hideButton = QToolButton()
        self._hideButton.setShortcut(QKeySequence(Qt.Key_Escape))
        self._hideButton.setIcon(QIcon(style_icons + 'closedock-16.png'))
        self._hideButton.clicked.connect(self.hide)
        self.addWidget(self._hideButton)
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.app: QCoreApplication = QApplication.instance()

        self.shortcut_close = QShortcut(QKeySequence("Ctrl+w"), self)
        self.shortcut_close.activated.connect(self.hide)
Ejemplo n.º 7
0
    def __init__(self):
        super().__init__()

        self._fileMenu = self.addMenu("&File")

        self._fileMenu.addAction("New").triggered.connect(self.newProgram.emit)
        self._fileMenu.addAction("Open...").triggered.connect(
            self.openProgram.emit)
        self._recentMenu = self._fileMenu.addMenu("Open Recent")
        saveAction = self._fileMenu.addAction("Save")
        saveAction.triggered.connect(self.saveProgram.emit)
        saveAction.setShortcut(QKeySequence("Ctrl+S"))
        self._fileMenu.addAction("Save As...").triggered.connect(
            self.saveProgramAs.emit)
        self._fileMenu.addAction("Close").triggered.connect(
            self.closeProgram.emit)
        self._fileMenu.addSeparator()
        self._fileMenu.addAction("Settings")
        self._fileMenu.addSeparator()
        self._fileMenu.addAction("Exit")

        self._editMenu = self.addMenu("&Edit")
        self._editMenu.addAction("Undo")
        self._editMenu.addAction("Redo")
        self._editMenu.addSeparator()
        self._editMenu.addAction("Cut")
        self._editMenu.addAction("Copy")
        self._editMenu.addAction("Paste")
        self._editMenu.addSeparator()
        self._editMenu.addAction("Select All")

        self._viewMenu = self.addMenu("&View")
Ejemplo n.º 8
0
    def setup_layouts_tab(self):
        layouts = settings.get_layouts()

        self.layouts_model = LayoutModel(layouts, self)
        #layouts_model = MyStringListModel(layouts, self)
        self.ui.listLayouts.setModel(self.layouts_model)

        shortcut_delete = QShortcut(QKeySequence(Qt.Key_Delete),
                                    self.ui.listLayouts)
        shortcut_delete.activated.connect(self.delete_layout)

        # Need to connect to the signal here instead of on the button box, so we are informed before anyone that is connected to the finish slot
        self.accepted.connect(self.save_settings)
        self.ui.buttonBox.button(QDialogButtonBox.Apply).clicked.connect(
            self.save_settings)

        # for layout in layouts:
        #     self.ui.listLayouts.addItem(layout)

        # # Make entries editable
        # for index in range(self.ui.listLayouts.count()):
        #     item = self.ui.listLayouts.item(index)
        #     item.setFlags(item.flags() | Qt.ItemIsEditable | Qt.Delete)

        self.ui.listLayouts.setDragDropMode(
            QListView.DragDropMode.InternalMove)
Ejemplo n.º 9
0
def create_action(
    parent: QObject,
    text: str = None,
    icon: QIcon = None,
    toggled=None,
    triggered=None,
    name: str = None,
    shortcut: str = None,
    is_checked: bool = False,
    is_checkable: bool = False,
    enable: bool = True,
) -> AAction:
    action = AAction(parent)
    if text is not None:
        action.setText(text)
    if triggered is not None:
        action.triggered.connect(triggered)  # type: ignore
    if toggled is not None:
        action.toggled.connect(toggled)  # type: ignore
        action.setCheckable(True)
    if icon is not None:
        action.setIcon(icon)
    if name is not None:
        action.setObjectName(name)
    if shortcut is not None:
        action.setShortcut(QKeySequence(shortcut))  # type: ignore
    action.setChecked(is_checked)
    action.setCheckable(is_checkable)
    action.setEnabled(enable)
    return action
Ejemplo n.º 10
0
    def __init__(self):
        super().__init__()

        self._fileMenu = self.addMenu("&File")

        newAction = self._fileMenu.addAction("New")
        newAction.triggered.connect(self.new.emit)
        newAction.setShortcut(QKeySequence("Ctrl+N"))
        openAction = self._fileMenu.addAction("Open...")
        openAction.triggered.connect(self.open.emit)
        openAction.setShortcut(QKeySequence("Ctrl+O"))

        saveAction = self._fileMenu.addAction("Save")
        saveAction.triggered.connect(self.save.emit)
        saveAction.setShortcut(QKeySequence("Ctrl+S"))

        saveAsAction = self._fileMenu.addAction("Save As...")
        saveAsAction.triggered.connect(self.saveAs.emit)
        saveAsAction.setShortcut(QKeySequence("Ctrl+Shift+S"))

        exitAction = self._fileMenu.addAction("Exit")
        exitAction.triggered.connect(self.exit.emit)

        self._editMenu = self.addMenu("&Edit")
        # self._editMenu.addAction("Undo")
        # self._editMenu.addAction("Redo")
        # self._editMenu.addSeparator()
        # self._editMenu.addAction("Cut")
        # self._editMenu.addAction("Copy")
        # self._editMenu.addAction("Paste")
        # self._editMenu.addSeparator()
        # self._editMenu.addAction("Select All")

        self._viewMenu = self.addMenu("&View")
        self._zoomMenu = self._viewMenu.addMenu("Zoom")
        # self._zoomMenu.addAction("In")
        # self._zoomMenu.addAction("Out")
        # self._zoomMenu.addAction("100%")
        # self._zoomMenu.addAction("150%")
        self._zoomMenu.addAction("Fit All").triggered.connect(
            self.zoomToFit.emit)
        # self._viewMenu.addSeparator()
        self._viewMenu.addAction("Chip Programs").triggered.connect(
            self.showProgramList.emit)
        self._viewMenu.addAction("Rig").triggered.connect(
            self.showRigView.emit)
Ejemplo n.º 11
0
    def setup_file_menu(self):
        file_menu = self.menuBar().addMenu(self.tr("&File"))

        new_file_act = file_menu.addAction(self.tr("&New..."))
        new_file_act.setShortcut(QKeySequence(QKeySequence.New))
        new_file_act.triggered.connect(self.new_file)

        open_file_act = file_menu.addAction(self.tr("&Open..."))
        open_file_act.setShortcut(QKeySequence(QKeySequence.Open))
        open_file_act.triggered.connect(self.open_file)

        quit_act = file_menu.addAction(self.tr("E&xit"))
        quit_act.setShortcut(QKeySequence(QKeySequence.Quit))
        quit_act.triggered.connect(self.close)

        help_menu = self.menuBar().addMenu("&Help")
        help_menu.addAction("About &Qt", qApp.aboutQt)
Ejemplo n.º 12
0
 def clearSelection(self):
     self.keySequenceEdit.clear()
     self.currentHotkey = QKeySequence()
     self.currentHotkeyLabel.setText("")
     self.currentFileLabel.setText("")
     self.snippetDescription.setText("")
     self.edit.clear()
     self.tree.clearSelection()
     self.currentFile = ""
Ejemplo n.º 13
0
 def eventFilter(self, source, event):
     if event.type() == QEvent.KeyPress:
         if event.key():
             # show new keys in window
             self.capturedKeyLabel.setText(
                 str(
                     QKeySequence(event.modifiers()
                                  | event.key()).toString()))
     return super(KeyCapturingWindow, self).eventFilter(source, event)
Ejemplo n.º 14
0
 def load(self) -> None:
     self.action_show_bridge = self.api.register_menu_entry(
         'CExplore Bridge', self.slot_show_bridge)
     if CREATE_LISTS:
         self.action_find_nonmatching = self.api.register_menu_entry(
             'List NONMATCH', self.slot_find_nonmatching)
         self.action_find_nonmatching.setShortcut(QKeySequence("Ctrl+F3"))
         self.action_find_asmfunc = self.api.register_menu_entry(
             'List ASM_FUNC', self.slot_find_asmfunc)
Ejemplo n.º 15
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.l, m = load_gif(self)
        self.l.setGeometry(0, 0, 20, 20)

        self.app: QApplication = QApplication.instance()

        self.calc: QThread = QThread()
        self.frm: QFrame = QFrame(self)
        self.tray_icon_menu: QMenu = QMenu(self)
        self.tray_icon: QSystemTrayIcon = QSystemTrayIcon(self)

        self.app.view_main = self
        Setting()
        About()
        self.init_settings()
        self.init_main_window()
        self.init_tray_icon()
        self.init_frm()

        self.setAttribute(Qt.WA_TransparentForMouseEvents)

        self.shortcut_settings = QShortcut(QKeySequence("Ctrl+,"), self)
        self.shortcut_settings.activated.connect(self.show_settings)
        self.shortcut_refresh = QShortcut(QKeySequence("Ctrl+r"), self)
        self.shortcut_refresh.activated.connect(self.start_to_hope)
        self.shortcut_refresh = QShortcut(QKeySequence("Ctrl+q"), self)
        self.shortcut_refresh.activated.connect(self.close)

        if 'darwin' in sys.platform:
            menubar = self.menuBar()
            hope_menu = menubar.addMenu('Hope')

            hope_menu.addAction(
                QAction('About', self, triggered=self.show_about))
            hope_menu.addAction(
                QAction('Settings', self, triggered=self.show_settings))

        self.show()
        # self.show_settings()
        self.start_to_check_update()
Ejemplo n.º 16
0
def add_commands(plugin):
    DbgAction = namedtuple('DbgAction', 'name, key_seq, handler')
    plugin_actions = (
        DbgAction("SyncEnable", QKeySequence(Qt.ALT + Qt.Key_S), UIAction(plugin.cmd_sync)),
        DbgAction("SyncDisable", QKeySequence(Qt.ALT + Qt.SHIFT + Qt.Key_S), UIAction(plugin.cmd_syncoff)),
        DbgAction("SyncGo", QKeySequence(Qt.ALT + Qt.Key_F5), UIAction(plugin.cmd_go)),
        DbgAction("SyncStepOver", QKeySequence(Qt.Key_F10), UIAction(plugin.cmd_so)),
        DbgAction("SyncStepInto", QKeySequence(Qt.Key_F11), UIAction(plugin.cmd_si)),
        DbgAction("SyncTranslate", QKeySequence(Qt.ALT + Qt.Key_F2), UIAction(plugin.cmd_translate)),
        DbgAction("SyncBp", QKeySequence(Qt.Key_F2), UIAction(plugin.cmd_bp)),
        DbgAction("SyncHwBp", QKeySequence(Qt.CTRL + Qt.Key_F2), UIAction(plugin.cmd_hwbp)),
        DbgAction("SyncBpOneShot", QKeySequence(Qt.ALT + Qt.Key_F3), UIAction(plugin.cmd_bp1)),
        DbgAction("SyncHwBpOneShot", QKeySequence(Qt.CTRL + Qt.Key_F3), UIAction(plugin.cmd_hwbp1))
        )

    for action in plugin_actions:
        UIAction.registerAction(action.name, action.key_seq)
        UIActionHandler.globalActions().bindAction(action.name, action.handler)

    rs_log('commands added')
Ejemplo n.º 17
0
    def on_context_menu(self, pos: QPoint):
        index = self.indexAt(pos)
        menu = QMenu(self)

        meta_action = menu.addAction("View metadata")
        meta_action.triggered.connect(
            lambda chk=False, index=index: self.show_metadata_menu(index))

        remove_action = menu.addAction("Remove")
        remove_action.setShortcut(QKeySequence(QKeySequence.Delete))
        remove_action.triggered.connect(self.remove_selected_items)

        menu.popup(self.viewport().mapToGlobal(pos))
Ejemplo n.º 18
0
 def loadSnippet(self):
     self.currentFileLabel.setText(QFileInfo(self.currentFile).baseName())
     (snippetDescription, snippetKeys,
      snippetCode) = loadSnippetFromFile(self.currentFile)
     self.snippetDescription.setText(
         snippetDescription
     ) if snippetDescription else self.snippetDescription.setText("")
     self.keySequenceEdit.setKeySequence(
         snippetKeys
     ) if snippetKeys else self.keySequenceEdit.setKeySequence(
         QKeySequence(""))
     self.edit.setPlainText(
         snippetCode) if snippetCode else self.edit.setPlainText("")
     self.readOnly(False)
Ejemplo n.º 19
0
    def initUI(self):
        """
        Init widget

        """
        grid = QGridLayout()
        hbox = QHBoxLayout()
        hbox.addSpacing(2)

        self._buttonBack = QPushButton(QIcon(PATH_IMAGE_BACK_NEDDLE), "", self)
        self._buttonBack.clicked.connect(self.signalController.back2menu)
        hbox.addWidget(self._buttonBack, 0, QtCore.Qt.AlignLeft)

        self.label = QLabel("SettingsView")
        hbox.addWidget(self.label, 1, QtCore.Qt.AlignCenter)

        grid.addLayout(hbox, 0, 0, QtCore.Qt.AlignTop)

        jsonDataSettings = self.get_settings(None)

        # TODO: Possibility to change settings via this widget
        #self._labels_settings = []

        counter = 1

        for name in jsonDataSettings:
            single = jsonDataSettings[name]

            translated = single[self.TRANSLATED]
            value = single[self.VALUE]

            newLabel = QLabel(name.replace('_', ' '))
            if translated:
                secondLabel = QLabel(QKeySequence(value).toString())
            else:
                secondLabel = QLabel(str(value))

            grid.addWidget(newLabel, counter, 0, QtCore.Qt.AlignLeft)
            grid.addWidget(secondLabel, counter, 1, QtCore.Qt.AlignRight)

            counter += 1

        self.setLayout(grid)
        self.setWindowTitle("Game settings")
Ejemplo n.º 20
0
    def __init__(self, dock: HexViewerDock, rom_variant: RomVariant, rom: Rom) -> None:
        super().__init__(parent=dock)
        self.dock = dock
        self.area = dock.ui.hexArea
        self.status_bar = dock.ui.labelStatusBar
        self.scroll_bar = dock.ui.scrollBar
        self.rom_variant = rom_variant
        self.rom = rom
        self.address_resolver = TrivialAddressResolver()
        self.diff_calculator = NoDiffCalculator()

        # State TODO put into different class?
        self.is_linked = False
        self.start_offset = 0
        self.cursor = 0
        self.selected_bytes = 1

        self.display_byte_cache = {}  # TODO invalidate this cache if a constraint is added

        # Settings # TODO move elsewhere
        self.diff_color = QColor(158, 80, 88)  # QColor(244, 108, 117)
        self.pointer_color = QColor(68, 69, 34)
        self.default_annotation_color = QColor(50, 180, 50)
        self.default_selection_size = settings.get_default_selection_size()
        self.highlight_8_bytes = settings.is_highlight_8_bytes()

        self.contextmenu_handlers = []

        self.setup_scroll_bar()
        self.scroll_bar.valueChanged.connect(self.slot_scroll_bar_changed)

        # Connect to all necessary UI signals
        self.dock.ui.pushButtonGoto.clicked.connect(self.slot_show_goto_dialog)
        self.dock.ui.pushButtonLink.clicked.connect(self.slot_toggle_linked)
        # self.dock.ui.scrollBar.valueChanged.connect(self.on_scroll_bar_changed)
        self.area.signal_resized.connect(self.slot_on_resize)
        self.area.signal_scroll_wheel_changed.connect(
            self.slot_scroll_wheel_changed)
        self.area.signal_cursor_changed.connect(
            self.slot_update_cursor_from_offset)
        self.area.signal_selection_updated.connect(
            self.slot_update_selection_from_offset)
        self.area.signal_key_cursor_pressed.connect(
            self.slot_key_cursor_pressed)
        self.area.signal_key_selection_pressed.connect(
            self.slot_key_selection_pressed)
        self.area.signal_context_menu_shown.connect(
            self.slot_shot_context_menu)
        self.area.signal_show_tooltip_at_offset.connect(
            self.slot_show_tooltip_at_offset)
        self.area.signal_go_to_pointer_at_offset.connect(
            self.slot_go_to_pointer_at)

        # Keyboard shortcuts
        QShortcut(QKeySequence(Qt.Key_G), self.dock,
                  self.slot_show_goto_dialog, context=Qt.WidgetWithChildrenShortcut)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_C), self.dock,
                  self.copy_selected_bytes, context=Qt.WidgetWithChildrenShortcut)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_A), self.dock,
                  self.mark_as_all_pointer, context=Qt.WidgetWithChildrenShortcut)
        QShortcut(QKeySequence(Qt.Key_4), self.dock, lambda:self.update_selected_bytes(4),
                  context=Qt.WidgetWithChildrenShortcut)
        QShortcut(QKeySequence(Qt.Key_8), self.dock, lambda:self.update_selected_bytes(8),
                  context=Qt.WidgetWithChildrenShortcut)
        QShortcut(QKeySequence(Qt.Key_F3), self.dock, self.slot_jump_to_next_diff,
                  context=Qt.WidgetWithChildrenShortcut)
        QShortcut(QKeySequence(Qt.Key_Delete), self.dock, self.slot_delete_current_pointer,
                  context=Qt.WidgetWithChildrenShortcut)

        # TODO tmp
        QShortcut(QKeySequence(Qt.Key_Tab), self.dock, lambda:(self.update_cursor(self.cursor+5), self.update_selected_bytes(4)),
                  context=Qt.WidgetWithChildrenShortcut) # Go to next midi command or whatever
        QShortcut(QKeySequence(Qt.Key_W), self.dock, lambda:(self.update_cursor(self.cursor+12), self.update_selected_bytes(4)),
                  context=Qt.WidgetWithChildrenShortcut)

        self.pointers: PointerList = None
        self.annotations: AnnotationList = None
        self.constraints: ConstraintList = None
        self.symbols: SymbolList = None

        if settings.is_using_constraints():
            self.update_pointers()
            get_pointer_database().pointers_changed.connect(self.slot_update_pointers)

        self.update_annotations()
        get_annotation_database().annotations_changed.connect(self.slot_update_annotations)

        if settings.is_using_constraints():
            self.update_constraints()
            get_constraint_database().constraints_changed.connect(self.slot_update_constraints)

        self.update_symbols()
        get_symbol_database().symbols_changed.connect(self.slot_update_symbols)

        self.update_hex_area()

        self.status_bar.setText('loaded')
Ejemplo n.º 21
0
    def setupUi(self):
        self.centralwidget = QWidget(self)
        with open(resource_path('style.css'), 'r') as file:
            self.centralwidget.setStyleSheet(file.read())
        self.appswidget = QWidget(self.centralwidget)
        self.appswidget.setGeometry(50, 0, 490, 470)
        self.appswidget.setProperty('class', 'appswidget')
        self.sidebar = QFrame(self.centralwidget)
        self.sidebar.setFrameShape(QFrame.StyledPanel)
        self.sidebar.setGeometry(0, 0, 50, 470)
        self.sidebar.setProperty('class', 'sidebar')

        self.refresh_btn = QPushButton(self.sidebar)
        self.refresh_btn.setGeometry(QRect(0, 0, 51, 51))
        self.refresh_btn.setProperty('class', 'sidebar_btns')
        self.refresh_btn.setIcon(QIcon(':/icon/refresh_icon.png'))
        self.refresh_btn.setIconSize(QSize(24, 24))
        self.refresh_bind = QShortcut(QKeySequence('Ctrl+R'), self)

        self.store_btn = QPushButton(self.sidebar)
        self.store_btn.setGeometry(QRect(0, 51, 51, 51))
        self.store_btn.setProperty('class', 'sidebar_btns')
        self.store_btn.setIcon(QIcon(':/icon/store_icon.png'))
        self.store_btn.setIconSize(QSize(24, 24))
        self.store_bind = QShortcut(QKeySequence('Ctrl+S'), self)

        self.homepage_btn = QPushButton(self.sidebar)
        self.homepage_btn.setGeometry(QRect(0, 102, 51, 51))
        self.homepage_btn.setProperty('class', 'sidebar_btns')
        self.homepage_btn.setIcon(QIcon(':/icon/github_icon.png'))
        self.homepage_btn.setIconSize(QSize(24, 24))
        self.homepage_bind = QShortcut(QKeySequence('Ctrl+G'), self)

        self.about_btn = QPushButton(self.sidebar)
        self.about_btn.setGeometry(QRect(0, 153, 51, 51))
        self.about_btn.setProperty('class', 'sidebar_btns')
        self.about_btn.setIcon(QIcon(':/icon/about_icon.png'))
        self.about_btn.setIconSize(QSize(24, 24))
        self.about_bind = QShortcut(QKeySequence('Ctrl+A'), self)

        self.quit_btn = QPushButton(self.sidebar)
        self.quit_btn.setGeometry(QRect(0, 420, 51, 51))
        self.quit_btn.setProperty('class', 'sidebar_btns_quit')
        self.quit_btn.setIcon(QIcon(':/icon/quit_icon.png'))
        self.quit_btn.setIconSize(QSize(24, 24))
        self.quit_bind = QShortcut(QKeySequence('Ctrl+Q'), self)

        self.font = QFont()
        self.font.setPointSize(8)
        self.font.setStyleStrategy(QFont.PreferAntialias)

        self.label_refresh = QLabel(self.appswidget)
        self.label_refresh.setFont(self.font)
        self.label_refresh.setGeometry(QRect(20, 10, 441, 15))

        self.label_info = QLabel(self.appswidget)
        self.label_info.setFont(self.font)
        self.label_info.setGeometry(QRect(20, 10, 441, 30))

        self.progressbar = QProgressBar(self.appswidget)
        self.progressbar.setGeometry(QRect(20, 30, 441, 20))

        self.layout_widget_checkboxes = QWidget(self.appswidget)
        self.layout_widget_checkboxes.setGeometry(QRect(20, 55, 155, 311))
        self.layout_checkboxes = QVBoxLayout(self.layout_widget_checkboxes)
        self.layout_checkboxes.setContentsMargins(0, 0, 0, 0)

        self.layout_widget_checkboxes_2 = QWidget(self.appswidget)
        self.layout_widget_checkboxes_2.setGeometry(QRect(175, 55, 155, 311))
        self.layout_checkboxes_2 = QVBoxLayout(self.layout_widget_checkboxes_2)
        self.layout_checkboxes_2.setContentsMargins(0, 0, 0, 0)

        self.layout_widget_checkboxes_3 = QWidget(self.appswidget)
        self.layout_widget_checkboxes_3.setGeometry(QRect(330, 55, 155, 311))
        self.layout_checkboxes_3 = QVBoxLayout(self.layout_widget_checkboxes_3)
        self.layout_checkboxes_3.setContentsMargins(0, 0, 0, 0)

        self.layout_widget_labels = QWidget(self.appswidget)
        self.layout_widget_labels.setGeometry(QRect(20, 390, 350, 16))
        self.layout_labels = QHBoxLayout(self.layout_widget_labels)
        self.layout_labels.setContentsMargins(0, 0, 0, 0)
        self.label_space = QLabel(self.appswidget)
        self.label_space.setFont(self.font)
        self.layout_labels.addWidget(self.label_space)
        self.label_size = QLabel(self.appswidget)
        self.label_size.setFont(self.font)
        self.layout_labels.addWidget(self.label_size)

        self.layout_widget_buttons = QWidget(self.appswidget)
        self.layout_widget_buttons.setGeometry(QRect(20, 420, 454, 31))
        self.layout_buttons = QHBoxLayout(self.layout_widget_buttons)
        self.layout_buttons.setContentsMargins(0, 0, 0, 0)
        self.button_select_all = QPushButton(self.layout_widget_buttons)
        self.button_select_all.setIcon(QIcon(':/icon/check_icon.png'))
        self.button_select_all.setIconSize(QSize(18, 18))
        self.button_select_all.setLayoutDirection(Qt.RightToLeft)
        self.layout_buttons.addWidget(self.button_select_all)
        self.button_select_all.setMinimumSize(100, 30)
        self.button_select_all.setProperty('class', 'Aqua')
        self.button_deselect_all = QPushButton(self.layout_widget_buttons)
        self.button_deselect_all.setIcon(QIcon(':/icon/cancel_icon.png'))
        self.button_deselect_all.setIconSize(QSize(18, 18))
        self.button_deselect_all.setLayoutDirection(Qt.RightToLeft)
        self.layout_buttons.addWidget(self.button_deselect_all)
        self.button_deselect_all.setMinimumSize(100, 30)
        self.button_deselect_all.setProperty('class', 'Aqua')
        self.layout_buttons.addStretch()
        self.button_uninstall = QPushButton(self.layout_widget_buttons)
        self.button_uninstall.setIcon(QIcon(':/icon/trash_icon.png'))
        self.button_uninstall.setIconSize(QSize(18, 18))
        self.button_uninstall.setLayoutDirection(Qt.RightToLeft)
        self.layout_buttons.addWidget(self.button_uninstall)
        self.button_uninstall.setMinimumSize(100, 30)
        self.button_uninstall.setProperty('class', 'Grapefruit')

        self.setCentralWidget(self.centralwidget)
        self.retranslateUi()
        QMetaObject.connectSlotsByName(self)
Ejemplo n.º 22
0
 def add_shortcuts(self) -> None:
     self.shortcutCloseQ = QShortcut(QKeySequence("Q"), self)
     self.shortcutCloseQ.activated.connect(self.close)
Ejemplo n.º 23
0
Settings().register_setting("triage.linearSweep", """
	{
		"title" : "Triage Linear Sweep Mode",
		"type" : "string",
		"default" : "partial",
		"description" : "Controls the level of linear sweep performed when opening for triage.",
		"enum" : ["none", "partial", "full"],
		"enumDescriptions" : [
			"Do not perform linear sweep of the binary.",
			"Perform linear sweep on the binary, but skip the control flow graph analysis phase.",
			"Perform full linear sweep on the binary." ]
	}
	""")

Settings().register_setting("triage.hiddenFiles", """
	{
		"title" : "Triage Shows Hidden Files",
		"type" : "boolean",
		"default" : false,
		"description" : "Whether the Triage file picker shows hidden files."
	}
	""")

UIAction.registerAction("Open for Triage...", QKeySequence("Ctrl+Alt+O"))
UIAction.registerAction("Open Selected Files")

UIActionHandler.globalActions().bindAction("Open for Triage...", UIAction(openForTriage))
Menu.mainMenu("File").addAction("Open for Triage...", "Open")

UIContext.registerFileOpenMode("Triage...", "Open file(s) for quick analysis in the Triage Summary view.", "Open for Triage...")
Ejemplo n.º 24
0
    def __init__(self, tile_contents, color, parent=None):
        super().__init__(parent)
        title_name, tile_items = tile_contents
        self.color = color
        self.setObjectName("subBoardFrame")

        shadow = QGraphicsDropShadowEffect(self,
                                           blurRadius=10,
                                           offset=5,
                                           color=QColor("lightgrey"))
        self.setGraphicsEffect(shadow)

        board = QVBoxLayout()
        board.setContentsMargins(20, 20, 20, 20)
        tile_title = NoteTile(title_name, "boardEdit", self)
        tile_title.setPlaceholderText("Title here ...")

        board.addWidget(tile_title)

        self.listwidget = BanListWidget(self)
        self.listwidget.setStyleSheet(TILE_STYLE.get(color, "black"))
        for tile in tile_items:
            self.listwidget.add_item(tile)

        board.addWidget(self.listwidget)

        btn_layout = QHBoxLayout()
        add_btn = BanButton(
            "+",
            clicked=self.add_listitem,
            toolTip="add tile",
            objectName="boardBtn",
        )
        del_btn = BanButton(
            "-",
            clicked=self.del_listitem,
            toolTip="delete tile",
            objectName="boardBtn",
            shortcut=QKeySequence(Qt.Key_Backspace),
        )
        color_btn = BanButton(
            "\u2261",
            toolTip="change color",
            objectName="boardBtn_color",
            color=[("white", "#bdbdbd"), ("grey", "white")],
        )

        self.color_menu = self.context_menu()
        color_btn.setMenu(self.color_menu)
        color_btn.sizeSig.connect(self.menu_resize)

        destory_btn = BanButton(
            "\u00D7",
            clicked=self.delete_board,
            toolTip="delete board",
            objectName="boardBtn_des",
            color=[("white", "tomato"), ("white", "red")],
        )

        btn_layout.addWidget(add_btn)
        btn_layout.addWidget(del_btn)

        btn_layout.addWidget(color_btn)
        btn_layout.addWidget(destory_btn)
        board.addLayout(btn_layout)

        self.setLayout(board)
Ejemplo n.º 25
0
 def load(self) -> None:
     self.action_calculate = self.api.register_menu_entry('Calculate Stats', self.slot_calculate_stats)
     self.action_calculate.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_F2))
     self.action_finished_files = self.api.register_menu_entry('Find finished files', self.slot_find_finished)
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self._main = QWidget()
        self.setCentralWidget(self._main)

        # Main menu bar
        self.menu = self.menuBar()
        self.menu_file = self.menu.addMenu("File")
        exit = QAction("Exit", self, triggered=qApp.quit)
        self.menu_file.addAction(exit)

        self.menu_about = self.menu.addMenu("&About")
        about = QAction("About Qt",
                        self,
                        shortcut=QKeySequence(QKeySequence.HelpContents),
                        triggered=qApp.aboutQt)
        self.menu_about.addAction(about)

        # Create an artificial color close to the original one
        self.ihc_rgb = data.immunohistochemistry()
        self.ihc_hed = rgb2hed(self.ihc_rgb)

        main_layout = QVBoxLayout(self._main)
        plot_layout = QHBoxLayout()
        button_layout = QHBoxLayout()
        label_layout = QHBoxLayout()

        self.canvas1 = FigureCanvas(Figure(figsize=(5, 5)))
        self.canvas2 = FigureCanvas(Figure(figsize=(5, 5)))

        self._ax1 = self.canvas1.figure.subplots()
        self._ax2 = self.canvas2.figure.subplots()

        self._ax1.imshow(self.ihc_rgb)

        plot_layout.addWidget(self.canvas1)
        plot_layout.addWidget(self.canvas2)

        self.button1 = QPushButton("Hematoxylin")
        self.button2 = QPushButton("Eosin")
        self.button3 = QPushButton("DAB")
        self.button4 = QPushButton("Fluorescence")

        self.button1.setSizePolicy(QSizePolicy.Preferred,
                                   QSizePolicy.Expanding)
        self.button2.setSizePolicy(QSizePolicy.Preferred,
                                   QSizePolicy.Expanding)
        self.button3.setSizePolicy(QSizePolicy.Preferred,
                                   QSizePolicy.Expanding)
        self.button4.setSizePolicy(QSizePolicy.Preferred,
                                   QSizePolicy.Expanding)

        self.button1.clicked.connect(self.plot_hematoxylin)
        self.button2.clicked.connect(self.plot_eosin)
        self.button3.clicked.connect(self.plot_dab)
        self.button4.clicked.connect(self.plot_final)

        self.label1 = QLabel("Original", alignment=Qt.AlignCenter)
        self.label2 = QLabel("", alignment=Qt.AlignCenter)

        font = self.label1.font()
        font.setPointSize(16)
        self.label1.setFont(font)
        self.label2.setFont(font)

        label_layout.addWidget(self.label1)
        label_layout.addWidget(self.label2)

        button_layout.addWidget(self.button1)
        button_layout.addWidget(self.button2)
        button_layout.addWidget(self.button3)
        button_layout.addWidget(self.button4)

        main_layout.addLayout(label_layout, 2)
        main_layout.addLayout(plot_layout, 88)
        main_layout.addLayout(button_layout, 10)

        # Default image
        self.plot_hematoxylin()
Ejemplo n.º 27
0
 def init_shortcuts(self):
     self.del_shortcut = QShortcut(QKeySequence(QKeySequence.Delete), self)
     self.del_shortcut.activated.connect(self.remove_selected_items)
Ejemplo n.º 28
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.column_names = ["Column A", "Column B", "Column C"]

        # Central widget
        self._main = QWidget()
        self.setCentralWidget(self._main)

        # Main menu bar
        self.menu = self.menuBar()
        self.menu_file = self.menu.addMenu("File")
        exit = QAction("Exit", self, triggered=qApp.quit)
        self.menu_file.addAction(exit)

        self.menu_about = self.menu.addMenu("&About")
        about = QAction("About Qt",
                        self,
                        shortcut=QKeySequence(QKeySequence.HelpContents),
                        triggered=qApp.aboutQt)
        self.menu_about.addAction(about)

        # Figure (Left)
        self.fig = Figure(figsize=(5, 3))
        self.canvas = FigureCanvas(self.fig)

        # Sliders (Left)
        self.slider_azim = QSlider(minimum=0,
                                   maximum=360,
                                   orientation=Qt.Horizontal)
        self.slider_elev = QSlider(minimum=0,
                                   maximum=360,
                                   orientation=Qt.Horizontal)

        self.slider_azim_layout = QHBoxLayout()
        self.slider_azim_layout.addWidget(
            QLabel("{}".format(self.slider_azim.minimum())))
        self.slider_azim_layout.addWidget(self.slider_azim)
        self.slider_azim_layout.addWidget(
            QLabel("{}".format(self.slider_azim.maximum())))

        self.slider_elev_layout = QHBoxLayout()
        self.slider_elev_layout.addWidget(
            QLabel("{}".format(self.slider_elev.minimum())))
        self.slider_elev_layout.addWidget(self.slider_elev)
        self.slider_elev_layout.addWidget(
            QLabel("{}".format(self.slider_elev.maximum())))

        # Table (Right)
        self.table = QTableWidget()
        header = self.table.horizontalHeader()
        header.setSectionResizeMode(QHeaderView.Stretch)

        # ComboBox (Right)
        self.combo = QComboBox()
        self.combo.addItems(
            ["Wired", "Surface", "Triangular Surface", "Sphere"])

        # Right layout
        rlayout = QVBoxLayout()
        rlayout.setContentsMargins(1, 1, 1, 1)
        rlayout.addWidget(QLabel("Plot type:"))
        rlayout.addWidget(self.combo)
        rlayout.addWidget(self.table)

        # Left layout
        llayout = QVBoxLayout()
        rlayout.setContentsMargins(1, 1, 1, 1)
        llayout.addWidget(self.canvas, 88)
        llayout.addWidget(QLabel("Azimuth:"), 1)
        llayout.addLayout(self.slider_azim_layout, 5)
        llayout.addWidget(QLabel("Elevation:"), 1)
        llayout.addLayout(self.slider_elev_layout, 5)

        # Main layout
        layout = QHBoxLayout(self._main)
        layout.addLayout(llayout, 70)
        layout.addLayout(rlayout, 30)

        # Signal and Slots connections
        self.combo.currentTextChanged.connect(self.combo_option)
        self.slider_azim.valueChanged.connect(self.rotate_azim)
        self.slider_elev.valueChanged.connect(self.rotate_elev)

        # Initial setup
        self.plot_wire()
        self._ax.view_init(30, 30)
        self.slider_azim.setValue(30)
        self.slider_elev.setValue(30)
        self.fig.canvas.mpl_connect("button_release_event", self.on_click)
Ejemplo n.º 29
0
    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)
Ejemplo n.º 30
0
 def load(self) -> None:
     self.action_test_shiftability = self.api.register_menu_entry(
         'Test Shiftability', self.slot_test_shiftability)
     self.action_next_location = self.api.register_menu_entry(
         'Next Location', self.slot_next_location)
     self.action_next_location.setShortcut(QKeySequence(Qt.Key_F4))