예제 #1
0
 def closeEvent(self, a0: QCloseEvent) -> None:
     """
     主窗体退出时的事件,包括弹框提示等。Mac 上测试点击无法退出,修改为QMessageBox.Warning
     """
     reply = QMessageBox(QMessageBox.Warning, '关闭', '是否关闭!')
     reply.addButton('确定', QMessageBox.ActionRole)
     reply.addButton('取消', QMessageBox.RejectRole)
     if reply.exec_() == QMessageBox.RejectRole:
         a0.ignore()
         return
     else:
         a0.accept()
     """
     reply = QMessageBox.question(
         self,
         '注意',
         '确认退出吗?',
         QMessageBox.Ok | QMessageBox.Cancel,
         QMessageBox.Cancel)
     if reply == QMessageBox.Ok:
         a0.accept()
     else:
         a0.ignore()
         return
     """
     self.delete_temporary_dock_windows()
     self.save_layout()
     Settings.get_instance().save()
     self.close_signal.emit()
     self.extensions_manager.stop()
     for k in self.dock_widgets.keys():
         self.dock_widgets[k].widget().closeEvent(a0)
     super().closeEvent(a0)
예제 #2
0
def get_work_dir() -> 'str':
    """
    获取主窗口或者主控件。
    Returns:
    """
    from pyminer2.features.io.settings import Settings
    return Settings.get_instance()['work_dir']
예제 #3
0
 def get_stylesheet(style_sheet_name: str = 'standard'):
     style_sheet = ""
     from pyminer2.pmutil import get_root_dir
     with open(
             os.path.join(get_root_dir(), 'config', 'ui',
                          '%s.qss' % style_sheet_name), 'rb') as f:
         b = f.read()
         enc = chardet.detect(b)
         if enc.get('encoding') is not None:
             s = b.decode(enc['encoding'])
             style_sheet = s.replace(
                 'MAIN_THEME',
                 Settings.get_instance()['main_theme']).replace(
                     'MARGIN_THEME',
                     Settings.get_instance()['margin_theme'])
     return style_sheet
예제 #4
0
파일: base.py 프로젝트: mgbin088/pyminer-1
 def refresh_settings(self):
     """
     窗口关闭时,调用此方法,刷新主界面设置项。
     :return:
     """
     settings = Settings.get_instance()
     settings['work_dir'] = self.lineEdit_workspace.text()
     settings['theme'] = self.comboBox_theme.currentText()
     from pyminer2.pmutil import get_main_window
     get_main_window().on_settings_changed()
     self.signal_settings_changed.emit()
예제 #5
0
파일: base.py 프로젝트: mgbin088/pyminer-1
 def load_settings(self):
     """
     在show()之前调用这个方法
     从而每次重新显示的时候都可以刷新数据。
     :return:
     """
     settings = Settings.get_instance()
     if settings.get('theme') is not None:
         for i in range(self.comboBox_theme.count()):
             if self.comboBox_theme.itemText(i) == settings['theme']:
                 self.comboBox_theme.setCurrentIndex(i)
     self.lineEdit_workspace.setText(settings['work_dir'])
예제 #6
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.main_option_form = base.OptionForm()

        import pyminer2.pmutil

        pyminer2.pmutil._main_window = self
        self.resize(1500, 850)
        self.setIconSize(QSize(40, 40))
        settings = Settings()

        root_dir = os.path.dirname(__file__)
        pyminer2.pmutil._root_dir = root_dir

        self.init_toolbar_tab()
        self.add_toolbar('toolbar_home', PMToolBarHome(), text='文件')
        self.setDockNestingEnabled(True)
        self.setWindowTitle('PyMiner')

        self.log_output_console = LogOutputConsole(self)

        self.add_widget_on_dock(
            'log_output_console',
            self.log_output_console,
            text='日志',
            side='right')

        self.extensions_manager = extensions_manager
        self.extensions_manager.load_from_extension_folder(updateSplashMsg)

        self.ext_manager_widget = PMPageExt(self)
        dw = self.add_widget_on_dock(
            'extension_panel',
            self.ext_manager_widget,
            text='插件管理',
            side='left')
        dw.setMaximumWidth(400)

        load_theme(settings['theme'])  # 组件都加载后再设置主题,否则可能有些组件不生效
        self.load_layout()
        self.show()

        self.switch_toolbar('toolbar_home')  # 启动完成时,将工具栏切换到‘主页’
        self.on_main_window_shown()
예제 #7
0
 def get_work_dir() -> str:
     """
     获取当前工作路径
     """
     return Settings.get_instance()['work_dir']
예제 #8
0
 def set_work_dir(work_dir: str) -> None:
     """
     设置当前工作路径
     """
     Settings.get_instance()['work_dir'] = work_dir
예제 #9
0
 def get_settings() -> Dict[str, str]:
     return Settings.get_instance()