Ejemplo n.º 1
0
class LoginBox(QDialog):

    def __init__(self, parent=None):
        super(LoginBox, self).__init__()
        self.parent = parent
        
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setWindowTitle('登陆')
        self.setObjectName('LoginBox')

        self.resize(520, 300)

        # 可能会有多个渠道登陆的后续扩展。
        self.currentFrame = 0

        self.mainLayout = VBoxLayout(self)

        self.phoneAndEMailFrame = PhoneAndEMailFrame(self)

        self.mainLayout.addWidget(self.phoneAndEMailFrame)

    def setWarningAndShowIt(self, warningStr):
        if not self.currentFrame:
            self.phoneAndEMailFrame.setWarningAndShowIt(warningStr)

    def connectLogin(self, functionName):
        if not self.currentFrame:
            self.phoneAndEMailFrame.connectLogin(functionName)
    
    def checkAndGetLoginInformation(self):
        if not self.currentFrame:
            return self.phoneAndEMailFrame.checkAndGetLoginInformation()            
    def __init__(self, parent):
        super(NetEaseSearchResultFrame, self).__init__()
        self.parent = parent

        # self.singsFrame = QFrame()
        self.singsFrameLayout = VBoxLayout(self)

        self.noSingsContentsLabel = QLabel(self)
        self.noSingsContentsLabel.setMaximumHeight(60)

        self.noSingsContentsLabel.setObjectName("noSingsLable")
        self.noSingsContentsLabel.hide()

        self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长'])
        self.singsResultTable.setObjectName('singsTable')
        self.singsResultTable.setMinimumWidth(self.parent.width())
        self.singsResultTable.setColumnWidths({
            i: j
            for i, j in zip(range(3), [
                self.parent.width() / 3 * 1.25,
                self.parent.width() / 3 * 1.25,
                self.parent.width() / 3 * 0.5
            ])
        })

        self.singsFrameLayout.addWidget(self.singsResultTable,
                                        Qt.AlignTop | Qt.AlignCenter)

        self.centerLabelLayout = HBoxLayout()
        self.centerLabelLayout.addStretch(1)
        self.centerLabelLayout.addWidget(self.noSingsContentsLabel)
        self.centerLabelLayout.addStretch(1)

        self.singsFrameLayout.addLayout(self.centerLabelLayout)
Ejemplo n.º 3
0
    def setSingsFrame(self):
        # 单曲界面。
        self.singsFrame = QFrame()
        self.singsFrameLayout = VBoxLayout(self.singsFrame)

        self.noSingsContentsLabel = QLabel(self.singsFrame)
        self.noSingsContentsLabel.setMaximumHeight(60)

        self.noSingsContentsLabel.setObjectName("noSingsLable")
        self.noSingsContentsLabel.hide()

        self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长'])
        self.singsResultTable.setObjectName('singsTable')
        self.singsResultTable.setMinimumWidth(self.width())
        self.singsResultTable.setColumnWidths({
            i: j
            for i, j in zip(range(3), [
                self.width() / 3 * 1.25,
                self.width() / 3 * 1.25,
                self.width() / 3 * 0.5
            ])
        })

        self.singsFrameLayout.addWidget(self.singsResultTable,
                                        Qt.AlignTop | Qt.AlignCenter)

        self.centerLabelLayout = HBoxLayout()
        self.centerLabelLayout.addStretch(1)
        self.centerLabelLayout.addWidget(self.noSingsContentsLabel)
        self.centerLabelLayout.addStretch(1)

        self.singsFrameLayout.addLayout(self.centerLabelLayout)

        self.contentsTab.addTab(self.singsFrame, "单曲")
Ejemplo n.º 4
0
class LoginBox(QDialog):
    def __init__(self, parent=None):
        super(LoginBox, self).__init__()
        self.parent = parent

        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setWindowTitle('登陆')
        self.setObjectName('LoginBox')

        self.resize(520, 300)

        # 可能会有多个渠道登陆的后续扩展。
        self.currentFrame = 0

        self.mainLayout = VBoxLayout(self)

        self.phoneAndEMailFrame = PhoneAndEMailFrame(self)

        self.mainLayout.addWidget(self.phoneAndEMailFrame)

    def setWarningAndShowIt(self, warningStr):
        if not self.currentFrame:
            self.phoneAndEMailFrame.setWarningAndShowIt(warningStr)

    def connectLogin(self, functionName):
        if not self.currentFrame:
            self.phoneAndEMailFrame.connectLogin(functionName)

    def checkAndGetLoginInformation(self):
        if not self.currentFrame:
            return self.phoneAndEMailFrame.checkAndGetLoginInformation()
Ejemplo n.º 5
0
class SingsSearchResultFrameBase(QFrame):

    def __init__(self, parent):
        super(SingsSearchResultFrameBase, self).__init__()
        self.parent = parent

        self.singsFrameLayout = VBoxLayout(self)

        self.noSingsContentsLabel = QLabel(self)
        self.noSingsContentsLabel.setMaximumHeight(60)

        self.noSingsContentsLabel.setObjectName("noSingsLable")
        self.noSingsContentsLabel.hide()

        self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长'])
        self.singsResultTable.setObjectName('singsTable')
        self.singsResultTable.setMinimumWidth(self.parent.width())
        self.singsResultTable.setColumnWidths({i:j for i,j in zip(range(3), 
            [self.parent.width()/3*1.25,self.parent.width()/3*1.25,self.parent.width()/3*0.5])})

        self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop|Qt.AlignCenter)

        self.centerLabelLayout = HBoxLayout()
        self.centerLabelLayout.addStretch(1)
        self.centerLabelLayout.addWidget(self.noSingsContentsLabel)
        self.centerLabelLayout.addStretch(1)

        self.singsFrameLayout.addLayout(self.centerLabelLayout)
