Commit eacbddd2 authored by Sebastian Kügler's avatar Sebastian Kügler
Browse files

Show config selection OSD when display button is pressed

Summary:
This makes the working of the display button much more intuitive.

FEATURE: 390096

Test Plan: Tested with external display plugged in, system behaves as expected

Reviewers: #plasma, dvratil

Reviewed By: dvratil

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10896
parent 5feb8430
......@@ -49,10 +49,8 @@ K_PLUGIN_FACTORY_WITH_JSON(KScreenDaemonFactory,
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 @@ void KScreenDaemon::init()
// 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 @@ void KScreenDaemon::displayButton()
{
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<int>(m_iteration) + 1);
qCDebug(KSCREEN_KDED) << "displayButton: " << m_iteration;
static QHash<Generator::DisplaySwitchAction, QString> 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 @@ void KScreenDaemon::outputConnectedChanged()
m_changeCompressor->start();
}
resetDisplaySwitch();
KScreen::Output *output = qobject_cast<KScreen::Output*>(sender());
qCDebug(KSCREEN_KDED) << "outputConnectedChanged():" << output->name();
......
......@@ -55,8 +55,6 @@ class Q_DECL_EXPORT KScreenDaemon : public KDEDModule
void configChanged();
void saveCurrentConfig();
void displayButton();
void resetDisplaySwitch();
void applyGenericConfig();
void lidClosedChanged(bool lidIsClosed);
void lidClosedTimeout();
void setMonitorForChanges(bool enabled);
......@@ -77,10 +75,8 @@ class Q_DECL_EXPORT KScreenDaemon : public KDEDModule
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;
};
......
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