Desktop: Support solid color

This commit is contained in:
cutefishd 2021-03-21 17:00:14 +08:00
parent 93b99bcf4b
commit aa449f52ad
3 changed files with 54 additions and 17 deletions

View file

@ -56,9 +56,16 @@ FolderViewDropArea {
id: settings id: settings
} }
Image { Loader {
id: wallpaper id: backgroundLoader
anchors.fill: parent anchors.fill: parent
sourceComponent: settings.backgroundType === 0 ? wallpaper : background
}
Component {
id: wallpaper
Image {
source: "file://" + settings.wallpaper source: "file://" + settings.wallpaper
sourceSize: Qt.size(width, height) sourceSize: Qt.size(width, height)
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
@ -67,8 +74,8 @@ FolderViewDropArea {
ColorOverlay { ColorOverlay {
id: dimsWallpaper id: dimsWallpaper
anchors.fill: wallpaper anchors.fill: parent
source: wallpaper source: parent
color: "#000000" color: "#000000"
opacity: Meui.Theme.darkMode && settings.dimsWallpaper ? 0.4 : 0.0 opacity: Meui.Theme.darkMode && settings.dimsWallpaper ? 0.4 : 0.0
@ -80,6 +87,16 @@ FolderViewDropArea {
} }
} }
}
Component {
id: background
Rectangle {
anchors.fill: parent
color: settings.backgroundColor
}
}
Loader { Loader {
id: folderViewLayer id: folderViewLayer

View file

@ -27,6 +27,16 @@ bool DesktopSettings::dimsWallpaper() const
return m_interface.property("darkModeDimsWallpaer").toBool(); return m_interface.property("darkModeDimsWallpaer").toBool();
} }
int DesktopSettings::backgroundType() const
{
return m_interface.property("backgroundType").toInt();
}
QString DesktopSettings::backgroundColor() const
{
return m_interface.property("backgroundColor").toString();
}
void DesktopSettings::launch(const QString &command, const QStringList &args) void DesktopSettings::launch(const QString &command, const QStringList &args)
{ {
QProcess process; QProcess process;
@ -40,6 +50,8 @@ void DesktopSettings::init()
if (m_interface.isValid()) { if (m_interface.isValid()) {
connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString))); connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString)));
connect(&m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged())); connect(&m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged()));
connect(&m_interface, SIGNAL(backgroundTypeChanged()), this, SIGNAL(backgroundTypeChanged()));
connect(&m_interface, SIGNAL(backgroundColorChanged()), this, SIGNAL(backgroundColorChanged()));
m_wallpaper = m_interface.property("wallpaper").toString(); m_wallpaper = m_interface.property("wallpaper").toString();
emit wallpaperChanged(); emit wallpaperChanged();

View file

@ -10,17 +10,25 @@ class DesktopSettings : public QObject
Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged) Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged)
Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper NOTIFY dimsWallpaperChanged) Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper NOTIFY dimsWallpaperChanged)
Q_PROPERTY(int backgroundType READ backgroundType NOTIFY backgroundTypeChanged)
Q_PROPERTY(QString backgroundColor READ backgroundColor NOTIFY backgroundColorChanged)
public: public:
explicit DesktopSettings(QObject *parent = nullptr); explicit DesktopSettings(QObject *parent = nullptr);
QString wallpaper() const; QString wallpaper() const;
bool dimsWallpaper() const; bool dimsWallpaper() const;
int backgroundType() const;
QString backgroundColor() const;
Q_INVOKABLE void launch(const QString &command, const QStringList &args); Q_INVOKABLE void launch(const QString &command, const QStringList &args);
signals: signals:
void wallpaperChanged(); void wallpaperChanged();
void dimsWallpaperChanged(); void dimsWallpaperChanged();
void backgroundColorChanged();
void backgroundTypeChanged();
private slots: private slots:
void init(); void init();