2021-03-29 01:51:34 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 CutefishOS Team.
|
|
|
|
*
|
|
|
|
* Author: revenmartin <revenmartin@gmail.com>
|
|
|
|
*
|
|
|
|
* This program 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 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program 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/>.
|
|
|
|
*/
|
|
|
|
|
2021-03-16 00:02:20 -07:00
|
|
|
#include "desktopsettings.h"
|
|
|
|
|
|
|
|
#include <QDBusServiceWatcher>
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
DesktopSettings::DesktopSettings(QObject *parent)
|
|
|
|
: QObject(parent)
|
2021-09-15 00:46:38 -07:00
|
|
|
, m_interface("com.cutefish.Settings",
|
|
|
|
"/Theme", "com.cutefish.Theme",
|
2021-03-16 00:02:20 -07:00
|
|
|
QDBusConnection::sessionBus(), this)
|
|
|
|
{
|
|
|
|
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(this);
|
|
|
|
watcher->setConnection(QDBusConnection::sessionBus());
|
2021-09-15 00:46:38 -07:00
|
|
|
watcher->addWatchedService("com.cutefish.Settings");
|
2021-03-16 00:02:20 -07:00
|
|
|
connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &DesktopSettings::init);
|
|
|
|
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DesktopSettings::wallpaper() const
|
|
|
|
{
|
|
|
|
return m_wallpaper;
|
|
|
|
}
|
|
|
|
|
2023-01-15 05:17:49 -08:00
|
|
|
bool DesktopSettings::backgroundVisible() const
|
|
|
|
{
|
|
|
|
return m_interface.property("backgroundVisible").toBool();
|
|
|
|
}
|
|
|
|
|
2021-03-16 00:02:20 -07:00
|
|
|
bool DesktopSettings::dimsWallpaper() const
|
|
|
|
{
|
|
|
|
return m_interface.property("darkModeDimsWallpaer").toBool();
|
|
|
|
}
|
|
|
|
|
2021-03-21 02:00:14 -07:00
|
|
|
int DesktopSettings::backgroundType() const
|
|
|
|
{
|
|
|
|
return m_interface.property("backgroundType").toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DesktopSettings::backgroundColor() const
|
|
|
|
{
|
|
|
|
return m_interface.property("backgroundColor").toString();
|
|
|
|
}
|
|
|
|
|
2021-03-16 00:02:20 -07:00
|
|
|
void DesktopSettings::launch(const QString &command, const QStringList &args)
|
|
|
|
{
|
|
|
|
QProcess process;
|
|
|
|
process.setProgram(command);
|
|
|
|
process.setArguments(args);
|
|
|
|
process.startDetached();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DesktopSettings::init()
|
|
|
|
{
|
|
|
|
if (m_interface.isValid()) {
|
|
|
|
connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString)));
|
|
|
|
connect(&m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged()));
|
2021-03-21 02:00:14 -07:00
|
|
|
connect(&m_interface, SIGNAL(backgroundTypeChanged()), this, SIGNAL(backgroundTypeChanged()));
|
|
|
|
connect(&m_interface, SIGNAL(backgroundColorChanged()), this, SIGNAL(backgroundColorChanged()));
|
2023-01-15 05:17:49 -08:00
|
|
|
connect(&m_interface, SIGNAL(backgroundVisibleChanged()), this, SIGNAL(backgroundVisibleChanged()));
|
2021-03-16 00:02:20 -07:00
|
|
|
m_wallpaper = m_interface.property("wallpaper").toString();
|
|
|
|
emit wallpaperChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DesktopSettings::onWallpaperChanged(QString path)
|
|
|
|
{
|
|
|
|
if (path != m_wallpaper) {
|
|
|
|
m_wallpaper = path;
|
|
|
|
emit wallpaperChanged();
|
|
|
|
}
|
|
|
|
}
|