Merge pull request #1629 from HeyaGlitz/storagelegendfix

Fix storage page chart legend not respecting theme
This commit is contained in:
Lenny McLennington 2024-01-06 13:49:44 +00:00 committed by GitHub
commit aeac0eb9ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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->setMargins(QMargins(0, 0, 0, 0));
m_chart->legend()->setAlignment(Qt::AlignLeft);
m_chart->legend()->setLabelColor(QApplication::palette().text().color());
m_chart_view->setRenderHint(QPainter::Antialiasing);
m_chart_view->installEventFilter(this);
ui->verticalLayout->addWidget(m_chart_view);
ui->retranslateUi(this);
@ -157,3 +159,13 @@ void StoragePage::updateCalculations()
for (auto slice : m_series->slices())
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();
protected:
bool eventFilter(QObject *object, QEvent *event) override;
private:
Ui::StoragePage *ui;
BaseInstance *m_inst;