comparison src/sidebar.cpp @ 6:1d82f6e04d7d

Update: add first parts to the settings dialog
author Paper <mrpapersonic@gmail.com>
date Wed, 16 Aug 2023 00:49:17 -0400
parents 1ae666fdf9e2
children 07a9095eaeed
comparison
equal deleted inserted replaced
5:51ae25154b70 6:1d82f6e04d7d
1 #include <QListWidget>
2 #include <QListWidgetItem>
3 #include <QFrame>
4 #include "sidebar.h"
5
6 SideBar::SideBar(QWidget *parent)
7 : QListWidget(parent)
8 {
9 setObjectName("sidebar");
10 setFrameShape(QFrame::NoFrame);
11 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
12 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
13 viewport()->setAutoFillBackground(false);
14 setStyleSheet("font-size: 12px");
15 }
16
17 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) {
18 QListWidgetItem* item = new QListWidgetItem(this);
19 item->setText(name);
20 if (!icon.isNull())
21 item->setIcon(icon);
22 return item;
23 }
24
25 QListWidgetItem* SideBar::AddSeparator() {
26 QListWidgetItem* item = new QListWidgetItem(this);
27 item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
28 setStyleSheet("QListWidget::item:disabled {background: transparent;}");
29 QFrame* line = new QFrame(this);
30 line->setFrameShape(QFrame::HLine);
31 line->setFrameShadow(QFrame::Sunken);
32 line->setEnabled(false);
33 setItemWidget(item, line);
34 return item;
35 }