mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: create themes on demand
Create the themes only when needed (singleton pattern). If the themes should do more than colors, such as for example fonts, it is not clear whether that can be done before main() runs. By creating the themes on demand, the Qt UI should be initialized in the constructors of the themes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7f1107408d
commit
5f91c69f9c
4 changed files with 21 additions and 10 deletions
|
@ -35,7 +35,7 @@ static const double selectionLassoWidth = 2.0; // Border between title and char
|
|||
|
||||
StatsView::StatsView(QQuickItem *parent) : QQuickItem(parent),
|
||||
backgroundDirty(true),
|
||||
currentTheme(statsThemes[0]),
|
||||
currentTheme(&getStatsTheme(false)),
|
||||
highlightedSeries(nullptr),
|
||||
xAxis(nullptr),
|
||||
yAxis(nullptr),
|
||||
|
@ -300,10 +300,9 @@ QQuickWindow *StatsView::w() const
|
|||
return window();
|
||||
}
|
||||
|
||||
void StatsView::setTheme(int idx)
|
||||
void StatsView::setTheme(bool dark)
|
||||
{
|
||||
idx = std::clamp(idx, 0, (int)statsThemes.size() - 1);
|
||||
currentTheme = statsThemes[idx];
|
||||
currentTheme = &getStatsTheme(dark);
|
||||
rootNode->backgroundNode->setColor(currentTheme->backgroundColor);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue