-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed the default layout spacing and added our own, to the left of each widget (or top for vertival panel) Uses a MiltiEffect mask and paddingRect to hide border/shadow when needed refs: #39
- Loading branch information
1 parent
431b3ac
commit ba5ed59
Showing
5 changed files
with
385 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQuick.Layouts | ||
import org.kde.kirigami as Kirigami | ||
|
||
Kirigami.AbstractCard { | ||
id: root | ||
property var widget | ||
signal updateWidget(unifyBgType: int) | ||
checked: widget.unifyBgType !== 0 | ||
|
||
contentItem: RowLayout { | ||
Kirigami.Icon { | ||
width: Kirigami.Units.gridUnit | ||
height: width | ||
source: widget.icon | ||
} | ||
ColumnLayout { | ||
RowLayout { | ||
Label { | ||
text: widget.title | ||
} | ||
Rectangle { | ||
visible: widget.inTray | ||
color: Kirigami.Theme.highlightColor | ||
Kirigami.Theme.colorSet: root.Kirigami.Theme["Selection"] | ||
radius: parent.height / 2 | ||
width: label.width + 12 | ||
height: label.height + 2 | ||
Kirigami.Theme.inherit: false | ||
Label { | ||
anchors.centerIn: parent | ||
id: label | ||
text: i18n("System Tray") | ||
color: Kirigami.Theme.textColor | ||
Kirigami.Theme.colorSet: root.Kirigami.Theme["Selection"] | ||
Kirigami.Theme.inherit: false | ||
} | ||
} | ||
} | ||
TextEdit { | ||
text: widget.name | ||
opacity: 0.6 | ||
readOnly: true | ||
color: Kirigami.Theme.textColor | ||
selectedTextColor: Kirigami.Theme.highlightedTextColor | ||
selectionColor: Kirigami.Theme.highlightColor | ||
} | ||
} | ||
Item { | ||
Layout.fillWidth: true | ||
} | ||
Button { | ||
text: i18n("D") | ||
checkable: true | ||
checked: widget?.unifyBgType === index | ||
icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic" | ||
Layout.preferredWidth: 50 | ||
property int index: 0 | ||
ButtonGroup.group: unifyButtonGroup | ||
} | ||
Button { | ||
text: i18n("S") | ||
checkable: true | ||
checked: widget?.unifyBgType === index | ||
icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic" | ||
Layout.preferredWidth: 50 | ||
property int index: 1 | ||
ButtonGroup.group: unifyButtonGroup | ||
} | ||
Button { | ||
text: i18n("M") | ||
checkable: true | ||
checked: widget?.unifyBgType === index | ||
icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic" | ||
Layout.preferredWidth: 50 | ||
property int index: 2 | ||
ButtonGroup.group: unifyButtonGroup | ||
} | ||
Button { | ||
text: i18n("E") | ||
checkable: true | ||
checked: widget?.unifyBgType === index | ||
icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic" | ||
property int index: 3 | ||
Layout.preferredWidth: 50 | ||
ButtonGroup.group: unifyButtonGroup | ||
} | ||
ButtonGroup { | ||
id: unifyButtonGroup | ||
onCheckedButtonChanged: { | ||
if (checkedButton) { | ||
widget.unifyBgType = checkedButton.index | ||
updateWidget(widget.unifyBgType) | ||
} | ||
} | ||
} | ||
// ComboBox { | ||
// model: ["Disabled", "Start", "Middle", "End"] | ||
// currentIndex: widget?.unifyBgType ?? 0 | ||
// onCurrentIndexChanged: { | ||
// updateWidget(currentIndex) | ||
// } | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import QtCore | ||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQuick.Layouts | ||
import org.kde.kcmutils as KCM | ||
import org.kde.kirigami as Kirigami | ||
import org.kde.plasma.plasmoid | ||
import "components" as Components | ||
import "code/utils.js" as Utils | ||
|
||
KCM.SimpleKCM { | ||
id:root | ||
property alias cfg_isEnabled: headerComponent.isEnabled | ||
property string cfg_panelWidgets | ||
property bool clearing: false | ||
property string cfg_allSettings | ||
property var config: JSON.parse(cfg_allSettings) | ||
property var unifiedBackgroundSettings | ||
property bool loaded: false | ||
property string configDir: StandardPaths.writableLocation( | ||
StandardPaths.HomeLocation).toString().substring(7) + "/.config/panel-colorizer/" | ||
property string importCmd: "cat '" + configDir + "forceForegroundColor.json'" | ||
property string crateConfigDirCmd: "mkdir -p " + configDir | ||
|
||
Component.onCompleted: { | ||
unifiedBackgroundSettings = config.unifiedBackground | ||
console.error(JSON.stringify(unifiedBackgroundSettings, null, null)) | ||
initWidgets() | ||
updateWidgetsModel() | ||
} | ||
|
||
function updateConfig() { | ||
for (let i = 0; i < widgetsModel.count; i++) { | ||
const widget = widgetsModel.get(i) | ||
const widgetName = widget.name | ||
const unifyBgType = widget.unifyBgType | ||
console.error(widgetName, unifyBgType) | ||
unifiedBackgroundSettings[widgetName] = unifyBgType | ||
} | ||
config.unifiedBackground = unifiedBackgroundSettings | ||
cfg_allSettings = JSON.stringify(config, null, null) | ||
} | ||
|
||
ListModel { | ||
id: widgetsModel | ||
} | ||
|
||
RunCommand { | ||
id: runCommand | ||
} | ||
|
||
function initWidgets(){ | ||
widgetsModel.clear() | ||
const object = JSON.parse(cfg_panelWidgets) | ||
for (const widget of object) { | ||
const name = widget.name | ||
const title = widget.title | ||
const icon = widget.icon | ||
const inTray = widget.inTray | ||
if (inTray) continue | ||
widgetsModel.append({ | ||
"name": name, "title": title, "icon": icon, "inTray":inTray, | ||
"unifyBgType": 0 | ||
}) | ||
} | ||
} | ||
|
||
function updateWidgetsModel(){ | ||
for (let i = 0; i < widgetsModel.count; i++) { | ||
const widget = widgetsModel.get(i) | ||
const name = widget.name | ||
if (name in unifiedBackgroundSettings) { | ||
let unifyBgType = unifiedBackgroundSettings[name] | ||
widgetsModel.set(i, {"unifyBgType": unifyBgType}) | ||
} else { | ||
widgetsModel.set(i, {"unifyBgType": 0}) | ||
} | ||
} | ||
loaded = true | ||
} | ||
|
||
header: ColumnLayout { | ||
Components.Header { | ||
id: headerComponent | ||
Layout.leftMargin: Kirigami.Units.mediumSpacing | ||
Layout.rightMargin: Kirigami.Units.mediumSpacing | ||
} | ||
} | ||
|
||
ColumnLayout { | ||
|
||
Kirigami.FormLayout { | ||
Kirigami.Separator { | ||
Kirigami.FormData.isSection: true | ||
Kirigami.FormData.label: i18n("Unify widget backgrounds") | ||
} | ||
} | ||
Kirigami.FormLayout { | ||
|
||
Label { | ||
text: i18n("<strong>[D]isabled</strong><br><strong>[S]tart</strong> unified background<br><strong>[M]iddle</strong>: unified background<br><strong>[E]nd</strong> unified background") | ||
opacity: 0.7 | ||
Layout.maximumWidth: widgetCards.width | ||
wrapMode: Text.Wrap | ||
} | ||
|
||
ColumnLayout { | ||
id: widgetCards | ||
Repeater { | ||
model: widgetsModel | ||
delegate: Components.WidgetCardUnifiedBg { | ||
widget: model | ||
onUpdateWidget: (unifyBgType) => { | ||
if (!loaded) return | ||
console.log(model.name, unifyBgType) | ||
widgetsModel.set(index, {"unifyBgType": unifyBgType}) | ||
root.updateConfig() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.