Add DarkTheme and LightTheme switching
This commit is contained in:
17 files changed
+206
-73
No files matched your search
@@ -189,6 +189,16 @@ void AppState::setSidebarOpen(bool open)
|
||||
emit sidebarOpenChanged();
|
||||
}
|
||||
|
||||
QString AppState::themeName() const { return m_themeName; }
|
||||
|
||||
void AppState::setThemeName(const QString &themeName)
|
||||
{
|
||||
if (m_themeName == themeName)
|
||||
return;
|
||||
m_themeName = themeName;
|
||||
emit themeNameChanged();
|
||||
}
|
||||
|
||||
void AppState::addOrUpdateLibraryBook(const QString &filePath, const QString &title, const QString &author, double progress)
|
||||
{
|
||||
QString lastOpened = QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||
@@ -284,6 +294,7 @@ void AppState::save()
|
||||
s.setValue(QStringLiteral("preferences/verticalMargin"), m_verticalMargin);
|
||||
s.setValue(QStringLiteral("preferences/fontSize"), m_fontSize);
|
||||
s.setValue(QStringLiteral("preferences/lineSpacing"), m_lineSpacing);
|
||||
s.setValue(QStringLiteral("preferences/themeName"), m_themeName);
|
||||
s.setValue(QStringLiteral("window/width"), m_windowWidth);
|
||||
s.setValue(QStringLiteral("window/height"), m_windowHeight);
|
||||
s.setValue(QStringLiteral("window/x"), m_windowX);
|
||||
@@ -305,6 +316,7 @@ void AppState::restore()
|
||||
m_verticalMargin = s.value(QStringLiteral("preferences/verticalMargin"), 8).toInt();
|
||||
m_fontSize = s.value(QStringLiteral("preferences/fontSize"), 16).toInt();
|
||||
m_lineSpacing = s.value(QStringLiteral("preferences/lineSpacing"), 1.6).toDouble();
|
||||
m_themeName = s.value(QStringLiteral("preferences/themeName"), QStringLiteral("dark")).toString();
|
||||
m_windowWidth = s.value(QStringLiteral("window/width"), 1024).toInt();
|
||||
m_windowHeight = s.value(QStringLiteral("window/height"), 768).toInt();
|
||||
m_windowX = s.value(QStringLiteral("window/x"), -1).toInt();
|
||||
|
||||
@@ -25,10 +25,14 @@ class AppState : public QObject {
|
||||
Q_PROPERTY(QVariantList libraryBooks READ libraryBooks NOTIFY libraryBooksChanged)
|
||||
Q_PROPERTY(QString lastPage READ lastPage WRITE setLastPage NOTIFY lastPageChanged)
|
||||
Q_PROPERTY(bool sidebarOpen READ sidebarOpen WRITE setSidebarOpen NOTIFY sidebarOpenChanged)
|
||||
Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
|
||||
|
||||
public:
|
||||
explicit AppState(QObject *parent = nullptr);
|
||||
|
||||
QString themeName() const;
|
||||
void setThemeName(const QString &themeName);
|
||||
|
||||
QString lastFilePath() const;
|
||||
void setLastFilePath(const QString &path);
|
||||
|
||||
@@ -104,6 +108,7 @@ signals:
|
||||
void libraryBooksChanged();
|
||||
void lastPageChanged();
|
||||
void sidebarOpenChanged();
|
||||
void themeNameChanged();
|
||||
|
||||
private:
|
||||
void loadLibraryBooks();
|
||||
@@ -124,6 +129,7 @@ private:
|
||||
QVariantList m_libraryBooks;
|
||||
QString m_lastPage = QStringLiteral("starter");
|
||||
bool m_sidebarOpen = false;
|
||||
QString m_themeName = QStringLiteral("dark");
|
||||
};
|
||||
|
||||
#endif // APPSTATE_H
|
||||
Reference in new issue
Block a user