mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: switch themes on the mobile version
When changing the theme to a dark theme, also change the statistics theme. The code is a mess, because it crashes when setting the theme right at the beginning. Therefore, there is a "theme has been set" flag. Also, this directly accesses the ThemeInterface singleton object. I have no time to fight QML, sorry. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1cff14fa7f
commit
ba95edc2d2
3 changed files with 22 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
- profile: include profile editing in undo system
|
- profile: include profile editing in undo system
|
||||||
|
- mobile: Add a dark theme for statistics
|
||||||
- core: avoid crash with corrupted cloud storage
|
- core: avoid crash with corrupted cloud storage
|
||||||
- mobile: fix profile scaling issue on high DPR devices
|
- mobile: fix profile scaling issue on high DPR devices
|
||||||
- mobile: bring back profile icons
|
- mobile: bring back profile icons
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "statsmanager.h"
|
#include "statsmanager.h"
|
||||||
|
#include "themeinterface.h"
|
||||||
#include "stats/chartlistmodel.h"
|
#include "stats/chartlistmodel.h"
|
||||||
|
|
||||||
StatsManager::StatsManager() : view(nullptr), charts(nullptr)
|
StatsManager::StatsManager() : view(nullptr), charts(nullptr), themeInitialized(false)
|
||||||
{
|
{
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +20,9 @@ void StatsManager::init(StatsView *v, ChartListModel *m)
|
||||||
fprintf(stderr, "StatsManager::init(): no ChartListModel - statistics will not work.\n");
|
fprintf(stderr, "StatsManager::init(): no ChartListModel - statistics will not work.\n");
|
||||||
view = v;
|
view = v;
|
||||||
charts = m;
|
charts = m;
|
||||||
|
|
||||||
|
connect(ThemeInterface::instance(), &ThemeInterface::currentThemeChanged,
|
||||||
|
this, &StatsManager::themeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsManager::doit()
|
void StatsManager::doit()
|
||||||
|
@ -64,6 +68,8 @@ void StatsManager::updateUi()
|
||||||
operation2IndexChanged();
|
operation2IndexChanged();
|
||||||
sortMode1IndexChanged();
|
sortMode1IndexChanged();
|
||||||
|
|
||||||
|
if (view && !std::exchange(themeInitialized, true))
|
||||||
|
themeChanged();
|
||||||
if (charts)
|
if (charts)
|
||||||
charts->update(uiState.charts);
|
charts->update(uiState.charts);
|
||||||
if (view)
|
if (view)
|
||||||
|
@ -123,3 +129,14 @@ void StatsManager::setChart(int idx)
|
||||||
state.chartChanged(idx);
|
state.chartChanged(idx);
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatsManager::themeChanged()
|
||||||
|
{
|
||||||
|
if (!view)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// We could just make currentTheme accessible instead of
|
||||||
|
// using Qt's inane propertySystem. Whatever.
|
||||||
|
QString theme = ThemeInterface::instance()->property("currentTheme").toString();
|
||||||
|
view->setTheme(theme == "Dark");
|
||||||
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ signals:
|
||||||
void binner2IndexChanged();
|
void binner2IndexChanged();
|
||||||
void operation2IndexChanged();
|
void operation2IndexChanged();
|
||||||
void sortMode1IndexChanged();
|
void sortMode1IndexChanged();
|
||||||
|
private slots:
|
||||||
|
void themeChanged();
|
||||||
private:
|
private:
|
||||||
StatsView *view;
|
StatsView *view;
|
||||||
ChartListModel *charts;
|
ChartListModel *charts;
|
||||||
|
@ -66,8 +68,8 @@ private:
|
||||||
int operation2Index;
|
int operation2Index;
|
||||||
int sortMode1Index;
|
int sortMode1Index;
|
||||||
StatsState::UIState uiState; // Remember UI state so that we can interpret indexes
|
StatsState::UIState uiState; // Remember UI state so that we can interpret indexes
|
||||||
|
bool themeInitialized; // setTheme() crashes if called in init()
|
||||||
void updateUi();
|
void updateUi();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue