mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-05 05:57:14 +02:00
158 lines
5.2 KiB
Diff
158 lines
5.2 KiB
Diff
From bf47a23d9edf0a584200c8aaa72c5fce18df3e89 Mon Sep 17 00:00:00 2001
|
|
From: Aster Boese <asterboese@mailbox.org>
|
|
Date: Fri, 22 Mar 2024 19:28:46 -0400
|
|
Subject: [PATCH 6/6] Change hard-coded launcher logo to one set by a resolver
|
|
|
|
---
|
|
plugins/Utils/constants.cpp | 1 +
|
|
plugins/Utils/constants.h | 3 ++
|
|
qml/Components/LogoResolver.qml | 61 +++++++++++++++++++++++++++++++++
|
|
qml/Launcher/LauncherPanel.qml | 22 ++++++++++--
|
|
4 files changed, 85 insertions(+), 2 deletions(-)
|
|
create mode 100644 qml/Components/LogoResolver.qml
|
|
|
|
diff --git a/plugins/Utils/constants.cpp b/plugins/Utils/constants.cpp
|
|
index a593c4cb9..507932882 100644
|
|
--- a/plugins/Utils/constants.cpp
|
|
+++ b/plugins/Utils/constants.cpp
|
|
@@ -29,4 +29,5 @@ Constants::Constants(QObject *parent)
|
|
|
|
QString snapRoot = QFile::decodeName(qgetenv("SNAP"));
|
|
m_defaultWallpaper = snapRoot + "/usr/share/backgrounds/lomiri-default-background.png";
|
|
+ m_defaultLogo = snapRoot + "/usr/share/lomiri/Launcher/graphics/home.svg";
|
|
}
|
|
diff --git a/plugins/Utils/constants.h b/plugins/Utils/constants.h
|
|
index c2ccc9cab..0e4eded31 100644
|
|
--- a/plugins/Utils/constants.h
|
|
+++ b/plugins/Utils/constants.h
|
|
@@ -30,14 +30,17 @@ class Constants: public QObject
|
|
Q_OBJECT
|
|
Q_PROPERTY(int indicatorValueTimeout READ indicatorValueTimeout CONSTANT)
|
|
Q_PROPERTY(QString defaultWallpaper READ defaultWallpaper CONSTANT)
|
|
+ Q_PROPERTY(QString defaultLogo READ defaultLogo CONSTANT)
|
|
|
|
public:
|
|
Constants(QObject *parent = 0);
|
|
|
|
int indicatorValueTimeout() const { return m_indicatorValueTimeout; }
|
|
QString defaultWallpaper() const { return m_defaultWallpaper; }
|
|
+ QString defaultLogo() const { return m_defaultLogo; }
|
|
|
|
private:
|
|
int m_indicatorValueTimeout;
|
|
QString m_defaultWallpaper;
|
|
+ QString m_defaultLogo;
|
|
};
|
|
diff --git a/qml/Components/LogoResolver.qml b/qml/Components/LogoResolver.qml
|
|
new file mode 100644
|
|
index 000000000..53b1bb937
|
|
--- /dev/null
|
|
+++ b/qml/Components/LogoResolver.qml
|
|
@@ -0,0 +1,61 @@
|
|
+/*
|
|
+ * Copyright (C) 2015 Canonical Ltd.
|
|
+ * Copyright (C) 2024 UBports Foundation
|
|
+ *
|
|
+ * 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; version 3.
|
|
+ *
|
|
+ * 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/>.
|
|
+ */
|
|
+
|
|
+import QtQuick 2.12
|
|
+import Lomiri.Components 1.3
|
|
+
|
|
+Item {
|
|
+ id: root
|
|
+
|
|
+ // Provide a list of logos to resolve here, preferred ones first
|
|
+ property var candidates: []
|
|
+
|
|
+ property bool cache: true
|
|
+
|
|
+ readonly property url logo: {
|
|
+ for (var i = 0; i < repeater.count; i++) {
|
|
+ var image = repeater.itemAt(i);
|
|
+ var expectedImageSource = Qt.resolvedUrl(candidates[i]);
|
|
+ if (image.source != expectedImageSource)
|
|
+ return "";
|
|
+ if (image.status === Image.Ready)
|
|
+ return candidates[i];
|
|
+ if (image.status === Image.Loading)
|
|
+ return "";
|
|
+ }
|
|
+ if (candidates.length > 0) {
|
|
+ return candidates.slice(-1)[0]; // last item is last resort
|
|
+ } else {
|
|
+ return "";
|
|
+ }
|
|
+ }
|
|
+
|
|
+ Repeater {
|
|
+ id: repeater
|
|
+ model: root.candidates.slice(0, -1)
|
|
+ delegate: Image {
|
|
+ source: modelData
|
|
+ autoTransform: true
|
|
+ asynchronous: true
|
|
+ cache: root.cache
|
|
+ height: 0
|
|
+ width: 0
|
|
+ sourceSize.height: 1
|
|
+ sourceSize.width: 1
|
|
+ }
|
|
+ }
|
|
+}
|
|
diff --git a/qml/Launcher/LauncherPanel.qml b/qml/Launcher/LauncherPanel.qml
|
|
index 8f6436ff9..c1fd43050 100644
|
|
--- a/qml/Launcher/LauncherPanel.qml
|
|
+++ b/qml/Launcher/LauncherPanel.qml
|
|
@@ -19,6 +19,7 @@ import QtQml.StateMachine 1.0 as DSM
|
|
import Lomiri.Components 1.3
|
|
import Lomiri.Launcher 0.1
|
|
import Lomiri.Components.Popups 1.3
|
|
+import GSettings 1.0
|
|
import Utils 0.1
|
|
import "../Components"
|
|
|
|
@@ -97,11 +98,28 @@ Rectangle {
|
|
width: parent.width * .6
|
|
height: width
|
|
anchors.centerIn: parent
|
|
- source: "graphics/home.svg"
|
|
- color: "white"
|
|
+ source: homeLogoResolver.logo
|
|
rotation: root.rotation
|
|
}
|
|
|
|
+ LogoResolver {
|
|
+ id: homeLogoResolver
|
|
+ objectName: "homeLogoResolver"
|
|
+
|
|
+ readonly property url defaultLogo: "file://" + Constants.defaultLogo
|
|
+ readonly property bool hasCustomLogo: logo != defaultLogo
|
|
+
|
|
+ GSettings {
|
|
+ id: logoSettings
|
|
+ schema.id: "com.lomiri.Shell.Launcher"
|
|
+ }
|
|
+
|
|
+ candidates: [
|
|
+ logoSettings.logoPictureUri,
|
|
+ defaultLogo
|
|
+ ]
|
|
+ }
|
|
+
|
|
AbstractButton {
|
|
id: dashItem
|
|
anchors.fill: parent
|
|
--
|
|
2.46.0
|
|
|