Skip to content

Commit 6937144

Browse files
committed
add lang and modify search button
1 parent 45519c6 commit 6937144

22 files changed

+463
-24
lines changed

.settings/org.eclipse.core.resources.prefs

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ encoding//Test/TestSkinDialog.py=utf-8
2020
encoding//Test/TestToolTip.py=utf-8
2121
encoding//Test/TestTreeView.py=utf-8
2222
encoding//Test/TestWaterWidget.py=utf-8
23-
encoding//Test/Ui2Py.py=utf-8
24-
encoding//Test/buildexetest/PyQtClient.py=utf-8
25-
encoding//Test/buildexetest/setup_win.py=utf-8
26-
encoding//Test/buildzip.py=utf-8
27-
encoding//Test/compilepy.py=utf-8
23+
encoding//Tools/Ui2Py.py=utf-8
24+
encoding//Tools/buildexetest/PyQtClient.py=utf-8
25+
encoding//Tools/buildexetest/setup_win.py=utf-8
26+
encoding//Tools/buildzip.py=utf-8
27+
encoding//Tools/compilepy.py=utf-8
28+
encoding//Tools/makelang.py=utf-8
2829
encoding//UiFiles/Ui_ErrorDialog.py=utf-8
2930
encoding//UiFiles/Ui_LoginDialog.py=utf-8
3031
encoding//UiFiles/Ui_MainWindow.py=utf-8

PyQtClient.pro

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
SOURCES = UiFiles/Ui_DonateDialog.py\
2+
UiFiles/Ui_ErrorDialog.py\
3+
UiFiles/Ui_IssuesDialog.py\
4+
UiFiles/Ui_LoginDialog.py\
5+
UiFiles/Ui_MainWindow.py\
6+
UiFiles/Ui_PreviewWidget.py\
7+
UiFiles/Ui_ScrollArea.py\
8+
UiFiles/Ui_SkinDialog.py\
9+
UiFiles/Ui_UpdateDialog.py\
10+
Utils/Application.py\
11+
Utils/ColorThief.py\
12+
Utils/CommonUtil.py\
13+
Utils/Constants.py\
14+
Utils/GitThread.py\
15+
Utils/GradientUtils.py\
16+
Utils/NetworkAccessManager.py\
17+
Utils/SortFilterModel.py\
18+
Utils/TestColourfulWidget.py\
19+
Utils/ThemeManager.py\
20+
Utils/ThemeThread.py\
21+
Utils/Version.py\
22+
Widgets/FramelessWindow.py\
23+
Widgets/MainWindow.py\
24+
Widgets/MainWindowBase.py\
25+
Widgets/ToolTip.py\
26+
Widgets/TreeView.py\
27+
Widgets/WaterWidget.py\
28+
29+
FORMS = UiFiles/DonateDialog.ui\
30+
UiFiles/ErrorDialog.ui\
31+
UiFiles/IssuesDialog.ui\
32+
UiFiles/LoginDialog.ui\
33+
UiFiles/MainWindow.ui\
34+
UiFiles/PreviewWidget.ui\
35+
UiFiles/ScrollArea.ui\
36+
UiFiles/SkinDialog.ui\
37+
UiFiles/UpdateDialog.ui\
38+
39+
TRANSLATIONS = pyqtclient_zh_CN.ts
40+
CODECFORTR = UTF-8
41+
CODECFORSRC = UTF-8

Resources/Themes/Dark/style.qss

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ QLineEdit {
114114
border-bottom-left-radius: 15px;
115115
}
116116
/*搜索框中的按钮*/
117-
#buttonSearch {
117+
#buttonClear {
118118
min-width: 26px;
119119
max-width: 26px;
120120
min-height: 26px;
@@ -124,7 +124,7 @@ QLineEdit {
124124
qproperty-bgColor: rgba(38, 38, 38, 255);
125125
outline: none;
126126
font-family: "pyqtclient";
127-
qproperty-text: "\5100";
127+
qproperty-text: "\2103";
128128
}
129129

130130
/*目录树*/

