fix: plasma 6.6 compat
This commit is contained in:
3 files changed
+103
-18
No files matched your search
+3
-1
@@ -3,7 +3,9 @@
|
|||||||
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
||||||
project(applet_windowbuttons)
|
project(applet_windowbuttons)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(VERSION 0.12.0)
|
set(VERSION 0.12.0)
|
||||||
set(AUTHOR "Michail Vourlakos")
|
set(AUTHOR "Michail Vourlakos")
|
||||||
set(EMAIL "mvourlakos@gmail.com")
|
set(EMAIL "mvourlakos@gmail.com")
|
||||||
|
|||||||
@@ -13,6 +13,46 @@ import QtQuick.Layouts
|
|||||||
ComboBox {
|
ComboBox {
|
||||||
id: combobox
|
id: combobox
|
||||||
|
|
||||||
|
function fileAt(row) {
|
||||||
|
if (row < 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return combobox.model.data(combobox.model.index(row, 0), Qt.UserRole + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
function backgroundColorAt(row) {
|
||||||
|
if (row < 0)
|
||||||
|
return "transparent";
|
||||||
|
|
||||||
|
return combobox.model.data(combobox.model.index(row, 0), Qt.UserRole + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
function textColorAt(row) {
|
||||||
|
if (row < 0)
|
||||||
|
return palette.text;
|
||||||
|
|
||||||
|
return combobox.model.data(combobox.model.index(row, 0), Qt.UserRole + 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayAt(row) {
|
||||||
|
if (row < 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return combobox.model.data(combobox.model.index(row, 0), Qt.DisplayRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applySelection(row) {
|
||||||
|
if (row < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectedScheme = combobox.fileAt(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
onActivated: {
|
||||||
|
combobox.applySelection(combobox.currentIndex);
|
||||||
|
}
|
||||||
|
displayText: combobox.displayAt(combobox.currentIndex)
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onClosed() {
|
function onClosed() {
|
||||||
root.forceActiveFocus();
|
root.forceActiveFocus();
|
||||||
@@ -24,10 +64,12 @@ ComboBox {
|
|||||||
delegate: MouseArea {
|
delegate: MouseArea {
|
||||||
width: combobox.width
|
width: combobox.width
|
||||||
height: combobox.height
|
height: combobox.height
|
||||||
|
implicitHeight: combobox.height
|
||||||
|
implicitWidth: combobox.width
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
combobox.currentIndex = index;
|
combobox.currentIndex = index;
|
||||||
selectedScheme = model.file;
|
combobox.applySelection(index);
|
||||||
combobox.popup.close();
|
combobox.popup.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,12 +98,12 @@ ComboBox {
|
|||||||
Layout.leftMargin: 2
|
Layout.leftMargin: 2
|
||||||
width: 1.25 * label.height
|
width: 1.25 * label.height
|
||||||
height: label.height
|
height: label.height
|
||||||
opacity: ((file == "kdeglobals") || (file == "_plasmatheme_")) ? 0 : 1
|
opacity: ((combobox.fileAt(index) == "kdeglobals") || (combobox.fileAt(index) == "_plasmatheme_")) ? 0 : 1
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: height
|
width: height
|
||||||
height: 0.75 * label.height
|
height: 0.75 * label.height
|
||||||
color: backgroundColor
|
color: combobox.backgroundColorAt(index)
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: containsMouse || (combobox.currentIndex === index) ? palette.highlightedText : palette.text
|
border.color: containsMouse || (combobox.currentIndex === index) ? palette.highlightedText : palette.text
|
||||||
|
|
||||||
@@ -70,7 +112,7 @@ ComboBox {
|
|||||||
anchors.verticalCenter: parent.bottom
|
anchors.verticalCenter: parent.bottom
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: textColor
|
color: combobox.textColorAt(index)
|
||||||
border.width: parent.border.width
|
border.width: parent.border.width
|
||||||
border.color: parent.border.color
|
border.color: parent.border.color
|
||||||
}
|
}
|
||||||
@@ -82,7 +124,7 @@ ComboBox {
|
|||||||
Label {
|
Label {
|
||||||
id: label
|
id: label
|
||||||
|
|
||||||
text: display
|
text: combobox.displayAt(index)
|
||||||
color: containsMouse ? palette.highlightedText : palette.text
|
color: containsMouse ? palette.highlightedText : palette.text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,59 @@ ComboBox {
|
|||||||
model: sortedDecorations
|
model: sortedDecorations
|
||||||
textRole: "display"
|
textRole: "display"
|
||||||
valueRole: "plugin"
|
valueRole: "plugin"
|
||||||
onActivated: {
|
function displayAt(row) {
|
||||||
var index = combobox.currentIndex;
|
if (row < 0)
|
||||||
if (index === -1)
|
return "";
|
||||||
return ;
|
|
||||||
|
return sortedDecorations.data(sortedDecorations.index(row, 0), Qt.DisplayRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
displayText: combobox.displayAt(combobox.currentIndex)
|
||||||
|
function applySelection(row) {
|
||||||
|
if (row < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const modelIndex = sortedDecorations.index(row, 0);
|
||||||
|
const pluginRole = Qt.UserRole + 4;
|
||||||
|
const themeRole = Qt.UserRole + 5;
|
||||||
|
|
||||||
console.log(currentTheme, combobox.currentText, combobox.currentValue);
|
|
||||||
root.useCurrent = false;
|
root.useCurrent = false;
|
||||||
root.selectedPlugin = combobox.currentValue;
|
root.selectedPlugin = sortedDecorations.data(modelIndex, pluginRole);
|
||||||
root.selectedTheme = combobox.currentText;
|
root.selectedTheme = sortedDecorations.data(modelIndex, themeRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncCurrentIndexFromSelection() {
|
||||||
|
const pluginRole = Qt.UserRole + 4;
|
||||||
|
const themeRole = Qt.UserRole + 5;
|
||||||
|
|
||||||
|
for (let row = 0; row < sortedDecorations.rowCount(); ++row) {
|
||||||
|
const modelIndex = sortedDecorations.index(row, 0);
|
||||||
|
if (sortedDecorations.data(modelIndex, pluginRole) === root.currentPlugin &&
|
||||||
|
sortedDecorations.data(modelIndex, themeRole) === root.currentTheme) {
|
||||||
|
combobox.currentIndex = row;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
combobox.currentIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
onActivated: {
|
||||||
|
combobox.applySelection(combobox.currentIndex);
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
combobox.currentIndex = combobox.find(root.currentTheme);
|
combobox.syncCurrentIndexFromSelection();
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
function onCurrentThemeChanged() {
|
||||||
|
combobox.syncCurrentIndexFromSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCurrentPluginChanged() {
|
||||||
|
combobox.syncCurrentIndexFromSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
target: root
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@@ -42,12 +83,12 @@ ComboBox {
|
|||||||
delegate: MouseArea {
|
delegate: MouseArea {
|
||||||
height: combobox.height
|
height: combobox.height
|
||||||
width: combobox.width
|
width: combobox.width
|
||||||
|
implicitHeight: combobox.height
|
||||||
|
implicitWidth: combobox.width
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
combobox.currentIndex = index;
|
combobox.currentIndex = index;
|
||||||
root.useCurrent = false;
|
combobox.applySelection(index);
|
||||||
root.selectedPlugin = plugin;
|
|
||||||
root.selectedTheme = theme;
|
|
||||||
combobox.popup.close();
|
combobox.popup.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +114,7 @@ ComboBox {
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: Kirigami.Units.smallSpacing
|
anchors.leftMargin: Kirigami.Units.smallSpacing
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: display
|
text: combobox.displayAt(index)
|
||||||
color: containsMouse ? palette.highlightedText : palette.text
|
color: containsMouse ? palette.highlightedText : palette.text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user