Skip to content

Commit f2422c7

Browse files
committed
Theming: Add option to change the accent color
- Settings => Theme
1 parent f2178e7 commit f2422c7

26 files changed

Lines changed: 437 additions & 64 deletions

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ New features:
1313
- Clicking on the waveform will make the editor jump to the corresponding location
1414
- The last recorded file path is saved and loaded along the project
1515

16+
* Theming: Add option to change the accent color
17+
- Settings => Theme
18+
1619
Bug fixes:
1720

1821
Other:

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ set(SOURCE_FILES
146146
application/service/selection_service.cpp
147147
application/service/settings_service.cpp
148148
application/service/side_chain_service.cpp
149+
application/service/theme_service.cpp
149150
application/service/util_service.cpp
150151
application/state_machine.cpp
151152
application/ui_logger.cpp
@@ -247,6 +248,7 @@ set(QML_SOURCE_FILES
247248
${QML_BASE_DIR}/Dialogs/SettingsDialog_AudioSettings.qml
248249
${QML_BASE_DIR}/Dialogs/SettingsDialog_GeneralSettings.qml
249250
${QML_BASE_DIR}/Dialogs/SettingsDialog_MidiSettings.qml
251+
${QML_BASE_DIR}/Dialogs/SettingsDialog_ThemeSettings.qml
250252
${QML_BASE_DIR}/Dialogs/ShortcutsDialog.qml
251253
${QML_BASE_DIR}/Dialogs/SideChainTargetDelegate.qml
252254
${QML_BASE_DIR}/Dialogs/TrackSettingsDialog.qml

src/application/application.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "service/selection_service.hpp"
4848
#include "service/settings_service.hpp"
4949
#include "service/side_chain_service.hpp"
50+
#include "service/theme_service.hpp"
5051
#include "service/util_service.hpp"
5152
#include "state_machine.hpp"
5253
#include "ui_logger.hpp"
@@ -74,6 +75,7 @@ Application::Application(int & argc, char ** argv)
7475
, m_application { std::make_unique<QGuiApplication>(argc, argv) }
7576
, m_applicationService { std::make_shared<ApplicationService>() }
7677
, m_settingsService { std::make_shared<SettingsService>() }
78+
, m_themeService { std::make_shared<ThemeService>() }
7779
, m_selectionService { std::make_shared<SelectionService>() }
7880
, m_utilService { std::make_shared<UtilService>() }
7981
, m_propertyService { std::make_shared<PropertyService>() }
@@ -180,6 +182,7 @@ void Application::setContextProperties()
180182
m_engine->rootContext()->setContextProperty("recentFilesModel", m_recentFilesModel.get());
181183
m_engine->rootContext()->setContextProperty("selectionService", m_selectionService.get());
182184
m_engine->rootContext()->setContextProperty("settingsService", m_settingsService.get());
185+
m_engine->rootContext()->setContextProperty("themeService", m_themeService.get());
183186
m_engine->rootContext()->setContextProperty("sideChainService", m_sideChainService.get());
184187
m_engine->rootContext()->setContextProperty("trackSettingsModel", m_trackSettingsModel.get());
185188
m_engine->rootContext()->setContextProperty("uiLogger", m_uiLogger.get());
@@ -856,3 +859,4 @@ Application::~Application()
856859
}
857860

858861
} // namespace noteahead
862+

src/application/application.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class RecentFilesModel;
6161
class SelectionService;
6262
class SettingsService;
6363
class SideChainService;
64+
class ThemeService;
6465
class TrackSettingsModel;
6566
class UiLogger;
6667
class UtilService;
@@ -124,6 +125,7 @@ class Application : public QObject
124125
std::shared_ptr<ApplicationService> m_applicationService;
125126

126127
std::shared_ptr<SettingsService> m_settingsService;
128+
std::shared_ptr<ThemeService> m_themeService;
127129