Resources/Themes/Default/style.qss

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ QLineEdit {
114114
border-bottom-left-radius: 15px;
115115
}
116116
/*搜索框中的按钮*/
117-
#buttonSearch {
117+
#buttonClear {
118118
min-width: 26px;
119119
max-width: 26px;
120120
min-height: 26px;
@@ -124,7 +124,7 @@ QLineEdit {
124124
qproperty-bgColor: rgba(39, 174, 97, 255);
125125
outline: none;
126126
font-family: "pyqtclient";
127-
qproperty-text: "\5100";
127+
qproperty-text: "\2103";
128128
}
129129

130130
/*目录树*/

Resources/Themes/春节/style.qss

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ QLineEdit {
115115
border-bottom-left-radius: 15px;
116116
}
117117
/*搜索框中的按钮*/
118-
#buttonSearch {
118+
#buttonClear {
119119
min-width: 26px;
120120
max-width: 26px;
121121
min-height: 26px;
@@ -125,7 +125,7 @@ QLineEdit {
125125
qproperty-bgColor: rgba(200, 47, 10, 255);
126126
outline: none;
127127
font-family: "pyqtclient";
128-
qproperty-text: "\5100";
128+
qproperty-text: "\2103";
129129
}
130130

131131
/*目录树*/

Test/Ui2Py.py Tools/Ui2Py.py

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Test/buildzip.py Tools/buildzip.py

File renamed without changes.
File renamed without changes.

Tools/makelang.bat

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cd %~dp0
2+
cd ..
3+
pylupdate5 PyQtClient.pro
4+
cd Tools

