Skip to content

Commit 1fb5146

Browse files
committed
feat: misc settings UI adjustments
1 parent 7e952c9 commit 1fb5146

3 files changed

Lines changed: 155 additions & 109 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>
3+
SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
4+
5+
SPDX-License-Identifier: GPL-2.0-or-later
6+
*/
7+
8+
import QtQuick
9+
import QtQuick.Controls as QQC2
10+
import org.kde.kirigami as Kirigami
11+
import org.kde.kitemmodels as KItemModels
12+
13+
QQC2.ComboBox {
14+
id: comboBox
15+
16+
onActivated: component.select(currentIndex)
17+
18+
// HACK QQC2 doesn't support icons, so we just tamper with the desktop style ComboBox's background
19+
function loadProps() {
20+
if (!background || !background.hasOwnProperty("properties")) {
21+
//not a KQuickStyleItem
22+
return;
23+
}
24+
25+
const props = background.properties || {};
26+
27+
background.properties = Qt.binding(() => {
28+
const modelIndex = model.index(currentIndex, 0);
29+
const currentIcon = model.data(modelIndex, model.KItemModels.KRoleNames.role("icon"));
30+
return Object.assign(props, {
31+
currentIcon,
32+
iconColor: Kirigami.Theme.textColor
33+
});
34+
});
35+
}
36+
37+
Connections {
38+
target: comboBox.component
39+
function onIndexChanged() {
40+
comboBox.loadProps();
41+
}
42+
}
43+
44+
delegate: QQC2.ItemDelegate {
45+
width: ListView.view.width
46+
text: model.name
47+
highlighted: comboBox.highlightedIndex == index
48+
icon.name: model.icon
49+
// fix bottom padding on the popup
50+
leftPadding: Kirigami.Units.mediumSpacing
51+
topPadding: Kirigami.Units.mediumSpacing
52+
rightPadding: Kirigami.Units.mediumSpacing
53+
bottomPadding: Kirigami.Units.mediumSpacing
54+
}
55+
56+
Component.onCompleted: loadProps()
57+
}

package/contents/ui/components/Header.qml

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import QtQuick
22
import QtQuick.Controls
33
import QtQuick.Layouts
4+
import org.kde.plasma.plasmoid
45
import "../" as Root
56

67
RowLayout {
@@ -14,43 +15,33 @@ RowLayout {
1415
readonly property string projects: "https://github.com/" + ghUser + "?tab=repositories&q=&type=source&language=&sort=stargazers"
1516
readonly property string kdeStore: "https://store.kde.org/p/2139746"
1617
readonly property string matrixRoom: "https://matrix.to/#/#kde-plasma-smart-video-wallpaper-reborn:matrix.org"
17-
property string wallpaperVersion
18-
19-
Root.RunCommand {
20-
id: runCommand
21-
onExited: (cmd, exitCode, exitStatus, stdout, stderr) => {
22-
if (exitCode !== 0) {
23-
root.wallpaperVersion = stderr;
24-
console.log(cmd, stderr);
25-
} else {
26-
try {
27-
root.wallpaperVersion = JSON.parse(stdout).KPlugin.Version;
28-
} catch (e) {
29-
console.log(e);
30-
root.wallpaperVersion = e;
31-
}
32-
}
33-
}
34-
}
18+
property string wallpaperVersion: Plasmoid.metaData.version
3519

3620
Component.onCompleted: {
3721
const metaDataFile = Qt.resolvedUrl("../../../").toString().substring(7) + "metadata.json";
3822
console.log(metaDataFile);
39-
runCommand.run(`cat "${metaDataFile}"`);
4023
}
4124

42-
Item {
43-
Layout.fillWidth: true
25+
// RowLayout {
26+
// }
27+
Layout.alignment: Qt.AlignRight
28+
Label {
29+
text: wallpaperVersion
30+
font.weight: Font.DemiBold
4431
}
45-
RowLayout {
46-
Layout.alignment: Qt.AlignRight
47-
Label {
48-
text: i18n("Version:")
49-
}
50-
Label {
51-
text: wallpaperVersion
52-
font.weight: Font.DemiBold
32+
33+
Button {
34+
id: linksButton
35+
text: i18n("About")
36+
icon.name: "info-symbolic"
37+
onClicked: {
38+
if (menu.opened) {
39+
menu.close();
40+
} else {
41+
menu.open();
42+
}
5343
}
44+
Layout.fillHeight: true
5445
}
5546

5647
Menu {
@@ -144,15 +135,4 @@ RowLayout {
144135
icon.name: "starred-symbolic"
145136
}
146137
}
147-
ToolButton {
148-
id: linksButton
149-
icon.name: "application-menu"
150-
onClicked: {
151-
if (menu.opened) {
152-
menu.close();
153-
} else {
154-
menu.open();
155-
}
156-
}
157-
}
158138
}

0 commit comments

Comments
 (0)