Ejemplo n.º 6
0
    def __init__(self, parent):
        super(CurrentMusicDetail, self).__init__()
        # with open('QSS/currentMusic.qss', 'r', encoding='utf-8') as f:
        #     self.setStyleSheet(f.read())

        self.setObjectName('detail')
        self.hide()

        self.mainLayout = VBoxLayout(self.frame)
        self.topLayout = HBoxLayout()
        self.topMainLayout = VBoxLayout()
        self.topHeaderLayout = HBoxLayout()

        # 为歌词创建索引方便删除。
        self.allLyrics = []

        # self.detailText = QTextEdit()
        # self.detailText.setObjectName('detailText')
        # self.detailText.setReadOnly(True)

        self.titleLabel = QLabel("✧✧✧")
        self.titleLabel.setObjectName('titleLabel')

        self.recoveryButton = QPushButton()
        self.recoveryButton.setObjectName('recoveryButton')
        self.recoveryButton.setMinimumSize(24, 24)
        self.recoveryButton.setMaximumSize(36, 36)

        self.setLayouts()
Ejemplo n.º 7
0
    def __init__(self, parent=None):
        super(PhoneAndEMailFrame, self).__init__()
        self.parent = parent
        self.resize(520, 300)
        with open('QSS/phoneAndEMailFrame.qss', 'r') as f:

            self.setStyleSheet(f.read())

        self.mainLayout = VBoxLayout(self)

        self.header = Header("用户名", self)
        self.header.setMinimumHeight(40)
        self.header.connectCloseButton(self.parent.accept)
        self.mainLayout.addWidget(self.header)

        self.mainLayout.addStretch(1)

        self.usernameLine = InputLine(self, 220, 32, '请输入用户名')
        self.usernameLine.setObjectName('usernameLine')
        self.usernameCenterBox = HStretchBox(self.mainLayout,
                                             self.usernameLine)

        self.mainLayout.addSpacing(10)

        self.passwordLine = InputLine(self, 220, 32, '请输入密码')
        self.passwordLine.setObjectName('passwordLine')
        self.passwordCenterBox = HStretchBox(self.mainLayout,
                                             self.passwordLine)
        self.passwordLine.setEchoMode(QLineEdit.Password)

        self.warningIconLabel = QLabel()
        self.warningIconLabel.setObjectName('warningIconLabel')
        self.warningIconLabel.setMaximumSize(14, 14)
        self.warningIconLabel.setMinimumSize(14, 14)
        self.warningIconLabel.hide()
        self.warningLabel = QLabel("请输入用户名")
        self.warningLabel.hide()
        self.warningLabel.setObjectName('warningLabel')

        self.warningCenterBox = HStretchBox(self.mainLayout,
                                            self.warningIconLabel,
                                            self.warningLabel,
                                            behindStretch=2)

        self.mainLayout.addSpacing(30)

        self.enterLoginButton = QPushButton("登 录")
        self.enterLoginButton.setObjectName("enterButton")
        self.enterLoginButton.setMaximumSize(217, 27)
        self.enterLoginButton.setMinimumSize(217, 27)
        self.enterLoginCenterBox = HStretchBox(self.mainLayout,
                                               self.enterLoginButton)

        self.mainLayout.addSpacing(30)

        self.mainLayout.addStretch(1)
Ejemplo n.º 8
0
    def setLabels(self):
        self.musicName = QLabel(self)
        self.musicName.adjustSize()
        self.musicAuthor = QLabel(self)

        self.musicPic = PicLabel('resource/no_music.png', 64, 64)
        self.musicPic.setObjectName("musicPic")

        self.musicMask = PicLabel('resource/expand.png', 64, 64)
        self.musicMask.hide()
        # 设置背景透明。
        self.musicMask.setStyleSheet('QLabel {background-color: rgba(0, 0, 0, 50%;)}')

        # 遮罩层属于musicPic, 用布局简单弄一下即可。
        self.musicLayout = VBoxLayout(self.musicPic)
        self.musicLayout.addWidget(self.musicMask)
Ejemplo n.º 9
0
    def __init__(self, parent=None):
        super(LoginBox, self).__init__()
        self.parent = parent

        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setWindowTitle('登陆')
        self.setObjectName('LoginBox')

        self.resize(520, 300)

        # 可能会有多个渠道登陆的后续扩展。
        self.currentFrame = 0

        self.mainLayout = VBoxLayout(self)

        self.phoneAndEMailFrame = PhoneAndEMailFrame(self)

        self.mainLayout.addWidget(self.phoneAndEMailFrame)
Ejemplo n.º 10
0
    def setLayouts(self):
        """定义布局。"""
        self.mainLayout = VBoxLayout(self.frame)
        self.mainLayout.addSpacing(10)
        self.mainLayout.addWidget(self.recommendLabel)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.navigationList)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addWidget(self.myMusic)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.nativeList)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addWidget(self.singsListLabel)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addStretch(1)

        self.setContentsMargins(0, 0, 0, 0)
