示例#1
0
 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()
         ui = Ui_FormMainWindow()
         ui.setupUi(self._UiMainWindow)
         # 修改名字防止受app的style影响
         ui.widgetMain.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'})
     elif which == self.Picture:
         ThemeManager.loadPictureTheme(poc, self._UiMainWindow,
                                       {'widgetMain': 'widgetMain1'})
     # 对隐藏窗口截图
     # 至于为什么要加延迟, 设置样式后可能UI还没刷新
     self._UiMainWindow.repaint()
     QTimer.singleShot(100, self._updatePixmap)
示例#2
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()
示例#3
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()
示例#4
0
 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)
     elif self._which == self.Picture:
         ThemeManager.loadPictureTheme(self._poc)
         Setting.setValue('colourful', None)
         Setting.setValue('picture', self._poc.replace('\\', '/'))
示例#5
0
 def setStyle(item):
     path = os.path.join('Resources/Images/Festival', item.text(), 'background.jpg')
     if os.path.isfile(path):
         ThemeManager.loadPictureTheme(path)