128130
std::shared_ptr<SelectionService> m_selectionService;
129131

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// This file is part of Noteahead.
2+
// Copyright (C) 2020 Jussi Lind <jussi.lind@iki.fi>
3+
//
4+
// Noteahead is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
// Noteahead is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Noteahead. If not, see <http://www.gnu.org/licenses/>.
15+
16+
#include "theme_service.hpp"
17+
18+
#include "../../infra/settings.hpp"
19+
20+
namespace noteahead {
21+
22+
ThemeService::ThemeService()
23+
: m_accentColor { Settings::accentColor(QColor { "orange" }) }
24+
{
25+
}
26+
27+
ThemeService::~ThemeService() = default;
28+
29+
QColor ThemeService::accentColor() const
30+
{
31+
return m_accentColor;
32+
}
33+
34+
void ThemeService::setAccentColor(const QColor & accentColor)
35+
{
36+
if (m_accentColor != accentColor) {
37+
m_accentColor = accentColor;
38+
Settings::setAccentColor(m_accentColor);
39+
emit accentColorChanged();
40+
emit trackHeaderTextColorsChanged();
41+
}
42+
}
43+
44+
QColor ThemeService::lineNumberColumnBackgroundColor() const
45+
{
46+
return QColor { "black" };
47+
}
48+
49+
QColor ThemeService::lineNumberColumnBorderColor() const
50+
{
51+
return QColor { "#444444" };
52+
}
53+
54+
QColor ThemeService::lineNumberColumnCellBackgroundColor() const
55+
{
56+
return QColor { "black" };
57+
}
58+
59+
QColor ThemeService::lineNumberColumnCellBorderColor() const
60+
{
61+
return QColor { "#222222" };
62+
}
63+
64+
QColor ThemeService::lineNumberColumnOverflowTextColor() const
65+
{
66+
return QColor { "#444444" };
67+
}
68+
69+
QColor ThemeService::mainMenuTextColor() const
70+
{
71+
return QColor { "white" };
72+
}
73+
74+
QColor ThemeService::mainToolBarGradientStartColor() const
75+
{
76+
return QColor { "#303030" };
77+
}
78+
79+
QColor ThemeService::mainToolBarGradientStopColor() const
80+
{
81+
return QColor { "black" };
82+
}
83+
84+
QColor ThemeService::mainToolBarSeparatorColor() const
85+
{
86+
return QColor { "white" };
87+
}
88+
89+
QColor ThemeService::mainToolBarTextColor() const
90+
{
91+
return QColor { "white" };
92+
}
93+
94+
QColor ThemeService::noteColumnBackgroundColor() const
95+
{
96+
return QColor { "black" };
97+
}
98+
99+
QColor ThemeService::noteColumnBorderColor() const
100+
{
101+
return QColor { "#444444" };
102+
}
103+
104+
QColor ThemeService::noteColumnCellBackgroundColor() const
105+
{
106+
return QColor { "black" };
107+
}
108+
109+
QColor ThemeService::noteColumnCellBorderColor() const
110+
{
111+
return QColor { "#222222" };
112+
}
113+
114+
QColor ThemeService::noteColumnTextColor() const
115+
{
116+
return QColor { "white" };
117+
}
118+
119+
QColor ThemeService::noteColumnTextColorEmpty() const
120+
{
121+
return QColor { "#888888" };
122+
}
123+
124+
QColor ThemeService::positionBarBorderColor() const
125+
{
126+
return QColor { "white" };
127+
}
128+
129+
QColor ThemeService::positionBarBorderColorEditMode() const
130+
{
131+
return QColor { "red" };
132+
}
133+
134+
QColor ThemeService::progressBarBackgroundColor() const
135+
{
136+
return QColor { "#4a4a4a" };
137+
}
138+
139+
QColor ThemeService::recentFileItemTextColor() const
140+
{
141+
return QColor { "white" };
142+
}
143+
144+
QColor ThemeService::trackBorderColor() const
145+
{
146+
return QColor { "#222222" };
147+
}
148+
149+
QColor ThemeService::trackHeaderBackgroundColor() const
150+
{
151+
return QColor { "black" };
152+
}
153+
154+
QColor ThemeService::trackHeaderBorderColor() const
155+
{
156+
return QColor { "#222222" };
157+
}
158+
159+
QVariantList ThemeService::trackHeaderTextColors() const
160+
{
161+
return QVariantList {
162+
m_accentColor,
163+
QColor { "white" },
164+
QColor { "#ff5555" },
165+
QColor { "#55ff55" },
166+
QColor { "#5555ff" },
167+
QColor { "#ffff55" },
168+
QColor { "#ff55ff" },
169+
QColor { "#55ffff" },
170+
QColor { "#aaaaaa" },
171+
QColor { "#ff8800" },
172+
QColor { "#88ff00" },
173+
QColor { "#0088ff" },
174+
QColor { "#ff0088" },
175+
QColor { "#8800ff" },
176+
QColor { "#00ff88" },
177+
QColor { "#888888" }
178+
};
179+
}
180+
181+
QColor ThemeService::trackHeaderTextColor(int trackIndex) const
182+
{
183+
const auto colors = trackHeaderTextColors();
184+
return colors.at(trackIndex % colors.size()).value<QColor>();
185+
}
186+
187+
} // namespace noteahead
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// This file is part of Noteahead.
2+
// Copyright (C) 2020 Jussi Lind <jussi.lind@iki.fi>
3+
//
4+
// Noteahead is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
// Noteahead is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Noteahead. If not, see <http://www.gnu.org/licenses/>.
15+
16+
#ifndef THEME_SERVICE_HPP
17+
#define THEME_SERVICE_HPP
18+
19+
#include <QColor>
20+
#include <QObject>
21+
#include <QVariantList>
22+
23+
namespace noteahead {
24+
25+
class ThemeService : public QObject
26+
{
27+
Q_OBJECT
28+
29+
Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged)
30+
31+
Q_PROPERTY(QColor lineNumberColumnBackgroundColor READ lineNumberColumnBackgroundColor CONSTANT)
32+
Q_PROPERTY(QColor lineNumberColumnBorderColor READ lineNumberColumnBorderColor CONSTANT)
33+
Q_PROPERTY(QColor lineNumberColumnCellBackgroundColor READ lineNumberColumnCellBackgroundColor CONSTANT)
34+
Q_PROPERTY(QColor lineNumberColumnCellBorderColor READ lineNumberColumnCellBorderColor CONSTANT)
35+
Q_PROPERTY(QColor lineNumberColumnOverflowTextColor READ lineNumberColumnOverflowTextColor CONSTANT)
36+
Q_PROPERTY(QColor mainMenuTextColor READ mainMenuTextColor CONSTANT)
37+
Q_PROPERTY(QColor mainToolBarGradientStartColor READ mainToolBarGradientStartColor CONSTANT)
38+
Q_PROPERTY(QColor mainToolBarGradientStopColor READ mainToolBarGradientStopColor CONSTANT)
39+
Q_PROPERTY(QColor mainToolBarSeparatorColor READ mainToolBarSeparatorColor CONSTANT)
40+
Q_PROPERTY(QColor mainToolBarTextColor READ mainToolBarTextColor CONSTANT)
41+
Q_PROPERTY(QColor noteColumnBackgroundColor READ noteColumnBackgroundColor CONSTANT)
42+
Q_PROPERTY(QColor noteColumnBorderColor READ noteColumnBorderColor CONSTANT)
43+
Q_PROPERTY(QColor noteColumnCellBackgroundColor READ noteColumnCellBackgroundColor CONSTANT)
44+
Q_PROPERTY(QColor noteColumnCellBorderColor READ noteColumnCellBorderColor CONSTANT)
45+
Q_PROPERTY(QColor noteColumnTextColor READ noteColumnTextColor CONSTANT)
46+
Q_PROPERTY(QColor noteColumnTextColorEmpty READ noteColumnTextColorEmpty CONSTANT)
47+
Q_PROPERTY(QColor positionBarBorderColor READ positionBarBorderColor CONSTANT)
48+
Q_PROPERTY(QColor positionBarBorderColorEditMode READ positionBarBorderColorEditMode CONSTANT)
49+
Q_PROPERTY(QColor progressBarBackgroundColor READ progressBarBackgroundColor CONSTANT)
50+
Q_PROPERTY(QColor recentFileItemTextColor READ recentFileItemTextColor CONSTANT)
51+
Q_PROPERTY(QColor trackBorderColor READ trackBorderColor CONSTANT)
52+
Q_PROPERTY(QColor trackHeaderBackgroundColor READ trackHeaderBackgroundColor CONSTANT)
53+
Q_PROPERTY(QColor trackHeaderBorderColor READ trackHeaderBorderColor CONSTANT)
54+
55+
Q_PROPERTY(QVariantList trackHeaderTextColors READ trackHeaderTextColors NOTIFY trackHeaderTextColorsChanged)
56+
57+
public:
58+
ThemeService();
59+
~ThemeService() override;
60+
61+
QColor accentColor() const;
62+
void setAccentColor(const QColor & accentColor);
63+
64+
QColor lineNumberColumnBackgroundColor() const;
65+
QColor lineNumberColumnBorderColor() const;
66+
QColor lineNumberColumnCellBackgroundColor() const;
67+
QColor lineNumberColumnCellBorderColor() const;
68+
QColor lineNumberColumnOverflowTextColor() const;
69+
QColor mainMenuTextColor() const;
70+
QColor mainToolBarGradientStartColor() const;
71+
QColor mainToolBarGradientStopColor() const;
72+
QColor mainToolBarSeparatorColor() const;
73+
QColor mainToolBarTextColor() const;
74+
QColor noteColumnBackgroundColor() const;
75+
QColor noteColumnBorderColor() const;
76+
QColor noteColumnCellBackgroundColor() const;
77+
QColor noteColumnCellBorderColor() const;
78+
QColor noteColumnTextColor() const;
79+
QColor noteColumnTextColorEmpty() const;
80+
QColor positionBarBorderColor() const;
81+
QColor positionBarBorderColorEditMode() const;
82+
QColor progressBarBackgroundColor() const;
83+
QColor recentFileItemTextColor() const;
84+
QColor trackBorderColor() const;
85+
QColor trackHeaderBackgroundColor() const;
86+
QColor trackHeaderBorderColor() const;
87+
88+
QVariantList trackHeaderTextColors() const;
89+
90+
Q_INVOKABLE QColor trackHeaderTextColor(int trackIndex) const;
91+
92+
signals:
93+
void accentColorChanged();
94+
void trackHeaderTextColorsChanged();
95+
96+
private:
97+
QColor m_accentColor;
98+
};
99+
100+
} // namespace noteahead
101+
102+
#endif // THEME_SERVICE_HPP

0 commit comments

Comments
 (0)