Skip to content

Commit

Permalink
optimize protocol shortcut show
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Mar 3, 2022
1 parent a764f77 commit b2e6381
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
1 change: 0 additions & 1 deletion COMTool/assets/qss/style-dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ QPushButton:default {
.remark {
min-width: 10px;
min-height: 10px;
width: 20px;
height: 20px;
}

Expand Down
1 change: 0 additions & 1 deletion COMTool/assets/qss/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ QPushButton:default {
.remark {
min-width: 10px;
min-height: 10px;
width: 20px;
height: 20px;
}

Expand Down
25 changes: 18 additions & 7 deletions COMTool/plugins/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def onInit(self, config, plugins):
self.encodeMethod = lambda x:x
self.decodeMethod = lambda x:x
self.pressedKeys = []
self.keyModeClickTimes = 0
self.keyModeClickTime = 0

def print(self, *args, **kw_args):
end = "\n"
Expand Down Expand Up @@ -297,12 +297,12 @@ def onWidgetMain(self, parent, rootWindow):
customSendItemsLayoutWrapper.setContentsMargins(0,0,0,0)
cutomSendItemsWraper.setLayout(customSendItemsLayoutWrapper)
# items container
customItems = QWidget()
self.customItems = QWidget()
self.customSendItemsLayout = QVBoxLayout()
self.customSendItemsLayout.setContentsMargins(0,0,0,0)
customItems.setLayout(self.customSendItemsLayout)
self.customItems.setLayout(self.customSendItemsLayout)

customSendItemsLayoutWrapper.addWidget(customItems)
customSendItemsLayoutWrapper.addWidget(self.customItems)
customSendItemsLayoutWrapper.addWidget(self.addButton)
customSendItemsLayoutWrapper.addStretch(0)

Expand All @@ -320,16 +320,26 @@ def clearReceived():
def keyModeOn(event):
self.keyModeBtn.setProperty("class", "deleteBtn")
utils_ui.updateStyle(self.mainWidget, self.keyModeBtn)
self.keyModeClickTimes = time.time()
self.keyModeClickTime = time.time()
# show all shortcut
widgets = self.customItems.findChildren(QPushButton, "editRemark")
for i, w in enumerate(widgets):
shortcut = "+".join((name for v, name in self.config["customSendItems"][i]["shortcut"]))
w.setText(shortcut)
utils_ui.updateStyle(self.mainWidget, w)

def keyModeOff(event):
self.keyModeBtn.setProperty("class", "")
utils_ui.updateStyle(self.mainWidget, self.keyModeBtn)
self.keyModeClickTimes = 0
self.keyModeClickTime = 0
# hide all shortcut
widgets = self.customItems.findChildren(QPushButton, "editRemark")
for w in widgets:
w.setText("")

def keyModeTuggle():
if self.keyModeBtn.property("class") == "deleteBtn":
if time.time() - self.keyModeClickTimes < 0.2:
if time.time() - self.keyModeClickTime < 0.2:
return
else:
self.keyModeBtn.clearFocus()
Expand Down Expand Up @@ -550,6 +560,7 @@ def insertSendItem(self, item = None, load = False):
item["shortcut"] = []
utils_ui.setButtonIcon(send, item["icon"])
editRemark = QPushButton("")
editRemark.setObjectName("editRemark")
utils_ui.setButtonIcon(editRemark, "ei.pencil")
editRemark.setProperty("class", "remark")
cmd.setToolTip(text)
Expand Down

0 comments on commit b2e6381

Please sign in to comment.