From 48beec2490548e651568840adf57cfdc706a88a7 Mon Sep 17 00:00:00 2001 From: "B. G. Kendall" <69401250+bgkendall@users.noreply.github.com> Date: Tue, 25 Jul 2023 22:47:01 -0400 Subject: [PATCH] Quick Toggle Key Override Layers (#159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Allow quick enabling/disabling of all layers for a Key Override Add small “Enable all” and “Enable none” buttons beneath the list of layers to which a Key Override applies. Clicking the buttons will enable or disable all the layer check boxes. * Update function names * Updated label https://github.com/vial-kb/vial-gui/pull/159#discussion_r1103895912 --- src/main/python/editor/key_override.py | 28 +++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/python/editor/key_override.py b/src/main/python/editor/key_override.py index acbe7f379d..62c3a253ec 100644 --- a/src/main/python/editor/key_override.py +++ b/src/main/python/editor/key_override.py @@ -1,10 +1,10 @@ # SPDX-License-Identifier: GPL-2.0-or-later from PyQt5 import QtCore -from PyQt5.QtCore import pyqtSignal, QObject -from PyQt5.QtWidgets import QWidget, QSizePolicy, QGridLayout, QVBoxLayout, QLabel, QCheckBox, QScrollArea, QFrame +from PyQt5.QtCore import Qt, pyqtSignal, QObject +from PyQt5.QtWidgets import QWidget, QSizePolicy, QGridLayout, QHBoxLayout, QVBoxLayout, QLabel, QCheckBox, QScrollArea, QFrame, QToolButton from protocol.constants import VIAL_PROTOCOL_DYNAMIC -from util import make_scrollable +from util import make_scrollable, tr from widgets.key_widget import KeyWidget from protocol.key_override import KeyOverrideOptions, KeyOverrideEntry from vial_device import VialKeyboard @@ -117,14 +117,28 @@ class LayersUI(QWidget): def __init__(self): super().__init__() container = QGridLayout() + buttons = QHBoxLayout() self.layer_chks = [CheckBoxNoPadding(str(x)) for x in range(16)] for w in self.layer_chks: w.stateChanged.connect(self.on_change) + btn_all_layers = QToolButton() + btn_all_layers.setText(tr("KeyOverride", "Enable all")) + btn_all_layers.setToolButtonStyle(Qt.ToolButtonTextOnly) + btn_no_layers = QToolButton() + btn_no_layers.setText(tr("KeyOverride", "Disable all")) + btn_no_layers.setToolButtonStyle(Qt.ToolButtonTextOnly) + btn_all_layers.clicked.connect(self.on_enable_all_layers) + btn_no_layers.clicked.connect(self.on_disable_all_layers) for x in range(8): container.addWidget(self.layer_chks[x], 0, x) container.addWidget(self.layer_chks[x + 8], 1, x) + buttons.addWidget(btn_all_layers) + buttons.addWidget(btn_no_layers) + buttons.addStretch() + container.addLayout(buttons, 2, 0, 1, -1) + self.setLayout(container) def load(self, data): @@ -140,6 +154,14 @@ def save(self): def on_change(self): self.changed.emit() + def on_enable_all_layers(self): + for x, w in enumerate(self.layer_chks): + w.setChecked(True) + + def on_disable_all_layers(self): + for x, w in enumerate(self.layer_chks): + w.setChecked(False) + class KeyOverrideEntryUI(QObject):