示例#1
0
文件: app.py 项目: snyiu100/Dwarf
    def __init__(self, dwarf_args, flags=None):
        super(AppWindow, self).__init__(flags)

        self.dwarf_args = dwarf_args

        self.session_manager = SessionManager(self)
        self.session_manager.sessionCreated.connect(self.session_created)
        self.session_manager.sessionStopped.connect(self.session_stopped)
        self.session_manager.sessionClosed.connect(self.session_closed)

        self._tab_order = [
            'debug', 'modules', 'ranges', 'jvm-inspector', 'jvm-debugger'
        ]

        self._is_newer_dwarf = False
        self.q_settings = QSettings(utils.home_path() + "dwarf_window_pos.ini",
                                    QSettings.IniFormat)

        self.menu = self.menuBar()
        self.view_menu = None

        self._initialize_ui_elements()

        self.setWindowTitle(
            'Dwarf - A debugger for reverse engineers, crackers and security analyst'
        )

        # load external assets
        _app = QApplication.instance()

        # themes
        self.prefs = Prefs()
        utils.set_theme(self.prefs.get('dwarf_ui_theme', 'black'), self.prefs)

        # load font
        if os.path.exists(utils.resource_path('assets/Anton.ttf')):
            QFontDatabase.addApplicationFont(
                utils.resource_path('assets/Anton.ttf'))
        else:
            QFontDatabase.addApplicationFont(':/assets/Anton.ttf')

        if os.path.exists(utils.resource_path('assets/OpenSans-Regular.ttf')):
            QFontDatabase.addApplicationFont(
                utils.resource_path('assets/OpenSans-Regular.ttf'))
        else:
            QFontDatabase.addApplicationFont(':/assets/OpenSans-Regular.ttf')

        if os.path.exists(utils.resource_path('assets/OpenSans-Bold.ttf')):
            QFontDatabase.addApplicationFont(
                utils.resource_path('assets/OpenSans-Bold.ttf'))
        else:
            QFontDatabase.addApplicationFont(':/assets/OpenSans-Bold.ttf')

        font = QFont("OpenSans", 9, QFont.Normal)
        # TODO: add settingsdlg
        font_size = self.prefs.get('dwarf_ui_font_size', 12)
        font.setPixelSize(font_size)
        _app.setFont(font)

        # mainwindow statusbar
        self.progressbar = QProgressBar()
        self.progressbar.setRange(0, 0)
        self.progressbar.setVisible(False)
        self.progressbar.setFixedHeight(15)
        self.progressbar.setFixedWidth(100)
        self.progressbar.setTextVisible(False)
        self.progressbar.setValue(30)
        self.statusbar = QStatusBar(self)
        self.statusbar.setAutoFillBackground(False)
        self.statusbar.addPermanentWidget(self.progressbar)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        self.main_tabs = QTabWidget(self)
        self.main_tabs.setMovable(False)
        self.main_tabs.setTabsClosable(True)
        self.main_tabs.setAutoFillBackground(True)
        self.main_tabs.tabCloseRequested.connect(self._on_close_tab)
        self.setCentralWidget(self.main_tabs)

        # pluginmanager
        self.plugin_manager = PluginManager(self)
        self.plugin_manager.reload_plugins()

        if dwarf_args.any == '':
            self.welcome_window = WelcomeDialog(self)
            self.welcome_window.setModal(True)
            self.welcome_window.onIsNewerVersion.connect(
                self._enable_update_menu)
            self.welcome_window.onUpdateComplete.connect(
                self._on_dwarf_updated)
            self.welcome_window.setWindowTitle(
                'Welcome to Dwarf - A debugger for reverse engineers, crackers and security analyst'
            )
            self.welcome_window.onSessionSelected.connect(self._start_session)
            # wait for welcome screen
            self.hide()
            self.welcome_window.show()
        else:
            print('* Starting new Session')
            self._start_session(dwarf_args.target)
示例#2
0
 def theme_checked(self, checkState, theme):
     utils.set_theme(theme, prefs=self.prefs)
示例#3
0
文件: app.py 项目: snyiu100/Dwarf
 def _set_theme(self, qaction):
     if qaction:
         utils.set_theme(qaction.text(), self.prefs)
示例#4
0
    def __init__(self, prefs, parent=None):
        super(SetupDialog, self).__init__(parent)
        self.prefs = prefs
        current_theme = self.prefs.get('dwarf_ui_theme', 'black')
        utils.set_theme(current_theme)

        self.setMinimumWidth(400)

        box = QVBoxLayout()
        box.setContentsMargins(10, 10, 10, 10)

        theme_container = QVBoxLayout()
        theme_container.setContentsMargins(0, 0, 0, 0)
        theme_label = QLabel('Theme')
        font = QFont('OpenSans', 20, QFont.Bold)
        font.setPixelSize(20)
        theme_label.setFont(font)
        theme_container.addWidget(theme_label)

        theme_box = QHBoxLayout()
        theme_box.setContentsMargins(0, 10, 0, 0)
        dark = QRadioButton('Dark')
        if current_theme == 'dark':
            dark.setChecked(True)
        dark.toggled.connect(lambda x: self.theme_checked(x, 'dark'))
        theme_box.addWidget(dark)
        black = QRadioButton('Black')
        if current_theme == 'black':
            dark.setChecked(True)
        black.toggled.connect(lambda x: self.theme_checked(x, 'black'))
        theme_box.addWidget(black)
        light = QRadioButton('Light')
        if current_theme == 'light':
            light.setChecked(True)
        light.toggled.connect(lambda x: self.theme_checked(x, 'light'))
        theme_box.addWidget(light)
        theme_container.addLayout(theme_box)

        box.addLayout(theme_container)

        if sys.platform == 'linux':
            dwarf_bin_path = os.path.join(
                '/'.join(os.path.realpath(__file__).split('/')[:-2]),
                'bin/dwarf')
            if not os.path.exists(dwarf_bin_path):
                self.launcher_box = QVBoxLayout()
                self.launcher_box.setContentsMargins(0, 40, 0, 0)
                launcher_label = QLabel('Launcher')
                font = QFont('OpenSans', 20, QFont.Bold)
                font.setPixelSize(20)
                launcher_label.setFont(font)
                self.launcher_box.addWidget(launcher_label)
                self.launcher_box.addWidget(
                    QLabel(
                        'Create dwarf alias and add to $path (dwarf --version)'
                    ))

                self.launcher_box.addWidget(self.btn_launcher_create)
                box.addLayout(self.launcher_box)

        buttons = QHBoxLayout()
        buttons.setContentsMargins(0, 30, 0, 0)

        finish = QPushButton('Finish')
        finish.clicked.connect(self.accept)
        buttons.addWidget(finish)

        box.addLayout(buttons)

        self.setLayout(box)