File indexing completed on 2024-05-26 04:50:02

0001 #include "background.h"
0002 #include "backgroundadaptor.h"
0003 #include <QDBusInterface>
0004 
0005 #include "settingsstore.h"
0006 
0007 #include <QDebug>
0008 
0009 Background::Background(QObject *parent) : QObject(parent)
0010 {
0011     qDebug( " INIT BACKGORUND MODULE");
0012     new BackgroundAdaptor(this);
0013     if(!QDBusConnection::sessionBus().registerObject(QStringLiteral("/Background"), this))
0014     {
0015         qDebug() << "FAILED TO REGISTER BACKGROUND DBUS OBJECT";
0016         return;
0017     }
0018     MauiMan::SettingsStore settings;
0019     settings.beginModule(QStringLiteral("Background"));
0020     m_wallpaperSource = settings.load(QStringLiteral("Wallpaper"), m_wallpaperSource).toString();
0021     m_dimWallpaper = settings.load(QStringLiteral("DimWallpaper"), m_dimWallpaper).toBool();
0022     m_fitWallpaper = settings.load(QStringLiteral("FitWallpaper"), m_fitWallpaper).toBool();
0023     m_showWallpaper = settings.load(QStringLiteral("ShowWallpaper"), m_showWallpaper).toBool();
0024     m_solidColor = settings.load(QStringLiteral("SolidColor"), m_solidColor).toString();
0025     settings.endModule();
0026 }
0027 
0028 QString Background::wallpaperSource() const
0029 {
0030     return m_wallpaperSource;
0031 }
0032 
0033 bool Background::dimWallpaper() const
0034 {
0035     return m_dimWallpaper;
0036 }
0037 
0038 bool Background::fitWallpaper() const
0039 {
0040     return m_fitWallpaper;
0041 }
0042 
0043 QString Background::solidColor() const
0044 {
0045     return m_solidColor;
0046 }
0047 
0048 bool Background::showWallpaper() const
0049 {
0050     return m_showWallpaper;
0051 }
0052 
0053 void Background::setWallpaperSource(const QString &wallpaperSource)
0054 {
0055     if (m_wallpaperSource == wallpaperSource)
0056         return;
0057 
0058     m_wallpaperSource = wallpaperSource;
0059     Q_EMIT wallpaperSourceChanged(m_wallpaperSource);
0060 }
0061 
0062 void Background::setDimWallpaper(bool dimWallpaper)
0063 {
0064     if (m_dimWallpaper == dimWallpaper)
0065         return;
0066 
0067     m_dimWallpaper = dimWallpaper;
0068     Q_EMIT dimWallpaperChanged(m_dimWallpaper);
0069 }
0070 
0071 void Background::setFitWallpaper(bool fitWallpaper)
0072 {
0073     if (m_fitWallpaper == fitWallpaper)
0074         return;
0075 
0076     m_fitWallpaper = fitWallpaper;
0077     Q_EMIT fitWallpaperChanged(m_fitWallpaper);
0078 }
0079 
0080 void Background::setSolidColor(const QString &solidColor)
0081 {
0082     if (m_solidColor == solidColor)
0083         return;
0084 
0085     m_solidColor = solidColor;
0086     Q_EMIT solidColorChanged(m_solidColor);
0087 }
0088 
0089 void Background::setShowWallpaper(bool showWallpaper)
0090 {
0091     if (m_showWallpaper == showWallpaper)
0092         return;
0093 
0094     m_showWallpaper = showWallpaper;
0095     Q_EMIT showWallpaperChanged(m_showWallpaper);
0096 }
0097 
0098