| 43 | } |
| 44 | |
| 45 | void NotificationCenterWidgetPrivate::initUI() |
| 46 | { |
| 47 | q->setFixedSize(420, 368); |
| 48 | q->setBackgroundRole(QPalette::Base); |
| 49 | |
| 50 | QVBoxLayout *mainLayout = new QVBoxLayout(q); |
| 51 | mainLayout->setContentsMargins(5, 10, 5, 10); |
| 52 | mainLayout->setSpacing(5); |
| 53 | |
| 54 | QLabel *titleLabel = new QLabel(NotificationCenterWidget::tr("Notification"), q); |
| 55 | DFontSizeManager::instance()->bind(titleLabel, DFontSizeManager::T5); |
| 56 | hideBtn = new DToolButton(q); |
| 57 | hideBtn->setIconSize({ 16, 16 }); |
| 58 | hideBtn->setIcon(QIcon::fromTheme("hide")); |
| 59 | |
| 60 | clearBtn = new DToolButton(q); |
| 61 | clearBtn->setIconSize({ 16, 16 }); |
| 62 | clearBtn->setIcon(QIcon::fromTheme("clear_history")); |
| 63 | |
| 64 | QHBoxLayout *titleLayout = new QHBoxLayout; |
| 65 | titleLayout->setContentsMargins(15, 0, 15, 0); |
| 66 | titleLayout->addWidget(titleLabel); |
| 67 | titleLayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding)); |
| 68 | titleLayout->addWidget(hideBtn); |
| 69 | titleLayout->addWidget(clearBtn); |
| 70 | |
| 71 | notifyView = new NotificationListView(q); |
| 72 | viewModel = new NotificationModel(q, notifyView); |
| 73 | notifyView->setModel(viewModel); |
| 74 | notifyView->setItemDelegate(new ItemDelegate(notifyView, q)); |
| 75 | notifyView->setAutoFillBackground(false); |
| 76 | notifyView->viewport()->setAutoFillBackground(false); |
| 77 | notifyView->setFrameStyle(QFrame::NoFrame); |
| 78 | notifyView->setMouseTracking(true); |
| 79 | notifyView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
| 80 | notifyView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
| 81 | notifyView->setVerticalScrollMode(QListView::ScrollPerPixel); |
| 82 | notifyView->setContentsMargins(0, 0, 0, 0); |
| 83 | notifyView->setUpdatesEnabled(true); |
| 84 | notifyView->setSelectionMode(QListView::NoSelection); |
| 85 | notifyView->setFocusPolicy(Qt::NoFocus); |
| 86 | |
| 87 | DLabel *noNotificationLabel = new DLabel(NotificationCenterWidget::tr("No new notifications"), q); |
| 88 | noNotificationLabel->setForegroundRole(DPalette::PlaceholderText); |
| 89 | noNotificationLabel->setAlignment(Qt::AlignCenter); |
| 90 | |
| 91 | contentLayout = new QStackedLayout; |
| 92 | contentLayout->setContentsMargins(0, 0, 0, 0); |
| 93 | contentLayout->addWidget(noNotificationLabel); |
| 94 | contentLayout->addWidget(notifyView); |
| 95 | |
| 96 | mainLayout->addLayout(titleLayout); |
| 97 | mainLayout->addLayout(contentLayout, 1); |
| 98 | } |
| 99 | |
| 100 | void NotificationCenterWidgetPrivate::initConntction() |
| 101 | { |
no test coverage detected