Fix storage page chart legend not respecting theme

Signed-off-by: HeyaGlitz <heyaglitz@waifu.club>
This commit is contained in:
HeyaGlitz 2024-01-02 00:20:50 +01:00
parent bce5a8df35
commit 87ea20df5a
2 changed files with 15 additions and 0 deletions

View File

@ -60,7 +60,9 @@ StoragePage::StoragePage(BaseInstance* inst, QWidget* parent) : QWidget(parent),
m_chart->setBackgroundVisible(false); m_chart->setBackgroundVisible(false);
m_chart->setMargins(QMargins(0, 0, 0, 0)); m_chart->setMargins(QMargins(0, 0, 0, 0));
m_chart->legend()->setAlignment(Qt::AlignLeft); m_chart->legend()->setAlignment(Qt::AlignLeft);
m_chart->legend()->setLabelColor(QApplication::palette().text().color());
m_chart_view->setRenderHint(QPainter::Antialiasing); m_chart_view->setRenderHint(QPainter::Antialiasing);
m_chart_view->installEventFilter(this);
ui->verticalLayout->addWidget(m_chart_view); ui->verticalLayout->addWidget(m_chart_view);
ui->retranslateUi(this); ui->retranslateUi(this);
@ -157,3 +159,13 @@ void StoragePage::updateCalculations()
for (auto slice : m_series->slices()) for (auto slice : m_series->slices())
slice->setLabel(slice->label() + " " + QString("%1%").arg(100 * slice->percentage(), 0, 'f', 1)); slice->setLabel(slice->label() + " " + QString("%1%").arg(100 * slice->percentage(), 0, 'f', 1));
} }
bool StoragePage::eventFilter(QObject *object, QEvent *event)
{
if(event->type() == QEvent::PaletteChange)
{
m_chart->legend()->setLabelColor(QApplication::palette().text().color());
return true;
}
return false;
}

View File

@ -75,6 +75,9 @@ public:
void updateCalculations(); void updateCalculations();
protected:
bool eventFilter(QObject *object, QEvent *event) override;
private: private:
Ui::StoragePage *ui; Ui::StoragePage *ui;
BaseInstance *m_inst; BaseInstance *m_inst;