|
@@ -7,29 +7,112 @@
|
|
|
@Desc : main ui
|
|
|
'''
|
|
|
|
|
|
-from PyQt5.QtWidgets import QMainWindow
|
|
|
+from PyQt5.QtWidgets import QApplication, QMainWindow, QGraphicsDropShadowEffect, QListWidgetItem, QListView, QWidget, \
|
|
|
+ QLabel, QHBoxLayout, QFileDialog
|
|
|
+from PyQt5.QtCore import Qt, QPropertyAnimation, QEasingCurve, QThread, pyqtSignal, QMutex, QSize, QEvent, QPoint
|
|
|
+from PyQt5.QtGui import QMouseEvent, QCursor, QColor
|
|
|
+from PyQt5.uic import loadUi
|
|
|
|
|
|
+class Window(QMainWindow):
|
|
|
+ '''主窗体'''
|
|
|
|
|
|
-class MyWindow(QMainWindow):
|
|
|
- def setWwarninginfo(self, text):
|
|
|
- """
|
|
|
- param self, text:
|
|
|
- return:
|
|
|
- """
|
|
|
- pass
|
|
|
+ def mousePressEvent(self, event):
|
|
|
+ # 重写一堆方法使其支持拖动
|
|
|
+ if event.button() == Qt.LeftButton:
|
|
|
+ self.m_drag = True
|
|
|
+ self.m_DragPosition = event.globalPos() - self.pos()
|
|
|
+ event.accept()
|
|
|
+
|
|
|
+ def mouseMoveEvent(self, QMouseEvent):
|
|
|
+ try:
|
|
|
+ if Qt.LeftButton and self.m_drag:
|
|
|
+ self.move(QMouseEvent.globalPos() - self.m_DragPosition)
|
|
|
+ QMouseEvent.accept()
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ def mouseReleaseEvent(self, QMouseEvent):
|
|
|
+ self.m_drag = False
|
|
|
+
|
|
|
+ def _frame(self):
|
|
|
+ # 边框
|
|
|
+ self.setWindowFlags(Qt.FramelessWindowHint)
|
|
|
+ self.setAttribute(Qt.WA_TranslucentBackground, True)
|
|
|
+ # 阴影
|
|
|
+ effect = QGraphicsDropShadowEffect(blurRadius=12, xOffset=0, yOffset=0)
|
|
|
+ effect.setColor(QColor(25, 25, 25, 170))
|
|
|
+ # self.mainFrame.setGraphicsEffect(effect)
|
|
|
+
|
|
|
+ def doFadeIn(self):
|
|
|
+ # 动画
|
|
|
+ self.animation = QPropertyAnimation(self, b'windowOpacity')
|
|
|
+ # 持续时间250ms
|
|
|
+ self.animation.setDuration(250)
|
|
|
+ try:
|
|
|
+ # 尝试先取消动画完成后关闭窗口的信号
|
|
|
+ self.animation.finished.disconnect(self.close)
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ self.animation.stop()
|
|
|
+ # 透明度范围从0逐渐增加到1
|
|
|
+ self.animation.setEasingCurve(QEasingCurve.InOutCubic)
|
|
|
+ self.animation.setStartValue(0)
|
|
|
+ self.animation.setEndValue(1)
|
|
|
+ self.animation.start()
|
|
|
|
|
|
def doFadeOut(self):
|
|
|
- """
|
|
|
- param self:
|
|
|
- return:
|
|
|
- """
|
|
|
- pass
|
|
|
+ self.animation.stop()
|
|
|
+ # 动画完成则关闭窗口
|
|
|
+ self.animation.finished.connect(self.close)
|
|
|
+ # 透明度范围从1逐渐减少到0s
|
|
|
+ self.animation.setEasingCurve(QEasingCurve.InOutCubic)
|
|
|
+ self.animation.setStartValue(1)
|
|
|
+ self.animation.setEndValue(0)
|
|
|
+ self.animation.start()
|
|
|
+
|
|
|
+ def setWarninginfo(self, text):
|
|
|
+ self.lab_info.setStyleSheet("""
|
|
|
+ .QLabel {
|
|
|
+ border:1px solid #ffccc7;
|
|
|
+ border-radius:3px;
|
|
|
+ line-height: 140px;
|
|
|
+ padding: 5px;
|
|
|
+ color: #434343;
|
|
|
+ background: #fff2f0;
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ self.lab_info.setText(text)
|
|
|
|
|
|
+ def setSuccessinfo(self, text):
|
|
|
+ self.lab_info.setStyleSheet("""
|
|
|
+ .QLabel {
|
|
|
+ border:1px solid #b7eb8f;
|
|
|
+ border-radius:3px;
|
|
|
+ line-height: 140px;
|
|
|
+ padding: 5px;
|
|
|
+ color: #434343;
|
|
|
+ background: #f6ffed;
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ self.lab_info.setText(text)
|
|
|
|
|
|
-class ConfigureWindow(MyWindow):
|
|
|
+class ConfigureWindow(Window):
|
|
|
+ '''配置弹框'''
|
|
|
config = {}
|
|
|
def __init__(self):
|
|
|
super().__init__()
|
|
|
+ loadUi("./conf/main.ui", self)
|
|
|
+ # self._frame()
|
|
|
+ # self._eventfilter()
|
|
|
+ # self.doFadeIn()
|
|
|
+ self.config_exists = True
|
|
|
+
|
|
|
+ # 判断配置文件是否存在
|
|
|
+ # if not os.path.exists(working_dir + "/config.json"):
|
|
|
+ # self.setWarninginfo("配置文件不存在!请单击“设置”创建配置文件")
|
|
|
+ # self.config_exists = False
|
|
|
+
|
|
|
+ self.show()
|
|
|
|
|
|
def saveConf(self):
|
|
|
self.updateConfig()
|