dev: 初步的加载界面
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -159,4 +159,7 @@ cython_debug/
|
|||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
.idea/
|
||||||
|
*.db
|
||||||
|
*.kdbx
|
||||||
|
|
||||||
|
|||||||
1
asset/img/eye-off.svg
Normal file
1
asset/img/eye-off.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512"><path d="M432 448a15.92 15.92 0 01-11.31-4.69l-352-352a16 16 0 0122.62-22.62l352 352A16 16 0 01432 448zM255.66 384c-41.49 0-81.5-12.28-118.92-36.5-34.07-22-64.74-53.51-88.7-91v-.08c19.94-28.57 41.78-52.73 65.24-72.21a2 2 0 00.14-2.94L93.5 161.38a2 2 0 00-2.71-.12c-24.92 21-48.05 46.76-69.08 76.92a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416a239.13 239.13 0 0075.8-12.58 2 2 0 00.77-3.31l-21.58-21.58a4 4 0 00-3.83-1 204.8 204.8 0 01-51.16 6.47zM490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96a227.34 227.34 0 00-74.89 12.83 2 2 0 00-.75 3.31l21.55 21.55a4 4 0 003.88 1 192.82 192.82 0 0150.21-6.69c40.69 0 80.58 12.43 118.55 37 34.71 22.4 65.74 53.88 89.76 91a.13.13 0 010 .16 310.72 310.72 0 01-64.12 72.73 2 2 0 00-.15 2.95l19.9 19.89a2 2 0 002.7.13 343.49 343.49 0 0068.64-78.48 32.2 32.2 0 00-.1-34.78z"/><path d="M256 160a95.88 95.88 0 00-21.37 2.4 2 2 0 00-1 3.38l112.59 112.56a2 2 0 003.38-1A96 96 0 00256 160zM165.78 233.66a2 2 0 00-3.38 1 96 96 0 00115 115 2 2 0 001-3.38z"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
1
asset/img/eye.svg
Normal file
1
asset/img/eye.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512"><path d="M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><circle cx="256" cy="256" r="80" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32"/></svg>
|
||||||
|
After Width: | Height: | Size: 500 B |
18
main.py
Normal file
18
main.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# coding: utf8
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from PySide6.QtWidgets import QApplication
|
||||||
|
|
||||||
|
from src.mw_kps_unifier import KpsUnifier
|
||||||
|
import src.rc_kps_unifier
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
win = KpsUnifier()
|
||||||
|
win.show()
|
||||||
|
return app.exec()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
6
src/kps_unifier.qrc
Normal file
6
src/kps_unifier.qrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>asset/img/eye.svg</file>
|
||||||
|
<file>asset/img/eye-off.svg</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
153
src/mw_kps_unifier.py
Normal file
153
src/mw_kps_unifier.py
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
# coding: utf8
|
||||||
|
from PySide6 import QtWidgets, QtCore, QtGui
|
||||||
|
|
||||||
|
|
||||||
|
class GbxKpsLogin(QtWidgets.QGroupBox):
|
||||||
|
def __init__(self, path: str, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.is_loaded = False
|
||||||
|
|
||||||
|
self.icon_eye = QtGui.QIcon(":/asset/img/eye.svg")
|
||||||
|
self.icon_eye_off = QtGui.QIcon(":/asset/img/eye-off.svg")
|
||||||
|
|
||||||
|
self.vly_m = QtWidgets.QVBoxLayout()
|
||||||
|
self.setLayout(self.vly_m)
|
||||||
|
|
||||||
|
self.hly_path = QtWidgets.QHBoxLayout()
|
||||||
|
self.vly_m.addLayout(self.hly_path)
|
||||||
|
|
||||||
|
self.lb_path = QtWidgets.QLabel("路径:", self)
|
||||||
|
self.hly_path.addWidget(self.lb_path)
|
||||||
|
self.lne_path = QtWidgets.QLineEdit(path, self)
|
||||||
|
self.lne_path.setEnabled(False)
|
||||||
|
self.hly_path.addWidget(self.lne_path)
|
||||||
|
|
||||||
|
self.hly_password = QtWidgets.QHBoxLayout()
|
||||||
|
self.vly_m.addLayout(self.hly_password)
|
||||||
|
|
||||||
|
self.lb_password = QtWidgets.QLabel("密码:", self)
|
||||||
|
self.hly_password.addWidget(self.lb_password)
|
||||||
|
self.lne_password = QtWidgets.QLineEdit(self)
|
||||||
|
self.lne_password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password)
|
||||||
|
self.hly_password.addWidget(self.lne_password)
|
||||||
|
|
||||||
|
self.pbn_eye = QtWidgets.QPushButton(icon=self.icon_eye_off, parent=self)
|
||||||
|
self.hly_password.addWidget(self.pbn_eye)
|
||||||
|
|
||||||
|
self.hly_bottom = QtWidgets.QHBoxLayout()
|
||||||
|
self.vly_m.addLayout(self.hly_bottom)
|
||||||
|
self.lb_loaded = QtWidgets.QLabel("【已加载】", self)
|
||||||
|
self.hly_bottom.addWidget(self.lb_loaded)
|
||||||
|
self.lb_loaded.setVisible(False)
|
||||||
|
self.hly_bottom.addStretch(1)
|
||||||
|
|
||||||
|
self.pbn_load = PushButtonWithItem(self, self, "加载")
|
||||||
|
self.hly_bottom.addWidget(self.pbn_load)
|
||||||
|
self.pbn_remove = PushButtonWithItem(self, self, "移除")
|
||||||
|
self.hly_bottom.addWidget(self.pbn_remove)
|
||||||
|
|
||||||
|
self.pbn_eye.clicked.connect(self.on_pbn_eye_clicked)
|
||||||
|
|
||||||
|
def on_pbn_eye_clicked(self):
|
||||||
|
is_pass_mode = self.lne_password.echoMode() == QtWidgets.QLineEdit.EchoMode.Password
|
||||||
|
if is_pass_mode:
|
||||||
|
self.lne_password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Normal)
|
||||||
|
self.pbn_eye.setIcon(self.icon_eye)
|
||||||
|
else:
|
||||||
|
self.lne_password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password)
|
||||||
|
self.pbn_eye.setIcon(self.icon_eye_off)
|
||||||
|
|
||||||
|
|
||||||
|
class PushButtonWithItem(QtWidgets.QPushButton):
|
||||||
|
|
||||||
|
clicked_with_item = QtCore.Signal(GbxKpsLogin)
|
||||||
|
|
||||||
|
def __init__(self, item: GbxKpsLogin, parent: QtWidgets.QWidget = None, title: str = ""):
|
||||||
|
super().__init__(title, parent)
|
||||||
|
self.item = item
|
||||||
|
self.clicked.connect(self.on_self_clicked)
|
||||||
|
|
||||||
|
def on_self_clicked(self):
|
||||||
|
self.clicked_with_item.emit(self.item)
|
||||||
|
|
||||||
|
|
||||||
|
class WgLoadKps(QtWidgets.QWidget):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.vly_m = QtWidgets.QVBoxLayout()
|
||||||
|
self.setLayout(self.vly_m)
|
||||||
|
self.vly_m.addStretch(1)
|
||||||
|
|
||||||
|
def add_kps(self, path: str):
|
||||||
|
wg = GbxKpsLogin(path, self)
|
||||||
|
wg.pbn_remove.clicked_with_item.connect(self.on_item_pbn_remove_clicked)
|
||||||
|
wg.pbn_load.clicked_with_item.connect(self.on_item_pbn_load_clicked)
|
||||||
|
# 从倒数第二个位置插入,保证弹簧始终在最后
|
||||||
|
self.vly_m.insertWidget(self.vly_m.count() - 1, wg)
|
||||||
|
|
||||||
|
def on_item_pbn_remove_clicked(self, item: GbxKpsLogin):
|
||||||
|
self.vly_m.removeWidget(item)
|
||||||
|
item.deleteLater()
|
||||||
|
|
||||||
|
def on_item_pbn_load_clicked(self, item: GbxKpsLogin):
|
||||||
|
item.is_loaded = True
|
||||||
|
item.lb_loaded.setVisible(True)
|
||||||
|
item.pbn_load.setDisabled(True)
|
||||||
|
|
||||||
|
|
||||||
|
class TabLoad(QtWidgets.QWidget):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.hly_m = QtWidgets.QHBoxLayout()
|
||||||
|
self.setLayout(self.hly_m)
|
||||||
|
self.vly_left = QtWidgets.QVBoxLayout()
|
||||||
|
self.hly_m.addLayout(self.vly_left)
|
||||||
|
|
||||||
|
self.pbn_add = QtWidgets.QPushButton("添加", self)
|
||||||
|
self.vly_left.addWidget(self.pbn_add)
|
||||||
|
self.pbn_load_all = QtWidgets.QPushButton("加载全部", self)
|
||||||
|
self.vly_left.addWidget(self.pbn_load_all)
|
||||||
|
self.vly_left.addStretch(1)
|
||||||
|
|
||||||
|
self.sa = QtWidgets.QScrollArea(self)
|
||||||
|
self.sa.setWidgetResizable(True)
|
||||||
|
self.hly_m.addWidget(self.sa)
|
||||||
|
self.wg_sa = WgLoadKps(self.sa)
|
||||||
|
self.sa.setWidget(self.wg_sa)
|
||||||
|
|
||||||
|
self.hly_m.setStretchFactor(self.vly_left, 1)
|
||||||
|
self.hly_m.setStretchFactor(self.sa, 6)
|
||||||
|
|
||||||
|
self.pbn_add.clicked.connect(self.on_pbn_add_clicked)
|
||||||
|
|
||||||
|
def on_pbn_add_clicked(self):
|
||||||
|
filenames, _ = QtWidgets.QFileDialog.getOpenFileNames(self, "选择", "../",
|
||||||
|
filter="KeePass 2 数据库 (*.kdbx);;所有文件(*)")
|
||||||
|
if len(filenames) == 0:
|
||||||
|
return
|
||||||
|
for filename in filenames:
|
||||||
|
self.wg_sa.add_kps(filename)
|
||||||
|
|
||||||
|
|
||||||
|
class UiKpsUnifier(object):
|
||||||
|
def __init__(self, window: QtWidgets.QWidget):
|
||||||
|
window.setWindowTitle('KeePassXC 多合一')
|
||||||
|
self.vly_m = QtWidgets.QVBoxLayout()
|
||||||
|
window.setLayout(self.vly_m)
|
||||||
|
|
||||||
|
self.tw_m = QtWidgets.QTabWidget(window)
|
||||||
|
self.vly_m.addWidget(self.tw_m)
|
||||||
|
|
||||||
|
self.tab_load = TabLoad(window)
|
||||||
|
self.tw_m.addTab(self.tab_load, "加载")
|
||||||
|
self.tab_query = QtWidgets.QWidget(window)
|
||||||
|
self.tw_m.addTab(self.tab_query, "查询")
|
||||||
|
|
||||||
|
|
||||||
|
class KpsUnifier(QtWidgets.QWidget):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.ui = UiKpsUnifier(self)
|
||||||
|
|
||||||
|
def sizeHint(self):
|
||||||
|
return QtCore.QSize(860, 640)
|
||||||
157
src/rc_kps_unifier.py
Normal file
157
src/rc_kps_unifier.py
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
# Resource object code (Python 3)
|
||||||
|
# Created by: object code
|
||||||
|
# Created by: The Resource Compiler for Qt version 6.5.2
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
from PySide6 import QtCore
|
||||||
|
|
||||||
|
qt_resource_data = b"\
|
||||||
|
\x00\x00\x01\xf4\
|
||||||
|
<\
|
||||||
|
svg xmlns=\x22http:\
|
||||||
|
//www.w3.org/200\
|
||||||
|
0/svg\x22 class=\x22io\
|
||||||
|
nicon\x22 viewBox=\x22\
|
||||||
|
0 0 512 512\x22><pa\
|
||||||
|
th d=\x22M255.66 11\
|
||||||
|
2c-77.94 0-157.8\
|
||||||
|
9 45.11-220.83 1\
|
||||||
|
35.33a16 16 0 00\
|
||||||
|
-.27 17.77C82.92\
|
||||||
|
340.8 161.8 400\
|
||||||
|
255.66 400c92.8\
|
||||||
|
4 0 173.34-59.38\
|
||||||
|
221.79-135.25a1\
|
||||||
|
6.14 16.14 0 000\
|
||||||
|
-17.47C428.89 17\
|
||||||
|
2.28 347.8 112 2\
|
||||||
|
55.66 112z\x22 fill\
|
||||||
|
=\x22none\x22 stroke=\x22\
|
||||||
|
currentColor\x22 st\
|
||||||
|
roke-linecap=\x22ro\
|
||||||
|
und\x22 stroke-line\
|
||||||
|
join=\x22round\x22 str\
|
||||||
|
oke-width=\x2232\x22/>\
|
||||||
|
<circle cx=\x22256\x22\
|
||||||
|
cy=\x22256\x22 r=\x2280\x22\
|
||||||
|
fill=\x22none\x22 str\
|
||||||
|
oke=\x22currentColo\
|
||||||
|
r\x22 stroke-miterl\
|
||||||
|
imit=\x2210\x22 stroke\
|
||||||
|
-width=\x2232\x22/></s\
|
||||||
|
vg>\
|
||||||
|
\x00\x00\x04|\
|
||||||
|
<\
|
||||||
|
svg xmlns=\x22http:\
|
||||||
|
//www.w3.org/200\
|
||||||
|
0/svg\x22 class=\x22io\
|
||||||
|
nicon\x22 viewBox=\x22\
|
||||||
|
0 0 512 512\x22><pa\
|
||||||
|
th d=\x22M432 448a1\
|
||||||
|
5.92 15.92 0 01-\
|
||||||
|
11.31-4.69l-352-\
|
||||||
|
352a16 16 0 0122\
|
||||||
|
.62-22.62l352 35\
|
||||||
|
2A16 16 0 01432 \
|
||||||
|
448zM255.66 384c\
|
||||||
|
-41.49 0-81.5-12\
|
||||||
|
.28-118.92-36.5-\
|
||||||
|
34.07-22-64.74-5\
|
||||||
|
3.51-88.7-91v-.0\
|
||||||
|
8c19.94-28.57 41\
|
||||||
|
.78-52.73 65.24-\
|
||||||
|
72.21a2 2 0 00.1\
|
||||||
|
4-2.94L93.5 161.\
|
||||||
|
38a2 2 0 00-2.71\
|
||||||
|
-.12c-24.92 21-4\
|
||||||
|
8.05 46.76-69.08\
|
||||||
|
76.92a31.92 31.\
|
||||||
|
92 0 00-.64 35.5\
|
||||||
|
4c26.41 41.33 60\
|
||||||
|
.4 76.14 98.28 1\
|
||||||
|
00.65C162 402 20\
|
||||||
|
7.9 416 255.66 4\
|
||||||
|
16a239.13 239.13\
|
||||||
|
0 0075.8-12.58 \
|
||||||
|
2 2 0 00.77-3.31\
|
||||||
|
l-21.58-21.58a4 \
|
||||||
|
4 0 00-3.83-1 20\
|
||||||
|
4.8 204.8 0 01-5\
|
||||||
|
1.16 6.47zM490.8\
|
||||||
|
4 238.6c-26.46-4\
|
||||||
|
0.92-60.79-75.68\
|
||||||
|
-99.27-100.53C34\
|
||||||
|
9 110.55 302 96 \
|
||||||
|
255.66 96a227.34\
|
||||||
|
227.34 0 00-74.\
|
||||||
|
89 12.83 2 2 0 0\
|
||||||
|
0-.75 3.31l21.55\
|
||||||
|
21.55a4 4 0 003\
|
||||||
|
.88 1 192.82 192\
|
||||||
|
.82 0 0150.21-6.\
|
||||||
|
69c40.69 0 80.58\
|
||||||
|
12.43 118.55 37\
|
||||||
|
34.71 22.4 65.7\
|
||||||
|
4 53.88 89.76 91\
|
||||||
|
a.13.13 0 010 .1\
|
||||||
|
6 310.72 310.72 \
|
||||||
|
0 01-64.12 72.73\
|
||||||
|
2 2 0 00-.15 2.\
|
||||||
|
95l19.9 19.89a2 \
|
||||||
|
2 0 002.7.13 343\
|
||||||
|
.49 343.49 0 006\
|
||||||
|
8.64-78.48 32.2 \
|
||||||
|
32.2 0 00-.1-34.\
|
||||||
|
78z\x22/><path d=\x22M\
|
||||||
|
256 160a95.88 95\
|
||||||
|
.88 0 00-21.37 2\
|
||||||
|
.4 2 2 0 00-1 3.\
|
||||||
|
38l112.59 112.56\
|
||||||
|
a2 2 0 003.38-1A\
|
||||||
|
96 96 0 00256 16\
|
||||||
|
0zM165.78 233.66\
|
||||||
|
a2 2 0 00-3.38 1\
|
||||||
|
96 96 0 00115 1\
|
||||||
|
15 2 2 0 001-3.3\
|
||||||
|
8z\x22/></svg>\
|
||||||
|
"
|
||||||
|
|
||||||
|
qt_resource_name = b"\
|
||||||
|
\x00\x05\
|
||||||
|
\x00h\xa9\xc4\
|
||||||
|
\x00a\
|
||||||
|
\x00s\x00s\x00e\x00t\
|
||||||
|
\x00\x03\
|
||||||
|
\x00\x00p7\
|
||||||
|
\x00i\
|
||||||
|
\x00m\x00g\
|
||||||
|
\x00\x07\
|
||||||
|
\x0c\xf8Z\x07\
|
||||||
|
\x00e\
|
||||||
|
\x00y\x00e\x00.\x00s\x00v\x00g\
|
||||||
|
\x00\x0b\
|
||||||
|
\x05\x10\xaaG\
|
||||||
|
\x00e\
|
||||||
|
\x00y\x00e\x00-\x00o\x00f\x00f\x00.\x00s\x00v\x00g\
|
||||||
|
"
|
||||||
|
|
||||||
|
qt_resource_struct = b"\
|
||||||
|
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
|
||||||
|
\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||||
|
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
|
||||||
|
\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||||
|
\x00\x00\x00\x10\x00\x02\x00\x00\x00\x02\x00\x00\x00\x03\
|
||||||
|
\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||||
|
\x00\x00\x000\x00\x00\x00\x00\x00\x01\x00\x00\x01\xf8\
|
||||||
|
\x00\x00\x01\x90\xc8\xe4\x89P\
|
||||||
|
\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
|
||||||
|
\x00\x00\x01\x90\xc8\xe4\xa5\xc7\
|
||||||
|
"
|
||||||
|
|
||||||
|
def qInitResources():
|
||||||
|
QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||||
|
|
||||||
|
def qCleanupResources():
|
||||||
|
QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||||
|
|
||||||
|
qInitResources()
|
||||||
Reference in New Issue
Block a user