[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kscreen/sebas/osd] kded: Addressing Kai's review, part 1
From: Sebastian_Kügler <sebas () kde ! org>
Date: 2016-12-05 22:40:52
Message-ID: E1cE1wK-00034I-EH () code ! kde ! org
[Download RAW message or body]
Git commit cc5b5e4e280111aecf94829d1f10d252f0b1e1a4 by Sebastian Kügler.
Committed on 05/12/2016 at 22:40.
Pushed by sebas into branch 'sebas/osd'.
Addressing Kai's review, part 1
M +4 -6 kded/daemon.cpp
M +13 -18 kded/osd.cpp
M +1 -5 kded/osd.h
M +7 -7 kded/osdmanager.cpp
M +1 -1 kded/osdmanager.h
https://commits.kde.org/kscreen/cc5b5e4e280111aecf94829d1f10d252f0b1e1a4
diff --git a/kded/daemon.cpp b/kded/daemon.cpp
index de67aa8..cdcc08b 100644
--- a/kded/daemon.cpp
+++ b/kded/daemon.cpp
@@ -239,8 +239,6 @@ void KScreenDaemon::showOsd(const QString &icon, const QString \
&text) );
msg << icon << text;
QDBusConnection::sessionBus().asyncCall(msg);
-
-
}
void KScreenDaemon::showOutputIdentifier()
@@ -280,15 +278,15 @@ void KScreenDaemon::applyGenericConfig()
m_iteration = Generator::DisplaySwitchAction(static_cast<int>(m_iteration) + 1);
qCDebug(KSCREEN_KDED) << "displayButton: " << m_iteration;
- QHash<Generator::DisplaySwitchAction, QString> actionMessages({
+ 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", "Embedded Off")},
- {Generator::DisplaySwitchAction::TurnOffExternal, i18nc("osd when \
displaybutton is pressed", "External Off")}, + \
{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")} });
- QString message = actionMessages.value(m_iteration);
+ 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,
diff --git a/kded/osd.cpp b/kded/osd.cpp
index 6c8b2d0..3c716f1 100644
--- a/kded/osd.cpp
+++ b/kded/osd.cpp
@@ -29,32 +29,30 @@
#include <KDeclarative/QmlObject>
-namespace KScreen {
+using namespace KScreen;
Osd::Osd(const KScreen::OutputPtr output, QObject *parent)
: QObject(parent)
, m_output(output)
- , m_osdPath(QStandardPaths::locate(QStandardPaths::QStandardPaths::GenericDataLocation, \
QStringLiteral("kded_kscreen/qml/Osd.qml"))) , m_osdObject(new \
KDeclarative::QmlObject(this)) {
- if (m_osdPath.isEmpty()) {
- qCWarning(KSCREEN_KDED) << "Failed to find OSD QML file" << m_osdPath;
+ const QString &osdPath = \
QStandardPaths::locate(QStandardPaths::QStandardPaths::GenericDataLocation, \
QStringLiteral("kded_kscreen/qml/Osd.qml")); + if (osdPath.isEmpty()) {
+ qCWarning(KSCREEN_KDED) << "Failed to find OSD QML file" << osdPath;
}
- m_osdObject->setSource(QUrl::fromLocalFile(m_osdPath));
+ m_osdObject->setSource(QUrl::fromLocalFile(osdPath));
if (m_osdObject->status() != QQmlComponent::Ready) {
- qCWarning(KSCREEN_KDED) << "Failed to load OSD QML file" << m_osdPath;
+ qCWarning(KSCREEN_KDED) << "Failed to load OSD QML file" << osdPath;
return;
}
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);
- }
+ m_osdTimer = new QTimer(this);
+ m_osdTimer->setSingleShot(true);
+ connect(m_osdTimer, &QTimer::timeout, this, &Osd::hideOsd);
}
Osd::~Osd()
@@ -78,11 +76,9 @@ void Osd::showOutputIdentifier(const KScreen::OutputPtr output)
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());
+ QSize realSize = mode->size();
+ if (!output->isHorizontal()) {
+ realSize.transpose();
}
rootObject->setProperty("itemSource", QStringLiteral("OutputIdentifier.qml"));
rootObject->setProperty("modeName", Utils::sizeToString(realSize));
@@ -117,7 +113,7 @@ 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")) {
+ if (qGuiApp->platformName() == QLatin1String("xcb")) {
rootObject->setProperty("animateOpacity", false);
rootObject->setProperty("opacity", 1);
rootObject->setProperty("visible", true);
@@ -139,4 +135,3 @@ void Osd::hideOsd()
rootObject->setProperty("visible", false);
}
-} // ns
diff --git a/kded/osd.h b/kded/osd.h
index 244fb61..93aeaf6 100644
--- a/kded/osd.h
+++ b/kded/osd.h
@@ -45,16 +45,12 @@ public:
void showGenericOsd(const QString &icon, const QString &text);
void showOutputIdentifier(const KScreen::OutputPtr output);
-
-private Q_SLOTS:
- void hideOsd();
-
private:
+ void hideOsd();
void showOsd();
void updatePosition();
KScreen::OutputPtr m_output;
- QString m_osdPath;
QRect m_outputGeometry;
KDeclarative::QmlObject *m_osdObject = nullptr;
QTimer *m_osdTimer = nullptr;
diff --git a/kded/osdmanager.cpp b/kded/osdmanager.cpp
index 8e0adca..08a7772 100644
--- a/kded/osdmanager.cpp
+++ b/kded/osdmanager.cpp
@@ -28,7 +28,7 @@
namespace KScreen {
-OsdManager* OsdManager::m_instance = 0;
+OsdManager* OsdManager::s_instance = nullptr;
OsdManager::OsdManager(QObject *parent)
: QObject(parent)
@@ -38,12 +38,12 @@ OsdManager::OsdManager(QObject *parent)
m_cleanupTimer->setInterval(60000);
m_cleanupTimer->setSingleShot(true);
connect(m_cleanupTimer, &QTimer::timeout, this, [this]() {
- qDeleteAll(m_osds.begin(), m_osds.end());
+ qDeleteAll(m_osds);
m_osds.clear();
});
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kscreen.osdService"));
- if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/kscreen/osdService"), \
this, QDBusConnection::ExportAllSlots | \
QDBusConnection::ExportAllSignals)) {
- qDebug() << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Failed to registerObject";
+ if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/kscreen/osdService"), \
this, QDBusConnection::ExportAllSlots)) { + qCWarning(KSCREEN_KDED) << "Failed \
to registerObject"; }
}
@@ -53,10 +53,10 @@ OsdManager::~OsdManager()
OsdManager* OsdManager::self()
{
- if (!OsdManager::m_instance) {
- m_instance = new OsdManager();
+ if (!OsdManager::s_instance) {
+ s_instance = new OsdManager();
}
- return m_instance;
+ return s_instance;
}
void OsdManager::showOutputIdentifiers()
diff --git a/kded/osdmanager.h b/kded/osdmanager.h
index 8cdb8cb..d75e3bf 100644
--- a/kded/osdmanager.h
+++ b/kded/osdmanager.h
@@ -49,7 +49,7 @@ private:
void slotIdentifyOutputs(KScreen::ConfigOperation *op);
QMap<QString, KScreen::Osd*> m_osds;
- static OsdManager* m_instance;
+ static OsdManager* s_instance;
QTimer* m_cleanupTimer;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic