MauiMan

backgroundmanager.h
1#pragma once
2
3#include <QObject>
4#include <QString>
5
6#include "mauiman_export.h"
7
9namespace MauiMan
10{
11class SettingsStore;
12
13/**
14 * @brief The BackgroundManager class
15 * Helpfull for third parties to connect to property changes from the Background module setting changes.
16 */
17class MAUIMAN_EXPORT BackgroundManager : public QObject
18{
19 Q_OBJECT
20
21 /**
22 * The image file path to be used as the wallpaper background
23 */
24 Q_PROPERTY(QString wallpaperSource READ wallpaperSource WRITE setWallpaperSource NOTIFY wallpaperSourceChanged)
25
26 /**
27 * Whether the wallpaper background should have a dimmed effect. This could be used to reduce eye strain, or for a night mode effect
28 */
29 Q_PROPERTY(bool dimWallpaper READ dimWallpaper WRITE setDimWallpaper NOTIFY dimWallpaperChanged)
30
31 /**
32 * Whether the wallpaper image should fit the screen area, preserving its aspect ratio, instead of filling it
33 */
34 Q_PROPERTY(bool fitWallpaper READ fitWallpaper WRITE setFitWallpaper NOTIFY fitWallpaperChanged)
35
36 /**
37 * A color to be used in the background. If not wallpaper image is shown then, this is the color visible
38 */
39 Q_PROPERTY(QString solidColor READ solidColor WRITE setSolidColor NOTIFY solidColorChanged)
40
41 /**
42 * Whether to display the wallpaper image
43 */
44 Q_PROPERTY(bool showWallpaper READ showWallpaper WRITE setShowWallpaper NOTIFY showWallpaperChanged)
45
46 /**
47 * The preferred file path to the directory containing the wallpaper images
48 */
49 Q_PROPERTY(QString wallpaperSourceDir READ wallpaperSourceDir WRITE setWallpaperSourceDir NOTIFY wallpaperSourceDirChanged)
50
51public:
52/**
53 * @brief The DefaultValues class
54 */
56 {
57 static inline const QString wallpaperSource = QStringLiteral("qrc:/wallpapers/maui_shell_dev_bg.png");
58 static inline const bool dimWallpaper = false;
59 static inline const bool fitWallpaper = false; //false is to fill, true to fit
60 static inline const QString solidColor = QStringLiteral("#333");
61 static inline const bool showWallpaper = true;
62 static inline const QString wallpaperSourceDir = QStringLiteral("file:///usr/share/wallpapers/Cask");
63 };
64
65 explicit BackgroundManager(QObject * parent = nullptr);
66
67 QString wallpaperSource() const;
68
69 bool dimWallpaper() const;
70
71 bool fitWallpaper() const;
72
73 QString solidColor() const;
74
75 bool showWallpaper() const;
76
77 void setWallpaperSource(QString wallpaperSource);
78
79 void setDimWallpaper(bool dimWallpaper);
80
81 void setFitWallpaper(bool fitWallpaper);
82
83 void setSolidColor(QString solidColor);
84
85 void setShowWallpaper(bool showWallpaper);
86
87 QString wallpaperSourceDir() const;
88 void setWallpaperSourceDir(QString wallpaperSourceDir);
89
90private Q_SLOTS:
91 void onWallpaperChanged(const QString &wallpaperSource);
92 void onSolidColorChanged(const QString &solidColor);
93 void onFitWallpaperChanged(const bool &fitWallpaper);
94 void onDimWallpaperChanged(const bool &dimWallpaper);
95 void onShowWallpaperChanged(const bool &showWallpaper);
96
97Q_SIGNALS:
98 void wallpaperSourceChanged(QString wallpaperSource);
99 void dimWallpaperChanged(bool dimWallpaper);
100 void fitWallpaperChanged(bool fitWallpaper);
101 void solidColorChanged(QString solidColor);
102 void showWallpaperChanged(bool showWallpaper);
103 void wallpaperSourceDirChanged(QString wallpaperSourceDir);
104
105private:
106#if !defined Q_OS_ANDROID
107 QDBusInterface *m_interface = nullptr;
108#endif
109 MauiMan::SettingsStore *m_settings;
110
111 QString m_wallpaperSource = MauiMan::BackgroundManager::DefaultValues::wallpaperSource;
112 bool m_dimWallpaper = MauiMan::BackgroundManager::DefaultValues::dimWallpaper;
113 bool m_fitWallpaper = MauiMan::BackgroundManager::DefaultValues::fitWallpaper; //false is to fill, true to fit
114 QString m_solidColor = MauiMan::BackgroundManager::DefaultValues::solidColor;
115 bool m_showWallpaper = MauiMan::BackgroundManager::DefaultValues::showWallpaper;
116
117 QString m_wallpaperSourceDir = MauiMan::BackgroundManager::DefaultValues::wallpaperSourceDir;
118
119 void sync(const QString &key, const QVariant &value);
120 void setConnections();
121 void loadSettings();
122};
123}
124
The BackgroundManager class Helpfull for third parties to connect to property changes from the Backgr...
The SettingsStore class Allows to store and read settings for MauiMan from the local conf file.
The MauiMan name-space contains all of the available modules for configuring the Maui Applications an...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.