Пример #1
0
        def __init__(self, parent=None):
            super().__init__(parent, objectName='DiaryListItem')
            self.title = NElideLabel(self, objectName='DiaryListItemTitle')
            self.title.setFont(font.title)
            self.title.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
            self.title.setSizePolicy(QSizePolicy.Expanding,
                                     QSizePolicy.Preferred)
            self.datetime = QLabel(self, objectName='DiaryListItemDt')
            self.datetime.setFont(font.datetime)
            self.datetime.setSizePolicy(QSizePolicy.Maximum,
                                        QSizePolicy.Preferred)

            self.text = MultiLineElideLabel(self,
                                            objectName='DiaryListItemText',
                                            forceHeightHint=True)
            self.text.setMaximumLineCount(
                settings['Main'].getint('previewLines'))
            self.text.setFont(font.text)

            self.tag = NElideLabel(self, objectName='DiaryListItemTag')

            # use QToolButton to display icons
            self.datetimeIco = QToolButton(self,
                                           objectName='DiaryListItemDtIco')
            minSz = max(font.datetime_m.ascent(), 12 * scaleRatio)
            self.datetimeIco.setIconSize(QSize(minSz, minSz))
            self.datetimeIco.setIcon(QIcon(':/calendar.png'))

            self.tagIco = QToolButton(self, objectName='DiaryListItemTagIco')
            minSz = max(font.default_m.ascent(), 12 * scaleRatio)
            self.tagIco.setIconSize(QSize(minSz, minSz))
            self.tagIco.setIcon(QIcon(':/tag.png'))

            self.vLayout0 = QVBoxLayout(self)
            self.hLayout0 = QHBoxLayout()
            self.hLayout1 = QHBoxLayout()
            for i in [self.vLayout0, self.hLayout0, self.hLayout1]:
                i.setContentsMargins(0, 0, 0, 0)
                i.setSpacing(0)

            for i in [self.datetimeIco, self.datetime, self.title]:
                self.hLayout0.addWidget(i)
            self.hLayout0.insertSpacing(2, 10)
            for i in [self.tagIco, self.tag]:
                self.hLayout1.addWidget(i)
            self.vLayout0.addLayout(self.hLayout0)
            self.vLayout0.addWidget(self.text)
            self.vLayout0.addLayout(self.hLayout1)