diff --git a/src/main/python/main_window.py b/src/main/python/main_window.py index 8c32fe8..b879efb 100644 --- a/src/main/python/main_window.py +++ b/src/main/python/main_window.py @@ -18,6 +18,7 @@ from layout_editor import LayoutEditor from macro_recorder import MacroRecorder from qmk_settings import QmkSettings from rgb_configurator import RGBConfigurator +from tap_dance import TapDance from unlocker import Unlocker from util import tr, find_vial_devices, EXAMPLE_KEYBOARDS from vial_device import VialKeyboard @@ -58,12 +59,14 @@ class MainWindow(QMainWindow): self.keymap_editor = KeymapEditor(self.layout_editor) self.firmware_flasher = FirmwareFlasher(self) self.macro_recorder = MacroRecorder() + self.tap_dance = TapDance() self.qmk_settings = QmkSettings(self.appctx) 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.qmk_settings, "QMK Settings"), + (self.rgb_configurator, "Lighting"), (self.tap_dance, "Tap Dance"), + (self.qmk_settings, "QMK Settings"), (self.matrix_tester, "Matrix tester"), (self.firmware_flasher, "Firmware updater")] Unlocker.global_layout_editor = self.layout_editor @@ -257,7 +260,7 @@ class MainWindow(QMainWindow): self.current_device.keyboard.reload() for e in [self.layout_editor, self.keymap_editor, self.firmware_flasher, self.macro_recorder, - self.qmk_settings, self.matrix_tester, self.rgb_configurator]: + self.tap_dance, self.qmk_settings, self.matrix_tester, self.rgb_configurator]: e.rebuild(self.current_device) def refresh_tabs(self): diff --git a/src/main/python/tap_dance.py b/src/main/python/tap_dance.py new file mode 100644 index 0000000..7d920a3 --- /dev/null +++ b/src/main/python/tap_dance.py @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +from PyQt5 import QtCore +from PyQt5.QtWidgets import QTabWidget, QWidget, QSizePolicy, QGridLayout, QVBoxLayout, QLabel, QLineEdit, QHBoxLayout, \ + QPushButton + +from util import tr +from vial_device import VialKeyboard +from basic_editor import BasicEditor + + +class TapDance(BasicEditor): + + def __init__(self): + super().__init__() + self.keyboard = None + + self.tabs = QTabWidget() + for x in range(32): + container = QGridLayout() + + container.addWidget(QLabel("On tap"), 0, 0) + container.addWidget(QLineEdit(), 0, 1) + container.addWidget(QLabel("On hold"), 1, 0) + container.addWidget(QLineEdit(), 1, 1) + container.addWidget(QLabel("On double tap"), 2, 0) + container.addWidget(QLineEdit(), 2, 1) + container.addWidget(QLabel("On tap + hold"), 3, 0) + container.addWidget(QLineEdit(), 3, 1) + + w = QWidget() + w.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) + w.setLayout(container) + l = QVBoxLayout() + l.addStretch() + l.addWidget(w) + l.setAlignment(w, QtCore.Qt.AlignHCenter) + l.addSpacing(100) + lbl = QLabel("Use TD({}) to set up this action in the keymap.".format(x)) + l.addWidget(lbl) + l.setAlignment(lbl, QtCore.Qt.AlignHCenter) + l.addStretch() + w2 = QWidget() + w2.setLayout(l) + self.tabs.addTab(w2, str(x)) + + self.addWidget(self.tabs) + buttons = QHBoxLayout() + buttons.addStretch() + btn_save = QPushButton(tr("TapDance", "Save")) + btn_revert = QPushButton(tr("TapDance", "Revert")) + buttons.addWidget(btn_save) + buttons.addWidget(btn_revert) + self.addLayout(buttons) + + def rebuild(self, device): + super().rebuild(device) + if self.valid(): + self.keyboard = device.keyboard + + def valid(self): + return isinstance(self.device, VialKeyboard) and \ + (self.device.keyboard and self.device.keyboard.vial_protocol >= 4)