2e67f95017
The rationale is explained in https://planet.kde.org/friedrich-kossebau-2023-06-28-include-also-moc-files-of-headers/ In case of KDEConnect, it impressively speeds up compilation. Before it took 390 seconds on a clean build and with this change it took 330 seconds. This is due to the mocs_compilation having to include the header files and thus all their headers. Due to the lots of small plugins we have, this means that the same headers must be compiled plenty of times. When we include the moc files directly in the C++ file, they are already available.
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
/**
|
|
* SPDX-FileCopyrightText: 2014 Pramod Dematagoda <pmdematagoda@mykolab.ch>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
*/
|
|
|
|
#include "screensaverinhibitplugin.h"
|
|
|
|
#include "generated/systeminterfaces/screensaver.h"
|
|
#include "kdeconnect_screensaverinhibit_debug.h"
|
|
#include <KLocalizedString>
|
|
#include <KPluginFactory>
|
|
#include <QDBusConnection>
|
|
|
|
K_PLUGIN_CLASS_WITH_JSON(ScreensaverInhibitPlugin, "kdeconnect_screensaver_inhibit.json")
|
|
|
|
#define INHIBIT_SERVICE QStringLiteral("org.freedesktop.ScreenSaver")
|
|
#define INHIBIT_PATH QStringLiteral("/ScreenSaver")
|
|
|
|
ScreensaverInhibitPlugin::ScreensaverInhibitPlugin(QObject *parent, const QVariantList &args)
|
|
: KdeConnectPlugin(parent, args)
|
|
{
|
|
OrgFreedesktopScreenSaverInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, QDBusConnection::sessionBus(), this);
|
|
|
|
inhibitCookie = inhibitInterface.Inhibit(QStringLiteral("org.kde.kdeconnect.daemon"), i18n("Phone is connected"));
|
|
}
|
|
|
|
ScreensaverInhibitPlugin::~ScreensaverInhibitPlugin()
|
|
{
|
|
if (inhibitCookie == 0)
|
|
return;
|
|
|
|
OrgFreedesktopScreenSaverInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, QDBusConnection::sessionBus(), this);
|
|
inhibitInterface.UnInhibit(inhibitCookie);
|
|
|
|
/*
|
|
* Simulate user activity because what ever manages the screensaver does not seem to start the timer
|
|
* automatically when all inhibitions are lifted and the user does nothing which results in an
|
|
* unlocked desktop which would be dangerous. Ideally we should not be doing this and the screen should
|
|
* be locked anyway.
|
|
*/
|
|
inhibitInterface.SimulateUserActivity();
|
|
}
|
|
|
|
bool ScreensaverInhibitPlugin::receivePacket(const NetworkPacket &np)
|
|
{
|
|
Q_UNUSED(np);
|
|
return false;
|
|
}
|
|
|
|
#include "moc_screensaverinhibitplugin.cpp"
|
|
#include "screensaverinhibitplugin.moc"
|