def set_theme(self, theme): themes.set_theme(theme) self.settings.setValue("theme", theme) msg = QMessageBox() msg.setText( tr( "MainWindow", "In order to fully apply the theme you should restart the application." )) msg.exec_()
def set_style(widget, style, correct_font=True): """ Applies style to application L&F. style - should be Style object. """ if not INITIALIZED: _init_styling(widget) sk1sdk.tkstyle.CURRENT_STYLE = style _apply_colors(widget, style) _apply_fonts(widget, style, correct_font) icons.load_icons(widget, style.iconset) themes.set_theme(widget, style.theme)
def __init__(self): super().__init__() self.settings = QSettings("Vial", "Vial") themes.set_theme(self.get_theme()) self.current_device = None self.devices = [] # create empty VIA definitions. Easier than setting it to none and handling a bunch of exceptions self.via_stack_json = {"definitions": {}} self.sideload_json = None self.sideload_vid = self.sideload_pid = -1 self.combobox_devices = QComboBox() self.combobox_devices.currentIndexChanged.connect( self.on_device_selected) self.btn_refresh_devices = QToolButton() self.btn_refresh_devices.setToolButtonStyle(Qt.ToolButtonTextOnly) self.btn_refresh_devices.setText(tr("MainWindow", "Refresh")) self.btn_refresh_devices.clicked.connect(self.on_click_refresh) layout_combobox = QHBoxLayout() layout_combobox.addWidget(self.combobox_devices) layout_combobox.addWidget(self.btn_refresh_devices) self.layout_editor = LayoutEditor() self.keymap_editor = KeymapEditor(self.layout_editor) self.firmware_flasher = FirmwareFlasher(self) self.macro_recorder = MacroRecorder() self.matrix_tester = MatrixTest(self.layout_editor) self.editors = [(self.keymap_editor, "Keymap"), (self.layout_editor, "Layout"), (self.macro_recorder, "Macros"), (self.matrix_tester, "Matrix tester"), (self.firmware_flasher, "Firmware updater")] Unlocker.global_layout_editor = self.layout_editor self.tabs = QTabWidget() self.refresh_tabs() self.lbl_no_devices = QLabel( tr( "MainWindow", 'No devices detected. Connect a Vial-compatible device and press ' '"Refresh"\n' 'or select "File" → "Download VIA definitions" in order to enable' ' support for VIA keyboards.')) self.lbl_no_devices.setAlignment(Qt.AlignCenter) layout = QVBoxLayout() layout.addLayout(layout_combobox) layout.addWidget(self.tabs) layout.addWidget(self.lbl_no_devices) layout.setAlignment(self.lbl_no_devices, Qt.AlignHCenter) w = QWidget() w.setLayout(layout) self.setCentralWidget(w) self.init_menu() # cache for via definition files self.cache_path = QStandardPaths.writableLocation( QStandardPaths.CacheLocation) if not os.path.exists(self.cache_path): os.makedirs(self.cache_path) # check if the via defitions already exist if os.path.isfile(os.path.join(self.cache_path, "via_keyboards.json")): with open(os.path.join(self.cache_path, "via_keyboards.json")) as vf: self.via_stack_json = json.load(vf) vf.close() # make sure initial state is valid self.on_click_refresh()
def __init__(self, appctx): super().__init__() self.appctx = appctx self.settings = QSettings("Vial", "Vial") if self.settings.value("size", None) and self.settings.value( "pos", None): self.resize(self.settings.value("size")) self.move(self.settings.value("pos")) else: self.resize(WINDOW_WIDTH, WINDOW_HEIGHT) themes.set_theme(self.get_theme()) self.combobox_devices = QComboBox() self.combobox_devices.currentIndexChanged.connect( self.on_device_selected) self.btn_refresh_devices = QToolButton() self.btn_refresh_devices.setToolButtonStyle(Qt.ToolButtonTextOnly) self.btn_refresh_devices.setText(tr("MainWindow", "Refresh")) self.btn_refresh_devices.clicked.connect(self.on_click_refresh) layout_combobox = QHBoxLayout() layout_combobox.addWidget(self.combobox_devices) layout_combobox.addWidget(self.btn_refresh_devices) self.layout_editor = LayoutEditor() self.keymap_editor = KeymapEditor(self.layout_editor) self.firmware_flasher = FirmwareFlasher(self) self.macro_recorder = MacroRecorder() self.tap_dance = TapDance() self.combos = Combos() QmkSettings.initialize(appctx) self.qmk_settings = QmkSettings() self.matrix_tester = MatrixTest(self.layout_editor) self.rgb_configurator = RGBConfigurator() self.editors = [(self.keymap_editor, "Keymap"), (self.layout_editor, "Layout"), (self.macro_recorder, "Macros"), (self.rgb_configurator, "Lighting"), (self.tap_dance, "Tap Dance"), (self.combos, "Combos"), (self.qmk_settings, "QMK Settings"), (self.matrix_tester, "Matrix tester"), (self.firmware_flasher, "Firmware updater")] Unlocker.global_layout_editor = self.layout_editor self.current_tab = None self.tabs = QTabWidget() self.tabs.currentChanged.connect(self.on_tab_changed) self.refresh_tabs() no_devices = 'No devices detected. Connect a Vial-compatible device and press "Refresh"<br>' \ 'or select "File" → "Download VIA definitions" in order to enable support for VIA keyboards.' if sys.platform.startswith("linux"): no_devices += '<br><br>On Linux you need to set up a custom udev rule for keyboards to be detected. ' \ 'Follow the instructions linked below:<br>' \ '<a href="https://get.vial.today/manual/linux-udev.html">https://get.vial.today/manual/linux-udev.html</a>' self.lbl_no_devices = QLabel(tr("MainWindow", no_devices)) self.lbl_no_devices.setTextFormat(Qt.RichText) self.lbl_no_devices.setAlignment(Qt.AlignCenter) layout = QVBoxLayout() layout.addLayout(layout_combobox) layout.addWidget(self.tabs) layout.addWidget(self.lbl_no_devices) layout.setAlignment(self.lbl_no_devices, Qt.AlignHCenter) self.tray_keycodes = TabbedKeycodes() self.tray_keycodes.make_tray() layout.addWidget(self.tray_keycodes) self.tray_keycodes.hide() w = QWidget() w.setLayout(layout) self.setCentralWidget(w) self.init_menu() self.autorefresh = Autorefresh() self.autorefresh.devices_updated.connect(self.on_devices_updated) # cache for via definition files self.cache_path = QStandardPaths.writableLocation( QStandardPaths.CacheLocation) if not os.path.exists(self.cache_path): os.makedirs(self.cache_path) # check if the via defitions already exist if os.path.isfile(os.path.join(self.cache_path, "via_keyboards.json")): with open(os.path.join(self.cache_path, "via_keyboards.json")) as vf: data = vf.read() try: self.autorefresh.load_via_stack(data) except JSONDecodeError as e: # the saved file is invalid - just ignore this logging.warning( "Failed to parse stored via_keyboards.json: {}".format(e)) # make sure initial state is valid self.on_click_refresh()