|
@@ -1,122 +1,94 @@
|
|
|
-#!/usr/bin/env python
|
|
|
-# -*- encoding: utf-8 -*-
|
|
|
-'''
|
|
|
-@Contact : liuyuqi.gov@msn.cn
|
|
|
-@Time : 2022/06/29 12:42:58
|
|
|
-@License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
|
|
|
-@Desc : main ui
|
|
|
-'''
|
|
|
-
|
|
|
-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):
|
|
|
- '''主窗体'''
|
|
|
-
|
|
|
- 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):
|
|
|
- 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(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()
|
|
|
- self.doFadeOut()
|
|
|
-
|
|
|
- def updateConfig():
|
|
|
- pass
|
|
|
+#!/usr/bin/env python
|
|
|
+# -*- encoding: utf-8 -*-
|
|
|
+'''
|
|
|
+@Contact : liuyuqi.gov@msn.cn
|
|
|
+@Time : 2023/03/16 01:29:59
|
|
|
+@License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
|
|
|
+@Desc : base windows
|
|
|
+'''
|
|
|
+from PyQt5.QtWidgets import QMainWindow, QGraphicsDropShadowEffect
|
|
|
+from PyQt5.QtCore import Qt, QPropertyAnimation, QEasingCurve
|
|
|
+from PyQt5.QtGui import QColor
|
|
|
+
|
|
|
+class BaseWindow(QMainWindow):
|
|
|
+ '''主窗体'''
|
|
|
+
|
|
|
+ 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):
|
|
|
+ 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)
|