Skip to content

Commit

Permalink
Quick Toggle Key Override Layers (#159)
Browse files Browse the repository at this point in the history
* 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

#159 (comment)
  • Loading branch information
bgkendall committed Jul 26, 2023
1 parent 64e7259 commit 48beec2
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/main/python/editor/key_override.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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):

Expand Down

0 comments on commit 48beec2

Please sign in to comment.