Changeset View
Changeset View
Standalone View
Standalone View
colorcorrection/manager.cpp
Show All 25 Lines | |||||
26 | #include <platform.h> | 26 | #include <platform.h> | ||
27 | #include <abstract_output.h> | 27 | #include <abstract_output.h> | ||
28 | #include <screens.h> | 28 | #include <screens.h> | ||
29 | #include <workspace.h> | 29 | #include <workspace.h> | ||
30 | #include <logind.h> | 30 | #include <logind.h> | ||
31 | 31 | | |||
32 | #include <colorcorrect_settings.h> | 32 | #include <colorcorrect_settings.h> | ||
33 | 33 | | |||
34 | #include <QTimer> | 34 | #include <KGlobalAccel> | ||
35 | #include <KLocalizedString> | ||||
36 | | ||||
37 | #include <QAction> | ||||
35 | #include <QDBusConnection> | 38 | #include <QDBusConnection> | ||
36 | #include <QSocketNotifier> | 39 | #include <QSocketNotifier> | ||
40 | #include <QTimer> | ||||
37 | 41 | | |||
38 | #ifdef Q_OS_LINUX | 42 | #ifdef Q_OS_LINUX | ||
39 | #include <sys/timerfd.h> | 43 | #include <sys/timerfd.h> | ||
40 | #endif | 44 | #endif | ||
41 | #include <unistd.h> | 45 | #include <unistd.h> | ||
42 | #include <fcntl.h> | 46 | #include <fcntl.h> | ||
43 | 47 | | |||
44 | namespace KWin { | 48 | namespace KWin { | ||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | |||||
147 | 151 | | |||
148 | void Manager::reparseConfigAndReset() | 152 | void Manager::reparseConfigAndReset() | ||
149 | { | 153 | { | ||
150 | cancelAllTimers(); | 154 | cancelAllTimers(); | ||
151 | readConfig(); | 155 | readConfig(); | ||
152 | hardReset(); | 156 | hardReset(); | ||
153 | } | 157 | } | ||
154 | 158 | | |||
159 | void Manager::toggle() | ||||
160 | { | ||||
161 | if (!kwinApp()->platform()->supportsGammaControl()) { | ||||
162 | return; | ||||
163 | } | ||||
164 | | ||||
165 | m_active = !m_active; | ||||
166 | | ||||
167 | resetAllTimers(); | ||||
168 | } | ||||
169 | | ||||
170 | void Manager::initShortcuts() | ||||
romangg: What would be nice is if it shows the current active mode. I.e. Night Color: Automatic. But can… | |||||
171 | { | ||||
172 | QAction *toggleAction = new QAction(this); | ||||
Everywhere else in KWin (and other apps) we use a KActionCollection for this: m_actionCollection = new KActionCollection(this, QStringLiteral("kwin")); m_actionCollection->setComponentDisplayName(i18n("KWin")); with m_actionCollection->addAction (which sets the objectName) broulik: Everywhere else in KWin (and other apps) we use a `KActionCollection` for this:
```… | |||||
That's inaccurate. We don't use KActionCollection in KWin core because we don't need most of its features. zzag: > Everywhere else in KWin
That's inaccurate.
We don't use KActionCollection in KWin core… | |||||
173 | toggleAction->setProperty("componentName", QStringLiteral(KWIN_NAME)); | ||||
174 | toggleAction->setObjectName(i18n("Toggle Night Color")); | ||||
davidedmundson: I don't think it needs the word "Manager" in the UI. | |||||
175 | toggleAction->setText(i18n("Toggle Night Color")); | ||||
176 | KGlobalAccel::setGlobalShortcut(toggleAction, QList<QKeySequence>()); | ||||
Given we don't actually set a shortcut, isn't KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>{}); the proper way? broulik: Given we don't actually set a shortcut, isn't
```
KGlobalAccel::self()->setShortcut(action… | |||||
zzag: That's a copy-paste thing. | |||||
It's not. There's a difference. one calls updateGlobalShortcut(KGlobalAccelPrivate::DefaultShortcut | KGlobalAccelPrivate::ActiveShortcut); the other updateGlobalShortcut(KGlobalAccelPrivate::ActiveShortcut); but it doesn't really matter in this case davidedmundson: It's not. There's a difference.
one calls
updateGlobalShortcut(KGlobalAccelPrivate… | |||||
177 | input()->registerShortcut(QKeySequence(), toggleAction, this, &Manager::toggle); | ||||
178 | } | ||||
179 | | ||||
155 | void Manager::readConfig() | 180 | void Manager::readConfig() | ||
156 | { | 181 | { | ||
157 | Settings *s = Settings::self(); | 182 | Settings *s = Settings::self(); | ||
158 | s->load(); | 183 | s->load(); | ||
159 | 184 | | |||
160 | m_active = s->active(); | 185 | m_active = s->active(); | ||
161 | 186 | | |||
162 | NightColorMode mode = s->mode(); | 187 | NightColorMode mode = s->mode(); | ||
▲ Show 20 Lines • Show All 619 Lines • Show Last 20 Lines |
What would be nice is if it shows the current active mode. I.e. Night Color: Automatic. But can be added later.