[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kscreen/sebas/osd] kded: show osd later
From:       Sebastian_Kügler <sebas () kde ! org>
Date:       2016-12-05 22:40:52
Message-ID: E1cE1wK-00034I-4P () code ! kde ! org
[Download RAW message or body]

Git commit e8f82a4d326613ee6af30c54be4a07795b16a877 by Sebastian Kügler.
Committed on 05/12/2016 at 17:03.
Pushed by sebas into branch 'sebas/osd'.

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.

M  +19   -4    kded/daemon.cpp
M  +0    -5    kded/osd.cpp
M  +23   -23   kded/osdmanager.cpp
M  +2    -2    kded/qml/OsdItem.qml

https://commits.kde.org/kscreen/e8f82a4d326613ee6af30c54be4a07795b16a877

diff --git a/kded/daemon.cpp b/kded/daemon.cpp
index 784b5ac..de67aa8 100644
--- a/kded/daemon.cpp
+++ b/kded/daemon.cpp
@@ -239,6 +239,8 @@ void KScreenDaemon::showOsd(const QString &icon, const QString \
&text)  );
     msg << icon << text;
     QDBusConnection::sessionBus().asyncCall(msg);
+
+
 }
 
 void KScreenDaemon::showOutputIdentifier()
@@ -248,16 +250,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";
@@ -282,6 +280,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));
 }
 
diff --git a/kded/osd.cpp b/kded/osd.cpp
index 6227f0d..6c8b2d0 100644
--- a/kded/osd.cpp
+++ b/kded/osd.cpp
@@ -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);
diff --git a/kded/osdmanager.cpp b/kded/osdmanager.cpp
index c9e2189..b6796d6 100644
--- a/kded/osdmanager.cpp
+++ b/kded/osdmanager.cpp
@@ -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();
+        }
+    );
 }
 
 
diff --git a/kded/qml/OsdItem.qml b/kded/qml/OsdItem.qml
index 6c3a532..43750f5 100644
--- a/kded/qml/OsdItem.qml
+++ b/kded/qml/OsdItem.qml
@@ -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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic