mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-27 06:03:51 +03:00
track files for schemes changes
--track changes for wm default scheme --track changes for colors in specific scheme
This commit is contained in:
parent
e1712dded4
commit
59f66233f2
@ -23,8 +23,10 @@
|
||||
#include "waylandinterface.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <QQuickWindow>
|
||||
|
||||
#include <KDirWatch>
|
||||
#include <KWindowSystem>
|
||||
|
||||
namespace Latte {
|
||||
@ -32,15 +34,23 @@ namespace Latte {
|
||||
AbstractWindowInterface::AbstractWindowInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
QString defaultSchemePath = SchemeColors::possibleSchemeFile("kdeglobals");
|
||||
SchemeColors *dScheme = new SchemeColors(this, defaultSchemePath);
|
||||
|
||||
m_schemes["kdeglobals"] = dScheme;
|
||||
m_schemes[defaultSchemePath] = dScheme;
|
||||
updateDefaultScheme();
|
||||
|
||||
connect(this, &AbstractWindowInterface::windowRemoved, this, [&](WindowId wid) {
|
||||
m_windowScheme.remove(wid);
|
||||
});
|
||||
|
||||
//! track for changing default scheme
|
||||
QString kdeSettingsFile = QDir::homePath() + "/.config/kdeglobals";
|
||||
|
||||
KDirWatch::self()->addFile(kdeSettingsFile);
|
||||
|
||||
QObject::connect(KDirWatch::self(), &KDirWatch::dirty,
|
||||
this, &AbstractWindowInterface::updateDefaultScheme,
|
||||
Qt::QueuedConnection);
|
||||
QObject::connect(KDirWatch::self(), &KDirWatch::created,
|
||||
this, &AbstractWindowInterface::updateDefaultScheme,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
AbstractWindowInterface::~AbstractWindowInterface()
|
||||
@ -67,6 +77,23 @@ void AbstractWindowInterface::removeDock(WindowId wid)
|
||||
|
||||
|
||||
//! Scheme support for windows
|
||||
void AbstractWindowInterface::updateDefaultScheme()
|
||||
{
|
||||
QString defaultSchemePath = SchemeColors::possibleSchemeFile("kdeglobals");
|
||||
|
||||
SchemeColors *dScheme;
|
||||
|
||||
if (!m_schemes.contains(defaultSchemePath)) {
|
||||
dScheme = new SchemeColors(this, defaultSchemePath);
|
||||
} else {
|
||||
dScheme = m_schemes[defaultSchemePath];
|
||||
}
|
||||
|
||||
if (!m_schemes.contains("kdeglobal") || m_schemes["kdeglobals"]->schemeFile() != defaultSchemePath) {
|
||||
m_schemes["kdeglobals"] = dScheme;
|
||||
}
|
||||
}
|
||||
|
||||
SchemeColors *AbstractWindowInterface::schemeForWindow(WindowId wid)
|
||||
{
|
||||
if (!m_windowScheme.contains(wid)) {
|
||||
|
@ -101,6 +101,9 @@ protected:
|
||||
std::list<WindowId> m_docks;
|
||||
QPointer<KActivities::Consumer> m_activities;
|
||||
|
||||
private slots:
|
||||
void updateDefaultScheme();
|
||||
|
||||
private:
|
||||
//! scheme file and its loaded colors
|
||||
QMap<QString, SchemeColors *> m_schemes;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KDirWatch>
|
||||
#include <KSharedConfig>
|
||||
|
||||
namespace Latte {
|
||||
@ -37,6 +38,16 @@ SchemeColors::SchemeColors(QObject *parent, QString scheme) :
|
||||
if (QFileInfo(pSchemeFile).exists()) {
|
||||
m_schemeFile = pSchemeFile;
|
||||
m_schemeName = scheme;
|
||||
|
||||
//! track scheme file for changes
|
||||
KDirWatch::self()->addFile(m_schemeFile);
|
||||
|
||||
QObject::connect(KDirWatch::self(), &KDirWatch::dirty,
|
||||
this, &SchemeColors::updateScheme,
|
||||
Qt::QueuedConnection);
|
||||
QObject::connect(KDirWatch::self(), &KDirWatch::created,
|
||||
this, &SchemeColors::updateScheme,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
updateScheme();
|
||||
|
Loading…
x
Reference in New Issue
Block a user