diff --git a/kded/daemon.h b/kded/daemon.h --- a/kded/daemon.h +++ b/kded/daemon.h @@ -55,8 +55,6 @@ void configChanged(); void saveCurrentConfig(); void displayButton(); - void resetDisplaySwitch(); - void applyGenericConfig(); void lidClosedChanged(bool lidIsClosed); void lidClosedTimeout(); void setMonitorForChanges(bool enabled); @@ -77,10 +75,8 @@ void showOsd(const QString &icon, const QString &text); KScreen::ConfigPtr m_monitoredConfig; - Generator::DisplaySwitchAction m_iteration; bool m_monitoring; QTimer* m_changeCompressor; - QTimer* m_buttonTimer; QTimer* m_saveTimer; QTimer* m_lidClosedTimer; }; diff --git a/kded/daemon.cpp b/kded/daemon.cpp --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -49,10 +49,8 @@ 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)) @@ -99,10 +97,6 @@ // Initialize OSD manager to register its dbus interface KScreen::OsdManager::self(); - 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); @@ -294,52 +288,9 @@ { 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"); - } - - 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; - - static QHash actionMessages({ - {Generator::DisplaySwitchAction::None, i18nc("osd when displaybutton is pressed", "No Action")}, - {Generator::DisplaySwitchAction::Clone, i18nc("osd when displaybutton is pressed", "Cloned Display")}, - {Generator::DisplaySwitchAction::ExtendToLeft, i18nc("osd when displaybutton is pressed", "Extend Left")}, - {Generator::DisplaySwitchAction::TurnOffEmbedded, i18nc("osd when displaybutton is pressed", "External Only")}, - {Generator::DisplaySwitchAction::TurnOffExternal, i18nc("osd when displaybutton is pressed", "Internal Only")}, - {Generator::DisplaySwitchAction::ExtendToRight, i18nc("osd when displaybutton is pressed", "Extended Right")} - }); - const QString &message = actionMessages.value(m_iteration); - - // We delay the OSD for two seconds and hope that X and hardware are done setting everything up. - QTimer::singleShot(2000, - [message]() { - KScreen::OsdManager::self()->showOsd(QStringLiteral("preferences-desktop-display-randr"), message); - } - ); - - doApplyConfig(Generator::self()->displaySwitch(m_iteration)); + auto action = KScreen::OsdManager::self()->showActionSelector(); + connect(action, &KScreen::OsdAction::selected, + this, &KScreenDaemon::applyOsdAction); } void KScreenDaemon::lidClosedChanged(bool lidIsClosed) @@ -410,8 +361,6 @@ m_changeCompressor->start(); } - resetDisplaySwitch(); - KScreen::Output *output = qobject_cast(sender()); qCDebug(KSCREEN_KDED) << "outputConnectedChanged():" << output->name();