示例#1
0
 def adjustHeight(self):
     """ 如果有换行的发生就调整高度 """
     newSongName, isSongNameWrap = autoWrap(self.songName.text(), 57)
     newSonger, isSongerWrap = autoWrap(self.songer.text(), 33)
     newAlbumName, isAlbumNameWrap = autoWrap(self.albumName.text(), 57)
     newAlbumSonger, isAlbumSongerWrap = autoWrap(self.albumSonger.text(),
                                                  33)
     newSongPath, isSongPathWrap = autoWrap(self.songPath.text(), 100)
     if isSongNameWrap or isSongerWrap:
         self.songName.setText(newSongName)
         self.songer.setText(newSonger)
         # 后面的所有标签向下平移25px
         for label in self.label_list_2:
             label.move(label.geometry().x(), label.geometry().y() + 25)
         self.resize(self.width(), self.height() + 25)
     if isAlbumNameWrap or isAlbumSongerWrap:
         self.albumName.setText(newAlbumName)
         self.albumSonger.setText(newAlbumSonger)
         # 后面的所有标签向下平移25px
         for label in self.label_list_2[8:]:
             label.move(label.geometry().x(), label.geometry().y() + 25)
         self.resize(self.width(), self.height() + 25)
     if isSongPathWrap:
         self.songPath.setText(newSongPath)
         self.resize(self.width(), self.height() + 25)
示例#2
0
    def __initLayout(self):
        """ 初始化小部件的排版 """
        self.editInfoLabel.move(30, 30)
        self.songPathLabel.move(30, 470)
        self.songPath.move(30, 502)
        self.saveButton.move(566, 595)
        self.cancelButton.move(736, 595)
        label_top_y = 95

        for i, (label_left, label_right) in enumerate(
            zip(self.leftLabel_list, self.rightLabel_list)
        ):
            label_left.setObjectName("infoTypeLabel")
            label_right.setObjectName("infoTypeLabel")
            label_left.move(30, label_top_y + i * 87)
            label_right.move(494, label_top_y + i * 87)

        editLine_top_y = 127

        for i, (editLine_left, editLine_right) in enumerate(
            zip(self.leftEditLine_list, self.rightEditLine_list)
        ):
            editLine_left.move(30, editLine_top_y + i * 87)
            editLine_right.move(494, editLine_top_y + i * 87)

        # 调整高度
        newSongPath, isWordWrap = autoWrap(self.songPath.text(), 100)
        if isWordWrap:
            self.songPath.setText(newSongPath)
            self.resize(self.width(), self.height() + 25)
            self.cancelButton.move(self.cancelButton.x(), self.cancelButton.y() + 25)
            self.saveButton.move(self.saveButton.x(), self.saveButton.y() + 25)
        # 调整报错标签的位置
        self.bottomErrorIcon.move(30, self.height() - 110)
        self.bottomErrorLabel.move(55, self.height() - 112)
示例#3
0
 def __initWidget(self):
     """ 初始化小部件 """
     self.windowMask.resize(self.size())
     self.widget.setMaximumWidth(675)
     self.titleLabel.move(30, 30)
     self.contentLabel.move(30, 70)
     self.contentLabel.setText(autoWrap(self.content, 71)[0])
     # 设置层叠样式和布局
     self.__setQss()
     self.__initLayout()
     # 信号连接到槽
     self.yesButton.clicked.connect(self.__onYesButtonClicked)
     self.cancelButton.clicked.connect(self.__onCancelButtonClicked)
示例#4
0
 def __adjustLabel(self):
     """ 调整标签的文本长度和位置 """
     newText, isWordWrap = autoWrap(self.playlistName, 32)
     if isWordWrap:
         # 添加省略号
         index = newText.index("\n")
         fontMetrics = QFontMetrics(QFont("Microsoft YaHei", 10, 75))
         secondLineText = fontMetrics.elidedText(newText[index + 1:],
                                                 Qt.ElideRight, 288)
         newText = newText[:index + 1] + secondLineText
         self.playlistNameLabel.setText(newText)
     self.playlistNameLabel.adjustSize()
     self.playlistLenLabel.adjustSize()
     self.playlistLenLabel.move(
         5,
         self.playlistNameLabel.y() + self.playlistNameLabel.height() + 5)
示例#5
0
    def __initWidget(self):
        """ 初始化小部件 """
        self.yesButton.setFocus()
        self.titleLabel.move(30, 22)
        # self.contentLabel.setMaximumWidth(900)
        self.contentLabel.setText(autoWrap(self.content, 100)[0])
        self.contentLabel.move(30, self.titleLabel.y() + 50)

        # 设置层叠样式
        self.__setQss()

        # 调整窗口大小
        rect = self.contentLabel.rect()
        self.setFixedSize(
            60 + rect.right() + self.cancelButton.width(),
            self.contentLabel.y() + self.contentLabel.height() +
            self.yesButton.height() + 60)

        # 信号连接到槽
        self.yesButton.clicked.connect(self.__onYesButtonClicked)
        self.cancelButton.clicked.connect(self.__onCancelButtonClicked)
示例#6
0
 def __adjustLabel(self):
     """ 根据专辑名的长度决定是否换行和添加省略号 """
     newText, isWordWrap = autoWrap(self.albumNameLabel.text(), 22)
     if isWordWrap:
         # 添加省略号
         index = newText.index("\n")
         fontMetrics = QFontMetrics(QFont("Microsoft YaHei", 10, 75))
         secondLineText = fontMetrics.elidedText(
             newText[index + 1 :], Qt.ElideRight, 200
         )
         newText = newText[: index + 1] + secondLineText
         self.albumNameLabel.setText(newText)
     # 给歌手名添加省略号
     fontMetrics = QFontMetrics(QFont("Microsoft YaHei", 10, 25))
     newSongerName = fontMetrics.elidedText(
         self.songerNameLabel.text(), Qt.ElideRight, 200
     )
     self.songerNameLabel.setText(newSongerName)
     self.songerNameLabel.adjustSize()
     self.albumNameLabel.adjustSize()
     self.songerNameLabel.move(
         5, self.albumNameLabel.y() + self.albumNameLabel.height() - 4
     )
示例#7
0
 def adjustHeight(self):
     """ 调整长度 """
     newText, isWordWrap = autoWrap(self.contentLabel.text(), 92)
     if isWordWrap:
         self.resize(852, self.height() + 23)
         self.contentLabel.setText(newText)