Skip to content

Commit d0332b5

Browse files
committed
ThemeEngine: Add foregroundColor property
1 parent 84d1111 commit d0332b5

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/ui/internal/themeengine.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void ThemeEngine::setTheme(Theme newTheme)
2929
void ThemeEngine::reloadTheme()
3030
{
3131
emit bgColorChanged();
32+
emit foregroundColorChanged();
3233
emit borderColorChanged();
3334
emit themeChanged();
3435
}
@@ -45,6 +46,13 @@ const QColor &ThemeEngine::bgColor() const
4546
return theme() == Theme::DarkTheme ? dark : light;
4647
}
4748

49+
const QColor &ThemeEngine::foregroundColor() const
50+
{
51+
static const QColor dark = QColor(255, 255, 255);
52+
static const QColor light = QColor(0, 0, 0);
53+
return theme() == Theme::DarkTheme ? dark : light;
54+
}
55+
4856
const QColor &ThemeEngine::borderColor() const
4957
{
5058
static const QColor dark = QColor(255, 255, 255, 64);

src/ui/internal/themeengine.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ThemeEngine : public IThemeEngine
1919
INJECT(ISettings, settings)
2020
Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged FINAL)
2121
Q_PROPERTY(QColor bgColor READ bgColor NOTIFY bgColorChanged FINAL)
22+
Q_PROPERTY(QColor foregroundColor READ foregroundColor NOTIFY foregroundColorChanged FINAL)
2223
Q_PROPERTY(QColor borderColor READ borderColor NOTIFY borderColorChanged FINAL)
2324
public:
2425
static std::shared_ptr<ThemeEngine> instance();
@@ -29,11 +30,13 @@ class ThemeEngine : public IThemeEngine
2930
Q_INVOKABLE void resetTheme() override;
3031

3132
const QColor &bgColor() const override;
33+
const QColor &foregroundColor() const override;
3234
const QColor &borderColor() const override;
3335

3436
signals:
3537
void themeChanged();
3638
void bgColorChanged();
39+
void foregroundColorChanged();
3740
void borderColorChanged();
3841

3942
private:

src/ui/ithemeengine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class IThemeEngine
3030
virtual void resetTheme() = 0;
3131

3232
virtual const QColor &bgColor() const = 0;
33+
virtual const QColor &foregroundColor() const = 0;
3334
virtual const QColor &borderColor() const = 0;
3435
};
3536

src/ui/test/themeengine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ThemeEngineTest : public testing::Test
2424

2525
m_themeSpies.push_back(std::make_unique<QSignalSpy>(&m_themeEngine, &ThemeEngine::themeChanged));
2626
m_themeSpies.push_back(std::make_unique<QSignalSpy>(&m_themeEngine, &ThemeEngine::bgColorChanged));
27+
m_themeSpies.push_back(std::make_unique<QSignalSpy>(&m_themeEngine, &ThemeEngine::foregroundColorChanged));
2728
m_themeSpies.push_back(std::make_unique<QSignalSpy>(&m_themeEngine, &ThemeEngine::borderColorChanged));
2829
}
2930

0 commit comments

Comments
 (0)