def setPixmap(self, which, poc):
     """设置图片
     :param which:        Theme = 0,Color = 1,Picture = 2
     :param poc:          color or path
     """
     self._which = which
     self._poc = poc
     if not hasattr(self, '_UiMainWindow'):
         # 创建一个隐藏的主界面
         self._UiMainWindow = QWidget()
         self.layout = QVBoxLayout(self._UiMainWindow)
         ui = Skin_MainLayout()
         self.layout.addWidget(ui)
         # 修改名字防止受app的style影响
         ui.setObjectName('widgetMain1')
         self._UiMainWindow.setAttribute(Qt.WA_TranslucentBackground, True)
         self._UiMainWindow.setWindowFlags(self.windowFlags()
                                           | Qt.FramelessWindowHint)
         self._UiMainWindow.hide()
     if which == self.Theme:
         self.labelPreviewImage.setPixmap(
             QPixmap(poc).scaledToWidth(400, Qt.SmoothTransformation))
         return
     elif which == self.Color:
         ThemeManager.loadColourfulTheme(poc, self._UiMainWindow,
                                         {'widgetMain': 'widgetMain1'})
     # 对隐藏窗口截图
     # 至于为什么要加延迟, 设置样式后可能UI还没刷新
     self._UiMainWindow.repaint()
     QTimer.singleShot(100, self._updatePixmap)
 def setStyle(item):
     path = os.path.join('Resources/Themes', item.text(), 'style.qss')
     if os.path.isfile(path):
         t = time()
         ThemeManager.loadUserTheme(item.text())
         print(time() - t)
         w.grab().save('Resources/Themes/{}/preview.png'.format(
             item.text()))
示例#3
0
 def setStyle(item):
     path = os.path.join('Resources/Themes', item.text(), 'style.qss')
     if os.path.isfile(path):
         t = time()
         ThemeManager.loadUserTheme(item.text())
         print(time() - t)
         path = 'Resources/Themes/{}/background.jpg'.format(item.text())
         if os.path.exists(path):
             print(ColorThief(path).get_color())
         w.grab().save('Resources/Themes/{}/preview.png'.format(
             item.text()))
示例#4
0
 def __init__(self, *args, **kwargs):
     super(IssuesDialog, self).__init__(*args, **kwargs)
     self.setupUi(self)
     # 关闭后自动销毁
     self.setAttribute(Qt.WA_DeleteOnClose, True)
     # 背景透明
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 无边框
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     # 加载鼠标样式
     ThemeManager.loadCursor(self)
示例#5
0
 def __init__(self, message, *args, reqfile='', **kwargs):
     super(ErrorDialog, self).__init__(*args, **kwargs)
     self.reqfile = reqfile
     self.setupUi(self)
     # 关闭后自动销毁
     self.setAttribute(Qt.WA_DeleteOnClose, True)
     # 背景透明
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 无边框
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     # 加载鼠标样式
     ThemeManager.loadCursor(self)
     self.plainTextEditDetail.appendPlainText(message)
示例#6
0
 def __init__(self, *args, **kwargs):
     super(UpdateDialog, self).__init__(*args, **kwargs)
     self.setupUi(self)
     # 关闭后自动销毁
     self.setAttribute(Qt.WA_DeleteOnClose, True)
     # 背景透明
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 无边框
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     # 加载鼠标样式
     ThemeManager.loadCursor(self)
     Signals.updateTextChanged.connect(self.onUpdateTextChanged)
     Signals.updateProgressChanged.connect(self.onUpdateProgressChanged)
     Signals.updateFinished.connect(self.labelMessage.setText)