Ejemplo n.º 11
0
    def __init__(self, parent):
        super(CurrentMusicDetail, self).__init__()

        self.setObjectName('detail')
        self.hide()

        self.mainLayout = VBoxLayout(self.frame)
        self.topLayout = HBoxLayout()
        self.topMainLayout = VBoxLayout()
        self.topHeaderLayout = HBoxLayout()

        self.lyricFrames = ScrollArea()
        self.lyricFrames.setObjectName('lyricScroll')
        self.lyricFrames.frame.setObjectName('lyricFrame')
        self.lyricFramesLayout = VBoxLayout(self.lyricFrames.frame)
        # self.lyricFrames.setMaximumHeight(500)
        # 为歌词创建索引方便删除。
        self.allLyrics = []

        # self.detailText = QTextEdit()
        # self.detailText.setObjectName('detailText')
        # self.detailText.setReadOnly(True)

        self.titleLabel = QLabel("✧✧✧")
        self.titleLabel.setObjectName('titleLabel')

        self.recoveryButton = QPushButton()
        self.recoveryButton.setObjectName('recoveryButton')
        self.recoveryButton.setMinimumSize(24, 24)
        self.recoveryButton.setMaximumSize(36, 36)

        self.setLayouts()
Ejemplo n.º 12
0
    def __init__(self, parent=None):
        super(PhoneAndEMailFrame, self).__init__()
        self.parent = parent
        self.resize(520, 300)
        with open('QSS/phoneAndEMailFrame.qss', 'r') as f:

            self.setStyleSheet(f.read())

        self.mainLayout = VBoxLayout(self)

        self.header = Header("用户名", self)
        self.header.setMinimumHeight(40)
        self.header.connectCloseButton(self.parent.accept)
        self.mainLayout.addWidget(self.header)

        self.mainLayout.addStretch(1)

        self.usernameLine = InputLine(self, 220, 32, '请输入用户名')
        self.usernameLine.setObjectName('usernameLine')
        self.usernameCenterBox = HStretchBox(self.mainLayout, self.usernameLine)   
        
        self.mainLayout.addSpacing(10) 
        
        self.passwordLine = InputLine(self, 220, 32, '请输入密码')
        self.passwordLine.setObjectName('passwordLine')
        self.passwordCenterBox = HStretchBox(self.mainLayout, self.passwordLine)
        self.passwordLine.setEchoMode(QLineEdit.Password)

        self.warningIconLabel = QLabel()
        self.warningIconLabel.setObjectName('warningIconLabel')
        self.warningIconLabel.setMaximumSize(14, 14)
        self.warningIconLabel.setMinimumSize(14, 14)
        self.warningIconLabel.hide()
        self.warningLabel = QLabel("请输入用户名")
        self.warningLabel.hide()
        self.warningLabel.setObjectName('warningLabel')

        self.warningCenterBox = HStretchBox(self.mainLayout, self.warningIconLabel, self.warningLabel, 
            behindStretch=2)

        self.mainLayout.addSpacing(30) 

        self.enterLoginButton = QPushButton("登 录")
        self.enterLoginButton.setObjectName("enterButton")
        self.enterLoginButton.setMaximumSize(217, 27)
        self.enterLoginButton.setMinimumSize(217, 27)
        self.enterLoginCenterBox = HStretchBox(self.mainLayout, self.enterLoginButton)

        self.mainLayout.addSpacing(30)
        
        self.mainLayout.addStretch(1)
    def setLayouts(self):
        self.mainLayout = VBoxLayout()

        self.topLayout = HBoxLayout()

        self.descriptionLayout = VBoxLayout()
        self.titleLayout = HBoxLayout()
        self.titleLayout.addWidget(self.showButton)
        self.titleLayout.addSpacing(5)
        self.titleLayout.addWidget(self.titleLabel)

        self.authorLayout = HBoxLayout()
        self.authorLayout.addWidget(self.authorPic)
        self.authorLayout.addWidget(self.authorName)
        self.authorLayout.addStretch(1)

        self.descriptLayout = HBoxLayout()
        self.descriptLayout.addWidget(self.descriptionButton)
        self.descriptLayout.addWidget(self.descriptionText)

        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addLayout(self.titleLayout)
        self.descriptionLayout.addLayout(self.authorLayout)
        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addWidget(self.playAllButton)
        self.descriptionLayout.addSpacing(10)
        self.descriptionLayout.addLayout(self.descriptLayout)

        # self.descriptionLayout.setSpacing(0)

        self.topLayout.addWidget(self.picLabel)
        self.topLayout.addSpacing(18)
        self.topLayout.addLayout(self.descriptionLayout)

        self.mainLayout.addLayout(self.topLayout)
        self.mainLayout.addWidget(self.contentsTab)

        self.frame.setLayout(self.mainLayout)
Ejemplo n.º 14
0
    def setLayouts(self):
        self.mainLayout = VBoxLayout()

        self.topLayout = HBoxLayout()

        self.descriptionLayout = VBoxLayout()
        self.titleLayout = HBoxLayout()
        self.titleLayout.addWidget(self.showButton)
        self.titleLayout.addSpacing(5)
        self.titleLayout.addWidget(self.titleLabel)

        self.authorLayout = HBoxLayout()
        self.authorLayout.addWidget(self.authorPic)
        self.authorLayout.addWidget(self.authorName)
        self.authorLayout.addStretch(1)

        self.descriptLayout = HBoxLayout()
        self.descriptLayout.addWidget(self.descriptionButton)
        self.descriptLayout.addWidget(self.descriptionText)
        
        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addLayout(self.titleLayout)
        self.descriptionLayout.addLayout(self.authorLayout)
        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addWidget(self.playAllButton)
        self.descriptionLayout.addSpacing(10)
        self.descriptionLayout.addLayout(self.descriptLayout)

        self.topLayout.addWidget(self.picLabel)
        self.topLayout.addSpacing(18)
        self.topLayout.addLayout(self.descriptionLayout)

        self.mainLayout.addLayout(self.topLayout)
        self.mainLayout.addWidget(self.contentsTab)
        
        self.frame.setLayout(self.mainLayout)
Ejemplo n.º 15
0
    def __init__(self, parent=None):
        super(LoginBox, self).__init__()
        self.parent = parent
        
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setWindowTitle('登陆')
        self.setObjectName('LoginBox')

        self.resize(520, 300)

        # 可能会有多个渠道登陆的后续扩展。
        self.currentFrame = 0

        self.mainLayout = VBoxLayout(self)

        self.phoneAndEMailFrame = PhoneAndEMailFrame(self)

        self.mainLayout.addWidget(self.phoneAndEMailFrame)
Ejemplo n.º 16
0
    def setLayouts(self):
        """定义布局。"""
        self.mainLayout = VBoxLayout(self.frame)
        self.mainLayout.addSpacing(10)
        self.mainLayout.addWidget(self.recommendLabel)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.navigationList)
        self.mainLayout.addSpacing(1)
        
        self.mainLayout.addWidget(self.myMusic)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.nativeList)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addWidget(self.singsListLabel)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addStretch(1)

        self.setContentsMargins(0, 0, 0, 0)
Ejemplo n.º 17
0
class Navigation(QScrollArea):
    def __init__(self, parent=None):
        """包括发现音乐,MV,我的音乐, 歌单等导航信息。"""
        super(Navigation, self).__init__(parent)
        self.parent = parent
        self.frame = QFrame()
        self.setMaximumWidth(200)

        self.setWidget(self.frame)
        self.setWidgetResizable(True)
        self.frame.setMinimumWidth(200)

        # 定义3个事件函数,方便扩展。
        self.navigationListFunction = self.none
        self.nativeListFunction = self.none
        self.singsFunction = self.none

        with open('QSS/navigation.qss', 'r') as f:
            style = f.read()
            self.setStyleSheet(style)
            self.frame.setStyleSheet(style)

        # 包括显示信息: 推荐 我的音乐 歌单。
        self.setLabels()
        # 包括详细的内容:发现音乐,FM,MV等。
        self.setListViews()

        self.setLayouts()

    # 布局。
    def setLabels(self):
        """定义所有的标签。"""
        self.recommendLabel = QLabel(" 推荐")
        self.recommendLabel.setObjectName("recommendLabel")
        self.recommendLabel.setMaximumHeight(27)

        self.myMusic = QLabel(" 我的音乐")
        self.myMusic.setObjectName("myMusic")
        self.myMusic.setMaximumHeight(27)
        # self.myMusic.setMaximumHeight(54)

        self.singsListLabel = QLabel(" 收藏与创建的歌单")
        self.singsListLabel.setObjectName("singsListLabel")
        self.singsListLabel.setMaximumHeight(27)

    def setListViews(self):
        """定义承载功能的ListView"""
        self.navigationList = QListWidget()
        self.navigationList.setMaximumHeight(110)
        self.navigationList.setObjectName("navigationList")
        self.navigationList.addItem(QListWidgetItem(QIcon('resource/music.png'), " 发现音乐"))
        self.navigationList.addItem(QListWidgetItem(QIcon('resource/signal.png'), " 私人FM"))
        self.navigationList.addItem(QListWidgetItem(QIcon('resource/movie.png'), " MV"))
        self.navigationList.setCurrentRow(0)

        self.nativeList = QListWidget()
        self.nativeList.setObjectName("nativeList")
        self.nativeList.setMaximumHeight(100)
        self.nativeList.addItem(QListWidgetItem(QIcon('resource/notes.png')," 本地音乐"))
        self.nativeList.addItem(QListWidgetItem(QIcon('resource/download_icon.png'), " 我的下载"))
        self.nativeList.addItem(QListWidgetItem(QIcon('resource/recommend_icon.png'), " 专属推荐"))

    def setLayouts(self):
        """定义布局。"""
        self.mainLayout = VBoxLayout(self.frame)
        self.mainLayout.addSpacing(10)
        self.mainLayout.addWidget(self.recommendLabel)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.navigationList)
        self.mainLayout.addSpacing(1)
        
        self.mainLayout.addWidget(self.myMusic)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.nativeList)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addWidget(self.singsListLabel)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addStretch(1)

        self.setContentsMargins(0, 0, 0, 0)

    # just a test.
    def setSingsList(self):

        pass

    # 功能。
    def none(self):
        # 没有用的空函数。
        pass
Ejemplo n.º 18
0
class CurrentMusicDetail(ScrollArea):
    """
    showPic | MusicDetails
    ---------------------
    comments.

    MusicDetails
    title| recovery
    T        E        X        T
    """
    def __init__(self, parent):
        super(CurrentMusicDetail, self).__init__()
        # with open('QSS/currentMusic.qss', 'r', encoding='utf-8') as f:
        #     self.setStyleSheet(f.read())

        self.setObjectName('detail')
        self.hide()

        self.mainLayout = VBoxLayout(self.frame)
        self.topLayout = HBoxLayout()
        self.topMainLayout = VBoxLayout()
        self.topHeaderLayout = HBoxLayout()

        # 为歌词创建索引方便删除。
        self.allLyrics = []

        # self.detailText = QTextEdit()
        # self.detailText.setObjectName('detailText')
        # self.detailText.setReadOnly(True)

        self.titleLabel = QLabel("✧✧✧")
        self.titleLabel.setObjectName('titleLabel')

        self.recoveryButton = QPushButton()
        self.recoveryButton.setObjectName('recoveryButton')
        self.recoveryButton.setMinimumSize(24, 24)
        self.recoveryButton.setMaximumSize(36, 36)

        self.setLayouts()

    def setLayouts(self):
        self.mainLayout.addLayout(self.topLayout)

        # 为showPic预留。
        # self.topLayout.addStretch(1)

        self.topLayout.addLayout(self.topMainLayout)
        self.topMainLayout.addSpacing(25)
        self.topMainLayout.addLayout(self.topHeaderLayout)
        self.topHeaderLayout.addStretch(1)
        self.topHeaderLayout.addSpacing(100)
        self.topHeaderLayout.addWidget(self.titleLabel)
        self.topHeaderLayout.addStretch(1)
        self.topHeaderLayout.addSpacing(20)
        self.topHeaderLayout.addWidget(self.recoveryButton)
        self.topHeaderLayout.addSpacing(50)
        self.topMainLayout.addSpacing(30)

    def addLyricLabel(self, label):

        HStretchBox(self.topMainLayout, label)

        self.allLyrics.append(label)

    def removeAllLyricLabels(self):
        for i in self.allLyrics:
            i.deleteLater()
        self.allLyrics = []

        for i in range(3, self.topMainLayout.count()):
            self.topMainLayout.takeAt(i)
