2024-02-17 22:51:19 +00:00
|
|
|
import QtQuick 2.4
|
2024-08-09 01:20:25 +00:00
|
|
|
import QtQuick.Controls
|
|
|
|
//import QtQuick.Controls.Styles
|
2024-02-17 22:51:19 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2024-08-09 01:20:25 +00:00
|
|
|
import QtQuick.Dialogs
|
2024-02-17 22:51:19 +00:00
|
|
|
import QtQuick.Window 2.1
|
2024-08-09 01:20:25 +00:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2024-02-17 22:51:19 +00:00
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
import org.kde.plasma.core as PlasmaCore
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
2024-02-17 22:51:19 +00:00
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
2024-08-09 01:20:25 +00:00
|
|
|
import org.kde.ksvg as KSvg
|
2024-02-17 22:51:19 +00:00
|
|
|
|
|
|
|
Control {
|
|
|
|
id: genericButton
|
|
|
|
signal clicked
|
|
|
|
|
|
|
|
property string text: "";
|
|
|
|
property var iconSource: "";
|
2024-08-09 01:20:25 +00:00
|
|
|
property int iconSize: Kirigami.Units.iconSizes.smallMedium;
|
2024-02-17 22:51:19 +00:00
|
|
|
property alias label: btnLabel
|
|
|
|
|
|
|
|
Keys.priority: Keys.AfterItem
|
2024-08-09 01:20:25 +00:00
|
|
|
Keys.onPressed: (event) => {
|
2024-02-17 22:51:19 +00:00
|
|
|
if(event.key == Qt.Key_Return) {
|
|
|
|
genericButton.clicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.FrameSvgItem {
|
2024-02-17 22:51:19 +00:00
|
|
|
id: texture
|
|
|
|
z: -1
|
|
|
|
anchors.fill: parent
|
|
|
|
imagePath: Qt.resolvedUrl("../Assets/button.svg");
|
|
|
|
prefix: {
|
|
|
|
var result = "";
|
|
|
|
if(genericButton.focus) result = "focus-";
|
|
|
|
if(buttonMA.containsPress) result = "pressed";
|
|
|
|
else if(buttonMA.containsMouse) result += "hover";
|
|
|
|
else result += "normal";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MouseArea {
|
|
|
|
id: buttonMA
|
|
|
|
z: 99
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
acceptedButtons: Qt.LeftButton;
|
2024-08-09 01:20:25 +00:00
|
|
|
onClicked: (mouse) => {
|
2024-02-17 22:51:19 +00:00
|
|
|
genericButton.clicked();
|
|
|
|
}
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
Kirigami.Icon{
|
2024-02-17 22:51:19 +00:00
|
|
|
id: btnIcon
|
|
|
|
z: 0
|
|
|
|
anchors.centerIn: genericButton
|
|
|
|
width: genericButton.iconSize
|
|
|
|
height: width
|
|
|
|
animated: false
|
2024-08-09 01:20:25 +00:00
|
|
|
//usesPlasmaTheme: false
|
2024-02-17 22:51:19 +00:00
|
|
|
source: genericButton.iconSource
|
|
|
|
visible: genericButton.iconSource !== ""
|
|
|
|
}
|
|
|
|
PlasmaComponents.Label {
|
|
|
|
id: btnLabel
|
|
|
|
z: 0
|
|
|
|
anchors.fill: parent
|
|
|
|
text: genericButton.text
|
|
|
|
visible: genericButton.text !== ""
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2024-08-09 01:20:25 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
color: "white"
|
2024-02-17 22:51:19 +00:00
|
|
|
layer.enabled: genericButton.text !== ""
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
//visible: !softwareRendering
|
|
|
|
horizontalOffset: 0
|
|
|
|
verticalOffset: 1
|
|
|
|
radius: 6
|
|
|
|
samples: 14
|
|
|
|
spread: 0.0001
|
|
|
|
color: "#bf000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|