示例#7
0
    def _initUi(self):
        """初始UI"""
        self.setupUi(self)

        # 隐藏还原按钮
        self.buttonNormal.setVisible(False)
        # 加载鼠标样式
        ThemeManager.loadCursor(self.widgetMain)
        ThemeManager.setPointerCursors([
            self.buttonHead,  # 主界面头像
            self.buttonGithub,  # Github按钮
            self.buttonQQ,  # QQ按钮
            self.buttonGroup,  # 群按钮
            self.buttonBackToUp,  # 返回顶部按钮
            self.buttonHome  # 显示主页readme
        ])
        # 安装事件过滤器用于还原鼠标样式
        self.widgetMain.installEventFilter(self)
        # 绑定返回顶部提示框
        ToolTip.bind(self.buttonBackToUp)
        ToolTip.bind(self.buttonHome)
        # 头像提示控件
        ToolTip.bind(self.buttonHead)
        # 加载主题
        colourful = Setting.value('colourful')
        picture = Setting.value('picture', 'Resources/Images/Wallpaper/t014d05b7c3e1708b2d.jpg', str)
        AppLog.debug('colourful: %s', str(colourful))
        AppLog.debug('picture: %s', picture)
        if picture:
            ThemeManager.loadFont()
            ThemeManager.loadPictureTheme(picture)

        self._initMyMplCanvas()
 def on_buttonPreviewApply_clicked(self):
     """设置主题
     """
     if self._which == self.Theme:
         ThemeManager.loadUserTheme(
             os.path.basename(os.path.dirname(self._poc)))
         Setting.setValue('picture', None)
         Setting.setValue('colourful', None)
     elif self._which == self.Color:
         ThemeManager.loadColourfulTheme(self._poc)
         if isinstance(self._poc, QColor):
             Setting.setValue('colourful', self._poc)
         else:
             # 渐变需要转成字典数据
             Setting.setValue('colourful', GradientUtils.toJson(self._poc))
         Setting.setValue('picture', None)
示例#9
0
 def __init__(self, *args, **kwargs):
     super(SkinDialog, self).__init__(*args, **kwargs)
     self.setupUi(self)
     # 背景透明
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 无边框
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     self.widgetBottom.setVisible(False)
     # 预览界面
     self.previewWidget = PreviewWidget(self.widgetSkinBg)
     self.previewWidget.setVisible(False)
     # 初始化信号槽
     self._initSignals()
     # 加载鼠标样式
     ThemeManager.loadCursor(self)
     self.on_tabWidgetSkinMain_currentChanged(0)
示例#10
0
 def onColourfulItemAddFinished(self):
     """添加完成
     """
     return
     # 添加一个+按钮
     self.buttonAdd = QPushButton('+',
                                  self,
                                  objectName='buttonAdd',
                                  clicked=self.onAddNewColor)
     # 加载鼠标样式
     ThemeManager.loadCursor(self.buttonAdd, ThemeManager.CursorPointer)
     if self.lastCol == 4:
         self.lastCol = 0
         self.lastRow += 1
     else:
         self.lastCol += 1
     self.gridLayout.addWidget(self.buttonAdd, self.lastRow, self.lastCol)
示例#11
0
 def _initStyle(self):
     colourful = Setting.value('colourful')
     if colourful:
         ThemeManager.loadFont()
         if isinstance(colourful, QColor):
             ThemeManager.loadColourfulTheme(colourful)
         else:
             # json数据转渐变
             ThemeManager.loadColourfulTheme(
                 GradientUtils.toGradient(colourful))
     else:
         ThemeManager.loadTheme()
 def __init__(self, *args, **kwargs):
     super(Skin_MainLayout, self).__init__(*args, **kwargs)
     self.setAttribute(Qt.WA_StyledBackground, True)
     self._initLocalLanguage()
     self.setupUi(self)
     self.constants = Constants()
     self.font = ThemeManager.font()
     self._initUi()
     self._initIndex()
     self._initStyle()
示例#13
0
 def __init__(self, name, colorimg, signal, *args, **kwargs):
     super(SkinBaseItemWidget, self).__init__(*args, **kwargs)
     self.setObjectName('skinBaseItemWidget')
     # 加载鼠标样式
     ThemeManager.loadCursor(self, ThemeManager.CursorPointer)
     self.name = name
     self.colorimg = colorimg
     self.hovered = False
     self.signal = signal
     self.colorHover = QColor(0, 0, 0, 40)
     self._textHoverColor = QColor(18, 183, 245)
     self.textColor = QColor(102, 102, 102)
     self.image = None
     # 图片
     if isinstance(self.colorimg, str) and os.path.isfile(self.colorimg):
         self.image = QPixmap(self.colorimg).scaled(PixmapWidth,
                                                    PixmapHeight,
                                                    Qt.IgnoreAspectRatio,
                                                    Qt.SmoothTransformation)
示例#14
0
 def __init__(self, *args, **kwargs):
     super(LoginDialog, self).__init__(*args, **kwargs)
     self.setupUi(self)
     # 设置闪烁的目标控件
     self.setTarget(self.widgetLogin)
     # 关闭后自动销毁
     self.setAttribute(Qt.WA_DeleteOnClose, True)
     # 背景透明
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 无边框
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     # 加载鼠标样式
     ThemeManager.loadCursor(self)
     # 加载鼠标样式
     ThemeManager.loadCursor(self.buttonHead, ThemeManager.CursorPointer)
     # 是否正在登录
     self._isLogin = False
     Signals.loginErrored.connect(self.onLoginErrored)
     Signals.loginSuccessed.connect(self.onLoginSuccessed)
     QTimer.singleShot(100, self.initAccount)
示例#15
0
 def __init__(self, *args, **kwargs):
     super(PreviewWidget, self).__init__(*args, **kwargs)
     self.setupUi(self)
     self.setAttribute(Qt.WA_StyledBackground, True)  # 支持样式
     # 图片边缘阴影效果
     effect = QGraphicsDropShadowEffect(self.labelPreviewImage)
     effect.setBlurRadius(40)
     effect.setOffset(0, 0)
     effect.setColor(Qt.gray)
     self.labelPreviewImage.setGraphicsEffect(effect)
     # 鼠标样式
     ThemeManager.loadCursor(self, ThemeManager.CursorDefault)
     ThemeManager.loadCursor(self.buttonPreviewApply,
                             ThemeManager.CursorPointer)
     ThemeManager.loadCursor(self.buttonPreviewClose,
                             ThemeManager.CursorPointer)
     ThemeManager.loadCursor(self.buttonPreviewNext,
                             ThemeManager.CursorPointer)
     ThemeManager.loadCursor(self.buttonPreviewPrevious,
                             ThemeManager.CursorPointer)
示例#16
0
 def _initUi(self):
     """初始UI"""
     self.setupUi(self)
     # 隐藏还原按钮
     self.buttonNormal.setVisible(False)
     # 隐藏目录树的滑动条
     self.treeViewCatalogs.verticalScrollBar().setVisible(False)
     # 加载主题
     ThemeManager.loadTheme()
     # 加载鼠标样式
     ThemeManager.loadCursor(self.widgetMain)
     ThemeManager.setPointerCursors([
         self.buttonHead,  # 主界面头像
         self.buttonSearch,  # 主界面搜索按钮
         self.buttonGithub,  # Github按钮
         self.buttonQQ,  # QQ按钮
         self.buttonGroup,  # 群按钮
         self.buttonBackToUp,  # 返回顶部按钮
         self.buttonHome  # 显示主页readme
     ])
     # 安装事件过滤器用于还原鼠标样式
     self.widgetMain.installEventFilter(self)
     # 绑定返回顶部提示框
     ToolTip.bind(self.buttonBackToUp)
     ToolTip.bind(self.buttonHome)
     # 头像提示控件
     ToolTip.bind(self.buttonHead)
示例#17
0
 def __init__(self, *args, **kwargs):
     super(PreviewWidget, self).__init__(*args, **kwargs)
     self.setupUi(self)
     self.setAttribute(Qt.WA_StyledBackground, True)  # 支持样式
     # 图片边缘阴影效果
     effect = QGraphicsDropShadowEffect(self.labelPreviewImage)
     effect.setBlurRadius(40)
     effect.setOffset(0, 0)
     effect.setColor(Qt.gray)
     self.labelPreviewImage.setGraphicsEffect(effect)
     self.font = ThemeManager.font()
     self.buttonPreviewClose.setText('\uf00d')
     self.buttonPreviewClose.setFont(self.font)
示例#18
0
 def __init__(self, *args, **kwargs):
     super(Window, self).__init__(*args, **kwargs)
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     self.setupUi(self)
     t = time()
     ThemeManager.loadTheme()
     print(time() - t)
     ThemeManager.loadCursor(self)
     ThemeManager.loadCursor(self.buttonHead, ThemeManager.CursorPointer)
示例#19
0
 def __init__(self, *args, **kwargs):
     super(SkinDialog, self).__init__(*args, **kwargs)
     self.setupUi(self)
     # 背景透明
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 无边框
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     self.widgetBottom.setVisible(False)
     # 预览界面
     self.previewWidget = PreviewWidget(self.widgetSkinBg)
     self.previewWidget.setVisible(False)
     # 初始化信号槽
     self._initSignals()
     self.on_tabWidgetSkinMain_currentChanged(0)
     self.font = ThemeManager.font()
     self.buttonClose.setText('\uf00d')
     self.buttonClose.setFont(self.font)
     self.tabPicture.hide()
     self.tabTheme.hide()
示例#20
0
 def __init__(self, *args, **kwargs):
     super(Window, self).__init__(*args, **kwargs)
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     self.setupUi(self)
     self.buttonClose.clicked.connect(self.close)
     self.buttonMaximum.clicked.connect(self.showMaximized)
     self.buttonMinimum.clicked.connect(self.showMinimized)
     self.buttonNormal.clicked.connect(self.showNormal)
     t = time()
     ThemeManager.loadTheme()
     print(time() - t)
     ThemeManager.loadCursor(self)
     ThemeManager.loadCursor(self.buttonHead, ThemeManager.CursorPointer)
示例#21
0
 def __init__(self, alipayImg, wechatImg, *args, **kwargs):
     super(DonateDialog, self).__init__(*args, **kwargs)
     self.setupUi(self)
     # 关闭后自动销毁
     self.setAttribute(Qt.WA_DeleteOnClose, True)
     # 背景透明
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 无边框
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
     # 加载鼠标样式
     ThemeManager.loadCursor(self)
     # 加载鼠标样式
     ThemeManager.loadCursor(self.labelAlipayImg)
     ThemeManager.loadCursor(self.labelWechatImg, 'pointer.png')
     # 加载图片
     self.labelAlipayImg.setPixmap(
         QPixmap(alipayImg).scaled(300, 300, Qt.IgnoreAspectRatio,
                                   Qt.SmoothTransformation))
     self.labelWechatImg.setPixmap(
         QPixmap(wechatImg).scaled(300, 300, Qt.IgnoreAspectRatio,
                                   Qt.SmoothTransformation))
示例#22
0
 def _initUi(self):
     """初始UI"""
     self.setupUi(self)
     # 隐藏还原按钮
     self.buttonNormal.setVisible(False)
     # 隐藏目录树的滑动条
     self.treeViewCatalogs.verticalScrollBar().setVisible(False)
     # 加载鼠标样式
     ThemeManager.loadCursor(self.widgetMain)
     ThemeManager.setPointerCursors([
         self.buttonHead,            # 主界面头像
         self.buttonClear,           # 主界面清空按钮
         self.buttonGithub,          # Github按钮
         self.buttonQQ,              # QQ按钮
         self.buttonGroup,           # 群按钮
         self.buttonBackToUp,        # 返回顶部按钮
         self.buttonHome             # 显示主页readme
     ])
     # 安装事件过滤器用于还原鼠标样式
     self.widgetMain.installEventFilter(self)
     # 绑定返回顶部提示框
     ToolTip.bind(self.buttonBackToUp)
     ToolTip.bind(self.buttonHome)
     # 头像提示控件
     ToolTip.bind(self.buttonHead)
     # 加载主题
     colourful = Setting.value('colourful')
     picture = Setting.value('picture', '', str)
     AppLog.debug('colourful: %s', str(colourful))
     AppLog.debug('picture: %s', picture)
     if picture:
         ThemeManager.loadFont()
         ThemeManager.loadPictureTheme(picture)
     elif colourful:
         ThemeManager.loadFont()
         if isinstance(picture, QColor):
             ThemeManager.loadColourfulTheme(colourful)
         else:
             # json数据转渐变
             ThemeManager.loadColourfulTheme(
                 GradientUtils.toGradient(colourful))
     else:
         ThemeManager.loadTheme()
示例#23
0
@site: https://pyqt5.com https://github.com/892768447
@email: [email protected]
@file: Test.TestPreviewWidget
@description: 
"""
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap

from Utils.ThemeManager import ThemeManager
from Widgets.Skins.PreviewWidget import PreviewWidget

__Author__ = 'Irony'
__Copyright__ = 'Copyright (c) 2019'

if __name__ == '__main__':
    import sys
    import os
    import cgitb
    os.chdir('../')
    sys.excepthook = cgitb.enable(1, None, 5, '')
    from PyQt5.QtWidgets import QApplication
    app = QApplication(sys.argv)
    ThemeManager.loadTheme()
    w = PreviewWidget()
    w.show()
    w.setTitle('Test')
    w.setPixmap(
        QPixmap('Resources/Themes/Default/preview.png').scaledToWidth(
            400, Qt.SmoothTransformation))
    sys.exit(app.exec_())
示例#24
0
 def setStyle(item):
     path = os.path.join('Resources/Images/Festival', item.text(), 'background.jpg')
     if os.path.isfile(path):
         ThemeManager.loadPictureTheme(path)