Ejemplo n.º 19
0
class CurrentMusicShort(QFrame):
    """用于显示当前歌曲的简单信息。"""
    def __init__(self, parent=None):
        super(CurrentMusicShort, self).__init__()
        self.parent = parent
        self.setObjectName('short')

        self.mousePos = None

        self.setLabels()

        # self.setButtons()

        self.setLayouts()

        self.init()

    # 布局。
    def setLabels(self):
        self.musicName = QLabel(self)
        self.musicName.adjustSize()
        self.musicAuthor = QLabel(self)

        self.musicPic = PicLabel('resource/no_music.png', 64, 64)
        self.musicPic.setObjectName("musicPic")

        self.musicMask = PicLabel('resource/expand.png', 64, 64)
        self.musicMask.hide()
        # 设置背景透明。
        self.musicMask.setStyleSheet(
            'QLabel {background-color: rgba(0, 0, 0, 50%;)}')

        # 遮罩层属于musicPic, 用布局简单弄一下即可。
        self.musicLayout = VBoxLayout(self.musicPic)
        self.musicLayout.addWidget(self.musicMask)

    def setLayouts(self):
        """布局。"""
        self.mainLayout = QHBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.musicInfo = QVBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.musicInfo.addWidget(self.musicName)
        self.musicInfo.addWidget(self.musicAuthor)

        self.mainLayout.addWidget(self.musicPic)
        self.mainLayout.addLayout(self.musicInfo)

        self.mainLayout.setStretch(0, 1)
        self.mainLayout.setStretch(1, 2)

        self.setLayout(self.mainLayout)

    # 功能.
    def init(self):
        """默认情况下的显示,包括音乐图片,音乐名和音乐作者。"""
        self.musicName.setText("Enjoy it")
        self.musicAuthor.setText("Enjoy it")

    # 事件。
    def enterEvent(self, event):
        if not self.musicMask.isVisible():
            self.musicMask.show()

    def leaveEvent(self, event):
        if self.musicMask.isVisible():
            self.musicMask.hide()
Ejemplo n.º 20
0
class PhoneAndEMailFrame(QFrame):
    def __init__(self, parent=None):
        super(PhoneAndEMailFrame, self).__init__()
        self.parent = parent
        self.resize(520, 300)
        with open('QSS/phoneAndEMailFrame.qss', 'r') as f:

            self.setStyleSheet(f.read())

        self.mainLayout = VBoxLayout(self)

        self.header = Header("用户名", self)
        self.header.setMinimumHeight(40)
        self.header.connectCloseButton(self.parent.accept)
        self.mainLayout.addWidget(self.header)

        self.mainLayout.addStretch(1)

        self.usernameLine = InputLine(self, 220, 32, '请输入用户名')
        self.usernameLine.setObjectName('usernameLine')
        self.usernameCenterBox = HStretchBox(self.mainLayout,
                                             self.usernameLine)

        self.mainLayout.addSpacing(10)

        self.passwordLine = InputLine(self, 220, 32, '请输入密码')
        self.passwordLine.setObjectName('passwordLine')
        self.passwordCenterBox = HStretchBox(self.mainLayout,
                                             self.passwordLine)
        self.passwordLine.setEchoMode(QLineEdit.Password)

        self.warningIconLabel = QLabel()
        self.warningIconLabel.setObjectName('warningIconLabel')
        self.warningIconLabel.setMaximumSize(14, 14)
        self.warningIconLabel.setMinimumSize(14, 14)
        self.warningIconLabel.hide()
        self.warningLabel = QLabel("请输入用户名")
        self.warningLabel.hide()
        self.warningLabel.setObjectName('warningLabel')

        self.warningCenterBox = HStretchBox(self.mainLayout,
                                            self.warningIconLabel,
                                            self.warningLabel,
                                            behindStretch=2)

        self.mainLayout.addSpacing(30)

        self.enterLoginButton = QPushButton("登 录")
        self.enterLoginButton.setObjectName("enterButton")
        self.enterLoginButton.setMaximumSize(217, 27)
        self.enterLoginButton.setMinimumSize(217, 27)
        self.enterLoginCenterBox = HStretchBox(self.mainLayout,
                                               self.enterLoginButton)

        self.mainLayout.addSpacing(30)

        self.mainLayout.addStretch(1)

    def checkAndGetLoginInformation(self):
        username = self.usernameLine.text()
        password = self.passwordLine.text()

        if not username or not password:
            self.warningIconLabel.show()

        if not username:
            self.warningLabel.setText('请输入用户名')
            self.warningLabel.show()
            return False

        if not password:
            self.warningLabel.setText('请输入密码')
            self.warningLabel.show()
            return False

        self.warningIconLabel.hide()
        self.warningLabel.hide()

        return username, password

    def setWarningAndShowIt(self, warningStr):
        self.warningLabel.setText(warningStr)

        self.warningLabel.show()
        self.warningIconLabel.show()

    def connectLogin(self, functionName):
        self.enterLoginButton.clicked.connect(functionName)
