Commit 8c623dee authored by Sebastian Kügler's avatar Sebastian Kügler Committed by Daniel Vrátil
Browse files

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.
parent 4af785ea
......@@ -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();
}
......@@ -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);
}
}
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment