本文整理汇总了Python中database.DatabaseManager.get_shortcut_key方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.get_shortcut_key方法的具体用法?Python DatabaseManager.get_shortcut_key怎么用?Python DatabaseManager.get_shortcut_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.get_shortcut_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_shortcut_key
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import get_shortcut_key [as 别名]
def save_shortcut_key(self):
DatabaseManager.set_shortcut_key(self.shortcut_key_cbox.currentData())
self.shortcut_key = DatabaseManager.get_shortcut_key()
self.register_shortcut_listener()
示例2: EKWindow
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import get_shortcut_key [as 别名]
class EKWindow(QDialog, dialog_ui.Ui_Dialog):
def __init__(self):
QDialog.__init__(self)
self.app_path = os.getenv("APPDATA") + "\\" + qApp.applicationName()
self.registrySettings = QSettings("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", QSettings.NativeFormat)
self.table_path = self.app_path + "\\tables"
self.engine = Engine()
self.minimize_action = QAction("Minimize", self)
self.maximize_action = QAction("Maximize", self)
self.settings_action = QAction("Settings", self)
self.about_action = QAction("About", self)
self.quit_action = QAction("Quit", self)
self.tray_icon_menu = QMenu(self)
self.tray_icon = QSystemTrayIcon(self)
self.setupUi(self)
self.icon = QIcon(QPixmap(":icon/off_logo"))
self.construct_tray_icon()
self.signal_connectors()
self.database = DatabaseManager()
self.shortcut_key = self.database.get_shortcut_key()
self.populate_modifier_cbox()
if self.database.get_current_state() == "True":
self.engine.conv_state = False
else:
self.engine.conv_state = True
self.icon_activated(QSystemTrayIcon.Trigger)
self.file_path_tview.setEnabled(False)
self.check_app_path()
self.update_table(True)
self.init_combobox()
if self.registrySettings.contains(qApp.applicationName()):
self.start_windows_check.setChecked(True)
else:
self.start_windows_check.setChecked(False)
def check_app_path(self):
if not os.path.exists(self.app_path):
os.makedirs(self.app_path)
if not os.path.exists(self.table_path):
os.makedirs(self.table_path)
return
def construct_tray_icon(self):
self.tray_icon.setIcon(self.icon)
self.tray_icon_menu.addAction(self.settings_action)
self.tray_icon_menu.addSeparator()
self.tray_icon_menu.addAction(self.about_action)
self.tray_icon_menu.addSeparator()
self.tray_icon_menu.addAction(self.quit_action)
self.tray_icon.setContextMenu(self.tray_icon_menu)
self.tray_icon.show()
def signal_connectors(self):
self.tray_icon.activated.connect(self.icon_activated)
self.settings_action.triggered.connect(self.show_setting)
self.about_action.triggered.connect(self.show_about)
self.quit_action.triggered.connect(self.quit)
self.add_new_button.clicked.connect(self.change_dialog_index)
self.back_button.clicked.connect(self.change_dialog_index)
self.modifier_cbox.currentIndexChanged.connect(self.populate_shortcut_key)
self.shortcut_key_cbox.currentIndexChanged.connect(self.save_shortcut_key)
self.browse_button.clicked.connect(self.open_file_dialog)
self.add_button.clicked.connect(self.save_file)
self.clear_button.clicked.connect(self.reset_form)
self.remove_button.clicked.connect(self.remove_keyboard)
self.keyboard_cbox.currentIndexChanged.connect(self.save_current_keyboard)
self.start_windows_check.stateChanged.connect(self.change_start_windows)
def reset_form(self):
self.clear_file_error()
self.file_path_tview.setText("")
def open_file_dialog(self):
file_dialog = QFileDialog()
self.file_path_tview.setText(QFileDialog.getOpenFileName(file_dialog,
str("Choose a SCIM Table"),
"",
str("Scim Tables (*.in *.txt)"))[0])
def validate(self):
try:
with open(str(self.file_path_tview.text()), encoding="utf-8") as search:
for line in search:
line = line.rstrip() # remove '\n' at end of line
if "SCIM_Generic_Table_Phrase_Library_TEXT" in line:
return True
self.show_file_error("Invalid SCIM Table file")
return False
except:
self.show_file_error("Some error occurred")
return False
def save_file(self):
if self.validate():
self.clear_file_error()
filepath = str(self.file_path_tview.text())
fileinfo = QFileInfo(filepath)
filename = str(int(time.time())) + "_" + fileinfo.fileName()
keyboard_name = "Unknown"
with open(filepath, encoding="utf-8") as search:
#.........这里部分代码省略.........