Ejemplo n.º 21
0
class Navigation(QScrollArea):
    def __init__(self, parent=None):
        """包括发现音乐,MV,我的音乐, 歌单等导航信息。"""
        super(Navigation, self).__init__(parent)
        self.parent = parent
        self.frame = QFrame()
        # self.setMaximumHeight(576)
        self.setMaximumWidth(200)

        self.setWidget(self.frame)
        self.setWidgetResizable(True)
        # self.frame.setMaximumWidth(200)
        self.frame.setMinimumWidth(200)

        # 定义3个事件函数,方便扩展。
        self.navigationListFunction = self.none
        self.nativeListFunction = self.none
        self.singsFunction = self.none

        with open('QSS/navigation.qss', 'r') as f:
            style = f.read()
            self.setStyleSheet(style)
            self.frame.setStyleSheet(style)

        # 包括显示信息: 推荐 我的音乐 歌单。
        self.setLabels()
        # 包括详细的内容:发现音乐,FM,MV等。
        self.setListViews()

        self.setLayouts()

    # 布局。
    def setLabels(self):
        """定义所有的标签。"""
        self.recommendLabel = QLabel(" 推荐")
        self.recommendLabel.setObjectName("recommendLabel")
        self.recommendLabel.setMaximumHeight(27)

        self.myMusic = QLabel(" 我的音乐")
        self.myMusic.setObjectName("myMusic")
        self.myMusic.setMaximumHeight(27)

        self.singsListLabel = QLabel(" 收藏与创建的歌单")
        self.singsListLabel.setObjectName("singsListLabel")
        self.singsListLabel.setMaximumHeight(27)

    def setListViews(self):
        """定义承载功能的ListView"""
        self.navigationList = QListWidget()
        # self.navigationList.setMinimumHeight(110)
        self.navigationList.setMaximumHeight(110)
        self.navigationList.setObjectName("navigationList")
        self.navigationList.addItem(
            QListWidgetItem(QIcon('resource/music.png'), " 发现音乐"))
        self.navigationList.addItem(
            QListWidgetItem(QIcon('resource/signal.png'), " 私人FM"))
        self.navigationList.addItem(
            QListWidgetItem(QIcon('resource/movie.png'), " MV"))
        self.navigationList.setCurrentRow(0)

        self.nativeList = QListWidget()
        self.nativeList.setObjectName("nativeList")
        # self.nativeList.setMinimumHeight(50)
        self.nativeList.setMaximumHeight(50)
        self.nativeList.addItem(
            QListWidgetItem(QIcon('resource/notes.png'), " 本地音乐"))

    def setLayouts(self):
        """定义布局。"""
        self.mainLayout = VBoxLayout(self.frame)
        self.mainLayout.addSpacing(10)
        self.mainLayout.addWidget(self.recommendLabel)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.navigationList)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addWidget(self.myMusic)
        self.mainLayout.addSpacing(3)
        self.mainLayout.addWidget(self.nativeList)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addWidget(self.singsListLabel)
        self.mainLayout.addSpacing(1)

        self.mainLayout.addStretch(1)

        self.setContentsMargins(0, 0, 0, 0)

    # just a test.
    def setSingsList(self):

        pass

    # 功能。
    def none(self):
        # 没有用的空函数。
        pass
