comparison src/gui/widgets/sidebar.cpp @ 73:f1fc8b04bc63

...: merge heads
author Paper <mrpapersonic@gmail.com>
date Tue, 03 Oct 2023 05:00:08 -0400
parents 5f9bdcea3d01
children 5ccb99bfa605
comparison
equal deleted inserted replaced
72:893ad99b174d 73:f1fc8b04bc63
13 setSelectionMode(QAbstractItemView::SingleSelection); 13 setSelectionMode(QAbstractItemView::SingleSelection);
14 setSelectionBehavior(QAbstractItemView::SelectItems); 14 setSelectionBehavior(QAbstractItemView::SelectItems);
15 setMouseTracking(true); 15 setMouseTracking(true);
16 /* FIXME: is there an easy way to do this with palettes? */ 16 /* FIXME: is there an easy way to do this with palettes? */
17 setStyleSheet("QListWidget::item:disabled { background: transparent }"); 17 setStyleSheet("QListWidget::item:disabled { background: transparent }");
18 viewport()->setAutoFillBackground(false); 18
19 SetBackgroundColor(Qt::transparent);
19 20
20 QFont font; 21 QFont font;
21 font.setPointSize(9); 22 font.setPointSize(9);
22 setFont(font); 23 setFont(font);
23 24
25 [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); }); 26 [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); });
26 } 27 }
27 28
28 void SideBar::SetCurrentItem(int index) { 29 void SideBar::SetCurrentItem(int index) {
29 setCurrentRow(AddSeparatorsToIndex(index)); 30 setCurrentRow(AddSeparatorsToIndex(index));
31 }
32
33 void SideBar::SetBackgroundColor(QColor color) {
34 viewport()->setAutoFillBackground(color != Qt::transparent);
35 QPalette pal(palette());
36 pal.setColor(QPalette::Window, color);
37 setPalette(pal);
30 } 38 }
31 39
32 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) { 40 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) {
33 QListWidgetItem* item = new QListWidgetItem(this); 41 QListWidgetItem* item = new QListWidgetItem(this);
34 item->setText(name); 42 item->setText(name);