Changeset View
Changeset View
Standalone View
Standalone View
kded/daemon.cpp
Show All 16 Lines | |||||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | ||
18 | *************************************************************************************/ | 18 | *************************************************************************************/ | ||
19 | 19 | | |||
20 | #include "daemon.h" | 20 | #include "daemon.h" | ||
21 | #include "serializer.h" | 21 | #include "serializer.h" | ||
22 | #include "generator.h" | 22 | #include "generator.h" | ||
23 | #include "device.h" | 23 | #include "device.h" | ||
24 | #include "kscreenadaptor.h" | 24 | #include "kscreenadaptor.h" | ||
25 | #include "osdmanager.h" | ||||
25 | #include "debug.h" | 26 | #include "debug.h" | ||
26 | 27 | | |||
27 | #include <QTimer> | 28 | #include <QTimer> | ||
28 | #include <QAction> | 29 | #include <QAction> | ||
29 | #include <QShortcut> | 30 | #include <QShortcut> | ||
30 | #include <QLoggingCategory> | 31 | #include <QLoggingCategory> | ||
31 | 32 | | |||
32 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Line(s) | 233 | { | |||
233 | QDBusMessage msg = QDBusMessage::createMethodCall( | 234 | QDBusMessage msg = QDBusMessage::createMethodCall( | ||
234 | QLatin1Literal("org.kde.plasmashell"), | 235 | QLatin1Literal("org.kde.plasmashell"), | ||
235 | QLatin1Literal("/org/kde/osdService"), | 236 | QLatin1Literal("/org/kde/osdService"), | ||
236 | QLatin1Literal("org.kde.osdService"), | 237 | QLatin1Literal("org.kde.osdService"), | ||
237 | QLatin1Literal("showText") | 238 | QLatin1Literal("showText") | ||
238 | ); | 239 | ); | ||
239 | msg << icon << text; | 240 | msg << icon << text; | ||
240 | QDBusConnection::sessionBus().asyncCall(msg); | 241 | QDBusConnection::sessionBus().asyncCall(msg); | ||
241 | } | 242 | } | ||
242 | 243 | | |||
broulik: Superfluous lines | |||||
244 | void KScreenDaemon::showOutputIdentifier() | ||||
245 | { | ||||
246 | KScreen::OsdManager::self()->showOutputIdentifiers(); | ||||
247 | } | ||||
248 | | ||||
243 | void KScreenDaemon::displayButton() | 249 | void KScreenDaemon::displayButton() | ||
244 | { | 250 | { | ||
245 | qCDebug(KSCREEN_KDED) << "displayBtn triggered"; | 251 | qCDebug(KSCREEN_KDED) << "displayBtn triggered"; | ||
246 | 252 | | |||
247 | QString message = i18nc("OSD text after XF86Display button press", "No External Display"); | 253 | QString message = i18nc("OSD text after XF86Display button press", "No External Display"); | ||
248 | if (m_monitoredConfig && m_monitoredConfig->connectedOutputs().count() > 1) { | 254 | if (m_monitoredConfig && m_monitoredConfig->connectedOutputs().count() > 1) { | ||
249 | message = i18nc("OSD text after XF86Display button press", "Changing Screen Layout"); | 255 | message = i18nc("OSD text after XF86Display button press", "Changing Screen Layout"); | ||
250 | } | 256 | } | ||
251 | showOsd(QStringLiteral("preferences-desktop-display-randr"), message); | | |||
252 | 257 | | |||
253 | if (m_buttonTimer->isActive()) { | 258 | if (m_buttonTimer->isActive()) { | ||
254 | qCDebug(KSCREEN_KDED) << "Too fast, cowboy"; | 259 | qCDebug(KSCREEN_KDED) << "Too fast, cowboy"; | ||
255 | return; | 260 | return; | ||
256 | } | 261 | } | ||
257 | 262 | | |||
258 | m_buttonTimer->start(); | 263 | m_buttonTimer->start(); | ||
259 | } | 264 | } | ||
260 | 265 | | |||
261 | void KScreenDaemon::resetDisplaySwitch() | 266 | void KScreenDaemon::resetDisplaySwitch() | ||
262 | { | 267 | { | ||
263 | qCDebug(KSCREEN_KDED) << "resetDisplaySwitch()"; | 268 | qCDebug(KSCREEN_KDED) << "resetDisplaySwitch()"; | ||
264 | m_iteration = Generator::None; | 269 | m_iteration = Generator::None; | ||
265 | } | 270 | } | ||
266 | 271 | | |||
267 | void KScreenDaemon::applyGenericConfig() | 272 | void KScreenDaemon::applyGenericConfig() | ||
268 | { | 273 | { | ||
269 | if (m_iteration == Generator::ExtendToRight) { | 274 | if (m_iteration == Generator::ExtendToRight) { | ||
270 | m_iteration = Generator::None; | 275 | m_iteration = Generator::None; | ||
271 | } | 276 | } | ||
272 | 277 | | |||
273 | m_iteration = Generator::DisplaySwitchAction(static_cast<int>(m_iteration) + 1); | 278 | m_iteration = Generator::DisplaySwitchAction(static_cast<int>(m_iteration) + 1); | ||
274 | qCDebug(KSCREEN_KDED) << "displayButton: " << m_iteration; | 279 | qCDebug(KSCREEN_KDED) << "displayButton: " << m_iteration; | ||
275 | 280 | | |||
281 | static QHash<Generator::DisplaySwitchAction, QString> actionMessages({ | ||||
broulik: static? | |||||
282 | {Generator::DisplaySwitchAction::None, i18nc("osd when displaybutton is pressed", "No Action")}, | ||||
283 | {Generator::DisplaySwitchAction::Clone, i18nc("osd when displaybutton is pressed", "Cloned Display")}, | ||||
284 | {Generator::DisplaySwitchAction::ExtendToLeft, i18nc("osd when displaybutton is pressed", "Extend Left")}, | ||||
285 | {Generator::DisplaySwitchAction::TurnOffEmbedded, i18nc("osd when displaybutton is pressed", "External Only")}, | ||||
Not sure about "Embedded", perhaps "Internal"? Dunno. Also I'd rather turn the wording around, rather than "internal off" and "external off", say "external only" and "internal only"? broulik: Not sure about "Embedded", perhaps "Internal"? Dunno.
Also I'd rather turn the wording around… | |||||
286 | {Generator::DisplaySwitchAction::TurnOffExternal, i18nc("osd when displaybutton is pressed", "Internal Only")}, | ||||
287 | {Generator::DisplaySwitchAction::ExtendToRight, i18nc("osd when displaybutton is pressed", "Extended Right")} | ||||
288 | }); | ||||
289 | const QString &message = actionMessages.value(m_iteration); | ||||
broulik: const & | |||||
290 | | ||||
291 | // We delay the OSD for two seconds and hope that X and hardware are done setting everything up. | ||||
292 | QTimer::singleShot(2000, | ||||
293 | [message]() { | ||||
294 | KScreen::OsdManager::self()->showOsd(QStringLiteral("preferences-desktop-display-randr"), message); | ||||
295 | } | ||||
296 | ); | ||||
297 | | ||||
276 | doApplyConfig(Generator::self()->displaySwitch(m_iteration)); | 298 | doApplyConfig(Generator::self()->displaySwitch(m_iteration)); | ||
277 | } | 299 | } | ||
278 | 300 | | |||
279 | void KScreenDaemon::lidClosedChanged(bool lidIsClosed) | 301 | void KScreenDaemon::lidClosedChanged(bool lidIsClosed) | ||
280 | { | 302 | { | ||
281 | // Ignore this when we don't have any external monitors, we can't turn off our | 303 | // Ignore this when we don't have any external monitors, we can't turn off our | ||
282 | // only screen | 304 | // only screen | ||
283 | if (m_monitoredConfig->connectedOutputs().count() == 1) { | 305 | if (m_monitoredConfig->connectedOutputs().count() == 1) { | ||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 446 | if (output->type() == KScreen::Output::Panel) { | |||
425 | return output; | 447 | return output; | ||
426 | } | 448 | } | ||
427 | } | 449 | } | ||
428 | 450 | | |||
429 | return KScreen::OutputPtr(); | 451 | return KScreen::OutputPtr(); | ||
430 | } | 452 | } | ||
431 | 453 | | |||
432 | 454 | | |||
433 | | ||||
434 | #include "daemon.moc" | 455 | #include "daemon.moc" |
Superfluous lines