macro_action: switch sequence to FlowLayout
parent
bd6955aa0a
commit
629541c0c5
|
|
@ -2,8 +2,9 @@
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, pyqtSignal, Qt
|
from PyQt5.QtCore import QObject, pyqtSignal, Qt
|
||||||
from PyQt5.QtWidgets import QLineEdit, QToolButton, QHBoxLayout, QComboBox
|
from PyQt5.QtWidgets import QLineEdit, QToolButton, QComboBox, QWidget, QSizePolicy
|
||||||
|
|
||||||
|
from flowlayout import FlowLayout
|
||||||
from keycodes import KEYCODES_BASIC
|
from keycodes import KEYCODES_BASIC
|
||||||
from util import tr
|
from util import tr
|
||||||
|
|
||||||
|
|
@ -62,8 +63,10 @@ class ActionSequence(BasicAction):
|
||||||
self.btn_plus.setToolButtonStyle(Qt.ToolButtonTextOnly)
|
self.btn_plus.setToolButtonStyle(Qt.ToolButtonTextOnly)
|
||||||
self.btn_plus.clicked.connect(self.on_add)
|
self.btn_plus.clicked.connect(self.on_add)
|
||||||
|
|
||||||
self.layout = QHBoxLayout()
|
self.layout = FlowLayout()
|
||||||
self.layout.addStretch()
|
self.layout_container = QWidget()
|
||||||
|
self.layout_container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
|
||||||
|
self.layout_container.setLayout(self.layout)
|
||||||
self.widgets = []
|
self.widgets = []
|
||||||
self.recreate_sequence()
|
self.recreate_sequence()
|
||||||
|
|
||||||
|
|
@ -84,15 +87,15 @@ class ActionSequence(BasicAction):
|
||||||
w.addItem(k.label.replace("\n", ""))
|
w.addItem(k.label.replace("\n", ""))
|
||||||
w.setCurrentIndex(2 + KEYCODES_BASIC.index(item))
|
w.setCurrentIndex(2 + KEYCODES_BASIC.index(item))
|
||||||
w.currentIndexChanged.connect(self.on_change)
|
w.currentIndexChanged.connect(self.on_change)
|
||||||
self.layout.insertWidget(self.layout.count() - 1, w)
|
self.layout.addWidget(w)
|
||||||
self.widgets.append(w)
|
self.widgets.append(w)
|
||||||
self.layout.insertWidget(self.layout.count() - 1, self.btn_plus)
|
self.layout.addWidget(self.btn_plus)
|
||||||
|
|
||||||
def insert(self, row):
|
def insert(self, row):
|
||||||
self.container.addLayout(self.layout, row, 2)
|
self.container.addWidget(self.layout_container, row, 2)
|
||||||
|
|
||||||
def remove(self):
|
def remove(self):
|
||||||
self.container.removeItem(self.layout)
|
self.container.removeWidget(self.layout_container)
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
for w in self.widgets:
|
for w in self.widgets:
|
||||||
|
|
@ -102,6 +105,8 @@ class ActionSequence(BasicAction):
|
||||||
self.btn_plus.deleteLater()
|
self.btn_plus.deleteLater()
|
||||||
self.layout.setParent(None)
|
self.layout.setParent(None)
|
||||||
self.layout.deleteLater()
|
self.layout.deleteLater()
|
||||||
|
self.layout_container.setParent(None)
|
||||||
|
self.layout_container.deleteLater()
|
||||||
|
|
||||||
def on_add(self):
|
def on_add(self):
|
||||||
self.sequence.append(KC_NO)
|
self.sequence.append(KC_NO)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue