[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kscreen/sebas/osd] tests/osd: improve osd test app
From:       Sebastian_Kügler <sebas () kde ! org>
Date:       2016-12-05 22:40:52
Message-ID: E1cE1wK-00034I-8a () code ! kde ! org
[Download RAW message or body]

Git commit 35705f89acd64443001db61718c0d92c6c218e0a by Sebastian Kügler.
Committed on 05/12/2016 at 18:06.
Pushed by sebas into branch 'sebas/osd'.

improve osd test app

We can now decide at runtime what kind of OSD to show, and wether to use
DBus or directly the classes.

DBus bits aren't implemented, though.

M  +26   -1    tests/osd/main.cpp
M  +26   -4    tests/osd/osdtest.cpp
M  +6    -1    tests/osd/osdtest.h

https://commits.kde.org/kscreen/35705f89acd64443001db61718c0d92c6c218e0a

diff --git a/tests/osd/main.cpp b/tests/osd/main.cpp
index a63151d..714c01e 100644
--- a/tests/osd/main.cpp
+++ b/tests/osd/main.cpp
@@ -25,11 +25,36 @@ int main(int argc, char **argv)
 {
     QGuiApplication app(argc, argv);
 
+    QCommandLineOption dbus = QCommandLineOption(QStringList() << \
QStringLiteral("d") << "dbus", +                                                  \
QStringLiteral("Call over dbus")); +    QCommandLineOption outputid = \
QCommandLineOption(QStringList() << QStringLiteral("o") << "outputidentifiers", +     \
QStringLiteral("Show output identifier")); +    QCommandLineOption icon = \
QCommandLineOption(QStringList() << QStringLiteral("i") << "icon", +                  \
QStringLiteral("Icon to use for OSD"), \
QStringLiteral("preferences-desktop-display-randr")); +    QCommandLineOption message \
= QCommandLineOption(QStringList() << QStringLiteral("m") << "message", +             \
QStringLiteral("Icon to use for OSD"), QStringLiteral("OSD Test"));  KScreen::OsdTest \
osdtest;  QCommandLineParser parser;
     parser.addHelpOption();
+    parser.addOption(dbus);
+    parser.addOption(outputid);
+    parser.addOption(icon);
+    parser.addOption(message);
     parser.process(app);
 
-    osdtest.start();
+
+
+    if (parser.isSet(dbus)) {
+        osdtest.setUseDBus(true);
+    }
+    if (parser.isSet(outputid)) {
+
+        osdtest.showOutputIdentifiers();
+    } else {
+        osdtest.showGenericOsd(parser.value(icon), parser.value(message));
+    }
+    if (parser.isSet(outputid)) {
+    }
+
     return app.exec();
 }
diff --git a/tests/osd/osdtest.cpp b/tests/osd/osdtest.cpp
index 6f25720..64b55fe 100644
--- a/tests/osd/osdtest.cpp
+++ b/tests/osd/osdtest.cpp
@@ -34,11 +34,33 @@ OsdTest::~OsdTest()
 {
 }
 
-void OsdTest::start()
+void OsdTest::showOutputIdentifiers()
 {
-    QTimer::singleShot(5500, qApp, &QCoreApplication::quit);
-//     KScreen::OsdManager::self()->showOutputIdentifiers();
-    KScreen::OsdManager::self()->showOsd(QStringLiteral("preferences-desktop-display-randr"), \
QStringLiteral("OSD Showing Up")); +    if (!m_useDBus) {
+        QTimer::singleShot(5500, qApp, &QCoreApplication::quit);
+        KScreen::OsdManager::self()->showOutputIdentifiers();
+    } else {
+        qCWarning(KSCREEN_KDED) << "Implement me.";
+        QTimer::singleShot(100, qApp, &QCoreApplication::quit);
+    }
+}
+
+
+void OsdTest::setUseDBus(bool yesno)
+{
+    m_useDBus = yesno;
+}
+
+void OsdTest::showGenericOsd(const QString& icon, const QString& message)
+{
+    if (!m_useDBus) {
+        QTimer::singleShot(5500, qApp, &QCoreApplication::quit);
+        KScreen::OsdManager::self()->showOsd(!icon.isEmpty() ? icon : \
QStringLiteral("preferences-desktop-display-randr"), +                                \
!message.isEmpty() ? message : QStringLiteral("On-Screen-Display")); +    } else {
+        qCWarning(KSCREEN_KDED) << "Implement me.";
+        QTimer::singleShot(100, qApp, &QCoreApplication::quit);
+    }
 }
 
 
diff --git a/tests/osd/osdtest.h b/tests/osd/osdtest.h
index f44094f..279e443 100644
--- a/tests/osd/osdtest.h
+++ b/tests/osd/osdtest.h
@@ -33,8 +33,13 @@ public:
     explicit OsdTest(QObject *parent = nullptr);
     virtual ~OsdTest();
 
-    void start();
+    void setUseDBus(bool yesno);
 
+    void showGenericOsd(const QString &icon, const QString &message);
+    void showOutputIdentifiers();
+
+private:
+    bool m_useDBus = false;
 };
 
 } // namespace


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic