Ejemplo n.º 1
0
    def initUI(self):
        '''自定义标题栏'''
        parent = self.parent() or self.parentWidget() or self
        self._titleBar = TitleWidget(parent=self)
        self._titleBar.minimized.connect(parent.showMinimized)
        self._titleBar.maximized.connect(parent.showMaximized)
        self._titleBar.normaled.connect(parent.showNormal)
        self._titleBar.closed.connect(self.exited.emit)
        self._titleBar.setMaximumHeight(40)
        '''自定义菜单栏'''
        self._menuBar = MenuWidget(parent=self)
        self._menuBar.setMaximumHeight(80)

        #首页面板
        self._indexPanel = IndexWidget(parent=self)
        #中间内容布局
        #self._webBar=OAuthWindow(self)
        #总体布局,采用垂直布局
        layout = QVBoxLayout(self, spacing=0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._titleBar)
        layout.addWidget(self._menuBar)
        #layout.addWidget(self._webBar)
        layout.addWidget(self._indexPanel)
        self.setLayout(layout)
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super(SkinWidget, self).__init__(*args, **kwargs)
        layout = QVBoxLayout(self, spacing=0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.titleWidget = TitleWidget(True,
                                       True,
                                       False,
                                       False,
                                       False,
                                       False,
                                       True,
                                       parent=self)
        self.titleWidget.closed.connect(self.close)
        layout.addWidget(self.titleWidget)
        scrollWidget = QScrollArea(self)
        layout.addWidget(scrollWidget)

        scrollWidget.setFrameShape(QScrollArea.NoFrame)
        scrollWidget.setWidgetResizable(True)
        scrollWidget.setAlignment(Qt.AlignCenter)
        scrollWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scrollWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        # 网格窗口
        self._widget = GridWidget(scrollWidget)
        scrollWidget.setWidget(self._widget)
        self._widget.itemClicked.connect(self.onItemClicked)
        self._widget.init("themes")
        # 预览
        self.previewWidget = PreviewWidget(self, visible=False)
Ejemplo n.º 3
0
class SkinWidget(FramelessWindow):
    '''主题窗口'''

    TITLE_WIDTH = 36

    def __init__(self, *args, **kwargs):
        super(SkinWidget, self).__init__(*args, **kwargs)
        layout = QVBoxLayout(self, spacing=0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.titleWidget = TitleWidget(True,
                                       True,
                                       False,
                                       False,
                                       False,
                                       False,
                                       True,
                                       parent=self)
        self.titleWidget.closed.connect(self.close)
        layout.addWidget(self.titleWidget)
        scrollWidget = QScrollArea(self)
        layout.addWidget(scrollWidget)

        scrollWidget.setFrameShape(QScrollArea.NoFrame)
        scrollWidget.setWidgetResizable(True)
        scrollWidget.setAlignment(Qt.AlignCenter)
        scrollWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scrollWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        # 网格窗口
        self._widget = GridWidget(scrollWidget)
        scrollWidget.setWidget(self._widget)
        self._widget.itemClicked.connect(self.onItemClicked)
        self._widget.init("themes")
        # 预览
        self.previewWidget = PreviewWidget(self, visible=False)

    def onItemClicked(self, title, path, image):
        if os.path.isfile(image):
            self.resizePreviewWidget()
            self.previewWidget.init(title, path, image)
            self.previewWidget.setVisible(True)

    def resizeEvent(self, event):
        super(SkinWidget, self).resizeEvent(event)
        self.resizePreviewWidget()

    def resizePreviewWidget(self):
        geometry = self.titleWidget.geometry()
        self.previewWidget.setGeometry(
            geometry.x(),
            geometry.y() + self.titleWidget.height(),
            self.width() - 2 * geometry.x(),
            self.height() - 2 * geometry.y() - self.titleWidget.height())
Ejemplo n.º 4
0
 def _initView(self):
     '''标题栏'''
     parent = self.parent() or self.parentWidget() or self
     self._titleBar = TitleWidget(parent=self)
     self._titleBar.minimized.connect(parent.showMinimized)
     self._titleBar.maximized.connect(parent.showMaximized)
     self._titleBar.normaled.connect(parent.showNormal)
     self._titleBar.closed.connect(self.onClose)
     '''左侧菜单栏和右侧内容栏'''
     cLayout = QHBoxLayout()
     self._menuWidget = MenuWidget(self)
     self._linkWidget = LinkWidget(self)
     self._contentWidget = ContentWidget(self)
     cLayout.addWidget(self._menuWidget)
     cLayout.addWidget(self._linkWidget)
     cLayout.addWidget(self._contentWidget)
     # 总体布局
     layout = QVBoxLayout(self, spacing=0)
     layout.setContentsMargins(0, 0, 0, 0)
     layout.addWidget(self._titleBar)
     layout.addLayout(cLayout)
Ejemplo n.º 5
0
class MainWidget(QWidget):
    showed = pyqtSignal()
    closed = pyqtSignal()
    exited = pyqtSignal()

    def __init__(self, *args, **kwargs):
        super(MainWidget, self).__init__(*args, **kwargs)
        self.resize(800, 600)
        #QSS
        self.setAttribute(Qt.WA_StyledBackground, True)
        self.initUI()

    def initUI(self):
        '''自定义标题栏'''
        parent = self.parent() or self.parentWidget() or self
        self._titleBar = TitleWidget(parent=self)
        self._titleBar.minimized.connect(parent.showMinimized)
        self._titleBar.maximized.connect(parent.showMaximized)
        self._titleBar.normaled.connect(parent.showNormal)
        self._titleBar.closed.connect(self.exited.emit)
        self._titleBar.setMaximumHeight(40)
        '''自定义菜单栏'''
        self._menuBar = MenuWidget(parent=self)
        self._menuBar.setMaximumHeight(80)

        #首页面板
        self._indexPanel = IndexWidget(parent=self)
        #中间内容布局
        #self._webBar=OAuthWindow(self)
        #总体布局,采用垂直布局
        layout = QVBoxLayout(self, spacing=0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._titleBar)
        layout.addWidget(self._menuBar)
        #layout.addWidget(self._webBar)
        layout.addWidget(self._indexPanel)
        self.setLayout(layout)
Ejemplo n.º 6
0
class MainWidget(QWidget):

    showed = pyqtSignal()
    closed = pyqtSignal()
    exited = pyqtSignal()

    def __init__(self, *args, **kwargs):
        super(MainWidget, self).__init__(*args, **kwargs)
        self.resize(800, 600)
        # 保证qss有效
        self.setAttribute(Qt.WA_StyledBackground, True)
        # 左侧菜单栏和右侧内容栏
        self._initView()

    def showEvent(self, event):
        super(MainWidget, self).showEvent(event)
        # 动画效果
        self._initAnimations()

    def resizeEvent(self, event):
        super(MainWidget, self).resizeEvent(event)
        if not hasattr(self, "_animationGroupShow"):
            return
        self._initAnimationsValues()

    def onClose(self):
        self._animationGroup.stop()
        self._initAnimationsValues(False)
        self._animationGroup.finished.connect(self.exited.emit)
        self._animationGroup.start()

    def showNormalBtn(self, visible):
        self._titleBar.showNormalBtn(visible)

    def _initView(self):
        '''标题栏'''
        parent = self.parent() or self.parentWidget() or self
        self._titleBar = TitleWidget(parent=self)
        self._titleBar.minimized.connect(parent.showMinimized)
        self._titleBar.maximized.connect(parent.showMaximized)
        self._titleBar.normaled.connect(parent.showNormal)
        self._titleBar.closed.connect(self.onClose)
        '''左侧菜单栏和右侧内容栏'''
        cLayout = QHBoxLayout()
        self._menuWidget = MenuWidget(self)
        self._linkWidget = LinkWidget(self)
        self._contentWidget = ContentWidget(self)
        cLayout.addWidget(self._menuWidget)
        cLayout.addWidget(self._linkWidget)
        cLayout.addWidget(self._contentWidget)
        # 总体布局
        layout = QVBoxLayout(self, spacing=0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._titleBar)
        layout.addLayout(cLayout)

    def _initAnimations(self):
        '''动画效果'''
        if hasattr(self, "_animationGroup"):
            return  # 由于showEvent的关系,这里要防止多次实例化
        self._animationGroup = QParallelAnimationGroup(self)  # 并行动画
        # 标题栏
        self._animationTitleBar = QPropertyAnimation(
            self._titleBar, b"geometry", self, easingCurve=QEasingCurve.OutBounce, duration=1000)
        # 菜单栏
        self._animationMenuWidget = QPropertyAnimation(
            self._menuWidget, b"geometry", self, easingCurve=QEasingCurve.OutBounce, duration=1000)
        # 链接
        self._animationLinkWidget = QPropertyAnimation(
            self._linkWidget, b"geometry", self, easingCurve=QEasingCurve.OutBounce, duration=1000)
        # 内容
        self._animationContentWidget = QPropertyAnimation(
            self._contentWidget, b"geometry", self, easingCurve=QEasingCurve.OutBounce, duration=1000)
        # add to group
        self._animationGroup.addAnimation(self._animationTitleBar)
        self._animationGroup.addAnimation(self._animationMenuWidget)
        self._animationGroup.addAnimation(self._animationLinkWidget)
        self._animationGroup.addAnimation(self._animationContentWidget)
        # 初始化位置
        self._initAnimationsValues(True)
        # 启动动画效果
        self._animationGroup.start()

    def _initAnimationsValues(self, show=True):
        # 标题栏
        startValue = QRect(self.width(), 0, self._titleBar.width(),
                           self._titleBar.height())
        endValue = QRect(0, 0, self._titleBar.width(),
                         self._titleBar.height())
        self._animationTitleBar.setStartValue(startValue if show else endValue)
        self._animationTitleBar.setEndValue(endValue if show else startValue)

        # 菜单栏
        startValue = QRect(-self._menuWidget.width(), self._titleBar.height(),
                           self._menuWidget.width(), self._menuWidget.height())
        endValue = QRect(0, self._titleBar.height(),
                         self._menuWidget.width(), self._menuWidget.height())
        self._animationMenuWidget.setStartValue(
            startValue if show else endValue)
        self._animationMenuWidget.setEndValue(endValue if show else startValue)

        # 链接
        startValue = QRect(self._menuWidget.width(
        ), -self.height(), self._linkWidget.width(), self._linkWidget.height())
        endValue = QRect(
            self._menuWidget.width(), self._titleBar.height(),
            self._linkWidget.width(), self._linkWidget.height())
        self._animationLinkWidget.setStartValue(
            startValue if show else endValue)
        self._animationLinkWidget.setEndValue(endValue if show else startValue)

        # 内容
        startValue = QRect(self.width(), self.height(), self._contentWidget.width(),
                           self._contentWidget.height())
        endValue = QRect(
            self._menuWidget.width() + self._linkWidget.width(),
            self._titleBar.height(), self._contentWidget.width(),
            self._contentWidget.height())
        self._animationContentWidget.setStartValue(
            startValue if show else endValue)
        self._animationContentWidget.setEndValue(
            endValue if show else startValue)