Changeset View
Changeset View
Standalone View
Standalone View
libcolorcorrect/compositorcoloradaptor.cpp
Show All 10 Lines | |||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | *********************************************************************/ | 16 | *********************************************************************/ | ||
17 | #include "compositorcoloradaptor.h" | 17 | #include "compositorcoloradaptor.h" | ||
18 | 18 | | |||
19 | #include <KWindowSystem> | | |||
20 | #include <KLocalizedString> | 19 | #include <KLocalizedString> | ||
21 | 20 | | |||
22 | #include <QDBusReply> | 21 | #include <QDBusReply> | ||
23 | #include <QDBusInterface> | 22 | #include <QDBusInterface> | ||
24 | 23 | | |||
25 | namespace ColorCorrect | 24 | namespace ColorCorrect | ||
26 | { | 25 | { | ||
27 | 26 | | |||
28 | CompositorAdaptor::CompositorAdaptor(QObject *parent) | 27 | CompositorAdaptor::CompositorAdaptor(QObject *parent) | ||
29 | : QObject(parent) | 28 | : QObject(parent) | ||
30 | { | 29 | { | ||
31 | if(KWindowSystem::isPlatformX11()) { | | |||
32 | setError(ErrorCode::ErrorCodeXSession); | | |||
33 | } | | |||
34 | | ||||
35 | m_iface = new QDBusInterface (QStringLiteral("org.kde.KWin"), | 30 | m_iface = new QDBusInterface (QStringLiteral("org.kde.KWin"), | ||
36 | QStringLiteral("/ColorCorrect"), | 31 | QStringLiteral("/ColorCorrect"), | ||
37 | QStringLiteral("org.kde.kwin.ColorCorrect"), | 32 | QStringLiteral("org.kde.kwin.ColorCorrect"), | ||
38 | QDBusConnection::sessionBus(), | 33 | QDBusConnection::sessionBus(), | ||
39 | this); | 34 | this); | ||
40 | 35 | | |||
41 | if (!m_iface->connection().connect(QString(), QStringLiteral("/ColorCorrect"), | 36 | if (!m_iface->connection().connect(QString(), QStringLiteral("/ColorCorrect"), | ||
42 | QStringLiteral("org.kde.kwin.ColorCorrect"), QStringLiteral("nightColorConfigChanged"), | 37 | QStringLiteral("org.kde.kwin.ColorCorrect"), QStringLiteral("nightColorConfigChanged"), | ||
43 | this, SLOT(compDataUpdated(QHash<QString, QVariant>)))) { | 38 | this, SLOT(compDataUpdated(QHash<QString, QVariant>)))) { | ||
44 | setError(ErrorCode::ErrorCodeConnectionFailed); | 39 | setError(ErrorCode::ErrorCodeConnectionFailed); | ||
45 | return; | 40 | return; | ||
46 | } | 41 | } | ||
47 | reloadData(); | 42 | reloadData(); | ||
48 | } | 43 | } | ||
49 | 44 | | |||
50 | void CompositorAdaptor::setError(ErrorCode error) | 45 | void CompositorAdaptor::setError(ErrorCode error) | ||
51 | { | 46 | { | ||
52 | if (m_error == error || m_error == ErrorCode::ErrorCodeXSession) { | 47 | if (m_error == error) { | ||
53 | return; | 48 | return; | ||
54 | } | 49 | } | ||
55 | m_error = error; | 50 | m_error = error; | ||
56 | switch(error) { | 51 | switch(error) { | ||
57 | case ErrorCode::ErrorCodeConnectionFailed: | 52 | case ErrorCode::ErrorCodeConnectionFailed: | ||
58 | m_errorText = i18nc("Critical error message", "Failed to connect to the Window Manager"); | 53 | m_errorText = i18nc("Critical error message", "Failed to connect to the Window Manager"); | ||
59 | break; | 54 | break; | ||
60 | case ErrorCode::ErrorCodeBackendNoSupport: | 55 | case ErrorCode::ErrorCodeBackendNoSupport: | ||
61 | m_errorText = i18nc("Critical error message", "Rendering backend doesn't support Color Correction."); | 56 | m_errorText = i18nc("Critical error message", "Rendering backend doesn't support Color Correction."); | ||
62 | break; | 57 | break; | ||
63 | case ErrorCode::ErrorCodeXSession: | | |||
64 | m_errorText = i18nc("Critical error message", "You're currently using the X Windowing System. This functionality is Wayland exclusive."); | | |||
65 | break; | | |||
66 | default: | 58 | default: | ||
67 | m_errorText = ""; | 59 | m_errorText = ""; | ||
68 | } | 60 | } | ||
69 | emit errorChanged(); | 61 | emit errorChanged(); | ||
70 | emit errorTextChanged(); | 62 | emit errorTextChanged(); | ||
71 | } | 63 | } | ||
72 | 64 | | |||
73 | void CompositorAdaptor::compDataUpdated(const QHash<QString, QVariant> &data) | 65 | void CompositorAdaptor::compDataUpdated(const QHash<QString, QVariant> &data) | ||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |