mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-11 13:18:13 +03:00
improve/support BackgroundTracker in app
--the new implementation is much improved and easy to support. No workaround and direct use of the libraries
This commit is contained in:
parent
63187ce5b4
commit
deb9c244ff
@ -36,6 +36,8 @@
|
|||||||
#include "layouts/launcherssignals.h"
|
#include "layouts/launcherssignals.h"
|
||||||
#include "shortcuts/globalshortcuts.h"
|
#include "shortcuts/globalshortcuts.h"
|
||||||
#include "package/lattepackage.h"
|
#include "package/lattepackage.h"
|
||||||
|
#include "plasma/extended/backgroundcache.h"
|
||||||
|
#include "plasma/extended/backgroundtracker.h"
|
||||||
#include "plasma/extended/screengeometries.h"
|
#include "plasma/extended/screengeometries.h"
|
||||||
#include "plasma/extended/screenpool.h"
|
#include "plasma/extended/screenpool.h"
|
||||||
#include "plasma/extended/theme.h"
|
#include "plasma/extended/theme.h"
|
||||||
@ -148,12 +150,6 @@ Corona::Corona(bool defaultLayoutOnStartup, QString layoutNameOnStartUp, int use
|
|||||||
m_viewsScreenSyncTimer.setInterval(m_universalSettings->screenTrackerInterval());
|
m_viewsScreenSyncTimer.setInterval(m_universalSettings->screenTrackerInterval());
|
||||||
});
|
});
|
||||||
|
|
||||||
//! initialize the background tracer for broadcasted backgrounds
|
|
||||||
m_backgroundTracer = new KDeclarative::QmlObjectSharedEngine(this);
|
|
||||||
m_backgroundTracer->setInitializationDelayed(true);
|
|
||||||
m_backgroundTracer->setSource(kPackage().filePath("backgroundTracer"));
|
|
||||||
m_backgroundTracer->completeInitialization();
|
|
||||||
|
|
||||||
//! Dbus adaptor initialization
|
//! Dbus adaptor initialization
|
||||||
new LatteDockAdaptor(this);
|
new LatteDockAdaptor(this);
|
||||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||||
@ -198,7 +194,6 @@ Corona::~Corona()
|
|||||||
m_screenPool->deleteLater();
|
m_screenPool->deleteLater();
|
||||||
m_universalSettings->deleteLater();
|
m_universalSettings->deleteLater();
|
||||||
m_plasmaScreenPool->deleteLater();
|
m_plasmaScreenPool->deleteLater();
|
||||||
m_backgroundTracer->deleteLater();
|
|
||||||
m_themeExtended->deleteLater();
|
m_themeExtended->deleteLater();
|
||||||
m_indicatorFactory->deleteLater();
|
m_indicatorFactory->deleteLater();
|
||||||
|
|
||||||
@ -1245,20 +1240,12 @@ void Corona::setBackgroundFromBroadcast(QString activity, QString screenName, QS
|
|||||||
filename = filename.remove(0,7);
|
filename = filename.remove(0,7);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(m_backgroundTracer->rootObject(),
|
PlasmaExtended::BackgroundCache::self()->setBackgroundFromBroadcast(activity, screenName, filename);
|
||||||
"setBackgroundFromBroadcast",
|
|
||||||
Q_ARG(QVariant, activity),
|
|
||||||
Q_ARG(QVariant, screenName),
|
|
||||||
Q_ARG(QVariant, filename));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::setBroadcastedBackgroundsEnabled(QString activity, QString screenName, bool enabled)
|
void Corona::setBroadcastedBackgroundsEnabled(QString activity, QString screenName, bool enabled)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(m_backgroundTracer->rootObject(),
|
PlasmaExtended::BackgroundCache::self()->setBroadcastedBackgroundsEnabled(activity, screenName, enabled);
|
||||||
"setBroadcastedBackgroundsEnabled",
|
|
||||||
Q_ARG(QVariant, activity),
|
|
||||||
Q_ARG(QVariant, screenName),
|
|
||||||
Q_ARG(QVariant, enabled));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::toggleHiddenState(QString layoutName, QString screenName, int screenEdge)
|
void Corona::toggleHiddenState(QString layoutName, QString screenName, int screenEdge)
|
||||||
@ -1284,6 +1271,9 @@ inline void Corona::qmlRegisterTypes() const
|
|||||||
"Settings", // name in QML
|
"Settings", // name in QML
|
||||||
"Error: only enums of latte app settings");
|
"Error: only enums of latte app settings");
|
||||||
|
|
||||||
|
qmlRegisterType<Latte::BackgroundTracker>("org.kde.latte.private.app", 0, 1, "BackgroundTracker");
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
qmlRegisterType<QScreen>();
|
qmlRegisterType<QScreen>();
|
||||||
qmlRegisterType<Latte::View>();
|
qmlRegisterType<Latte::View>();
|
||||||
|
@ -220,8 +220,6 @@ private:
|
|||||||
|
|
||||||
QList<KDeclarative::QmlObjectSharedEngine *> m_alternativesObjects;
|
QList<KDeclarative::QmlObjectSharedEngine *> m_alternativesObjects;
|
||||||
|
|
||||||
KDeclarative::QmlObjectSharedEngine *m_backgroundTracer;
|
|
||||||
|
|
||||||
QTimer m_viewsScreenSyncTimer;
|
QTimer m_viewsScreenSyncTimer;
|
||||||
|
|
||||||
KActivities::Consumer *m_activitiesConsumer;
|
KActivities::Consumer *m_activitiesConsumer;
|
||||||
|
@ -64,8 +64,6 @@ void Package::initPackage(KPackage::Package *package)
|
|||||||
package->addFileDefinition("preset4", QStringLiteral("presets/Extended.layout.latte"), i18n("extended preset file"));
|
package->addFileDefinition("preset4", QStringLiteral("presets/Extended.layout.latte"), i18n("extended preset file"));
|
||||||
package->addFileDefinition("preset10", QStringLiteral("presets/multiple-layouts_hidden.layout.latte"), i18n("multiple layouts hidden file"));
|
package->addFileDefinition("preset10", QStringLiteral("presets/multiple-layouts_hidden.layout.latte"), i18n("multiple layouts hidden file"));
|
||||||
|
|
||||||
package->addFileDefinition("backgroundTracer", QStringLiteral("scripting/BackgroundTracer.qml"), i18n("a qml file that is used to publish broadcasted backgrounds"));
|
|
||||||
|
|
||||||
package->setFallbackPackage(fallback);
|
package->setFallbackPackage(fallback);
|
||||||
qDebug() << "package is valid" << package->isValid();
|
qDebug() << "package is valid" << package->isValid();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
set(lattedock-app_SRCS
|
set(lattedock-app_SRCS
|
||||||
${lattedock-app_SRCS}
|
${lattedock-app_SRCS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/backgroundcache.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/backgroundtracker.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/screengeometries.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/screengeometries.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/screenpool.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/screenpool.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/theme.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/theme.cpp
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "backgroundcache.h"
|
#include "backgroundcache.h"
|
||||||
|
|
||||||
// local
|
// local
|
||||||
#include "../../commontools.h"
|
#include "../../tools/commontools.h"
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QDebug>
|
#include <QDebug>
|
@ -119,14 +119,4 @@ void BackgroundTracker::update()
|
|||||||
emit isBusyChanged();
|
emit isBusyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundTracker::setBackgroundFromBroadcast(QString activity, QString screen, QString filename)
|
|
||||||
{
|
|
||||||
PlasmaExtended::BackgroundCache::self()->setBackgroundFromBroadcast(activity, screen, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BackgroundTracker::setBroadcastedBackgroundsEnabled(QString activity, QString screen, bool enabled)
|
|
||||||
{
|
|
||||||
PlasmaExtended::BackgroundCache::self()->setBroadcastedBackgroundsEnabled(activity, screen, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -59,10 +59,6 @@ public:
|
|||||||
QString screenName() const;
|
QString screenName() const;
|
||||||
void setScreenName(QString name);
|
void setScreenName(QString name);
|
||||||
|
|
||||||
public slots:
|
|
||||||
Q_INVOKABLE void setBackgroundFromBroadcast(QString activity, QString screen, QString filename);
|
|
||||||
Q_INVOKABLE void setBroadcastedBackgroundsEnabled(QString activity, QString screen, bool enabled);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activityChanged();
|
void activityChanged();
|
||||||
void currentBrightnessChanged();
|
void currentBrightnessChanged();
|
@ -23,6 +23,7 @@ import org.kde.plasma.plasmoid 2.0
|
|||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
import org.kde.latte.core 0.2 as LatteCore
|
import org.kde.latte.core 0.2 as LatteCore
|
||||||
|
import org.kde.latte.private.app 0.1 as LatteApp
|
||||||
import org.kde.latte.private.containment 0.1 as LatteContainment
|
import org.kde.latte.private.containment 0.1 as LatteContainment
|
||||||
|
|
||||||
import "../../code/ColorizerTools.js" as ColorizerTools
|
import "../../code/ColorizerTools.js" as ColorizerTools
|
||||||
@ -198,7 +199,7 @@ Loader{
|
|||||||
return applyTheme.schemeFile;
|
return applyTheme.schemeFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceComponent: LatteCore.BackgroundTracker {
|
sourceComponent: LatteApp.BackgroundTracker {
|
||||||
activity: viewLayout ? viewLayout.lastUsedActivity : ""
|
activity: viewLayout ? viewLayout.lastUsedActivity : ""
|
||||||
location: plasmoid.location
|
location: plasmoid.location
|
||||||
screenName: latteView && latteView.positioner ? latteView.positioner.currentScreenName : ""
|
screenName: latteView && latteView.positioner ? latteView.positioner.currentScreenName : ""
|
||||||
|
@ -2,16 +2,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-latte-lib.h.cmake ${CMAKE_CURR
|
|||||||
|
|
||||||
set(lattecoreplugin_SRCS
|
set(lattecoreplugin_SRCS
|
||||||
lattecoreplugin.cpp
|
lattecoreplugin.cpp
|
||||||
backgroundtracker.cpp
|
|
||||||
environment.cpp
|
environment.cpp
|
||||||
commontools.cpp
|
|
||||||
iconitem.cpp
|
iconitem.cpp
|
||||||
quickwindowsystem.cpp
|
quickwindowsystem.cpp
|
||||||
types.h
|
types.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(plasma/extended)
|
|
||||||
|
|
||||||
add_library(lattecoreplugin SHARED ${lattecoreplugin_SRCS})
|
add_library(lattecoreplugin SHARED ${lattecoreplugin_SRCS})
|
||||||
|
|
||||||
target_link_libraries(lattecoreplugin
|
target_link_libraries(lattecoreplugin
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "commontools.h"
|
|
||||||
|
|
||||||
// Qt
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QtMath>
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
|
|
||||||
float colorBrightness(QColor color)
|
|
||||||
{
|
|
||||||
return colorBrightness(color.red(), color.green(), color.blue());
|
|
||||||
}
|
|
||||||
|
|
||||||
float colorBrightness(QRgb rgb)
|
|
||||||
{
|
|
||||||
return colorBrightness(qRed(rgb), qGreen(rgb), qBlue(rgb));
|
|
||||||
}
|
|
||||||
|
|
||||||
float colorBrightness(float r, float g, float b)
|
|
||||||
{
|
|
||||||
float brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
||||||
|
|
||||||
return brightness;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float colorLumina(QRgb rgb)
|
|
||||||
{
|
|
||||||
float r = (float)(qRed(rgb)) / 255;
|
|
||||||
float g = (float)(qGreen(rgb)) / 255;
|
|
||||||
float b = (float)(qBlue(rgb)) / 255;
|
|
||||||
|
|
||||||
return colorLumina(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
float colorLumina(QColor color)
|
|
||||||
{
|
|
||||||
return colorLumina(color.redF(), color.greenF(), color.blueF());
|
|
||||||
}
|
|
||||||
|
|
||||||
float colorLumina(float r, float g, float b)
|
|
||||||
{
|
|
||||||
// formula for luminance according to:
|
|
||||||
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
||||||
|
|
||||||
float rS = (r <= 0.03928 ? r / 12.92 : qPow(((r + 0.055) / 1.055), 2.4));
|
|
||||||
float gS = (g <= 0.03928 ? g / 12.92 : qPow(((g + 0.055) / 1.055), 2.4));
|
|
||||||
float bS = (b <= 0.03928 ? b / 12.92 : qPow(((b + 0.055) / 1.055), 2.4));
|
|
||||||
|
|
||||||
float luminosity = 0.2126 * rS + 0.7152 * gS + 0.0722 * bS;
|
|
||||||
|
|
||||||
return luminosity;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString standardPath(QString subPath, bool localfirst)
|
|
||||||
{
|
|
||||||
QStringList paths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
|
|
||||||
|
|
||||||
if (localfirst) {
|
|
||||||
for (const auto &pt : paths) {
|
|
||||||
QString ptF = pt + "/" +subPath;
|
|
||||||
if (QFileInfo(ptF).exists()) {
|
|
||||||
return ptF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int i=paths.count()-1; i>=0; i--) {
|
|
||||||
QString ptF = paths[i] + "/" +subPath;
|
|
||||||
if (QFileInfo(ptF).exists()) {
|
|
||||||
return ptF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! in any case that above fails
|
|
||||||
if (QFileInfo("/usr/share/"+subPath).exists()) {
|
|
||||||
return "/usr/share/"+subPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMMONTOOLS_H
|
|
||||||
#define COMMONTOOLS_H
|
|
||||||
|
|
||||||
// Qt
|
|
||||||
#include <QColor>
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
|
|
||||||
float colorBrightness(QColor color);
|
|
||||||
float colorBrightness(QRgb rgb);
|
|
||||||
float colorBrightness(float r, float g, float b);
|
|
||||||
|
|
||||||
float colorLumina(QColor color);
|
|
||||||
float colorLumina(QRgb rgb);
|
|
||||||
float colorLumina(float r, float g, float b);
|
|
||||||
|
|
||||||
//! returns the standard path found that contains the subPath
|
|
||||||
//! local paths have higher priority by default
|
|
||||||
QString standardPath(QString subPath, bool localFirst = true);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -21,7 +21,6 @@
|
|||||||
#include "lattecoreplugin.h"
|
#include "lattecoreplugin.h"
|
||||||
|
|
||||||
// local
|
// local
|
||||||
#include "backgroundtracker.h"
|
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "iconitem.h"
|
#include "iconitem.h"
|
||||||
#include "quickwindowsystem.h"
|
#include "quickwindowsystem.h"
|
||||||
@ -36,7 +35,6 @@ void LatteCorePlugin::registerTypes(const char *uri)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.latte.core"));
|
Q_ASSERT(uri == QLatin1String("org.kde.latte.core"));
|
||||||
qmlRegisterUncreatableType<Latte::Types>(uri, 0, 2, "Types", "Latte Types uncreatable");
|
qmlRegisterUncreatableType<Latte::Types>(uri, 0, 2, "Types", "Latte Types uncreatable");
|
||||||
qmlRegisterType<Latte::BackgroundTracker>(uri, 0, 2, "BackgroundTracker");
|
|
||||||
qmlRegisterType<Latte::IconItem>(uri, 0, 2, "IconItem");
|
qmlRegisterType<Latte::IconItem>(uri, 0, 2, "IconItem");
|
||||||
qmlRegisterSingletonType<Latte::Environment>(uri, 0, 2, "Environment", &Latte::environment_qobject_singletontype_provider);
|
qmlRegisterSingletonType<Latte::Environment>(uri, 0, 2, "Environment", &Latte::environment_qobject_singletontype_provider);
|
||||||
qmlRegisterSingletonType<Latte::QuickWindowSystem>(uri, 0, 2, "WindowSystem", &Latte::windowsystem_qobject_singletontype_provider);
|
qmlRegisterSingletonType<Latte::QuickWindowSystem>(uri, 0, 2, "WindowSystem", &Latte::windowsystem_qobject_singletontype_provider);
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
set(lattecoreplugin_SRCS
|
|
||||||
${lattecoreplugin_SRCS}
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/backgroundcache.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/screenpool.cpp
|
|
||||||
PARENT_SCOPE
|
|
||||||
)
|
|
@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "screenpool.h"
|
|
||||||
|
|
||||||
// Qt
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QScreen>
|
|
||||||
|
|
||||||
// KDE
|
|
||||||
#include <KConfigGroup>
|
|
||||||
#include <KDirWatch>
|
|
||||||
#include <KSharedConfig>
|
|
||||||
|
|
||||||
#define PLASMARC "plasmashellrc"
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
namespace PlasmaExtended {
|
|
||||||
|
|
||||||
ScreenPool::ScreenPool(QObject *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
{
|
|
||||||
KSharedConfigPtr plasmaPtr = KSharedConfig::openConfig(PLASMARC);
|
|
||||||
m_screensGroup = KConfigGroup(plasmaPtr, "ScreenConnectors");
|
|
||||||
|
|
||||||
load();
|
|
||||||
|
|
||||||
QString plasmaSettingsFile = QDir::homePath() + "/.config/" + PLASMARC;
|
|
||||||
|
|
||||||
KDirWatch::self()->addFile(plasmaSettingsFile);
|
|
||||||
|
|
||||||
connect(KDirWatch::self(), &KDirWatch::dirty, this, [ &, plasmaSettingsFile](const QString & path) {
|
|
||||||
if (path == plasmaSettingsFile) {
|
|
||||||
load();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(KDirWatch::self(), &KDirWatch::created, this, [ &, plasmaSettingsFile](const QString & path) {
|
|
||||||
if (path == plasmaSettingsFile) {
|
|
||||||
load();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ScreenPool::~ScreenPool()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenPool::load()
|
|
||||||
{
|
|
||||||
QMap<int, QString> connectorForId = m_connectorForId;
|
|
||||||
QHash<QString, int> idForConnector = m_idForConnector;
|
|
||||||
|
|
||||||
m_connectorForId.clear();
|
|
||||||
m_idForConnector.clear();
|
|
||||||
|
|
||||||
bool updated{false};
|
|
||||||
|
|
||||||
for (const auto &screenId : m_screensGroup.keyList()) {
|
|
||||||
QString screenName = m_screensGroup.readEntry(screenId, QString());
|
|
||||||
if (screenId != 0) {
|
|
||||||
int scrId = screenId.toInt();
|
|
||||||
insertScreenMapping(scrId, screenName);
|
|
||||||
|
|
||||||
if (!connectorForId.contains(scrId) || connectorForId[scrId] != m_connectorForId[scrId]) {
|
|
||||||
updated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! If there are changes then print the new plasma screen ids and send a relevant signal
|
|
||||||
if (connectorForId.count() != m_connectorForId.count()) {
|
|
||||||
updated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updated) {
|
|
||||||
qDebug() << "---------------- Plasma Screen Ids ------------------";
|
|
||||||
for (const auto &id : m_connectorForId.keys()) {
|
|
||||||
qDebug() << id << " __ " << m_connectorForId[id];
|
|
||||||
}
|
|
||||||
qDebug() << "---------------- --------------- ------------------";
|
|
||||||
|
|
||||||
emit idsChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenPool::insertScreenMapping(int id, const QString &connector)
|
|
||||||
{
|
|
||||||
if (id==0 || connector.startsWith(":")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_connectorForId[id] = connector;
|
|
||||||
m_idForConnector[connector] = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScreenPool::id(const QString &connector) const
|
|
||||||
{
|
|
||||||
if (!m_idForConnector.contains(connector)) {
|
|
||||||
//! return 0 for primary screen, -1 for not found
|
|
||||||
return qGuiApp->primaryScreen()->name() == connector ? 0 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_idForConnector.value(connector);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ScreenPool::connector(int id) const
|
|
||||||
{
|
|
||||||
if (!m_connectorForId.contains(id)) {
|
|
||||||
return id == 0 ? qGuiApp->primaryScreen()->name() : QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_connectorForId.value(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PLASMASCREENPOOL_H
|
|
||||||
#define PLASMASCREENPOOL_H
|
|
||||||
|
|
||||||
// Qt
|
|
||||||
#include <QHash>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
// KDE
|
|
||||||
#include <KConfigGroup>
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
namespace PlasmaExtended {
|
|
||||||
|
|
||||||
class ScreenPool: public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ScreenPool(QObject *parent = nullptr);
|
|
||||||
~ScreenPool() override;
|
|
||||||
|
|
||||||
int id(const QString &connector) const;
|
|
||||||
QString connector(int id) const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void idsChanged();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void load();
|
|
||||||
void insertScreenMapping(int id, const QString &connector);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QHash<int, QString> m_screens;
|
|
||||||
|
|
||||||
//order is important
|
|
||||||
QMap<int, QString> m_connectorForId;
|
|
||||||
QHash<QString, int> m_idForConnector;
|
|
||||||
|
|
||||||
KConfigGroup m_screensGroup;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.7
|
|
||||||
import org.kde.latte.core 0.2 as LatteCore
|
|
||||||
|
|
||||||
Item{
|
|
||||||
LatteCore.BackgroundTracker {
|
|
||||||
id: backgroundTracker
|
|
||||||
}
|
|
||||||
|
|
||||||
function setBackgroundFromBroadcast(activity, screen, filename) {
|
|
||||||
console.log(" Background Tracer set image ::: " + activity + " _ " + screen + " _ " + filename);
|
|
||||||
backgroundTracker.setBackgroundFromBroadcast(activity, screen, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setBroadcastedBackgroundsEnabled(activity, screen, enabled) {
|
|
||||||
console.log(" Background Tracer State ::: " + activity + " _ " + screen + " _ " + enabled);
|
|
||||||
backgroundTracker.setBroadcastedBackgroundsEnabled(activity, screen, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user