File indexing completed on 2024-04-14 05:46:46

0001 /*
0002     SPDX-FileCopyrightText: 2009-2010 Tom Albers <toma@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "plasmaeffect.h"
0008 
0009 #include <QApplication>
0010 #include <QDBusInterface>
0011 #include <QDebug>
0012 #include <QScreen>
0013 
0014 PlasmaEffect::PlasmaEffect(QObject *parent)
0015     : BreakBase(parent)
0016 {
0017     // Make all other screens gray...
0018     slotGray();
0019 
0020     connect(qApp, &QGuiApplication::screenAdded, this, &PlasmaEffect::slotGray);
0021     connect(qApp, &QGuiApplication::screenRemoved, this, &PlasmaEffect::slotGray);
0022 }
0023 
0024 void PlasmaEffect::slotGray()
0025 {
0026     // Make all other screens gray...
0027     setGrayEffectOnAllScreens(true);
0028     excludeGrayEffectOnScreen(QGuiApplication::primaryScreen());
0029 }
0030 
0031 void PlasmaEffect::activate()
0032 {
0033     QDBusInterface dbus("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell");
0034     QDBusMessage reply = dbus.call(QLatin1String("setDashboardShown"), true);
0035     BreakBase::activate();
0036 
0037     if (reply.type() == QDBusMessage::ErrorMessage) {
0038         qWarning() << reply.errorMessage() << reply.errorName();
0039     }
0040 }
0041 
0042 void PlasmaEffect::deactivate()
0043 {
0044     QDBusInterface dbus("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell");
0045     QDBusMessage reply = dbus.call(QLatin1String("setDashboardShown"), false);
0046 
0047     if (reply.type() == QDBusMessage::ErrorMessage) {
0048         qWarning() << reply.errorMessage() << reply.errorName();
0049     }
0050 
0051     BreakBase::deactivate();
0052 }