Changeset View
Changeset View
Standalone View
Standalone View
kcms/input/kapplymousetheme.cpp
- This file was moved from kcms/input/backends/x11/kapplymousetheme.cpp.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * main.cpp | 2 | * main.cpp | ||
3 | * | 3 | * | ||
4 | * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> | 4 | * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> | ||
5 | * Copyright (c) 2005 Lubos Lunak <l.lunak@kde.org> | 5 | * Copyright (c) 2005 Lubos Lunak <l.lunak@kde.org> | ||
6 | * Copyright (c) 2017 Xuetian Weng <wengxt@gmail.com> | 6 | * Copyright (c) 2017 Xuetian Weng <wengxt@gmail.com> | ||
7 | * Copyright (c) 2018 Roman Gilg <subdiff@gmail.com> | ||||
7 | * | 8 | * | ||
8 | * Requires the Qt widget libraries, available at no cost at | 9 | * Requires the Qt widget libraries, available at no cost at | ||
9 | * http://www.troll.no/ | 10 | * http://www.troll.no/ | ||
10 | * | 11 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | 15 | * (at your option) any later version. | ||
15 | * | 16 | * | ||
16 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | 20 | * GNU General Public License for more details. | ||
20 | * | 21 | * | ||
21 | * You should have received a copy of the GNU General Public License | 22 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | 23 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
24 | */ | 25 | */ | ||
26 | #include "backends/x11/x11_backend.h" | ||||
27 | | ||||
28 | #include <KWindowSystem/kwindowsystem.h> | ||||
29 | | ||||
25 | #include <QGuiApplication> | 30 | #include <QGuiApplication> | ||
26 | #include <QFile> | 31 | #include <QFile> | ||
27 | 32 | | |||
28 | #include "mousebackend.h" | 33 | #include <QDebug> | ||
29 | 34 | | |||
30 | int main( int argc, char* argv[] ) | 35 | int main( int argc, char* argv[] ) | ||
31 | { | 36 | { | ||
32 | int ret = 0; | 37 | int ret = 0; | ||
33 | QGuiApplication app(argc, argv); | 38 | QGuiApplication app(argc, argv); | ||
34 | if( argc != 3 ) | 39 | if( argc != 3 ) | ||
35 | return 1; | 40 | return 1; | ||
36 | QString theme = QFile::decodeName(argv[ 1 ]); | 41 | QString theme = QFile::decodeName(argv[ 1 ]); | ||
37 | QString size = QFile::decodeName(argv[ 2 ]); | 42 | QString size = QFile::decodeName(argv[ 2 ]); | ||
38 | auto backend = MouseBackend::implementation(); | 43 | | ||
39 | if (!backend || !backend->isValid()) { | 44 | if (!KWindowSystem::isPlatformX11()) { | ||
45 | qDebug() << "X11 backend not detected. Exit."; | ||||
46 | return 2; | ||||
47 | } | ||||
48 | | ||||
49 | X11Backend backend; | ||||
50 | | ||||
51 | if (!backend.isValid()) { | ||||
40 | return 2; | 52 | return 2; | ||
41 | } | 53 | } | ||
42 | 54 | | |||
43 | // Note: If you update this code, update main.cpp as well. | 55 | // Note: If you update this code, update main.cpp as well. | ||
44 | 56 | | |||
45 | // use a default value for theme only if it's not configured at all, not even in X resources | 57 | // use a default value for theme only if it's not configured at all, not even in X resources | ||
46 | if(theme.isEmpty() && backend->currentCursorTheme().isEmpty()) | 58 | if(theme.isEmpty() && backend.currentCursorTheme().isEmpty()) | ||
47 | { | 59 | { | ||
48 | theme = "breeze_cursors"; | 60 | theme = "breeze_cursors"; | ||
49 | ret = 10; // means to switch to default | 61 | ret = 10; // means to switch to default | ||
50 | } | 62 | } | ||
51 | 63 | | |||
52 | backend->applyCursorTheme(theme, size.toInt()); | 64 | backend.applyCursorTheme(theme, size.toInt()); | ||
53 | return ret; | 65 | return ret; | ||
54 | } | 66 | } |