-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathoption.py
77 lines (65 loc) · 3.1 KB
/
option.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- coding: utf-8 -*-
from PySide2.QtWidgets import *
from PySide2.QtCore import *
def _translate(context, text, disambig):
return QApplication.translate(context, text, disambig)
class OptionWidget(QWidget):
color = Signal(str)
opacity = Signal(bool)
top = Signal(bool)
def __init__(self, color, opacityToken, topToken):
super().__init__()
self.resize(540, 130)
self.setWindowTitle('高级设置')
layout = QGridLayout()
self.setLayout(layout)
backgroundColorButton = QPushButton('背景颜色')
backgroundColorButton.clicked.connect(self.selectBackgroundColor)
layout.addWidget(backgroundColorButton, 0, 0, 1, 1)
self.backgroundColorLabel = QLabel(color)
self.backgroundColorLabel.setStyleSheet('color:%s' % color)
layout.addWidget(self.backgroundColorLabel, 0, 1, 1, 1)
self.opacityButton = QPushButton('透明背景 (需重启)')
self.opacityButton.clicked.connect(self.setOpacity)
self.opacityToken = opacityToken
if self.opacityToken:
self.opacityButton.setStyleSheet('background-color:#3daee9')
else:
self.opacityButton.setStyleSheet('background-color:#31363b')
layout.addWidget(self.opacityButton, 0, 2, 1, 2)
self.stayTopButton = QPushButton('特效置顶 (需重启)')
self.stayTopButton.clicked.connect(self.setTop)
self.topToken = topToken
if self.topToken:
self.stayTopButton.setStyleSheet('background-color:#3daee9')
else:
self.stayTopButton.setStyleSheet('background-color:#31363b')
layout.addWidget(self.stayTopButton, 0, 4, 1, 2)
layout.addWidget(QLabel('更多使用教程 请访问'), 1, 0, 1, 2)
bilibili_url = QLabel()
bilibili_url.setOpenExternalLinks(True)
bilibili_url.setText(_translate("MainWindow", "<html><head/><body><p><a href=\"https://space.bilibili.com/637783\">\
<span style=\" text-decoration: underline; color:#cccccc;\">执明神君B站主页: https://space.bilibili.com/637783</span></a></p></body></html>",
None))
layout.addWidget(bilibili_url, 1, 2, 1, 4)
def selectBackgroundColor(self):
color = QColorDialog.getColor(self.backgroundColorLabel.text())
if color.isValid():
color = color.name()
self.color.emit(color)
self.backgroundColorLabel.setText(color)
self.backgroundColorLabel.setStyleSheet('color:%s' % color)
def setOpacity(self):
self.opacityToken = not self.opacityToken
if self.opacityToken:
self.opacityButton.setStyleSheet('background-color:#3daee9')
else:
self.opacityButton.setStyleSheet('background-color:#31363b')
self.opacity.emit(self.opacityToken)
def setTop(self):
self.topToken = not self.topToken
if self.topToken:
self.stayTopButton.setStyleSheet('background-color:#3daee9')
else:
self.stayTopButton.setStyleSheet('background-color:#31363b')
self.top.emit(self.topToken)