class DetailSings(ScrollArea):
    def __init__(self, parent=None):
        super(DetailSings, self).__init__(self)

        # self.hide()
        self.parent = parent
        self.setObjectName('detailSings')
        with open('QSS/detailSings.qss', 'r', encoding='utf-8') as f:
            self.setStyleSheet(f.read())

        self.setLabels()
        self.setButtons()
        self.setTabs()
        self.setLayouts()

        # self.config = ConfigDetailSings(self)

    # 布局。
    def setLabels(self):
        self.picLabel = PicLabel(width=200, height=200)
        self.picLabel.setObjectName('picLabel')

        self.titleLabel = QLabel(self.frame)
        self.titleLabel.setObjectName('titleLabel')
        self.titleLabel.setWordWrap(True)
        self.titleLabel.setMaximumHeight(40)

        self.authorPic = QLabel(self.frame)
        self.authorName = QLabel(self.frame)
        self.authorName.setObjectName('authorName')
        self.authorName.setMaximumHeight(28)

        # self.descriptionLabel = QLabel(self.frame)
        self.descriptionText = QTextEdit(self.frame)
        self.descriptionText.setReadOnly(True)
        self.descriptionText.setObjectName('descriptionText')
        self.descriptionText.setMaximumWidth(450)
        self.descriptionText.setMaximumHeight(100)
        self.descriptionText.setMinimumHeight(100)
        # self.descriptionLabel.setWordWrap(True)

    def setButtons(self):
        self.showButton = QPushButton("歌单")
        self.showButton.setObjectName('showButton')
        self.showButton.setMaximumSize(36, 20)

        self.descriptionButton = QPushButton(" 简介 :")
        self.descriptionButton.setObjectName('descriptionButton')
        self.descriptionButton.setMaximumSize(36, 36)

        self.playAllButton = QPushButton("全部播放")
        self.playAllButton.setIcon(QIcon('resource/playAll.png'))
        self.playAllButton.setObjectName('playAllButton')
        self.playAllButton.setMaximumSize(90, 24)
        # self.playAllButton.clicked.connect(self.addAllMusicToPlayer)

    def setTabs(self):
        self.contentsTab = QTabWidget(self.frame)

        self.singsTable = TableWidget(3, ['音乐标题', '歌手', '时长'])
        self.singsTable.setObjectName('singsTable')
        self.singsTable.setMinimumWidth(self.width())
        self.singsTable.setColumnWidths({
            i: j
            for i, j in zip(range(3), [
                self.width() / 3 * 1.25,
                self.width() / 3 * 1.25,
                self.width() / 3 * 0.5
            ])
        })

        # self.singsTable.itemDoubleClicked.connect(self.itemDoubleClickedEvent)

        self.contentsTab.addTab(self.singsTable, "歌曲列表")

    def setLayouts(self):
        self.mainLayout = VBoxLayout()

        self.topLayout = HBoxLayout()

        self.descriptionLayout = VBoxLayout()
        self.titleLayout = HBoxLayout()
        self.titleLayout.addWidget(self.showButton)
        self.titleLayout.addSpacing(5)
        self.titleLayout.addWidget(self.titleLabel)

        self.authorLayout = HBoxLayout()
        self.authorLayout.addWidget(self.authorPic)
        self.authorLayout.addWidget(self.authorName)
        self.authorLayout.addStretch(1)

        self.descriptLayout = HBoxLayout()
        self.descriptLayout.addWidget(self.descriptionButton)
        self.descriptLayout.addWidget(self.descriptionText)

        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addLayout(self.titleLayout)
        self.descriptionLayout.addLayout(self.authorLayout)
        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addWidget(self.playAllButton)
        self.descriptionLayout.addSpacing(10)
        self.descriptionLayout.addLayout(self.descriptLayout)

        # self.descriptionLayout.setSpacing(0)

        self.topLayout.addWidget(self.picLabel)
        self.topLayout.addSpacing(18)
        self.topLayout.addLayout(self.descriptionLayout)

        self.mainLayout.addLayout(self.topLayout)
        self.mainLayout.addWidget(self.contentsTab)

        self.frame.setLayout(self.mainLayout)
Ejemplo n.º 23
0
class SearchArea(ScrollArea):
    def __init__(self, parent=None):
        super(SearchArea, self).__init__(self)
        self.parent = parent
        self.setObjectName("searchArea")
        with open('QSS/searchArea.qss', 'r', encoding='utf-8') as f:
            self.setStyleSheet(f.read())

        self.mainLayout = QVBoxLayout(self.frame)

        self.titleLabel = QLabel(self.frame)

        # 搜索结果的tab。
        self.contentsTab = QTabWidget(self.frame)

        # 加入布局。
        self.mainLayout.addWidget(self.titleLabel)
        self.mainLayout.addWidget(self.contentsTab)

        self.setSingsFrame()

    # 布局。
    def setSingsFrame(self):
        # 单曲界面。
        self.singsFrame = QFrame()
        self.singsFrameLayout = VBoxLayout(self.singsFrame)

        self.noSingsContentsLabel = QLabel(self.singsFrame)
        self.noSingsContentsLabel.setMaximumHeight(60)

        self.noSingsContentsLabel.setObjectName("noSingsLable")
        self.noSingsContentsLabel.hide()

        self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长'])
        self.singsResultTable.setObjectName('singsTable')
        self.singsResultTable.setMinimumWidth(self.width())
        self.singsResultTable.setColumnWidths({
            i: j
            for i, j in zip(range(3), [
                self.width() / 3 * 1.25,
                self.width() / 3 * 1.25,
                self.width() / 3 * 0.5
            ])
        })

        self.singsFrameLayout.addWidget(self.singsResultTable,
                                        Qt.AlignTop | Qt.AlignCenter)

        self.centerLabelLayout = HBoxLayout()
        self.centerLabelLayout.addStretch(1)
        self.centerLabelLayout.addWidget(self.noSingsContentsLabel)
        self.centerLabelLayout.addStretch(1)

        self.singsFrameLayout.addLayout(self.centerLabelLayout)

        self.contentsTab.addTab(self.singsFrame, "单曲")

    # 功能。
    def setText(self, text):
        self.text = text
        self.titleLabel.setText(
            "搜索<font color='#23518F'>“{0}”</font><br>".format(self.text))
