diff --git a/kded/daemon.cpp b/kded/daemon.cpp index 55d122b..68bced0 100644 --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -1,447 +1,445 @@ /************************************************************************************* * Copyright (C) 2012 by Alejandro Fiestas Olivares * * Copyright 2016 by Sebastian Kügler * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * *************************************************************************************/ #include "daemon.h" #include "serializer.h" #include "generator.h" #include "device.h" #include "kscreenadaptor.h" #include "kscreen_daemon_debug.h" #include "osdmanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include K_PLUGIN_FACTORY_WITH_JSON(KScreenDaemonFactory, "kscreen.json", registerPlugin();) KScreenDaemon::KScreenDaemon(QObject* parent, const QList< QVariant >& ) : KDEDModule(parent) , m_monitoredConfig(nullptr) , m_iteration(Generator::None) , m_monitoring(false) , m_changeCompressor(new QTimer(this)) , m_buttonTimer(new QTimer(this)) , m_saveTimer(new QTimer(this)) , m_lidClosedTimer(new QTimer(this)) { KScreen::Log::instance(); QMetaObject::invokeMethod(this, "requestConfig", Qt::QueuedConnection); } void KScreenDaemon::requestConfig() { connect(new KScreen::GetConfigOperation, &KScreen::GetConfigOperation::finished, this, &KScreenDaemon::configReady); } void KScreenDaemon::configReady(KScreen::ConfigOperation* op) { if (op->hasError()) { return; } m_monitoredConfig = qobject_cast(op)->config(); qCDebug(KSCREEN_KDED) << "Config" << m_monitoredConfig.data() << "is ready"; KScreen::ConfigMonitor::instance()->addConfig(m_monitoredConfig); init(); } KScreenDaemon::~KScreenDaemon() { Generator::destroy(); Device::destroy(); } void KScreenDaemon::init() { KActionCollection *coll = new KActionCollection(this); QAction* action = coll->addAction(QStringLiteral("display")); action->setText(i18n("Switch Display" )); QList switchDisplayShortcuts({Qt::Key_Display, Qt::MetaModifier + Qt::Key_P}); KGlobalAccel::self()->setGlobalShortcut(action, switchDisplayShortcuts); connect(action, &QAction::triggered, [&](bool) { displayButton(); }); new KScreenAdaptor(this); m_buttonTimer->setInterval(300); m_buttonTimer->setSingleShot(true); connect(m_buttonTimer, &QTimer::timeout, this, &KScreenDaemon::applyGenericConfig); m_saveTimer->setInterval(300); m_saveTimer->setSingleShot(true); connect(m_saveTimer, &QTimer::timeout, this, &KScreenDaemon::saveCurrentConfig); m_changeCompressor->setInterval(10); m_changeCompressor->setSingleShot(true); connect(m_changeCompressor, &QTimer::timeout, this, &KScreenDaemon::applyConfig); m_lidClosedTimer->setInterval(1000); m_lidClosedTimer->setSingleShot(true); connect(m_lidClosedTimer, &QTimer::timeout, this, &KScreenDaemon::lidClosedTimeout); connect(Device::self(), &Device::lidClosedChanged, this, &KScreenDaemon::lidClosedChanged); connect(Device::self(), &Device::resumingFromSuspend, this, [&]() { KScreen::Log::instance()->setContext("resuming"); qCDebug(KSCREEN_KDED) << "Resumed from suspend, checking for screen changes"; // We don't care about the result, we just want to force the backend // to query XRandR so that it will detect possible changes that happened // while the computer was suspended, and will emit the change events. new KScreen::GetConfigOperation(KScreen::GetConfigOperation::NoEDID, this); }); connect(Device::self(), &Device::aboutToSuspend, this, [&]() { qCDebug(KSCREEN_KDED) << "System is going to suspend, won't be changing config (waited for " << (m_lidClosedTimer->interval() - m_lidClosedTimer->remainingTime()) << "ms)"; m_lidClosedTimer->stop(); }); connect(Generator::self(), &Generator::ready, this, &KScreenDaemon::applyConfig); Generator::self()->setCurrentConfig(m_monitoredConfig); monitorConnectedChange(); } void KScreenDaemon::doApplyConfig(const KScreen::ConfigPtr& config) { qCDebug(KSCREEN_KDED) << "doApplyConfig()"; setMonitorForChanges(false); m_monitoredConfig = config; KScreen::ConfigMonitor::instance()->addConfig(m_monitoredConfig); connect(new KScreen::SetConfigOperation(config), &KScreen::SetConfigOperation::finished, this, [&]() { qCDebug(KSCREEN_KDED) << "Config applied"; setMonitorForChanges(true); }); } void KScreenDaemon::applyConfig() { qCDebug(KSCREEN_KDED) << "Applying config"; if (Serializer::configExists(m_monitoredConfig)) { applyKnownConfig(); return; } applyIdealConfig(); } void KScreenDaemon::applyKnownConfig() { const QString configId = Serializer::configId(m_monitoredConfig); qCDebug(KSCREEN_KDED) << "Applying known config" << configId; // We may look for a config that has been set when the lid was closed, Bug: 353029 if (Device::self()->isLaptop() && !Device::self()->isLidClosed()) { Serializer::moveConfig(configId + QStringLiteral("_lidOpened"), configId); } KScreen::ConfigPtr config = Serializer::config(m_monitoredConfig, configId); // It's possible that the Serializer returned a nullptr if (!config || !KScreen::Config::canBeApplied(config, KScreen::Config::ValidityFlag::RequireAtLeastOneEnabledScreen)) { return applyIdealConfig(); } doApplyConfig(config); } void KScreenDaemon::applyIdealConfig() { qCDebug(KSCREEN_KDED) << "Applying ideal config"; doApplyConfig(Generator::self()->idealConfig(m_monitoredConfig)); } void logConfig(const KScreen::ConfigPtr &config) { if (config) { foreach (auto o, config->outputs()) { if (o->isConnected()) { qCDebug(KSCREEN_KDED) << o; } } } } void KScreenDaemon::configChanged() { qCDebug(KSCREEN_KDED) << "Change detected"; logConfig(m_monitoredConfig); // Modes may have changed, fix-up current mode id Q_FOREACH(const KScreen::OutputPtr &output, m_monitoredConfig->outputs()) { if (output->isConnected() && output->isEnabled() && output->currentMode().isNull()) { qCDebug(KSCREEN_KDED) << "Current mode" << output->currentModeId() << "invalid, setting preferred mode" << output->preferredModeId(); output->setCurrentModeId(output->preferredModeId()); doApplyConfig(m_monitoredConfig); } } // Reset timer, delay the writeback m_saveTimer->start(); } void KScreenDaemon::saveCurrentConfig() { qCDebug(KSCREEN_KDED) << "Saving current config to file"; // We assume the config is valid, since it's what we got, but we are interested // in the "at least one enabled screen" check const bool valid = KScreen::Config::canBeApplied(m_monitoredConfig, KScreen::Config::ValidityFlag::RequireAtLeastOneEnabledScreen); if (valid) { Serializer::saveConfig(m_monitoredConfig, Serializer::configId(m_monitoredConfig)); logConfig(m_monitoredConfig); } else { qCWarning(KSCREEN_KDED) << "Config does not have at least one screen enabled, WILL NOT save this config, this is not what user wants."; logConfig(m_monitoredConfig); } } void KScreenDaemon::showOsd(const QString &icon, const QString &text) { QDBusMessage msg = QDBusMessage::createMethodCall( QLatin1Literal("org.kde.plasmashell"), QLatin1Literal("/org/kde/osdService"), QLatin1Literal("org.kde.osdService"), QLatin1Literal("showText") ); msg << icon << text; QDBusConnection::sessionBus().asyncCall(msg); } void KScreenDaemon::showOutputIdentifier() { - auto osd = new KScreen::OsdManager(this); - osd->showOutputIdentifiers(); + KScreen::OsdManager::self()->showOutputIdentifiers(); } - void KScreenDaemon::displayButton() { showOutputIdentifier(); return; qCDebug(KSCREEN_KDED) << "displayBtn triggered"; QString message = i18nc("OSD text after XF86Display button press", "No External Display"); if (m_monitoredConfig && m_monitoredConfig->connectedOutputs().count() > 1) { message = i18nc("OSD text after XF86Display button press", "Changing Screen Layout"); } showOsd(QStringLiteral("preferences-desktop-display-randr"), message); if (m_buttonTimer->isActive()) { qCDebug(KSCREEN_KDED) << "Too fast, cowboy"; return; } m_buttonTimer->start(); } void KScreenDaemon::resetDisplaySwitch() { qCDebug(KSCREEN_KDED) << "resetDisplaySwitch()"; m_iteration = Generator::None; } void KScreenDaemon::applyGenericConfig() { if (m_iteration == Generator::ExtendToRight) { m_iteration = Generator::None; } m_iteration = Generator::DisplaySwitchAction(static_cast(m_iteration) + 1); qCDebug(KSCREEN_KDED) << "displayButton: " << m_iteration; doApplyConfig(Generator::self()->displaySwitch(m_iteration)); } void KScreenDaemon::lidClosedChanged(bool lidIsClosed) { // Ignore this when we don't have any external monitors, we can't turn off our // only screen if (m_monitoredConfig->connectedOutputs().count() == 1) { return; } if (lidIsClosed) { // Lid is closed, now we wait for couple seconds to find out whether it // will trigger a suspend (see Device::aboutToSuspend), or whether we should // turn off the screen qCDebug(KSCREEN_KDED) << "Lid closed, waiting to see if the computer goes to sleep..."; m_lidClosedTimer->start(); return; } else { qCDebug(KSCREEN_KDED) << "Lid opened!"; // We should have a config with "_lidOpened" suffix lying around. If not, // then the configuration has changed while the lid was closed and we just // use applyConfig() and see what we can do ... const QString openConfigId = Serializer::configId(m_monitoredConfig) + QStringLiteral("_lidOpened"); if (Serializer::configExists(openConfigId)) { const KScreen::ConfigPtr openedConfig = Serializer::config(m_monitoredConfig, openConfigId); Serializer::removeConfig(openConfigId); doApplyConfig(openedConfig); } } } void KScreenDaemon::lidClosedTimeout() { // Make sure nothing has changed in the past second... :-) if (!Device::self()->isLidClosed()) { return; } // If we are here, it means that closing the lid did not result in suspend // action. // FIXME: This could be simply because the suspend took longer than m_lidClosedTimer // timeout. Ideally we need to be able to look into PowerDevil config to see // what's the configured action for lid events, but there's no API to do that // and I'm no parsing PowerDevil's configs... qCDebug(KSCREEN_KDED) << "Lid closed without system going to suspend -> turning off the screen"; for (KScreen::OutputPtr &output : m_monitoredConfig->outputs()) { if (output->type() == KScreen::Output::Panel) { if (output->isConnected() && output->isEnabled()) { // Save the current config with opened lid, just so that we know // how to restore it later const QString configId = Serializer::configId(m_monitoredConfig) + QStringLiteral("_lidOpened"); Serializer::saveConfig(m_monitoredConfig, configId); disableOutput(m_monitoredConfig, output); doApplyConfig(m_monitoredConfig); return; } } } } void KScreenDaemon::outputConnectedChanged() { if (!m_changeCompressor->isActive()) { m_changeCompressor->start(); } resetDisplaySwitch(); KScreen::Output *output = qobject_cast(sender()); qCDebug(KSCREEN_KDED) << "outputConnectedChanged():" << output->name(); if (output->isConnected()) { Q_EMIT outputConnected(output->name()); if (!Serializer::configExists(m_monitoredConfig)) { Q_EMIT unknownOutputConnected(output->name()); } } } void KScreenDaemon::monitorConnectedChange() { KScreen::OutputList outputs = m_monitoredConfig->outputs(); Q_FOREACH(const KScreen::OutputPtr &output, outputs) { connect(output.data(), &KScreen::Output::isConnectedChanged, this, &KScreenDaemon::outputConnectedChanged, Qt::UniqueConnection); } connect(m_monitoredConfig.data(), &KScreen::Config::outputAdded, this, [this] (const KScreen::OutputPtr output) { if (output->isConnected()) { m_changeCompressor->start(); } connect(output.data(), &KScreen::Output::isConnectedChanged, this, &KScreenDaemon::outputConnectedChanged, Qt::UniqueConnection); }, Qt::UniqueConnection ); } void KScreenDaemon::setMonitorForChanges(bool enabled) { if (m_monitoring == enabled) { return; } qCDebug(KSCREEN_KDED) << "Monitor for changes: " << enabled; m_monitoring = enabled; if (m_monitoring) { connect(KScreen::ConfigMonitor::instance(), &KScreen::ConfigMonitor::configurationChanged, this, &KScreenDaemon::configChanged, Qt::UniqueConnection); } else { disconnect(KScreen::ConfigMonitor::instance(), &KScreen::ConfigMonitor::configurationChanged, this, &KScreenDaemon::configChanged); } } void KScreenDaemon::disableOutput(KScreen::ConfigPtr &config, KScreen::OutputPtr &output) { const QRect geom = output->geometry(); qCDebug(KSCREEN_KDED) << "Laptop geometry:" << geom << output->pos() << (output->currentMode() ? output->currentMode()->size() : QSize()); // Move all outputs right from the @p output to left for (KScreen::OutputPtr &otherOutput : config->outputs()) { if (otherOutput == output || !otherOutput->isConnected() || !otherOutput->isEnabled()) { continue; } QPoint otherPos = otherOutput->pos(); if (otherPos.x() >= geom.right() && otherPos.y() >= geom.top() && otherPos.y() <= geom.bottom()) { otherPos.setX(otherPos.x() - geom.width()); } qCDebug(KSCREEN_KDED) << "Moving" << otherOutput->name() << "from" << otherOutput->pos() << "to" << otherPos; otherOutput->setPos(otherPos); } // Disable the output output->setEnabled(false); } KScreen::OutputPtr KScreenDaemon::findEmbeddedOutput(const KScreen::ConfigPtr &config) { Q_FOREACH (const KScreen::OutputPtr &output, config->outputs()) { if (output->type() == KScreen::Output::Panel) { return output; } } return KScreen::OutputPtr(); } #include "daemon.moc" diff --git a/kded/osd.cpp b/kded/osd.cpp index 7c81e45..bb4dd03 100644 --- a/kded/osd.cpp +++ b/kded/osd.cpp @@ -1,196 +1,198 @@ /* * Copyright 2014 (c) Martin Klapetek * Copyright 2016 Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "osd.h" #include "utils.h" #include #include #include #include #include #include #include #include #include #include namespace KScreen { Osd::Osd(QObject *parent) : QObject(parent) , m_osdPath(QStandardPaths::locate(QStandardPaths::QStandardPaths::GenericDataLocation, QStringLiteral("kded_kscreen/qml/Osd.qml"))) { + qDebug()<<"NEW OSD"; init(); } Osd::~Osd() { } bool Osd::setRootProperty(const char* name, const QVariant& value) { return m_osdObject->rootObject()->setProperty(name, value); } void Osd::showOutputIdentifier(const KScreen::OutputPtr output) { m_output = output; if (!init()) { return; } auto *rootObject = m_osdObject->rootObject(); auto mode = output->currentMode(); QSize realSize; if (output->isHorizontal()) { realSize = mode->size(); } else { realSize = QSize(mode->size().height(), mode->size().width()); } rootObject->setProperty("itemSource", QStringLiteral("OutputIdentifier.qml")); rootObject->setProperty("modeName", Utils::sizeToString(realSize)); rootObject->setProperty("showingProgress", false); rootObject->setProperty("outputName", Utils::outputName(output)); rootObject->setProperty("osdValue", Utils::outputName(output)); rootObject->setProperty("icon", QStringLiteral("preferences-desktop-display-randr")); showOsd(); } void Osd::updatePosition() { if (m_output == nullptr) { return; } + auto *rootObject = m_osdObject->rootObject(); const int dialogWidth = rootObject->property("width").toInt(); const int dialogHeight = rootObject->property("height").toInt(); const int relx = m_output->pos().x(); const int rely = m_output->pos().y(); const int pos_x = relx + (m_output->geometry().width() - dialogWidth) / 2; const int pos_y = rely + (m_output->geometry().height() - dialogHeight) / 2; rootObject->setProperty("x", pos_x); rootObject->setProperty("y", pos_y); } bool Osd::init() { if (m_osdObject && m_osdObject->rootObject()) { return true; } if (m_osdPath.isEmpty()) { return false; } if (!m_osdObject) { m_osdObject = new KDeclarative::QmlObject(this); } m_osdObject->setSource(QUrl::fromLocalFile(m_osdPath)); if (m_osdObject->status() != QQmlComponent::Ready) { qWarning() << "Failed to load OSD QML file" << m_osdPath; return false; } m_timeout = m_osdObject->rootObject()->property("timeout").toInt(); if (!m_osdTimer) { m_osdTimer = new QTimer(this); m_osdTimer->setSingleShot(true); connect(m_osdTimer, &QTimer::timeout, this, &Osd::hideOsd); } return true; } void Osd::showProgress(const QString &icon, const int percent, const QString &additionalText) { if (!init()) { return; } auto *rootObject = m_osdObject->rootObject(); int value = qBound(0, percent, 100); rootObject->setProperty("osdValue", value); rootObject->setProperty("osdAdditionalText", additionalText); rootObject->setProperty("showingProgress", true); rootObject->setProperty("icon", icon); emit osdProgress(icon, value, additionalText); showOsd(); } void Osd::showText(const QString &icon, const QString &text) { if (!init()) { return; } auto *rootObject = m_osdObject->rootObject(); rootObject->setProperty("showingProgress", false); rootObject->setProperty("osdValue", text); rootObject->setProperty("icon", icon); emit osdText(icon, text); showOsd(); } void Osd::showOsd() { m_osdTimer->stop(); auto *rootObject = m_osdObject->rootObject(); // if our OSD understands animating the opacity, do it; // otherwise just show it to not break existing lnf packages if (rootObject->property("animateOpacity").isValid()) { rootObject->setProperty("animateOpacity", false); rootObject->setProperty("opacity", 1); rootObject->setProperty("visible", true); rootObject->setProperty("animateOpacity", true); rootObject->setProperty("opacity", 0); } else { rootObject->setProperty("visible", true); } updatePosition(); m_osdTimer->start(m_timeout); } void Osd::hideOsd() { auto *rootObject = m_osdObject->rootObject(); if (!rootObject) { return; } rootObject->setProperty("visible", false); // this is needed to prevent fading from "old" values when the OSD shows up rootObject->setProperty("osdValue", 0); } } // ns diff --git a/kded/osdmanager.cpp b/kded/osdmanager.cpp index 2a3545f..e343d8d 100644 --- a/kded/osdmanager.cpp +++ b/kded/osdmanager.cpp @@ -1,87 +1,97 @@ /* * Copyright 2016 Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "osdmanager.h" #include "osd.h" #include #include #include #include #include #include namespace KScreen { +OsdManager* OsdManager::m_instance = 0; + OsdManager::OsdManager(QObject *parent) : QObject(parent) { } OsdManager::~OsdManager() { } +OsdManager* OsdManager::self() +{ + if (!OsdManager::m_instance) { + m_instance = new OsdManager(); + } + + return m_instance; +} + void OsdManager::showOutputIdentifiers() { connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, &OsdManager::slotIdentifyOutputs); } void OsdManager::slotIdentifyOutputs(KScreen::ConfigOperation *op) { if (op->hasError()) { return; } const KScreen::ConfigPtr config = qobject_cast(op)->config(); Q_FOREACH (const KScreen::OutputPtr &output, config->outputs()) { connect(output.data(), &KScreen::Output::isConnectedChanged, this, [this](){ KScreen::Output *output = qobject_cast(sender()); qDebug() << "outputConnectedChanged():" << output->name(); - if (!output->isConnected()) { + if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) { KScreen::Osd* osd = nullptr; - if (m_osds.keys().contains(output)) { + if (m_osds.keys().contains(output->name())) { osd->deleteLater(); - m_osds.remove(output); + m_osds.remove(output->name()); } } - }, - Qt::UniqueConnection); - if (!output->isConnected() || !output->currentMode()) { + }, Qt::UniqueConnection); + + if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) { continue; } - - const KScreen::ModePtr mode = output->currentMode(); - KScreen::Osd* osd = nullptr; - if (m_osds.keys().contains(output.data())) { - osd = m_osds.value(output.data()); + qDebug() << "output:" << output->name() << m_osds; + if (m_osds.keys().contains(output->name())) { + osd = m_osds.value(output->name()); } else { - osd = new KScreen::Osd(output.data()); + osd = new KScreen::Osd(this); + m_osds.insert(output->name(), osd); } osd->showOutputIdentifier(output); } } } diff --git a/kded/osdmanager.h b/kded/osdmanager.h index ca0ac67..70d2400 100644 --- a/kded/osdmanager.h +++ b/kded/osdmanager.h @@ -1,51 +1,56 @@ /* * Copyright 2016 Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef OSDM_H #define OSDM_H #include #include #include class QmlObject; namespace KScreen { class ConfigOperation; class Osd; class Output; class OsdManager : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kscreen.osdService") public: OsdManager(QObject *parent = nullptr); ~OsdManager() override; + static OsdManager* self(); + public Q_SLOTS: void showOutputIdentifiers(); private: void slotIdentifyOutputs(KScreen::ConfigOperation *op); - QMap m_osds; + QMap m_osds; + + static OsdManager* m_instance; + bool m_showing; }; } // ns #endif // OSDM_H diff --git a/tests/osd/CMakeLists.txt b/tests/osd/CMakeLists.txt index 370205b..b731b90 100644 --- a/tests/osd/CMakeLists.txt +++ b/tests/osd/CMakeLists.txt @@ -1,15 +1,17 @@ include_directories(${CMAKE_SOURCE_DIR}/kcm/src) add_executable(osdtest main.cpp osdtest.cpp ../../kded/osd.cpp ../../kded/osdmanager.cpp ../../kcm/src/utils.cpp) target_link_libraries(osdtest Qt5::Core Qt5::DBus Qt5::Quick Qt5::Qml KF5::Screen KF5::PlasmaQuick KF5::I18n KF5::Declarative KF5::IconThemes KF5::QuickAddons ) +add_test(kscreen-kded-osdtest osdtest) +ecm_mark_as_test(osdtest) diff --git a/tests/osd/osdtest.cpp b/tests/osd/osdtest.cpp index 02c416b..5b2ed88 100644 --- a/tests/osd/osdtest.cpp +++ b/tests/osd/osdtest.cpp @@ -1,56 +1,55 @@ /************************************************************************************* * Copyright 2016 Sebastian Kügler * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *************************************************************************************/ #include "osdtest.h" #include "../../kded/osd.h" #include "../../kded/osdmanager.h" #include "../../kcm/src/utils.h" #include #include #include #include #include #include #include #include - Q_LOGGING_CATEGORY(KSCREEN_KDED, "kscreen.kded") namespace KScreen { OsdTest::OsdTest(QObject *parent) : QObject(parent) { } OsdTest::~OsdTest() { } void OsdTest::start() { QTimer::singleShot(5500, qApp, &QCoreApplication::quit); - auto osdManager = new KScreen::OsdManager(this); - osdManager->showOutputIdentifiers(); + KScreen::OsdManager::self()->showOutputIdentifiers(); + QTimer::singleShot(200, KScreen::OsdManager::self(), &KScreen::OsdManager::showOutputIdentifiers); } } // ns \ No newline at end of file