From 5e7e567a181816b559cf13d2ff6684e7cb0ca57f Mon Sep 17 00:00:00 2001
From: gfdgd_xi <3025613752@qq.com>
Date: Sun, 9 Oct 2022 21:43:56 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90Deepin/UOS=E5=BF=AB=E6=8D=B7?=
=?UTF-8?q?=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
UI/KeyAddKeyboardGui.py | 12 +-
UI/KeyAddKeyboardGui.ui | 19 ++-
key/UI/KeyAddGui.ui | 9 +-
key/UI/KeyAddKeyboardGui.py | 86 ++++++++++++
key/UI/KeyAddKeyboardGui.ui | 130 ++++++++++++++++++
key/UI/__pycache__/KeyAddGui.cpython-37.pyc | Bin 3118 -> 2881 bytes
.../KeyAddKeyboardGui.cpython-37.pyc | Bin 0 -> 2690 bytes
key/keyboard-add-gui.py | 70 ++++++++++
8 files changed, 322 insertions(+), 4 deletions(-)
create mode 100644 key/UI/KeyAddKeyboardGui.py
create mode 100644 key/UI/KeyAddKeyboardGui.ui
create mode 100644 key/UI/__pycache__/KeyAddKeyboardGui.cpython-37.pyc
create mode 100644 key/keyboard-add-gui.py
diff --git a/UI/KeyAddKeyboardGui.py b/UI/KeyAddKeyboardGui.py
index 14f6eca..5e4e12c 100644
--- a/UI/KeyAddKeyboardGui.py
+++ b/UI/KeyAddKeyboardGui.py
@@ -21,6 +21,15 @@ class Ui_MainWindow(object):
self.addTips = QtWidgets.QLabel(self.centralwidget)
self.addTips.setObjectName("addTips")
self.verticalLayout.addWidget(self.addTips)
+ self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
+ self.horizontalLayout_3.setObjectName("horizontalLayout_3")
+ self.exeNameTips = QtWidgets.QLabel(self.centralwidget)
+ self.exeNameTips.setObjectName("exeNameTips")
+ self.horizontalLayout_3.addWidget(self.exeNameTips)
+ self.exeName = QtWidgets.QLineEdit(self.centralwidget)
+ self.exeName.setObjectName("exeName")
+ self.horizontalLayout_3.addWidget(self.exeName)
+ self.verticalLayout.addLayout(self.horizontalLayout_3)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.localTips = QtWidgets.QLabel(self.centralwidget)
@@ -66,8 +75,9 @@ class Ui_MainWindow(object):
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "添加快捷键"))
- self.addTips.setText(_translate("MainWindow", "暂时只支持 Ctrl+Alt+? 和 Alt+? 的组合\n"
+ self.addTips.setText(_translate("MainWindow", "暂时只支持特定组合\n"
"文本框内的只能输入单字母"))
+ self.exeNameTips.setText(_translate("MainWindow", "可这执行文件名称:"))
self.localTips.setText(_translate("MainWindow", "本地映射:"))
self.addTips_2.setText(_translate("MainWindow", "+"))
self.wineTips.setText(_translate("MainWindow", "Wine 容器映射内容:"))
diff --git a/UI/KeyAddKeyboardGui.ui b/UI/KeyAddKeyboardGui.ui
index 7fc70d7..b6eb4bc 100644
--- a/UI/KeyAddKeyboardGui.ui
+++ b/UI/KeyAddKeyboardGui.ui
@@ -14,18 +14,33 @@
添加快捷键
-
+
+ ../../../.designer/backup../../../.designer/backup
-
- 暂时只支持 Ctrl+Alt+? 和 Alt+? 的组合
+ 暂时只支持特定组合
文本框内的只能输入单字母
+ -
+
+
-
+
+
+ 可这执行文件名称:
+
+
+
+ -
+
+
+
+
-
-
diff --git a/key/UI/KeyAddGui.ui b/key/UI/KeyAddGui.ui
index d672769..c024da2 100644
--- a/key/UI/KeyAddGui.ui
+++ b/key/UI/KeyAddGui.ui
@@ -18,7 +18,7 @@
-
- 此工具可以用于设置快捷键到 Wine 容器的映射,以便 Wine 程序可以正常的使用快捷键<br>Deepin/UOS将会使用默认的快捷键服务,其它发行版将使用此运行器提供的快捷键服务
+ <html><head/><body><p>此工具可以用于设置快捷键到 Wine 容器的映射,以便 Wine 程序可以正常的使用快捷键<br/>Deepin/UOS将会使用默认的快捷键服务,其它发行版将使用此运行器提供的快捷键服务<br>Deepin/UOS将只会提供快捷键添加功能,请在控制中心进行快捷键的修改管理</p></body></html>
@@ -40,6 +40,13 @@
+ -
+
+
+ 添加
+
+
+
-
diff --git a/key/UI/KeyAddKeyboardGui.py b/key/UI/KeyAddKeyboardGui.py
new file mode 100644
index 0000000..46041e3
--- /dev/null
+++ b/key/UI/KeyAddKeyboardGui.py
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'KeyAddKeyboardGui.ui'
+#
+# Created by: PyQt5 UI code generator 5.11.3
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+class Ui_MainWindow(object):
+ def setupUi(self, MainWindow):
+ MainWindow.setObjectName("MainWindow")
+ MainWindow.resize(800, 195)
+ icon = QtGui.QIcon.fromTheme("..")
+ MainWindow.setWindowIcon(icon)
+ self.centralwidget = QtWidgets.QWidget(MainWindow)
+ self.centralwidget.setObjectName("centralwidget")
+ self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.addTips = QtWidgets.QLabel(self.centralwidget)
+ self.addTips.setObjectName("addTips")
+ self.verticalLayout.addWidget(self.addTips)
+ self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
+ self.horizontalLayout_3.setObjectName("horizontalLayout_3")
+ self.exeNameTips = QtWidgets.QLabel(self.centralwidget)
+ self.exeNameTips.setObjectName("exeNameTips")
+ self.horizontalLayout_3.addWidget(self.exeNameTips)
+ self.exeName = QtWidgets.QLineEdit(self.centralwidget)
+ self.exeName.setObjectName("exeName")
+ self.horizontalLayout_3.addWidget(self.exeName)
+ self.verticalLayout.addLayout(self.horizontalLayout_3)
+ self.horizontalLayout = QtWidgets.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.localTips = QtWidgets.QLabel(self.centralwidget)
+ self.localTips.setObjectName("localTips")
+ self.horizontalLayout.addWidget(self.localTips)
+ self.localKeyboardChoose = QtWidgets.QComboBox(self.centralwidget)
+ self.localKeyboardChoose.setObjectName("localKeyboardChoose")
+ self.horizontalLayout.addWidget(self.localKeyboardChoose)
+ self.addTips_2 = QtWidgets.QLabel(self.centralwidget)
+ self.addTips_2.setObjectName("addTips_2")
+ self.horizontalLayout.addWidget(self.addTips_2)
+ self.localKey = QtWidgets.QLineEdit(self.centralwidget)
+ self.localKey.setObjectName("localKey")
+ self.horizontalLayout.addWidget(self.localKey)
+ self.wineTips = QtWidgets.QLabel(self.centralwidget)
+ self.wineTips.setObjectName("wineTips")
+ self.horizontalLayout.addWidget(self.wineTips)
+ self.wineKeyboardChoose = QtWidgets.QComboBox(self.centralwidget)
+ self.wineKeyboardChoose.setObjectName("wineKeyboardChoose")
+ self.horizontalLayout.addWidget(self.wineKeyboardChoose)
+ self.addTipsWine = QtWidgets.QLabel(self.centralwidget)
+ self.addTipsWine.setObjectName("addTipsWine")
+ self.horizontalLayout.addWidget(self.addTipsWine)
+ self.wineKey = QtWidgets.QLineEdit(self.centralwidget)
+ self.wineKey.setObjectName("wineKey")
+ self.horizontalLayout.addWidget(self.wineKey)
+ self.verticalLayout.addLayout(self.horizontalLayout)
+ spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
+ self.verticalLayout.addItem(spacerItem)
+ self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem1)
+ self.addButton = QtWidgets.QPushButton(self.centralwidget)
+ self.addButton.setObjectName("addButton")
+ self.horizontalLayout_2.addWidget(self.addButton)
+ self.verticalLayout.addLayout(self.horizontalLayout_2)
+ MainWindow.setCentralWidget(self.centralwidget)
+
+ self.retranslateUi(MainWindow)
+ QtCore.QMetaObject.connectSlotsByName(MainWindow)
+
+ def retranslateUi(self, MainWindow):
+ _translate = QtCore.QCoreApplication.translate
+ MainWindow.setWindowTitle(_translate("MainWindow", "添加快捷键"))
+ self.addTips.setText(_translate("MainWindow", "暂时只支持 Ctrl+Alt+? 和 Alt+? 的组合\n"
+"文本框内的只能输入单字母"))
+ self.exeNameTips.setText(_translate("MainWindow", "可这执行文件名称:"))
+ self.localTips.setText(_translate("MainWindow", "本地映射:"))
+ self.addTips_2.setText(_translate("MainWindow", "+"))
+ self.wineTips.setText(_translate("MainWindow", "Wine 容器映射内容:"))
+ self.addTipsWine.setText(_translate("MainWindow", "+"))
+ self.addButton.setText(_translate("MainWindow", "添加快捷键"))
+
diff --git a/key/UI/KeyAddKeyboardGui.ui b/key/UI/KeyAddKeyboardGui.ui
new file mode 100644
index 0000000..847a464
--- /dev/null
+++ b/key/UI/KeyAddKeyboardGui.ui
@@ -0,0 +1,130 @@
+
+
+ MainWindow
+
+
+
+ 0
+ 0
+ 800
+ 195
+
+
+
+ 添加快捷键
+
+
+
+ ../../../.designer/backup../../../.designer/backup
+
+
+
+
-
+
+
+ 暂时只支持 Ctrl+Alt+? 和 Alt+? 的组合
+文本框内的只能输入单字母
+
+
+
+ -
+
+
-
+
+
+ 可这执行文件名称:
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ 本地映射:
+
+
+
+ -
+
+
+ -
+
+
+ +
+
+
+
+ -
+
+
+ -
+
+
+ Wine 容器映射内容:
+
+
+
+ -
+
+
+ -
+
+
+ +
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ 添加快捷键
+
+
+
+
+
+
+
+
+
+
+
diff --git a/key/UI/__pycache__/KeyAddGui.cpython-37.pyc b/key/UI/__pycache__/KeyAddGui.cpython-37.pyc
index cb9a5ca0593211aae528aa42174c338e33f5b3e3..03b5fff5d7d520ec5af8548d8d4ae397e96cb935 100644
GIT binary patch
delta 784
zcmZWmO=#0#82-Mr${y1&@>Z`$HF2Ci~J}ngu|jHtoV@
z$re8zkO{+2h-2b`tNj)~iFF1WMlO@40b8k?V5jfVHatu3!kXNmGq54oXaQcyrd`C}
z!2Y6^HIYcj{^}
z<4cS(<$)CKsc{+JPOa9%P4r8yf(hekgsLP`1s
Da3H-Q
delta 982
zcmZ8fO-~b16rDGv({@a2p{4W#sC-%ktub-MWFkbv!Wd&v6Iq~z8Ret2b(qGOR9Rq%
z5)jN|1tz|(G#aZc6pU!q@DJP>SK29cVKlDPmG`}AYjh@abMHClo_Y7qy!GY$u70Oe
zzt#9-~-5u99`ndkS1I_3>@npD(nk>q2=Y5d*2&Xu+2yu`*iGw2LN+1msV-+HP
z$e{~y;1I|l)*l2cNJ4reX;NHp^UCfl(=eP<++}?;ty#ypFr;C4Wi6#Li0m;bX4_J>
zZ3V0qGQFel|6IeD19JmF4=e>0HiXZ}l2nhUT
zt1#)J=GAInmSY<+@s27^Rh`x9U)A0!PF0a|6=cp~(w%MLOo;T*Ibq_)iT&h&nJe5N
z*A>7EmP?`|rYQYsT~8+P56g8F#g}WgdCiRvS-Vjk9=5h0@xXT-5~o%DgqleA$Fw2a
zslHKtJeknEz-aXq`dA`15?2+?N6`iv{4@mcJF6}P#BtJ?J{6axF*T+{Woaa-
zT$QDijQw^EMwz!KW~32KKB}sz@kI2@$wA}koU!zb38
z#ym0R@0Dg>ecM_nJ=rksJ}BP4Z`^!d*nDi{XG{6DQg)%L-&ws;$mfbHFLrX-o#i`_^a3x`75egf3Qna
PNhKXuWe1h>5WM^!B$pb~
diff --git a/key/UI/__pycache__/KeyAddKeyboardGui.cpython-37.pyc b/key/UI/__pycache__/KeyAddKeyboardGui.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000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*f*&@1fi8~EoE(Q-IYvk`W8fMZt1Nn9*nYJ#V_~qJ1(*~yrgp+l
z%w0fdLvl2M;jJYy$-iS2
zle6*YvHwNgfAUjf<!i#FV;+$IJeW&ti>lK5eYsZLDAQuU-Kz=xtp7ZR7W^{43x2D_{FR-)h`nsSbi&|N8xn
zC$}4)-`QBd21@@te(2v=d3xu;zrU`Ey{z5!*B&&!t@{s_f%i-utzr&iw;1v7{o>#L
zUdX@?ECG@36zQAD;=h+;l?s$e&b92a7j31u(beh#)0SJLys~*-P16OJS23?rQI)(P
zc`c&nw9fFaj>!6$*|NzKTui%Bj)yx1!@;6f)QFl;lUh=3{+0%}=FXM^oP^qnm}VKO
z%rw22X_jnKEh61%njcnkMIm8(z%qCAoO7%*#&>|Jhh53RCKpj7M;LM@(;*{xb}{R|
h#pA^LByWRW$mU&?qh4mvi@YuN@eX!H2b)An`wtE5;E4bL
literal 0
HcmV?d00001
diff --git a/key/keyboard-add-gui.py b/key/keyboard-add-gui.py
new file mode 100644
index 0000000..9219e4e
--- /dev/null
+++ b/key/keyboard-add-gui.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3
+import os
+import sys
+import traceback
+programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
+sys.path.append(f"{programPath}/..")
+
+import dbus
+import threading
+from UI.KeyAddKeyboardGui import *
+import PyQt5.QtWidgets as QtWidgets
+
+keyList = ["无快捷键", "shift", "ctrl", "alt", "ctrl+alt", "ctrl+shift", "alt+shift"]
+keyListDeepinMap = ["", "", "", "", "", "", ""]
+keyListDebianMap = [[], ["shift"], ["ctrl"], ["alt"], ["ctrl", "alt"], ["ctrl", "shift"], ["alt", "shift"]]
+
+class Check:
+ def VersionCheck():
+ try:
+ bus = dbus.SessionBus()
+ bus.get_object("com.deepin.daemon.Keybinding", "/com/deepin/daemon/Keybinding").List()
+ return True
+ except:
+ print("无法检测到 Deepin/UOS 快捷键服务")
+ return False
+
+class Click:
+ def LocalValueChange():
+ ui.wineKeyboardChoose.setCurrentIndex(ui.localKeyboardChoose.currentIndex())
+
+ def LocalKeyChange():
+ ui.wineKey.setText(ui.localKey.text())
+
+ def AddButton():
+ # 完整性检测
+ if ui.exeName.text() == "" or ui.localKey.text() == "" or ui.wineKey.text() == "":
+ QtWidgets.QMessageBox.critical(window, "错误", "您的信息暂未填写完整")
+ return
+ # Deepin/UOS 的情况
+ if Check.VersionCheck():
+ # 接入 dbus
+ try:
+ bus = dbus.SessionBus()
+ bus.get_object("com.deepin.daemon.Keybinding", "/com/deepin/daemon/Keybinding").Add(
+ ui.exeName.text(),
+ f"'{programPath}/sendkeys.sh' {ui.wineKey.text()[0]} '{ui.exeName.text()}' {ui.wineKeyboardChoose.currentIndex()}",
+ f"{keyListDeepinMap[ui.localKeyboardChoose.currentIndex()]}{ui.localKey.text()[0]}"
+ )
+ QtWidgets.QMessageBox.information(window, "提示", "添加成功!")
+ except:
+ traceback.print_exc()
+ QtWidgets.QMessageBox.critical(window, "错误", traceback.format_exc())
+ return
+
+
+if __name__ == "__main__":
+ app = QtWidgets.QApplication(sys.argv)
+ window = QtWidgets.QMainWindow()
+ ui = Ui_MainWindow()
+ ui.setupUi(window)
+ # 连接槽
+ ui.addButton.clicked.connect(Click.AddButton)
+ ui.localKeyboardChoose.currentIndexChanged.connect(Click.LocalValueChange)
+ ui.localKey.textChanged.connect(Click.LocalKeyChange)
+ window.show()
+ # 添加选项
+ ui.localKeyboardChoose.addItems(keyList)
+ ui.wineKeyboardChoose.addItems(keyList)
+ #threading.Thread(target=Check.CheckThreading).start()
+ sys.exit(app.exec_())
\ No newline at end of file