Ejemplo n.º 24
0
class PhoneAndEMailFrame(QFrame):

    def __init__(self, parent=None):
        super(PhoneAndEMailFrame, self).__init__()
        self.parent = parent
        self.resize(520, 300)
        with open('QSS/phoneAndEMailFrame.qss', 'r') as f:

            self.setStyleSheet(f.read())

        self.mainLayout = VBoxLayout(self)

        self.header = Header("用户名", self)
        self.header.setMinimumHeight(40)
        self.header.connectCloseButton(self.parent.accept)
        self.mainLayout.addWidget(self.header)

        self.mainLayout.addStretch(1)

        self.usernameLine = InputLine(self, 220, 32, '请输入用户名')
        self.usernameLine.setObjectName('usernameLine')
        self.usernameCenterBox = HStretchBox(self.mainLayout, self.usernameLine)   
        
        self.mainLayout.addSpacing(10) 
        
        self.passwordLine = InputLine(self, 220, 32, '请输入密码')
        self.passwordLine.setObjectName('passwordLine')
        self.passwordCenterBox = HStretchBox(self.mainLayout, self.passwordLine)
        self.passwordLine.setEchoMode(QLineEdit.Password)

        self.warningIconLabel = QLabel()
        self.warningIconLabel.setObjectName('warningIconLabel')
        self.warningIconLabel.setMaximumSize(14, 14)
        self.warningIconLabel.setMinimumSize(14, 14)
        self.warningIconLabel.hide()
        self.warningLabel = QLabel("请输入用户名")
        self.warningLabel.hide()
        self.warningLabel.setObjectName('warningLabel')

        self.warningCenterBox = HStretchBox(self.mainLayout, self.warningIconLabel, self.warningLabel, 
            behindStretch=2)

        self.mainLayout.addSpacing(30) 

        self.enterLoginButton = QPushButton("登 录")
        self.enterLoginButton.setObjectName("enterButton")
        self.enterLoginButton.setMaximumSize(217, 27)
        self.enterLoginButton.setMinimumSize(217, 27)
        self.enterLoginCenterBox = HStretchBox(self.mainLayout, self.enterLoginButton)

        self.mainLayout.addSpacing(30)
        
        self.mainLayout.addStretch(1)

    def checkAndGetLoginInformation(self):
        username = self.usernameLine.text()
        password = self.passwordLine.text()
        
        if not username or not password:
            self.warningIconLabel.show()

        if not username:
            self.warningLabel.setText('请输入用户名')
            self.warningLabel.show()
            return False

        if not password:
            self.warningLabel.setText('请输入密码')
            self.warningLabel.show()
            return False

        self.warningIconLabel.hide()
        self.warningLabel.hide()

        return username, password

    def setWarningAndShowIt(self, warningStr):
        self.warningLabel.setText(warningStr)

        self.warningLabel.show()
        self.warningIconLabel.show()

    def connectLogin(self, functionName):
        self.enterLoginButton.clicked.connect(functionName)
Ejemplo n.º 25
0
class DetailSings(ScrollArea):

    def __init__(self, parent=None):
        super(DetailSings, self).__init__(self)

        # self.hide()
        self.parent = parent
        self.setObjectName('detailSings')
        with open('QSS/detailSings.qss', 'r', encoding='utf-8') as f:
            self.setStyleSheet(f.read())

        self.setLabels()
        self.setButtons()
        self.setTabs()
        self.setLayouts()

    # 布局。
    def setLabels(self):
        self.picLabel = PicLabel(width=200, height=200)
        self.picLabel.setObjectName('picLabel')

        self.titleLabel = QLabel(self.frame)
        self.titleLabel.setObjectName('titleLabel')
        self.titleLabel.setWordWrap(True)
        self.titleLabel.setMaximumHeight(40)

        self.authorPic = QLabel(self.frame)
        self.authorName = QLabel(self.frame)
        self.authorName.setObjectName('authorName')
        self.authorName.setMaximumHeight(28)

        self.descriptionText = QTextEdit(self.frame)
        self.descriptionText.setReadOnly(True)
        self.descriptionText.setObjectName('descriptionText')
        self.descriptionText.setMaximumWidth(450)
        self.descriptionText.setMaximumHeight(100)
        self.descriptionText.setMinimumHeight(100)

    def setButtons(self):
        self.showButton = QPushButton("歌单")
        self.showButton.setObjectName('showButton')
        self.showButton.setMaximumSize(36, 20)

        self.descriptionButton = QPushButton(" 简介 :")
        self.descriptionButton.setObjectName('descriptionButton')
        self.descriptionButton.setMaximumSize(36, 36)

        self.playAllButton = QPushButton("全部播放")
        self.playAllButton.setIcon(QIcon('resource/playAll.png'))
        self.playAllButton.setObjectName('playAllButton')
        self.playAllButton.setMaximumSize(90, 24)

    def setTabs(self):
        self.contentsTab = QTabWidget(self.frame)

        self.singsTable = TableWidget(3, ['音乐标题', '歌手', '时长'])
        self.singsTable.setObjectName('singsTable')
        self.singsTable.setMinimumWidth(self.width())
        self.singsTable.setColumnWidths({i:j for i,j in zip(range(3), 
            [self.width()/3*1.25,self.width()/3*1.25,self.width()/3*0.5])})

        self.contentsTab.addTab(self.singsTable, "歌曲列表")

    def setLayouts(self):
        self.mainLayout = VBoxLayout()

        self.topLayout = HBoxLayout()

        self.descriptionLayout = VBoxLayout()
        self.titleLayout = HBoxLayout()
        self.titleLayout.addWidget(self.showButton)
        self.titleLayout.addSpacing(5)
        self.titleLayout.addWidget(self.titleLabel)

        self.authorLayout = HBoxLayout()
        self.authorLayout.addWidget(self.authorPic)
        self.authorLayout.addWidget(self.authorName)
        self.authorLayout.addStretch(1)

        self.descriptLayout = HBoxLayout()
        self.descriptLayout.addWidget(self.descriptionButton)
        self.descriptLayout.addWidget(self.descriptionText)
        
        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addLayout(self.titleLayout)
        self.descriptionLayout.addLayout(self.authorLayout)
        self.descriptionLayout.addSpacing(5)
        self.descriptionLayout.addWidget(self.playAllButton)
        self.descriptionLayout.addSpacing(10)
        self.descriptionLayout.addLayout(self.descriptLayout)

        self.topLayout.addWidget(self.picLabel)
        self.topLayout.addSpacing(18)
        self.topLayout.addLayout(self.descriptionLayout)

        self.mainLayout.addLayout(self.topLayout)
        self.mainLayout.addWidget(self.contentsTab)
        
        self.frame.setLayout(self.mainLayout)