Skip to content

Commit f72d285

Browse files
committed
refactor: move components to separate files
Also fix some type and unqualified acccess warnings
1 parent 3f0de32 commit f72d285

11 files changed

Lines changed: 1319 additions & 1286 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import QtQuick
2+
import QtQuick.Effects
3+
4+
MultiEffect {
5+
// a not very effective way to recolor things that can't be recolored
6+
// the usual way
7+
id: effectRect
8+
property bool luisbocanegraPanelColorizerEffectManaged: true
9+
property Item target
10+
height: target?.height ?? 0
11+
width: target?.width ?? 0
12+
anchors.centerIn: parent
13+
source: target
14+
colorization: 1
15+
autoPaddingEnabled: false
16+
}
File renamed without changes.

package/contents/ui/components/CustomBackground.qml

Lines changed: 975 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import QtQuick
2+
import QtQuick.Layouts
3+
import org.kde.kirigami as Kirigami
4+
import org.kde.plasma.components as PlasmaComponents
5+
6+
Item {
7+
property var main
8+
Layout.minimumWidth: Kirigami.Units.gridUnit * 10
9+
Layout.minimumHeight: Kirigami.Units.gridUnit * 10
10+
Layout.maximumWidth: Kirigami.Units.gridUnit * 10
11+
Layout.maximumHeight: Kirigami.Units.gridUnit * 10
12+
13+
ColumnLayout {
14+
id: column
15+
anchors.fill: parent
16+
Kirigami.Icon {
17+
Layout.fillWidth: true
18+
Layout.preferredHeight: 64
19+
source: main.icon
20+
isMask: true
21+
color: Kirigami.Theme.negativeTextColor
22+
}
23+
PlasmaComponents.Label {
24+
text: "<font color='" + Kirigami.Theme.neutralTextColor + "'>" + i18n("Panel not found, this widget must be placed on a panel to work") + "</font>"
25+
Layout.fillWidth: true
26+
wrapMode: Text.Wrap
27+
}
28+
}
29+
}

package/contents/ui/GradientRoundedRectangle.qml renamed to package/contents/ui/components/GradientRoundedRectangle.qml

File renamed without changes.
File renamed without changes.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import QtCore
2+
import QtQuick
3+
import QtQuick.Layouts
4+
import org.kde.kirigami as Kirigami
5+
import org.kde.plasma.components as PlasmaComponents
6+
import org.kde.plasma.extras as PlasmaExtras
7+
import org.kde.plasma.plasmoid
8+
import "../"
9+
10+
ColumnLayout {
11+
id: popup
12+
property var main
13+
Layout.minimumWidth: Kirigami.Units.gridUnit * 25
14+
Layout.minimumHeight: Kirigami.Units.gridUnit * 25
15+
Layout.maximumWidth: Kirigami.Units.gridUnit * 25
16+
Layout.maximumHeight: Kirigami.Units.gridUnit * 25
17+
18+
property string presetsDir: StandardPaths.writableLocation(StandardPaths.HomeLocation).toString().substring(7) + "/.config/panel-colorizer/presets"
19+
property string cratePresetsDirCmd: "mkdir -p " + presetsDir
20+
property string presetsBuiltinDir: Qt.resolvedUrl("../presets").toString().substring(7) + "/"
21+
property string toolsDir: Qt.resolvedUrl("../tools").toString().substring(7) + "/"
22+
property string listUserPresetsCmd: "'" + toolsDir + "list_presets.sh' '" + presetsDir + "'"
23+
property string listBuiltinPresetsCmd: "'" + toolsDir + "list_presets.sh' '" + presetsBuiltinDir + "' b"
24+
property string listPresetsCmd: listBuiltinPresetsCmd + ";" + listUserPresetsCmd
25+
26+
ListModel {
27+
id: presetsModel
28+
}
29+
30+
RunCommand {
31+
id: listPresets
32+
}
33+
34+
Component.onCompleted: {
35+
listPresets.run(listPresetsCmd);
36+
}
37+
38+
Connections {
39+
target: listPresets
40+
function onExited(cmd, exitCode, exitStatus, stdout, stderr) {
41+
if (exitCode !== 0) {
42+
console.error(cmd, exitCode, exitStatus, stdout, stderr);
43+
return;
44+
}
45+
if (cmd === popup.listPresetsCmd) {
46+
if (stdout.length === 0)
47+
return;
48+
const out = stdout.trim().split("\n");
49+
for (const line of out) {
50+
let builtin = false;
51+
const parts = line.split(":");
52+
const path = parts[parts.length - 1];
53+
let name = path.split("/");
54+
name = name[name.length - 1];
55+
const dir = parts[1];
56+
if (line.startsWith("b:")) {
57+
builtin = true;
58+
}
59+
presetsModel.append({
60+
"name": name,
61+
"value": dir
62+
});
63+
}
64+
}
65+
}
66+
}
67+
ColumnLayout {
68+
visible: popup.main.runningLatest
69+
PlasmaComponents.Label {
70+
text: i18n("Select a preset")
71+
Layout.fillWidth: true
72+
font.weight: Font.DemiBold
73+
Layout.leftMargin: Kirigami.Units.smallSpacing
74+
}
75+
76+
ListView {
77+
id: listView
78+
clip: true
79+
// Layout.preferredWidth: Kirigami.Units.gridUnit * 10
80+
// Layout.preferredHeight: Kirigami.Units.gridUnit * 12
81+
Layout.fillWidth: true
82+
Layout.fillHeight: true
83+
model: presetsModel
84+
delegate: PlasmaComponents.ItemDelegate {
85+
id: presetDelegate
86+
width: ListView.view.width
87+
required property string name
88+
required property string value
89+
contentItem: RowLayout {
90+
spacing: Kirigami.Units.smallSpacing
91+
PlasmaComponents.Label {
92+
Layout.fillWidth: true
93+
text: presetDelegate.name
94+
textFormat: Text.PlainText
95+
elide: Text.ElideRight
96+
}
97+
}
98+
99+
onClicked: {
100+
popup.main.applyPreset(value);
101+
}
102+
}
103+
}
104+
}
105+
106+
ColumnLayout {
107+
visible: !popup.main.runningLatest
108+
PlasmaExtras.PlaceholderMessage {
109+
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
110+
Layout.margins: Kirigami.Units.gridUnit
111+
iconName: "dialog-warning"
112+
text: i18n("Running outdated version of %1", Plasmoid.metaData.name)
113+
}
114+
115+
PlasmaComponents.Label {
116+
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
117+
Layout.margins: Kirigami.Units.gridUnit
118+
text: i18n("Running version of the widget (%1) is different to the one on disk (%2), please log out and back in (or restart plasmashell user unit) to ensure things work correctly!", Plasmoid.metaData.version, popup.main.localVersion.version)
119+
Layout.fillWidth: true
120+
wrapMode: Text.Wrap
121+
}
122+
}
123+
}
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import QtQuick
2+
3+
Rectangle {
4+
// quickly flash a small rectangle for items that have been updated
5+
id: speedDebugItem
6+
color: "cyan"
7+
height: 4
8+
width: 4
9+
anchors.top: parent.top
10+
anchors.left: parent.left
11+
Timer {
12+
id: deleteThisTimer
13+
interval: 100
14+
onTriggered: {
15+
speedDebugItem.destroy();
16+
}
17+
}
18+
Component.onCompleted: {
19+
deleteThisTimer.start();
20+
}
21+
}

0 commit comments

Comments
 (0)