Changeset View
Changeset View
Standalone View
Standalone View
tests/osd/osdtest.cpp
- This file was added.
1 | /************************************************************************************* | ||||
---|---|---|---|---|---|
2 | * Copyright 2016 Sebastian Kügler <sebas@kde.org> * | ||||
3 | * * | ||||
4 | * This library is free software; you can redistribute it and/or * | ||||
5 | * modify it under the terms of the GNU Lesser General Public * | ||||
6 | * License as published by the Free Software Foundation; either * | ||||
7 | * version 2.1 of the License, or (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This library is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | ||||
12 | * Lesser General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU Lesser General Public * | ||||
15 | * License along with this library; if not, write to the Free Software * | ||||
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | ||||
17 | *************************************************************************************/ | ||||
18 | | ||||
19 | #include "osdtest.h" | ||||
20 | #include "../../kded/osdmanager.h" | ||||
21 | | ||||
22 | #include <QCoreApplication> | ||||
23 | #include <QDBusConnection> | ||||
24 | #include <QDBusMessage> | ||||
25 | #include <QDBusPendingCall> | ||||
26 | #include <QLoggingCategory> | ||||
27 | | ||||
28 | Q_LOGGING_CATEGORY(KSCREEN_KDED, "kscreen.kded") | ||||
29 | | ||||
30 | namespace KScreen { | ||||
31 | OsdTest::OsdTest(QObject *parent) | ||||
32 | : QObject(parent) | ||||
33 | { | ||||
34 | } | ||||
35 | | ||||
36 | OsdTest::~OsdTest() | ||||
37 | { | ||||
38 | } | ||||
39 | | ||||
40 | void OsdTest::showOutputIdentifiers() | ||||
41 | { | ||||
42 | if (!m_useDBus) { | ||||
43 | QTimer::singleShot(5500, qApp, &QCoreApplication::quit); | ||||
44 | KScreen::OsdManager::self()->showOutputIdentifiers(); | ||||
45 | } else { | ||||
46 | QDBusMessage msg = QDBusMessage::createMethodCall( | ||||
47 | QLatin1Literal("org.kde.kscreen.osdService"), | ||||
48 | QLatin1Literal("/org/kde/kscreen/osdService"), | ||||
49 | QLatin1Literal("org.kde.kscreen.osdService"), | ||||
50 | QLatin1Literal("showOutputIdentifiers") | ||||
51 | ); | ||||
52 | //msg << icon << text; | ||||
53 | QDBusConnection::sessionBus().asyncCall(msg); | ||||
54 | | ||||
55 | qCWarning(KSCREEN_KDED) << "Sent dbus message."; | ||||
56 | QTimer::singleShot(500, qApp, &QCoreApplication::quit); | ||||
57 | } | ||||
58 | } | ||||
59 | | ||||
60 | | ||||
61 | void OsdTest::setUseDBus(bool yesno) | ||||
62 | { | ||||
63 | m_useDBus = yesno; | ||||
64 | } | ||||
65 | | ||||
66 | void OsdTest::showGenericOsd(const QString& icon, const QString& message) | ||||
67 | { | ||||
68 | if (!m_useDBus) { | ||||
69 | QTimer::singleShot(5500, qApp, &QCoreApplication::quit); | ||||
70 | KScreen::OsdManager::self()->showOsd(!icon.isEmpty() ? icon : QStringLiteral("preferences-desktop-display-randr"), | ||||
71 | !message.isEmpty() ? message : QStringLiteral("On-Screen-Display")); | ||||
72 | } else { | ||||
73 | qCWarning(KSCREEN_KDED) << "Implement me."; | ||||
74 | QTimer::singleShot(100, qApp, &QCoreApplication::quit); | ||||
75 | } | ||||
76 | } | ||||
77 | | ||||
78 | | ||||
79 | } // ns |