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

show osd later

This patch moves the OSD to a later point. As we're setting the mode,
the display changes, so we now wait a bit after setting, and then show
the OSD to indicate what happened. This uses some timer magic to delay
the OSD since we really don't want to start showing it while outputs
still change, ... but ... X11.
parent 757cf9fd
......@@ -242,6 +242,8 @@ void KScreenDaemon::showOsd(const QString &icon, const QString &text)
);
msg << icon << text;
QDBusConnection::sessionBus().asyncCall(msg);
}
void KScreenDaemon::showOutputIdentifier()
......@@ -251,16 +253,12 @@ void KScreenDaemon::showOutputIdentifier()
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";
......@@ -285,6 +283,23 @@ void KScreenDaemon::applyGenericConfig()
m_iteration = Generator::DisplaySwitchAction(static_cast<int>(m_iteration) + 1);
qCDebug(KSCREEN_KDED) << "displayButton: " << m_iteration;
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", "Embedded Off")},
{Generator::DisplaySwitchAction::TurnOffExternal, i18nc("osd when displaybutton is pressed", "External Off")},
{Generator::DisplaySwitchAction::ExtendToRight, i18nc("osd when displaybutton is pressed", "Extended Right")}
});
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));
}
......
......@@ -68,7 +68,6 @@ void Osd::showGenericOsd(const QString &icon, const QString &text)
rootObject->setProperty("itemSource", QStringLiteral("OsdItem.qml"));
rootObject->setProperty("infoText", text);
rootObject->setProperty("icon", icon);
qCDebug(KSCREEN_KDED) << "icon / text:" << icon << text;
showOsd();
}
......@@ -88,7 +87,6 @@ void Osd::showOutputIdentifier(const KScreen::OutputPtr output)
rootObject->setProperty("itemSource", QStringLiteral("OutputIdentifier.qml"));
rootObject->setProperty("modeName", Utils::sizeToString(realSize));
rootObject->setProperty("outputName", Utils::outputName(output));
//rootObject->setProperty("icon", QStringLiteral("preferences-desktop-display-randr"));
showOsd();
}
......@@ -109,8 +107,6 @@ void Osd::updatePosition()
rootObject->setProperty("x", pos_x);
rootObject->setProperty("y", pos_y);
qCDebug(KSCREEN_KDED) << "pos:" << QPoint(pos_x, pos_y);
}
void Osd::showOsd()
......@@ -122,7 +118,6 @@ void Osd::showOsd()
// only animate on X11, wayland plugin doesn't support this and
// pukes loads of warnings into our logs
if (qGuiApp->platformName() == QStringLiteral("xcb")) {
qCDebug(KSCREEN_KDED) << "vibsible";
rootObject->setProperty("animateOpacity", false);
rootObject->setProperty("opacity", 1);
rootObject->setProperty("visible", true);
......
......@@ -25,8 +25,6 @@
#include <KScreen/Output>
#include <QDBusConnection>
#include <QLoggingCategory>
#include <QDebug>
namespace KScreen {
......@@ -90,30 +88,32 @@ void OsdManager::slotIdentifyOutputs(KScreen::ConfigOperation *op)
void OsdManager::showOsd(const QString& icon, const QString& text)
{
qDeleteAll(m_osds);
m_osds.clear();
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished,
this, [this, icon, text] (KScreen::ConfigOperation *op) {
qCDebug(KSCREEN_KDED) << "whoooooopwhoooooopwhoooooop";
if (op->hasError()) {
return;
}
this, [this, icon, text] (KScreen::ConfigOperation *op) {
if (op->hasError()) {
return;
}
const KScreen::ConfigPtr config = qobject_cast<KScreen::GetConfigOperation*>(op)->config();
const KScreen::ConfigPtr config = qobject_cast<KScreen::GetConfigOperation*>(op)->config();
Q_FOREACH (const KScreen::OutputPtr &output, config->outputs()) {
if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) {
continue;
}
KScreen::Osd* osd = nullptr;
if (m_osds.keys().contains(output->name())) {
osd = m_osds.value(output->name());
} else {
osd = new KScreen::Osd(output, this);
m_osds.insert(output->name(), osd);
}
osd->showGenericOsd(icon, text);
Q_FOREACH (const KScreen::OutputPtr &output, config->outputs()) {
if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) {
continue;
}
m_cleanupTimer->start();
});
KScreen::Osd* osd = nullptr;
if (m_osds.keys().contains(output->name())) {
osd = m_osds.value(output->name());
} else {
osd = new KScreen::Osd(output, this);
m_osds.insert(output->name(), osd);
}
osd->showGenericOsd(icon, text);
}
m_cleanupTimer->start();
}
);
}
......
......@@ -20,7 +20,7 @@ import QtQuick 2.5
import QtQuick.Window 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtra
import org.kde.plasma.extras 2.0 as PlasmaExtras
Item {
property QtObject rootItem
......@@ -35,7 +35,7 @@ Item {
source: rootItem.icon
}
PlasmaExtra.Heading {
PlasmaExtras.Heading {
id: label
anchors {
bottom: parent.bottom
......
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