You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
|
5 years ago
|
#include "wallpaper.h"
|
||
|
|
|
||
|
3 weeks ago
|
#include <QDBusServiceWatcher>
|
||
|
|
|
||
|
5 years ago
|
Wallpaper::Wallpaper(QObject *parent)
|
||
|
|
: QObject(parent)
|
||
|
3 weeks ago
|
, m_interface(nullptr)
|
||
|
5 years ago
|
{
|
||
|
3 weeks ago
|
// The shell starts before cutefish-services, so the signals are hooked up
|
||
|
3 weeks ago
|
// again once the service appears; without this the desktop would keep the
|
||
|
|
// background it read at startup for the rest of the session.
|
||
|
|
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(this);
|
||
|
|
watcher->setConnection(QDBusConnection::sessionBus());
|
||
|
3 weeks ago
|
watcher->addWatchedService("com.cutefish.Services");
|
||
|
3 weeks ago
|
connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &Wallpaper::init);
|
||
|
|
|
||
|
|
init();
|
||
|
|
}
|
||
|
|
|
||
|
|
void Wallpaper::init()
|
||
|
|
{
|
||
|
|
delete m_interface;
|
||
|
3 weeks ago
|
m_interface = new QDBusInterface("com.cutefish.Services",
|
||
|
|
"/com/cutefish/Services/Appearance",
|
||
|
|
"com.cutefish.Services.Appearance",
|
||
|
3 weeks ago
|
QDBusConnection::sessionBus(), this);
|
||
|
|
|
||
|
|
if (!m_interface->isValid())
|
||
|
|
return;
|
||
|
|
|
||
|
|
connect(m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onPathChanged(QString)));
|
||
|
|
connect(m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged()));
|
||
|
|
connect(m_interface, SIGNAL(backgroundTypeChanged()), this, SIGNAL(typeChanged()));
|
||
|
|
connect(m_interface, SIGNAL(backgroundColorChanged()), this, SIGNAL(colorChanged()));
|
||
|
|
connect(m_interface, SIGNAL(backgroundVisibleChanged()), this, SIGNAL(backgroundVisibleChanged()));
|
||
|
|
|
||
|
|
emit typeChanged();
|
||
|
|
emit pathChanged();
|
||
|
|
emit colorChanged();
|
||
|
|
emit dimsWallpaperChanged();
|
||
|
|
emit backgroundVisibleChanged();
|
||
|
|
}
|
||
|
|
|
||
|
|
QVariant Wallpaper::themeProperty(const char *name) const
|
||
|
|
{
|
||
|
|
return m_interface ? m_interface->property(name) : QVariant();
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
int Wallpaper::type() const
|
||
|
|
{
|
||
|
3 weeks ago
|
return themeProperty("backgroundType").toInt();
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
QString Wallpaper::path() const
|
||
|
|
{
|
||
|
3 weeks ago
|
return themeProperty("wallpaper").toString();
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
bool Wallpaper::dimsWallpaper() const
|
||
|
|
{
|
||
|
3 weeks ago
|
return themeProperty("darkModeDimsWallpaer").toBool();
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
QString Wallpaper::color() const
|
||
|
|
{
|
||
|
3 weeks ago
|
return themeProperty("backgroundColor").toString();
|
||
|
|
}
|
||
|
|
|
||
|
|
bool Wallpaper::backgroundVisible() const
|
||
|
|
{
|
||
|
|
return themeProperty("backgroundVisible").toBool();
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
void Wallpaper::onPathChanged(QString path)
|
||
|
|
{
|
||
|
|
Q_UNUSED(path);
|
||
|
|
|
||
|
|
emit pathChanged();
|
||
|
|
}
|