comparison src/gui/sidebar.cpp @ 36:2743011a6042

*: mass update formatted all source files, converted ALL instances of setStyleSheet() to palettes and fonts (stylesheets suck), and I changed the clang-format file because it wasn't working on my laptop for some reason.
author Paper <mrpapersonic@gmail.com>
date Thu, 21 Sep 2023 15:17:47 -0400
parents cde8f67a7c7d
children 9ae9365dd4ea
comparison
equal deleted inserted replaced
35:329b7921a6be 36:2743011a6042
12 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 12 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
13 setSelectionMode(QAbstractItemView::SingleSelection); 13 setSelectionMode(QAbstractItemView::SingleSelection);
14 setSelectionBehavior(QAbstractItemView::SelectItems); 14 setSelectionBehavior(QAbstractItemView::SelectItems);
15 setMouseTracking(true); 15 setMouseTracking(true);
16 viewport()->setAutoFillBackground(false); 16 viewport()->setAutoFillBackground(false);
17 setStyleSheet("font-size: 12px"); 17 QFont font;
18 font.setPointSize(9);
19 setFont(font);
18 connect(this, &QListWidget::currentRowChanged, this, 20 connect(this, &QListWidget::currentRowChanged, this,
19 [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); }); 21 [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); });
20 } 22 }
21 23
22 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) { 24 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) {
35 return result; 37 return result;
36 } 38 }
37 39
38 QListWidgetItem* SideBar::AddSeparator() { 40 QListWidgetItem* SideBar::AddSeparator() {
39 QListWidgetItem* item = new QListWidgetItem(this); 41 QListWidgetItem* item = new QListWidgetItem(this);
40 setStyleSheet("QListWidget::item:disabled {background: transparent;}");
41 QFrame* line = new QFrame(this); 42 QFrame* line = new QFrame(this);
42 line->setFrameShape(QFrame::HLine); 43 line->setFrameShape(QFrame::HLine);
43 line->setFrameShadow(QFrame::Sunken); 44 line->setFrameShadow(QFrame::Sunken);
44 line->setMouseTracking(true); 45 line->setMouseTracking(true);
45 line->setEnabled(false); 46 line->setEnabled(false);
47
48 QPalette pal;
49 pal.setColor(QPalette::Window, QColor(0, 0, 0, 0));
50 line->setPalette(pal);
51
46 setItemWidget(item, line); 52 setItemWidget(item, line);
47 item->setFlags(Qt::NoItemFlags); 53 item->setFlags(Qt::NoItemFlags);
48 return item; 54 return item;
49 } 55 }
50 56
59 65
60 bool SideBar::IndexIsSeparator(QModelIndex index) const { 66 bool SideBar::IndexIsSeparator(QModelIndex index) const {
61 return !(index.isValid() && index.flags() & Qt::ItemIsEnabled); 67 return !(index.isValid() && index.flags() & Qt::ItemIsEnabled);
62 } 68 }
63 69
64 QItemSelectionModel::SelectionFlags SideBar::selectionCommand(const QModelIndex& index, 70 QItemSelectionModel::SelectionFlags SideBar::selectionCommand(const QModelIndex& index, const QEvent*) const {
65 const QEvent*) const {
66 if (IndexIsSeparator(index)) 71 if (IndexIsSeparator(index))
67 return QItemSelectionModel::NoUpdate; 72 return QItemSelectionModel::NoUpdate;
68 return QItemSelectionModel::ClearAndSelect; 73 return QItemSelectionModel::ClearAndSelect;
69 } 74 }
70 75