def _init_menu_bar(self):
     self.menu_bar = self.menuBar()
     self.file_menu = self.menu_bar.addMenu(UILangHolder.get(App.MENU_FILE))
     self.file_menu.setFont(FontHolder.get())
     self.open_act.setCheckable(False)
     self.file_menu.addAction(self.open_act)
     self.file_menu.addAction(self.open_dir_act)
     self.file_menu.addSeparator()
     self.file_menu.addAction(self.close_act)
     self.file_menu.addAction(self.close_all_act)
     self.file_menu.addSeparator()
     self.file_menu.addAction(self.exit_act)
     self.view_menu = self.menu_bar.addMenu(UILangHolder.get(App.MENU_VIEW))
     self.view_menu.setFont(FontHolder.get())
     self.view_menu.addAction(self.tool_bar_act)
     self.view_menu.addSeparator()
     self.view_menu.addAction(self.font_act)
     self.view_menu.addMenu(self.lang_menu)
     self.func_menu = self.menu_bar.addMenu(UILangHolder.get(App.MENU_FUNC))
     self.func_menu.setFont(FontHolder.get())
     # self.func_menu.addAction(self.find_act)
     self.func_menu.addAction(self.find_dir_act)
     self.func_menu.addSeparator()
     self.func_menu.addAction(self.calc_act)
     self.help_menu = self.menu_bar.addMenu(UILangHolder.get(App.MENU_HELP))
     self.help_menu.setFont(FontHolder.get())
 def update_ui(self):
     font = FontHolder.get()
     self.export_act.setFont(font)
     self.export_act.setText(UILangHolder.get(App.EXPORT))
     self.import_act.setFont(font)
     self.import_act.setText(UILangHolder.get(App.IMPORT))
     self.exit_act.setFont(font)
     self.exit_act.setText(UILangHolder.get(App.EXIT))
 def __init__(self):
     super(FindResultModel, self).__init__()
     self.header = [
         UILangHolder.get(App.LOCATION),
         UILangHolder.get(App.FOUND),
         UILangHolder.get(App.ERROR_INFO)
     ]
     self.setColumnCount(len(self.header))
     self.setHorizontalHeaderLabels(self.header)
 def _update_ui(self):
     font = FontHolder.get()
     self.dir_label.setFont(font)
     self.dir_label.setText(UILangHolder.get(App.DIR_LABEL))
     self.dir_edit.setFont(font)
     self.dir_edit.update_lang()
     self.start_btn.setFont(font)
     self.start_btn.setText(UILangHolder.get(App.START))
     self.filter_label.setFont(font)
     self.filter_label.setText(UILangHolder.get(App.FILTER_LABEL))
     self.filter_edit.setFont(font)
     self.result_table.setFont(font)
 def _init_view_actions(self):
     self.tool_bar_act = QAction(self)
     self.tool_bar_act.setCheckable(True)
     if ConfigsHolder.get(App.TOOL_BAR) == "True":
         self.tool_bar_act.setChecked(True)
     self.font_act = QAction(self)
     self.lang_menu = QMenu(self)
     self.lang_act_grp = QActionGroup(self)
     for lang in UILangHolder.get_langs():
         action = QAction(lang, self)
         action.setFont(FontHolder.get())
         action.setCheckable(True)
         self.lang_menu.addAction(action)
         self.lang_act_grp.addAction(action)
         if UILangHolder.get(App.LANG_TYPE) == lang:
             action.setChecked(True)
 def __init__(self, controller, parent=None):
     super(CalcWindow, self).__init__(parent)
     self.controller = controller
     self.setWindowTitle(UILangHolder.get(App.CALC_WINDOW_TITLE))
     self.widget = CalcWidget(controller, self)
     self.setCentralWidget(self.widget)
     self.setStyleSheet(open_file("./res/css/func.css"))
     self.exit_act.triggered.connect(self._exit)
 def set_ui(self):
     """ Set all ui state to BUSY, disable all components.
     """
     self.set_state(self.BUSY)
     self.dir_edit.setEnabled(False)
     self.start_btn.setText(UILangHolder.get(App.STOP))
     self.filter_edit.setEnabled(False)
     self.filter_box.setEnabled(False)
     self.result_table.setSortingEnabled(False)
 def reset_ui(self):
     """ Reset all ui state to IDLE, enable all components.
     """
     self.set_state(self.IDLE)
     self.dir_edit.setEnabled(True)
     self.start_btn.setText(UILangHolder.get(App.START))
     self.filter_edit.setEnabled(True)
     self.filter_box.setEnabled(True)
     self.result_table.setSortingEnabled(True)
 def __init__(self, controller=None, parent=None):
     super(AppFrame, self).__init__(parent)
     self.controller = controller
     # self.setStyleSheet('background-color: rgb(0, 44, 56)')
     self.setWindowTitle(UILangHolder.get(App.WINDOW_TITLE))
     self.setWindowIcon(IconsHolder.get_by_id(IconsHolder.ID_OPEN))
     self._init_actions()
     self._init_menu_bar()
     self._init_tool_bar()
     self.update_lang()
     self.update_font()
     self._init_signals()
 def _init_menu_bar(self):
     self.menu_bar = self.menuBar()
     self.file_menu = self.menu_bar.addMenu(UILangHolder.get(App.MENU_FILE))
     self.export_act = QAction(self)
     self.export_act.setIcon(IconsHolder.get_by_id(IconsHolder.ID_OPEN))
     self.import_act = QAction(self)
     self.import_act.setIcon(IconsHolder.get_by_id(IconsHolder.ID_CLOSE))
     self.exit_act = QAction(self)
     self.exit_act.setIcon(IconsHolder.get_by_id(IconsHolder.ID_EXIT))
     self.file_menu.addAction(self.export_act)
     self.file_menu.addAction(self.import_act)
     self.file_menu.addSeparator()
     self.file_menu.addAction(self.exit_act)
 def _init_func_actions(self):
     # find all matches in current file action
     self.find_act = QAction(self)
     self.find_act.setIcon(IconsHolder.get_by_id(IconsHolder.ID_FIND))
     self.find_act.setShortcut("Ctrl+F")
     # find all matches in the whole dir action
     self.find_dir_act = QAction(self)
     self.find_dir_act.setIcon(IconsHolder.get_by_id(IconsHolder.ID_FIND_DIR))
     self.find_dir_act.setShortcut("Ctrl+Shift+F")
     self.find_act.setEnabled(False)
     # account function action
     self.calc_act = QAction(self)
     self.calc_act.setIcon(IconsHolder.get_by_id(IconsHolder.ID_CALC))
     self.calc_act.setShortcut("Ctrl+Alt+L")
     self.calc_act.setToolTip(UILangHolder.get(App.CALC))
 def __init__(self):
     super(CalcResultModel, self).__init__()
     self.header = [
         UILangHolder.get(App.LOCATION),
         UILangHolder.get(App.SIZE),
         UILangHolder.get(App.LINES),
         UILangHolder.get(App.TOTAL_LINES),
         UILangHolder.get(App.WORDS),
         UILangHolder.get(App.ERROR_INFO)
     ]
     self.column = len(self.header)
     self.setColumnCount(self.column)
     self.setHorizontalHeaderLabels(self.header)
 def __init__(self, parent=None):
     super(FilterComboBox, self).__init__(parent)
     self.setLayoutDirection(Qt.LeftToRight)
     self.setAutoFillBackground(True)
     self.setInsertPolicy(QComboBox.InsertAtBottom)
     self.setSizeAdjustPolicy(QComboBox.AdjustToContents)
     self.setDuplicatesEnabled(True)
     # The font is set by self
     font = QFont()
     font.setFamily("微软雅黑")
     font.setPointSize(9)
     self.setFont(font)
     self.setCurrentText(UILangHolder.get(App.FILTER))
     self.addItem("All types")
     self.addItem("Assembly (*.s;*.S)")
     self.addItem("C (*.c)")
     self.addItem("C++ (*.cpp;*.C;*.cc;*.cxx;*.c++)")
     self.addItem("Header (*.h;*.hpp;*.hxx)")
     self.addItem("Java (*.java)")
     self.addItem("Python (*.py)")
     self.addItem("C# (*.cs)")
     self.addItem("Shell (*.sh)")
     self.pattern = re.compile("[^(]*?(?=\))")  # match the content in ()
 def update_lang(self):
     self.setWindowTitle(UILangHolder.get(App.WINDOW_TITLE))
     self.file_menu.setTitle(UILangHolder.get(App.MENU_FILE))
     self.view_menu.setTitle(UILangHolder.get(App.MENU_VIEW))
     self.func_menu.setTitle(UILangHolder.get(App.MENU_FUNC))
     self.help_menu.setTitle(UILangHolder.get(App.MENU_HELP))
     self.open_act.setText(UILangHolder.get(App.OPEN))
     self.open_act.setToolTip(UILangHolder.get(App.OPEN) + '(O)')
     self.open_dir_act.setText(UILangHolder.get(App.OPEN_DIR))
     self.open_dir_act.setToolTip(UILangHolder.get(App.OPEN_DIR) + '(O)')
     self.close_act.setText(UILangHolder.get(App.CLOSE))
     self.close_act.setToolTip(UILangHolder.get(App.CLOSE) + '(W)')
     self.close_all_act.setText(UILangHolder.get(App.CLOSE_ALL))
     self.close_all_act.setToolTip(UILangHolder.get(App.CLOSE_ALL) + '(W)')
     self.exit_act.setText(UILangHolder.get(App.EXIT))
     self.exit_act.setToolTip(UILangHolder.get(App.EXIT) + '(Q)')
     self.tool_bar_act.setText(UILangHolder.get(App.TOOL_BAR))
     self.tool_bar_act.setToolTip(UILangHolder.get(App.TOOL_BAR))
     self.font_act.setText(UILangHolder.get(App.FONT))
     self.font_act.setToolTip(UILangHolder.get(App.FONT))
     self.lang_menu.setTitle(UILangHolder.get(App.LANG))
     self.find_act.setText(UILangHolder.get(App.FIND))
     self.find_act.setToolTip(UILangHolder.get(App.FIND) + '(F)')
     self.find_dir_act.setText(UILangHolder.get(App.FIND_DIR))
     self.find_dir_act.setToolTip(UILangHolder.get(App.FIND_DIR) + '(F)')
     self.calc_act.setText(UILangHolder.get(App.CALC))
     self.help_act.setText(UILangHolder.get(App.HELP))
Beispiel #15
0
import sys

from PyQt5.QtWidgets import QApplication

from core.common import App
from core.common.config import ConfigsHolder
from core.common.uilang import UILangHolder
from ctrl.app import AppController

if __name__ == '__main__':
    config = ConfigsHolder.get_configs()
    UILangHolder.get_ui_lang(config[App.CONFIG_LANG])
    app = QApplication(sys.argv)
    instance = AppController()
    sys.exit(app.exec_())
Beispiel #16
0
 def do_change_lang(self, lang_type):
     UILangHolder.get_ui_lang(lang_type)
     self.ui.update_lang()