Mercurial > minori
annotate 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 |
rev | line source |
---|---|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
1 #include <QListWidget> |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
2 #include <QListWidgetItem> |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
3 #include <QFrame> |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
4 #include "sidebar.h" |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
5 |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
6 SideBar::SideBar(QWidget *parent) |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
7 : QListWidget(parent) |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
8 { |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
9 setObjectName("sidebar"); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
10 setFrameShape(QFrame::NoFrame); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
11 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
12 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
13 viewport()->setAutoFillBackground(false); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
14 setStyleSheet("font-size: 12px"); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
15 } |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
16 |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
17 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) { |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
18 QListWidgetItem* item = new QListWidgetItem(this); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
19 item->setText(name); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
20 if (!icon.isNull()) |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
21 item->setIcon(icon); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
22 return item; |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
23 } |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
24 |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
25 QListWidgetItem* SideBar::AddSeparator() { |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
26 QListWidgetItem* item = new QListWidgetItem(this); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
27 item->setFlags(item->flags() & ~Qt::ItemIsEnabled); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
28 setStyleSheet("QListWidget::item:disabled {background: transparent;}"); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
29 QFrame* line = new QFrame(this); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
30 line->setFrameShape(QFrame::HLine); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
31 line->setFrameShadow(QFrame::Sunken); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
32 line->setEnabled(false); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
33 setItemWidget(item, line); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
34 return item; |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
1
diff
changeset
|
35 } |