Tools/makelang.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Created on 2018年3月29日
6+
@author: Irony
7+
@site: https://github.com/892768447
8+
@email: 892768447@qq.com
9+
@file: 生成多语言文件
10+
@description:
11+
"""
12+
import os
13+
14+
15+
__Author__ = """By: Irony
16+
QQ: 892768447
17+
Email: 892768447@qq.com"""
18+
__Copyright__ = "Copyright (c) 2018 Irony"
19+
__Version__ = "Version 1.0"
20+
21+
os.chdir('../')
22+
23+
fp = open('PyQtClient.pro', 'wb')
24+
25+
fp.write(b'SOURCES = ')
26+
for path in ('UiFiles', 'Utils', 'Widgets'):
27+
for name in os.listdir(path):
28+
if name.find('__init__') > -1 or not name.endswith('.py'):
29+
continue
30+
fp.write(' {}/{}\\\n'.format(path, name).encode())
31+
32+
fp.write(b'\n')
33+
fp.write(b'FORMS = ')
34+
path = 'UiFiles'
35+
for name in os.listdir(path):
36+
if not name.endswith('.ui'):
37+
continue
38+
fp.write(' {}/{}\\\n'.format(path, name).encode())
39+
40+
fp.write(b'\n')
41+
fp.write(b'TRANSLATIONS = pyqtclient_zh_CN.ts\n')
42+
fp.write(b'CODECFORTR = UTF-8\n')
43+
fp.write(b'CODECFORSRC = UTF-8\n')

UiFiles/MainWindow.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
</widget>
246246
</item>
247247
<item>
248-
<widget class="RubberBandButton" name="buttonSearch">
248+
<widget class="RubberBandButton" name="buttonClear">
249249
<property name="text">
250250
<string/>
251251
</property>

UiFiles/Ui_MainWindow.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ def setupUi(self, FormMainWindow):
9494
self.lineEditSearch.setAlignment(QtCore.Qt.AlignCenter)
9595
self.lineEditSearch.setObjectName("lineEditSearch")
9696
self.horizontalLayout_3.addWidget(self.lineEditSearch)
97-
self.buttonSearch = RubberBandButton(self.widgetSearch)
98-
self.buttonSearch.setText("")
99-
self.buttonSearch.setObjectName("buttonSearch")
100-
self.horizontalLayout_3.addWidget(self.buttonSearch)
97+
self.buttonClear = RubberBandButton(self.widgetSearch)
98+
self.buttonClear.setText("")
99+
self.buttonClear.setObjectName("buttonClear")
100+
self.horizontalLayout_3.addWidget(self.buttonClear)
101101
self.verticalLayout_4.addWidget(self.widgetSearch)
102102
self.treeViewCatalogs = TreeView(self.widgetCatalogs)
103103
self.treeViewCatalogs.setFrameShape(QtWidgets.QFrame.NoFrame)

Utils/SortFilterModel.py

+13
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,16 @@ def lessThan(self, source_left, source_right):
3939
# return super(SortFilterModel, self).lessThan(source_left,
4040
# source_right)
4141
return len(leftData) < len(rightData)
42+
43+
def filterAcceptsRow(self, sourceRow, sourceParent):
44+
# 过滤
45+
result = super(SortFilterModel, self).filterAcceptsRow(
46+
sourceRow, sourceParent)
47+
if result:
48+
return result
49+
else:
50+
sourceIndex = self.sourceModel().index(sourceRow, 0, sourceParent)
51+
for k in range(self.sourceModel().rowCount(sourceIndex)):
52+
if self.filterAcceptsRow(k, sourceIndex):
53+
return True
54+
return False

Utils/ThemeManager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}}
4343
4444
/*搜索框中的按钮*/
45-
#buttonSearch {{
45+
#buttonClear {{
4646
qproperty-bgColor: rgba({0}, {1}, {2}, 255);
4747
}}
4848
@@ -149,7 +149,7 @@
149149
}}
150150
151151
/*搜索框中的按钮*/
152-
#buttonSearch {{
152+
#buttonClear {{
153153
qproperty-bgColor: rgba({0}, {1}, {2}, 255);
154154
}}
155155

Widgets/MainWindow.py

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class MainWindow(FramelessWindow, MainWindowBase, Ui_FormMainWindow):
4242
def __init__(self, *args, **kwargs):
4343
super(MainWindow, self).__init__(*args, **kwargs)
4444
Setting.init(self)
45+
self._initLanguage()
4546
self._initUi()
4647
self._initSignals()
4748
# 加载窗口大小并恢复

Widgets/MainWindowBase.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
import os
1313
import webbrowser
1414

15-
from PyQt5.QtCore import pyqtSlot, QUrl
15+
from PyQt5.QtCore import pyqtSlot, QUrl, QLocale, QTranslator
1616
from PyQt5.QtGui import QColor
1717
from PyQt5.QtWebKit import QWebSettings
1818
from PyQt5.QtWebKitWidgets import QWebPage
19+
from PyQt5.QtWidgets import QApplication
1920

2021
from Utils import Constants
2122
from Utils.CommonUtil import Signals, Setting, AppLog
@@ -43,7 +44,7 @@ def _initUi(self):
4344
ThemeManager.loadCursor(self.widgetMain)
4445
ThemeManager.setPointerCursors([
4546
self.buttonHead, # 主界面头像
46-
self.buttonSearch, # 主界面搜索按钮
47+
self.buttonClear, # 主界面清空按钮
4748
self.buttonGithub, # Github按钮
4849
self.buttonQQ, # QQ按钮
4950
self.buttonGroup, # 群按钮
@@ -89,6 +90,15 @@ def _initSignals(self):
8990
Signals.progressUpdated.connect(self.widgetCatalogs.setValue)
9091
Signals.updateDialogShowed.connect(self._initUpdate)
9192

93+
def _initLanguage(self):
94+
"""加载国际化翻译
95+
"""
96+
if QLocale.system().language() in (QLocale.China, QLocale.Chinese, QLocale.Taiwan, QLocale.HongKong):
97+
# 加载中文
98+
translator = QTranslator(self)
99+
translator.load('translations/pyqtclient_zh_CN.qm')
100+
QApplication.instance().installTranslator(translator)
101+
92102
def _initWebView(self):
93103
"""初始化网页"""
94104
settings = self.webViewContent.settings()
@@ -157,14 +167,13 @@ def on_buttonHead_clicked(self):
157167
def on_lineEditSearch_textChanged(self, text):
158168
"""过滤筛选
159169
"""
160-
return
161170
Signals.filterChanged.emit(text)
162171

163172
@pyqtSlot()
164-
def on_buttonSearch_clicked(self):
165-
"""点击搜索按钮
173+
def on_buttonClear_clicked(self):
174+
"""点击清空按钮
166175
"""
167-
pass
176+
self.lineEditSearch.setText('')
168177

169178
@pyqtSlot()
170179
def on_buttonGithub_clicked(self):

0 commit comments

Comments
 (0)