mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 23:42:51 -05:00
sysmon: change spacing of monitor widgets
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Modules.Plugins
|
import qs.Modules.Plugins
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -15,7 +14,7 @@ BasePill {
|
|||||||
property var widgetData: null
|
property var widgetData: null
|
||||||
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
||||||
|
|
||||||
signal cpuClicked()
|
signal cpuClicked
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
DgopService.addRef(["cpu"]);
|
DgopService.addRef(["cpu"]);
|
||||||
@@ -26,7 +25,7 @@ BasePill {
|
|||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
Item {
|
Item {
|
||||||
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuContent.implicitWidth
|
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuContentRoot.implicitWidth
|
||||||
implicitHeight: root.isVerticalOrientation ? cpuColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
implicitHeight: root.isVerticalOrientation ? cpuColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -66,55 +65,78 @@ BasePill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: cpuContent
|
id: cpuContentRoot
|
||||||
visible: !root.isVerticalOrientation
|
visible: !root.isVerticalOrientation
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: 3
|
|
||||||
|
|
||||||
DankIcon {
|
implicitWidth: cpuRow.implicitWidth
|
||||||
name: "memory"
|
implicitHeight: cpuRow.implicitHeight
|
||||||
size: Theme.barIconSize(root.barThickness)
|
|
||||||
color: {
|
Row {
|
||||||
if (DgopService.cpuUsage > 80) {
|
id: cpuRow
|
||||||
return Theme.tempDanger;
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
id: cpuIcon
|
||||||
|
name: "memory"
|
||||||
|
size: Theme.barIconSize(root.barThickness)
|
||||||
|
color: {
|
||||||
|
if (DgopService.cpuUsage > 80) {
|
||||||
|
return Theme.tempDanger;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DgopService.cpuUsage > 60) {
|
||||||
|
return Theme.tempWarning;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Theme.widgetIconColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DgopService.cpuUsage > 60) {
|
implicitWidth: size
|
||||||
return Theme.tempWarning;
|
implicitHeight: size
|
||||||
|
width: size
|
||||||
|
height: size
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: textBox
|
||||||
|
|
||||||
|
implicitWidth: root.minimumWidth ? Math.max(cpuBaseline.width, cpuText.paintedWidth) : cpuText.paintedWidth
|
||||||
|
implicitHeight: cpuText.implicitHeight
|
||||||
|
|
||||||
|
width: implicitWidth
|
||||||
|
height: implicitHeight
|
||||||
|
|
||||||
|
Behavior on width {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Theme.widgetIconColor;
|
StyledTextMetrics {
|
||||||
}
|
id: cpuBaseline
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
}
|
text: "88%"
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: {
|
|
||||||
if (DgopService.cpuUsage === undefined || DgopService.cpuUsage === null || DgopService.cpuUsage === 0) {
|
|
||||||
return "--%";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DgopService.cpuUsage.toFixed(0) + "%";
|
StyledText {
|
||||||
}
|
id: cpuText
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
text: {
|
||||||
color: Theme.widgetTextColor
|
const v = DgopService.cpuUsage;
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
if (v === undefined || v === null || v === 0) {
|
||||||
horizontalAlignment: Text.AlignLeft
|
return "--%";
|
||||||
elide: Text.ElideNone
|
}
|
||||||
|
return v.toFixed(0) + "%";
|
||||||
|
}
|
||||||
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
|
color: Theme.widgetTextColor
|
||||||
|
|
||||||
StyledTextMetrics {
|
anchors.fill: parent
|
||||||
id: cpuBaseline
|
horizontalAlignment: Text.AlignHCenter
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
verticalAlignment: Text.AlignVCenter
|
||||||
text: "100%"
|
elide: Text.ElideNone
|
||||||
}
|
|
||||||
|
|
||||||
width: root.minimumWidth ? Math.max(cpuBaseline.width, paintedWidth) : paintedWidth
|
|
||||||
|
|
||||||
Behavior on width {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 120
|
|
||||||
easing.type: Easing.OutCubic
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,8 +149,8 @@ BasePill {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onPressed: {
|
onPressed: {
|
||||||
DgopService.setSortBy("cpu")
|
DgopService.setSortBy("cpu");
|
||||||
cpuClicked()
|
cpuClicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Modules.Plugins
|
import qs.Modules.Plugins
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -15,7 +14,7 @@ BasePill {
|
|||||||
property var widgetData: null
|
property var widgetData: null
|
||||||
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
||||||
|
|
||||||
signal cpuTempClicked()
|
signal cpuTempClicked
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
DgopService.addRef(["cpu"]);
|
DgopService.addRef(["cpu"]);
|
||||||
@@ -26,7 +25,7 @@ BasePill {
|
|||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
Item {
|
Item {
|
||||||
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuTempContent.implicitWidth
|
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuTempContentRoot.implicitWidth
|
||||||
implicitHeight: root.isVerticalOrientation ? cpuTempColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
implicitHeight: root.isVerticalOrientation ? cpuTempColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -66,55 +65,78 @@ BasePill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: cpuTempContent
|
id: cpuTempContentRoot
|
||||||
visible: !root.isVerticalOrientation
|
visible: !root.isVerticalOrientation
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: 3
|
|
||||||
|
|
||||||
DankIcon {
|
implicitWidth: cpuTempRow.implicitWidth
|
||||||
name: "device_thermostat"
|
implicitHeight: cpuTempRow.implicitHeight
|
||||||
size: Theme.barIconSize(root.barThickness)
|
|
||||||
color: {
|
Row {
|
||||||
if (DgopService.cpuTemperature > 85) {
|
id: cpuTempRow
|
||||||
return Theme.tempDanger;
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
id: cpuTempIcon
|
||||||
|
name: "device_thermostat"
|
||||||
|
size: Theme.barIconSize(root.barThickness)
|
||||||
|
color: {
|
||||||
|
if (DgopService.cpuTemperature > 85) {
|
||||||
|
return Theme.tempDanger;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DgopService.cpuTemperature > 69) {
|
||||||
|
return Theme.tempWarning;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Theme.widgetIconColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DgopService.cpuTemperature > 69) {
|
implicitWidth: size
|
||||||
return Theme.tempWarning;
|
implicitHeight: size
|
||||||
|
width: size
|
||||||
|
height: size
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: textBox
|
||||||
|
|
||||||
|
implicitWidth: root.minimumWidth ? Math.max(tempBaseline.width, cpuTempText.paintedWidth) : cpuTempText.paintedWidth
|
||||||
|
implicitHeight: cpuTempText.implicitHeight
|
||||||
|
|
||||||
|
width: implicitWidth
|
||||||
|
height: implicitHeight
|
||||||
|
|
||||||
|
Behavior on width {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Theme.widgetIconColor;
|
StyledTextMetrics {
|
||||||
}
|
id: tempBaseline
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
}
|
text: "88°"
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: {
|
|
||||||
if (DgopService.cpuTemperature === undefined || DgopService.cpuTemperature === null || DgopService.cpuTemperature < 0) {
|
|
||||||
return "--°";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(DgopService.cpuTemperature) + "°";
|
StyledText {
|
||||||
}
|
id: cpuTempText
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
text: {
|
||||||
color: Theme.widgetTextColor
|
if (DgopService.cpuTemperature === undefined || DgopService.cpuTemperature === null || DgopService.cpuTemperature < 0) {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
return "--°";
|
||||||
horizontalAlignment: Text.AlignLeft
|
}
|
||||||
elide: Text.ElideNone
|
|
||||||
|
|
||||||
StyledTextMetrics {
|
return Math.round(DgopService.cpuTemperature) + "°";
|
||||||
id: tempBaseline
|
}
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
text: "100°"
|
color: Theme.widgetTextColor
|
||||||
}
|
|
||||||
|
|
||||||
width: root.minimumWidth ? Math.max(tempBaseline.width, paintedWidth) : paintedWidth
|
anchors.fill: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
Behavior on width {
|
verticalAlignment: Text.AlignVCenter
|
||||||
NumberAnimation {
|
elide: Text.ElideNone
|
||||||
duration: 120
|
|
||||||
easing.type: Easing.OutCubic
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,8 +149,8 @@ BasePill {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onPressed: {
|
onPressed: {
|
||||||
DgopService.setSortBy("cpu")
|
DgopService.setSortBy("cpu");
|
||||||
cpuTempClicked()
|
cpuTempClicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Modules.Plugins
|
import qs.Modules.Plugins
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -16,7 +15,7 @@ BasePill {
|
|||||||
property int selectedGpuIndex: (widgetData && widgetData.selectedGpuIndex !== undefined) ? widgetData.selectedGpuIndex : 0
|
property int selectedGpuIndex: (widgetData && widgetData.selectedGpuIndex !== undefined) ? widgetData.selectedGpuIndex : 0
|
||||||
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
|
||||||
|
|
||||||
signal gpuTempClicked()
|
signal gpuTempClicked
|
||||||
|
|
||||||
property real displayTemp: {
|
property real displayTemp: {
|
||||||
if (!DgopService.availableGpus || DgopService.availableGpus.length === 0) {
|
if (!DgopService.availableGpus || DgopService.availableGpus.length === 0) {
|
||||||
@@ -32,9 +31,9 @@ BasePill {
|
|||||||
|
|
||||||
function updateWidgetPciId(pciId) {
|
function updateWidgetPciId(pciId) {
|
||||||
const sections = ["left", "center", "right"];
|
const sections = ["left", "center", "right"];
|
||||||
const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default")
|
const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default");
|
||||||
if (!defaultBar) return
|
if (!defaultBar)
|
||||||
|
return;
|
||||||
for (let s = 0; s < sections.length; s++) {
|
for (let s = 0; s < sections.length; s++) {
|
||||||
const sectionId = sections[s];
|
const sectionId = sections[s];
|
||||||
let widgets = [];
|
let widgets = [];
|
||||||
@@ -61,7 +60,7 @@ BasePill {
|
|||||||
} else if (sectionId === "right") {
|
} else if (sectionId === "right") {
|
||||||
SettingsData.setDankBarRightWidgets(widgets);
|
SettingsData.setDankBarRightWidgets(widgets);
|
||||||
}
|
}
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +93,7 @@ BasePill {
|
|||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
Item {
|
Item {
|
||||||
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : gpuTempContent.implicitWidth
|
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : gpuTempContentRoot.implicitWidth
|
||||||
implicitHeight: root.isVerticalOrientation ? gpuTempColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
implicitHeight: root.isVerticalOrientation ? gpuTempColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -134,55 +133,78 @@ BasePill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: gpuTempContent
|
id: gpuTempContentRoot
|
||||||
visible: !root.isVerticalOrientation
|
visible: !root.isVerticalOrientation
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: 3
|
|
||||||
|
|
||||||
DankIcon {
|
implicitWidth: gpuTempRow.implicitWidth
|
||||||
name: "auto_awesome_mosaic"
|
implicitHeight: gpuTempRow.implicitHeight
|
||||||
size: Theme.barIconSize(root.barThickness)
|
|
||||||
color: {
|
Row {
|
||||||
if (root.displayTemp > 80) {
|
id: gpuTempRow
|
||||||
return Theme.tempDanger;
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
id: gpuTempIcon
|
||||||
|
name: "auto_awesome_mosaic"
|
||||||
|
size: Theme.barIconSize(root.barThickness)
|
||||||
|
color: {
|
||||||
|
if (root.displayTemp > 80) {
|
||||||
|
return Theme.tempDanger;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.displayTemp > 65) {
|
||||||
|
return Theme.tempWarning;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Theme.widgetIconColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.displayTemp > 65) {
|
implicitWidth: size
|
||||||
return Theme.tempWarning;
|
implicitHeight: size
|
||||||
|
width: size
|
||||||
|
height: size
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: textBox
|
||||||
|
|
||||||
|
implicitWidth: root.minimumWidth ? Math.max(gpuTempBaseline.width, gpuTempText.paintedWidth) : gpuTempText.paintedWidth
|
||||||
|
implicitHeight: gpuTempText.implicitHeight
|
||||||
|
|
||||||
|
width: implicitWidth
|
||||||
|
height: implicitHeight
|
||||||
|
|
||||||
|
Behavior on width {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Theme.widgetIconColor;
|
StyledTextMetrics {
|
||||||
}
|
id: gpuTempBaseline
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
}
|
text: "88°"
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: {
|
|
||||||
if (root.displayTemp === undefined || root.displayTemp === null || root.displayTemp === 0) {
|
|
||||||
return "--°";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(root.displayTemp) + "°";
|
StyledText {
|
||||||
}
|
id: gpuTempText
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
text: {
|
||||||
color: Theme.widgetTextColor
|
if (root.displayTemp === undefined || root.displayTemp === null || root.displayTemp === 0) {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
return "--°";
|
||||||
horizontalAlignment: Text.AlignLeft
|
}
|
||||||
elide: Text.ElideNone
|
|
||||||
|
|
||||||
StyledTextMetrics {
|
return Math.round(root.displayTemp) + "°";
|
||||||
id: gpuTempBaseline
|
}
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
text: "100°"
|
color: Theme.widgetTextColor
|
||||||
}
|
|
||||||
|
|
||||||
width: root.minimumWidth ? Math.max(gpuTempBaseline.width, paintedWidth) : paintedWidth
|
anchors.fill: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
Behavior on width {
|
verticalAlignment: Text.AlignVCenter
|
||||||
NumberAnimation {
|
elide: Text.ElideNone
|
||||||
duration: 120
|
|
||||||
easing.type: Easing.OutCubic
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,8 +217,8 @@ BasePill {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onPressed: {
|
onPressed: {
|
||||||
DgopService.setSortBy("cpu")
|
DgopService.setSortBy("cpu");
|
||||||
gpuTempClicked()
|
gpuTempClicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Modules.Plugins
|
import qs.Modules.Plugins
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -17,7 +16,7 @@ BasePill {
|
|||||||
property bool showSwap: (widgetData && widgetData.showSwap !== undefined) ? widgetData.showSwap : false
|
property bool showSwap: (widgetData && widgetData.showSwap !== undefined) ? widgetData.showSwap : false
|
||||||
readonly property real swapUsage: DgopService.totalSwapKB > 0 ? (DgopService.usedSwapKB / DgopService.totalSwapKB) * 100 : 0
|
readonly property real swapUsage: DgopService.totalSwapKB > 0 ? (DgopService.usedSwapKB / DgopService.totalSwapKB) * 100 : 0
|
||||||
|
|
||||||
signal ramClicked()
|
signal ramClicked
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
DgopService.addRef(["memory"]);
|
DgopService.addRef(["memory"]);
|
||||||
@@ -28,7 +27,7 @@ BasePill {
|
|||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
Item {
|
Item {
|
||||||
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : ramContent.implicitWidth
|
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : ramContentRoot.implicitWidth
|
||||||
implicitHeight: root.isVerticalOrientation ? ramColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
implicitHeight: root.isVerticalOrientation ? ramColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -76,68 +75,91 @@ BasePill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: ramContent
|
id: ramContentRoot
|
||||||
visible: !root.isVerticalOrientation
|
visible: !root.isVerticalOrientation
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: 3
|
|
||||||
|
|
||||||
DankIcon {
|
implicitWidth: ramRow.implicitWidth
|
||||||
name: "developer_board"
|
implicitHeight: ramRow.implicitHeight
|
||||||
size: Theme.barIconSize(root.barThickness)
|
|
||||||
color: {
|
|
||||||
if (DgopService.memoryUsage > 90) {
|
|
||||||
return Theme.tempDanger;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DgopService.memoryUsage > 75) {
|
Row {
|
||||||
return Theme.tempWarning;
|
id: ramRow
|
||||||
}
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
return Theme.widgetIconColor;
|
DankIcon {
|
||||||
}
|
id: ramIcon
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
name: "developer_board"
|
||||||
}
|
size: Theme.barIconSize(root.barThickness)
|
||||||
|
color: {
|
||||||
StyledText {
|
if (DgopService.memoryUsage > 90) {
|
||||||
text: {
|
return Theme.tempDanger;
|
||||||
if (DgopService.memoryUsage === undefined || DgopService.memoryUsage === null || DgopService.memoryUsage === 0) {
|
|
||||||
return "--%";
|
|
||||||
}
|
|
||||||
|
|
||||||
let ramText = DgopService.memoryUsage.toFixed(0) + "%";
|
|
||||||
if (root.showSwap && DgopService.totalSwapKB > 0) {
|
|
||||||
return ramText + " · " + root.swapUsage.toFixed(0) + "%";
|
|
||||||
}
|
|
||||||
return ramText;
|
|
||||||
}
|
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
|
||||||
color: Theme.widgetTextColor
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
horizontalAlignment: Text.AlignLeft
|
|
||||||
elide: Text.ElideNone
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
|
|
||||||
StyledTextMetrics {
|
|
||||||
id: ramBaseline
|
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
|
||||||
text: {
|
|
||||||
if (!root.showSwap) {
|
|
||||||
return "100%";
|
|
||||||
}
|
}
|
||||||
if (root.swapUsage < 10) {
|
|
||||||
return "100% · 0%";
|
if (DgopService.memoryUsage > 75) {
|
||||||
|
return Theme.tempWarning;
|
||||||
}
|
}
|
||||||
return "100% · 100%";
|
|
||||||
|
return Theme.widgetIconColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implicitWidth: size
|
||||||
|
implicitHeight: size
|
||||||
|
width: size
|
||||||
|
height: size
|
||||||
}
|
}
|
||||||
|
|
||||||
width: root.minimumWidth ? Math.max(ramBaseline.width, paintedWidth) : paintedWidth
|
Item {
|
||||||
|
id: textBox
|
||||||
|
|
||||||
Behavior on width {
|
implicitWidth: root.minimumWidth ? Math.max(ramBaseline.width, ramText.paintedWidth) : ramText.paintedWidth
|
||||||
NumberAnimation {
|
implicitHeight: ramText.implicitHeight
|
||||||
duration: 120
|
|
||||||
easing.type: Easing.OutCubic
|
width: implicitWidth
|
||||||
|
height: implicitHeight
|
||||||
|
|
||||||
|
Behavior on width {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledTextMetrics {
|
||||||
|
id: ramBaseline
|
||||||
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
|
text: {
|
||||||
|
if (!root.showSwap) {
|
||||||
|
return "88%";
|
||||||
|
}
|
||||||
|
if (root.swapUsage < 10) {
|
||||||
|
return "88% · 0%";
|
||||||
|
}
|
||||||
|
return "88% · 88%";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: ramText
|
||||||
|
text: {
|
||||||
|
if (DgopService.memoryUsage === undefined || DgopService.memoryUsage === null || DgopService.memoryUsage === 0) {
|
||||||
|
return "--%";
|
||||||
|
}
|
||||||
|
|
||||||
|
let ramText = DgopService.memoryUsage.toFixed(0) + "%";
|
||||||
|
if (root.showSwap && DgopService.totalSwapKB > 0) {
|
||||||
|
return ramText + " · " + root.swapUsage.toFixed(0) + "%";
|
||||||
|
}
|
||||||
|
return ramText;
|
||||||
|
}
|
||||||
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
|
color: Theme.widgetTextColor
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideNone
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,8 +172,8 @@ BasePill {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onPressed: {
|
onPressed: {
|
||||||
DgopService.setSortBy("memory")
|
DgopService.setSortBy("memory");
|
||||||
ramClicked()
|
ramClicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Modals.Common
|
import qs.Modals.Common
|
||||||
@@ -18,108 +17,108 @@ DankModal {
|
|||||||
property bool isLoading: false
|
property bool isLoading: false
|
||||||
property var parentModal: null
|
property var parentModal: null
|
||||||
|
|
||||||
width: 600
|
modalWidth: 600
|
||||||
height: 650
|
modalHeight: 650
|
||||||
allowStacking: true
|
allowStacking: true
|
||||||
backgroundOpacity: 0
|
backgroundOpacity: 0
|
||||||
closeOnEscapeKey: false
|
closeOnEscapeKey: false
|
||||||
|
|
||||||
function updateFilteredPlugins() {
|
function updateFilteredPlugins() {
|
||||||
var filtered = []
|
var filtered = [];
|
||||||
var query = searchQuery ? searchQuery.toLowerCase() : ""
|
var query = searchQuery ? searchQuery.toLowerCase() : "";
|
||||||
|
|
||||||
for (var i = 0; i < allPlugins.length; i++) {
|
for (var i = 0; i < allPlugins.length; i++) {
|
||||||
var plugin = allPlugins[i]
|
var plugin = allPlugins[i];
|
||||||
var isFirstParty = plugin.firstParty || false
|
var isFirstParty = plugin.firstParty || false;
|
||||||
|
|
||||||
if (!SessionData.showThirdPartyPlugins && !isFirstParty) {
|
if (!SessionData.showThirdPartyPlugins && !isFirstParty) {
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.length > 0) {
|
if (query.length > 0) {
|
||||||
var name = plugin.name ? plugin.name.toLowerCase() : ""
|
var name = plugin.name ? plugin.name.toLowerCase() : "";
|
||||||
var description = plugin.description ? plugin.description.toLowerCase() : ""
|
var description = plugin.description ? plugin.description.toLowerCase() : "";
|
||||||
var author = plugin.author ? plugin.author.toLowerCase() : ""
|
var author = plugin.author ? plugin.author.toLowerCase() : "";
|
||||||
|
|
||||||
if (name.indexOf(query) !== -1 ||
|
if (name.indexOf(query) !== -1 || description.indexOf(query) !== -1 || author.indexOf(query) !== -1) {
|
||||||
description.indexOf(query) !== -1 ||
|
filtered.push(plugin);
|
||||||
author.indexOf(query) !== -1) {
|
|
||||||
filtered.push(plugin)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filtered.push(plugin)
|
filtered.push(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredPlugins = filtered
|
filteredPlugins = filtered;
|
||||||
selectedIndex = -1
|
selectedIndex = -1;
|
||||||
keyboardNavigationActive = false
|
keyboardNavigationActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectNext() {
|
function selectNext() {
|
||||||
if (filteredPlugins.length === 0) return
|
if (filteredPlugins.length === 0)
|
||||||
keyboardNavigationActive = true
|
return;
|
||||||
selectedIndex = Math.min(selectedIndex + 1, filteredPlugins.length - 1)
|
keyboardNavigationActive = true;
|
||||||
|
selectedIndex = Math.min(selectedIndex + 1, filteredPlugins.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectPrevious() {
|
function selectPrevious() {
|
||||||
if (filteredPlugins.length === 0) return
|
if (filteredPlugins.length === 0)
|
||||||
keyboardNavigationActive = true
|
return;
|
||||||
selectedIndex = Math.max(selectedIndex - 1, -1)
|
keyboardNavigationActive = true;
|
||||||
|
selectedIndex = Math.max(selectedIndex - 1, -1);
|
||||||
if (selectedIndex === -1) {
|
if (selectedIndex === -1) {
|
||||||
keyboardNavigationActive = false
|
keyboardNavigationActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function installPlugin(pluginName) {
|
function installPlugin(pluginName) {
|
||||||
ToastService.showInfo("Installing plugin: " + pluginName)
|
ToastService.showInfo("Installing plugin: " + pluginName);
|
||||||
DMSService.install(pluginName, response => {
|
DMSService.install(pluginName, response => {
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
ToastService.showError("Install failed: " + response.error)
|
ToastService.showError("Install failed: " + response.error);
|
||||||
} else {
|
} else {
|
||||||
ToastService.showInfo("Plugin installed: " + pluginName)
|
ToastService.showInfo("Plugin installed: " + pluginName);
|
||||||
PluginService.scanPlugins()
|
PluginService.scanPlugins();
|
||||||
refreshPlugins()
|
refreshPlugins();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshPlugins() {
|
function refreshPlugins() {
|
||||||
isLoading = true
|
isLoading = true;
|
||||||
DMSService.listPlugins()
|
DMSService.listPlugins();
|
||||||
if (DMSService.apiVersion >= 8) {
|
if (DMSService.apiVersion >= 8) {
|
||||||
DMSService.listInstalled()
|
DMSService.listInstalled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
if (parentModal) {
|
if (parentModal) {
|
||||||
parentModal.shouldHaveFocus = false
|
parentModal.shouldHaveFocus = false;
|
||||||
}
|
}
|
||||||
open()
|
open();
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (contentLoader.item && contentLoader.item.searchField) {
|
if (contentLoader.item && contentLoader.item.searchField) {
|
||||||
contentLoader.item.searchField.forceActiveFocus()
|
contentLoader.item.searchField.forceActiveFocus();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
close()
|
close();
|
||||||
if (parentModal) {
|
if (parentModal) {
|
||||||
parentModal.shouldHaveFocus = Qt.binding(() => {
|
parentModal.shouldHaveFocus = Qt.binding(() => {
|
||||||
return parentModal.shouldBeVisible
|
return parentModal.shouldBeVisible;
|
||||||
})
|
});
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (parentModal.modalFocusScope) {
|
if (parentModal.modalFocusScope) {
|
||||||
parentModal.modalFocusScope.forceActiveFocus()
|
parentModal.modalFocusScope.forceActiveFocus();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
refreshPlugins()
|
refreshPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@@ -127,23 +126,23 @@ DankModal {
|
|||||||
function onLoaded() {
|
function onLoaded() {
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (contentLoader.item && contentLoader.item.searchField) {
|
if (contentLoader.item && contentLoader.item.searchField) {
|
||||||
contentLoader.item.searchField.forceActiveFocus()
|
contentLoader.item.searchField.forceActiveFocus();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDialogClosed: () => {
|
onDialogClosed: () => {
|
||||||
allPlugins = []
|
allPlugins = [];
|
||||||
searchQuery = ""
|
searchQuery = "";
|
||||||
filteredPlugins = []
|
filteredPlugins = [];
|
||||||
selectedIndex = -1
|
selectedIndex = -1;
|
||||||
keyboardNavigationActive = false
|
keyboardNavigationActive = false;
|
||||||
isLoading = false
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackgroundClicked: () => {
|
onBackgroundClicked: () => {
|
||||||
hide()
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
@@ -155,19 +154,19 @@ DankModal {
|
|||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
browserSearchField.forceActiveFocus()
|
browserSearchField.forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onPressed: event => {
|
Keys.onPressed: event => {
|
||||||
if (event.key === Qt.Key_Escape) {
|
if (event.key === Qt.Key_Escape) {
|
||||||
root.close()
|
root.close();
|
||||||
event.accepted = true
|
event.accepted = true;
|
||||||
} else if (event.key === Qt.Key_Down) {
|
} else if (event.key === Qt.Key_Down) {
|
||||||
root.selectNext()
|
root.selectNext();
|
||||||
event.accepted = true
|
event.accepted = true;
|
||||||
} else if (event.key === Qt.Key_Up) {
|
} else if (event.key === Qt.Key_Up) {
|
||||||
root.selectPrevious()
|
root.selectPrevious();
|
||||||
event.accepted = true
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,10 +214,10 @@ DankModal {
|
|||||||
height: 28
|
height: 28
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (SessionData.showThirdPartyPlugins) {
|
if (SessionData.showThirdPartyPlugins) {
|
||||||
SessionData.setShowThirdPartyPlugins(false)
|
SessionData.setShowThirdPartyPlugins(false);
|
||||||
root.updateFilteredPlugins()
|
root.updateFilteredPlugins();
|
||||||
} else {
|
} else {
|
||||||
thirdPartyConfirmModal.open()
|
thirdPartyConfirmModal.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,8 +277,8 @@ DankModal {
|
|||||||
ignoreLeftRightKeys: true
|
ignoreLeftRightKeys: true
|
||||||
keyForwardTargets: [browserKeyHandler]
|
keyForwardTargets: [browserKeyHandler]
|
||||||
onTextEdited: {
|
onTextEdited: {
|
||||||
root.searchQuery = text
|
root.searchQuery = text;
|
||||||
root.updateFilteredPlugins()
|
root.updateFilteredPlugins();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,13 +349,8 @@ DankModal {
|
|||||||
property bool isSelected: root.keyboardNavigationActive && index === root.selectedIndex
|
property bool isSelected: root.keyboardNavigationActive && index === root.selectedIndex
|
||||||
property bool isInstalled: modelData.installed || false
|
property bool isInstalled: modelData.installed || false
|
||||||
property bool isFirstParty: modelData.firstParty || false
|
property bool isFirstParty: modelData.firstParty || false
|
||||||
color: isSelected ? Theme.primarySelected :
|
color: isSelected ? Theme.primarySelected : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
|
||||||
Qt.rgba(Theme.surfaceVariant.r,
|
border.color: isSelected ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||||
Theme.surfaceVariant.g,
|
|
||||||
Theme.surfaceVariant.b,
|
|
||||||
0.3)
|
|
||||||
border.color: isSelected ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g,
|
|
||||||
Theme.outline.b, 0.2)
|
|
||||||
border.width: isSelected ? 2 : 1
|
border.width: isSelected ? 2 : 1
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -435,9 +429,9 @@ DankModal {
|
|||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: {
|
text: {
|
||||||
const author = "by " + (modelData.author || "Unknown")
|
const author = "by " + (modelData.author || "Unknown");
|
||||||
const source = modelData.repo ? ` • <a href="${modelData.repo}" style="text-decoration:none; color:${Theme.primary};">source</a>` : ""
|
const source = modelData.repo ? ` • <a href="${modelData.repo}" style="text-decoration:none; color:${Theme.primary};">source</a>` : "";
|
||||||
return author + source
|
return author + source;
|
||||||
}
|
}
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.outline
|
color: Theme.outline
|
||||||
@@ -502,7 +496,7 @@ DankModal {
|
|||||||
enabled: !isInstalled
|
enabled: !isInstalled
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!isInstalled) {
|
if (!isInstalled) {
|
||||||
root.installPlugin(modelData.name)
|
root.installPlugin(modelData.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -563,8 +557,8 @@ DankModal {
|
|||||||
DankModal {
|
DankModal {
|
||||||
id: thirdPartyConfirmModal
|
id: thirdPartyConfirmModal
|
||||||
|
|
||||||
width: 500
|
modalWidth: 500
|
||||||
height: 300
|
modalHeight: 300
|
||||||
allowStacking: true
|
allowStacking: true
|
||||||
backgroundOpacity: 0.4
|
backgroundOpacity: 0.4
|
||||||
closeOnEscapeKey: true
|
closeOnEscapeKey: true
|
||||||
@@ -576,8 +570,8 @@ DankModal {
|
|||||||
|
|
||||||
Keys.onPressed: event => {
|
Keys.onPressed: event => {
|
||||||
if (event.key === Qt.Key_Escape) {
|
if (event.key === Qt.Key_Escape) {
|
||||||
thirdPartyConfirmModal.close()
|
thirdPartyConfirmModal.close();
|
||||||
event.accepted = true
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,9 +650,9 @@ DankModal {
|
|||||||
text: I18n.tr("I Understand")
|
text: I18n.tr("I Understand")
|
||||||
iconName: "check"
|
iconName: "check"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
SessionData.setShowThirdPartyPlugins(true)
|
SessionData.setShowThirdPartyPlugins(true);
|
||||||
root.updateFilteredPlugins()
|
root.updateFilteredPlugins();
|
||||||
thirdPartyConfirmModal.close()
|
thirdPartyConfirmModal.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,327 +20,318 @@ DankModal {
|
|||||||
|
|
||||||
function updateFilteredWidgets() {
|
function updateFilteredWidgets() {
|
||||||
if (!searchQuery || searchQuery.length === 0) {
|
if (!searchQuery || searchQuery.length === 0) {
|
||||||
filteredWidgets = allWidgets.slice()
|
filteredWidgets = allWidgets.slice();
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var filtered = []
|
var filtered = [];
|
||||||
var query = searchQuery.toLowerCase()
|
var query = searchQuery.toLowerCase();
|
||||||
|
|
||||||
for (var i = 0; i < allWidgets.length; i++) {
|
for (var i = 0; i < allWidgets.length; i++) {
|
||||||
var widget = allWidgets[i]
|
var widget = allWidgets[i];
|
||||||
var text = widget.text ? widget.text.toLowerCase() : ""
|
var text = widget.text ? widget.text.toLowerCase() : "";
|
||||||
var description = widget.description ? widget.description.toLowerCase() : ""
|
var description = widget.description ? widget.description.toLowerCase() : "";
|
||||||
var id = widget.id ? widget.id.toLowerCase() : ""
|
var id = widget.id ? widget.id.toLowerCase() : "";
|
||||||
|
|
||||||
if (text.indexOf(query) !== -1 ||
|
if (text.indexOf(query) !== -1 || description.indexOf(query) !== -1 || id.indexOf(query) !== -1) {
|
||||||
description.indexOf(query) !== -1 ||
|
filtered.push(widget);
|
||||||
id.indexOf(query) !== -1) {
|
|
||||||
filtered.push(widget)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredWidgets = filtered
|
filteredWidgets = filtered;
|
||||||
selectedIndex = -1
|
selectedIndex = -1;
|
||||||
keyboardNavigationActive = false
|
keyboardNavigationActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onAllWidgetsChanged: {
|
onAllWidgetsChanged: {
|
||||||
updateFilteredWidgets()
|
updateFilteredWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectNext() {
|
function selectNext() {
|
||||||
if (filteredWidgets.length === 0) return
|
if (filteredWidgets.length === 0)
|
||||||
keyboardNavigationActive = true
|
return;
|
||||||
selectedIndex = Math.min(selectedIndex + 1, filteredWidgets.length - 1)
|
keyboardNavigationActive = true;
|
||||||
|
selectedIndex = Math.min(selectedIndex + 1, filteredWidgets.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectPrevious() {
|
function selectPrevious() {
|
||||||
if (filteredWidgets.length === 0) return
|
if (filteredWidgets.length === 0)
|
||||||
keyboardNavigationActive = true
|
return;
|
||||||
selectedIndex = Math.max(selectedIndex - 1, -1)
|
keyboardNavigationActive = true;
|
||||||
|
selectedIndex = Math.max(selectedIndex - 1, -1);
|
||||||
if (selectedIndex === -1) {
|
if (selectedIndex === -1) {
|
||||||
keyboardNavigationActive = false
|
keyboardNavigationActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectWidget() {
|
function selectWidget() {
|
||||||
if (selectedIndex >= 0 && selectedIndex < filteredWidgets.length) {
|
if (selectedIndex >= 0 && selectedIndex < filteredWidgets.length) {
|
||||||
var widget = filteredWidgets[selectedIndex]
|
var widget = filteredWidgets[selectedIndex];
|
||||||
root.widgetSelected(widget.id, root.targetSection)
|
root.widgetSelected(widget.id, root.targetSection);
|
||||||
root.close()
|
root.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
if (parentModal) {
|
if (parentModal) {
|
||||||
parentModal.shouldHaveFocus = false
|
parentModal.shouldHaveFocus = false;
|
||||||
}
|
}
|
||||||
open()
|
open();
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (contentLoader.item && contentLoader.item.searchField) {
|
if (contentLoader.item && contentLoader.item.searchField) {
|
||||||
contentLoader.item.searchField.forceActiveFocus()
|
contentLoader.item.searchField.forceActiveFocus();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
close()
|
close();
|
||||||
if (parentModal) {
|
if (parentModal) {
|
||||||
parentModal.shouldHaveFocus = Qt.binding(() => {
|
parentModal.shouldHaveFocus = Qt.binding(() => {
|
||||||
return parentModal.shouldBeVisible
|
return parentModal.shouldBeVisible;
|
||||||
})
|
});
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (parentModal && parentModal.modalFocusScope) {
|
if (parentModal && parentModal.modalFocusScope) {
|
||||||
parentModal.modalFocusScope.forceActiveFocus()
|
parentModal.modalFocusScope.forceActiveFocus();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 500
|
modalWidth: 500
|
||||||
height: 550
|
modalHeight: 550
|
||||||
allowStacking: true
|
allowStacking: true
|
||||||
backgroundOpacity: 0
|
backgroundOpacity: 0
|
||||||
closeOnEscapeKey: false
|
closeOnEscapeKey: false
|
||||||
onDialogClosed: () => {
|
onDialogClosed: () => {
|
||||||
allWidgets = []
|
allWidgets = [];
|
||||||
targetSection = ""
|
targetSection = "";
|
||||||
searchQuery = ""
|
searchQuery = "";
|
||||||
filteredWidgets = []
|
filteredWidgets = [];
|
||||||
selectedIndex = -1
|
selectedIndex = -1;
|
||||||
keyboardNavigationActive = false
|
keyboardNavigationActive = false;
|
||||||
if (parentModal) {
|
if (parentModal) {
|
||||||
parentModal.shouldHaveFocus = Qt.binding(() => {
|
parentModal.shouldHaveFocus = Qt.binding(() => {
|
||||||
return parentModal.shouldBeVisible
|
return parentModal.shouldBeVisible;
|
||||||
})
|
});
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (parentModal && parentModal.modalFocusScope) {
|
if (parentModal && parentModal.modalFocusScope) {
|
||||||
parentModal.modalFocusScope.forceActiveFocus()
|
parentModal.modalFocusScope.forceActiveFocus();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onBackgroundClicked: () => {
|
onBackgroundClicked: () => {
|
||||||
return hide()
|
return hide();
|
||||||
}
|
}
|
||||||
content: widgetSelectionContent
|
content: widgetSelectionContent
|
||||||
|
|
||||||
widgetSelectionContent: Component {
|
widgetSelectionContent: Component {
|
||||||
FocusScope {
|
FocusScope {
|
||||||
id: widgetKeyHandler
|
id: widgetKeyHandler
|
||||||
property alias searchField: searchField
|
property alias searchField: searchField
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
focus: true
|
|
||||||
|
|
||||||
Keys.onPressed: event => {
|
|
||||||
if (event.key === Qt.Key_Escape) {
|
|
||||||
root.close()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Down) {
|
|
||||||
root.selectNext()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Up) {
|
|
||||||
root.selectPrevious()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_N && event.modifiers & Qt.ControlModifier) {
|
|
||||||
root.selectNext()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_P && event.modifiers & Qt.ControlModifier) {
|
|
||||||
root.selectPrevious()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_J && event.modifiers & Qt.ControlModifier) {
|
|
||||||
root.selectNext()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_K && event.modifiers & Qt.ControlModifier) {
|
|
||||||
root.selectPrevious()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
|
||||||
if (root.keyboardNavigationActive) {
|
|
||||||
root.selectWidget()
|
|
||||||
} else if (root.filteredWidgets.length > 0) {
|
|
||||||
var firstWidget = root.filteredWidgets[0]
|
|
||||||
root.widgetSelected(firstWidget.id, root.targetSection)
|
|
||||||
root.close()
|
|
||||||
}
|
|
||||||
event.accepted = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
iconName: "close"
|
|
||||||
iconSize: Theme.iconSize - 2
|
|
||||||
iconColor: Theme.outline
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.topMargin: Theme.spacingM
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: Theme.spacingM
|
|
||||||
onClicked: root.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: contentColumn
|
|
||||||
|
|
||||||
spacing: Theme.spacingM
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.spacingL
|
focus: true
|
||||||
anchors.topMargin: Theme.spacingL + 30 // Space for close button
|
|
||||||
|
Keys.onPressed: event => {
|
||||||
|
if (event.key === Qt.Key_Escape) {
|
||||||
|
root.close();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Down) {
|
||||||
|
root.selectNext();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Up) {
|
||||||
|
root.selectPrevious();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_N && event.modifiers & Qt.ControlModifier) {
|
||||||
|
root.selectNext();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_P && event.modifiers & Qt.ControlModifier) {
|
||||||
|
root.selectPrevious();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_J && event.modifiers & Qt.ControlModifier) {
|
||||||
|
root.selectNext();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_K && event.modifiers & Qt.ControlModifier) {
|
||||||
|
root.selectPrevious();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
||||||
|
if (root.keyboardNavigationActive) {
|
||||||
|
root.selectWidget();
|
||||||
|
} else if (root.filteredWidgets.length > 0) {
|
||||||
|
var firstWidget = root.filteredWidgets[0];
|
||||||
|
root.widgetSelected(firstWidget.id, root.targetSection);
|
||||||
|
root.close();
|
||||||
|
}
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankActionButton {
|
||||||
|
iconName: "close"
|
||||||
|
iconSize: Theme.iconSize - 2
|
||||||
|
iconColor: Theme.outline
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: Theme.spacingM
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: Theme.spacingM
|
||||||
|
onClicked: root.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: contentColumn
|
||||||
|
|
||||||
Row {
|
|
||||||
width: parent.width
|
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Theme.spacingL
|
||||||
|
anchors.topMargin: Theme.spacingL + 30 // Space for close button
|
||||||
|
|
||||||
DankIcon {
|
Row {
|
||||||
name: "add_circle"
|
width: parent.width
|
||||||
size: Theme.iconSize
|
spacing: Theme.spacingM
|
||||||
color: Theme.primary
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
DankIcon {
|
||||||
|
name: "add_circle"
|
||||||
|
size: Theme.iconSize
|
||||||
|
color: Theme.primary
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: I18n.tr("Add Widget to ") + root.targetSection + " Section"
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("Add Widget to ") + root.targetSection + " Section"
|
text: I18n.tr("Select a widget to add to the ") + root.targetSection.toLowerCase() + " section of the top bar. You can add multiple instances of the same widget if needed."
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
font.weight: Font.Medium
|
color: Theme.outline
|
||||||
color: Theme.surfaceText
|
width: parent.width
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
wrapMode: Text.WordWrap
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
DankTextField {
|
||||||
text: I18n.tr("Select a widget to add to the ") + root.targetSection.toLowerCase(
|
id: searchField
|
||||||
) + " section of the top bar. You can add multiple instances of the same widget if needed."
|
width: parent.width
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
height: 48
|
||||||
color: Theme.outline
|
cornerRadius: Theme.cornerRadius
|
||||||
width: parent.width
|
backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
|
||||||
wrapMode: Text.WordWrap
|
normalBorderColor: Theme.outlineMedium
|
||||||
}
|
focusedBorderColor: Theme.primary
|
||||||
|
leftIconName: "search"
|
||||||
DankTextField {
|
leftIconSize: Theme.iconSize
|
||||||
id: searchField
|
leftIconColor: Theme.surfaceVariantText
|
||||||
width: parent.width
|
leftIconFocusedColor: Theme.primary
|
||||||
height: 48
|
showClearButton: true
|
||||||
cornerRadius: Theme.cornerRadius
|
textColor: Theme.surfaceText
|
||||||
backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
normalBorderColor: Theme.outlineMedium
|
placeholderText: ""
|
||||||
focusedBorderColor: Theme.primary
|
text: root.searchQuery
|
||||||
leftIconName: "search"
|
focus: true
|
||||||
leftIconSize: Theme.iconSize
|
ignoreLeftRightKeys: true
|
||||||
leftIconColor: Theme.surfaceVariantText
|
keyForwardTargets: [widgetKeyHandler]
|
||||||
leftIconFocusedColor: Theme.primary
|
onTextEdited: {
|
||||||
showClearButton: true
|
root.searchQuery = text;
|
||||||
textColor: Theme.surfaceText
|
updateFilteredWidgets();
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
}
|
||||||
placeholderText: ""
|
Keys.onPressed: event => {
|
||||||
text: root.searchQuery
|
if (event.key === Qt.Key_Escape) {
|
||||||
focus: true
|
root.close();
|
||||||
ignoreLeftRightKeys: true
|
event.accepted = true;
|
||||||
keyForwardTargets: [widgetKeyHandler]
|
} else if (event.key === Qt.Key_Down || event.key === Qt.Key_Up || ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && text.length === 0)) {
|
||||||
onTextEdited: {
|
event.accepted = false;
|
||||||
root.searchQuery = text
|
}
|
||||||
updateFilteredWidgets()
|
|
||||||
}
|
|
||||||
Keys.onPressed: event => {
|
|
||||||
if (event.key === Qt.Key_Escape) {
|
|
||||||
root.close()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Down || event.key === Qt.Key_Up ||
|
|
||||||
((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && text.length === 0)) {
|
|
||||||
event.accepted = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
DankListView {
|
DankListView {
|
||||||
id: widgetList
|
id: widgetList
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - y
|
height: parent.height - y
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
model: root.filteredWidgets
|
model: root.filteredWidgets
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
width: widgetList.width
|
width: widgetList.width
|
||||||
height: 60
|
height: 60
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
property bool isSelected: root.keyboardNavigationActive && index === root.selectedIndex
|
property bool isSelected: root.keyboardNavigationActive && index === root.selectedIndex
|
||||||
color: isSelected ? Theme.primarySelected :
|
color: isSelected ? Theme.primarySelected : widgetArea.containsMouse ? Theme.primaryHover : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
|
||||||
widgetArea.containsMouse ? Theme.primaryHover : Qt.rgba(
|
border.color: isSelected ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||||
Theme.surfaceVariant.r,
|
border.width: isSelected ? 2 : 1
|
||||||
Theme.surfaceVariant.g,
|
|
||||||
Theme.surfaceVariant.b,
|
|
||||||
0.3)
|
|
||||||
border.color: isSelected ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g,
|
|
||||||
Theme.outline.b, 0.2)
|
|
||||||
border.width: isSelected ? 2 : 1
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.spacingM
|
anchors.margins: Theme.spacingM
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
name: modelData.icon
|
name: modelData.icon
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
spacing: 2
|
|
||||||
width: parent.width - Theme.iconSize - Theme.spacingM * 3
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: modelData.text
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
font.weight: Font.Medium
|
|
||||||
color: Theme.surfaceText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
width: parent.width
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
Column {
|
||||||
text: modelData.description
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
spacing: 2
|
||||||
color: Theme.outline
|
width: parent.width - Theme.iconSize - Theme.spacingM * 3
|
||||||
elide: Text.ElideRight
|
|
||||||
width: parent.width
|
StyledText {
|
||||||
wrapMode: Text.WordWrap
|
text: modelData.text
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
elide: Text.ElideRight
|
||||||
|
width: parent.width
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: modelData.description
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.outline
|
||||||
|
elide: Text.ElideRight
|
||||||
|
width: parent.width
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
name: "add"
|
||||||
|
size: Theme.iconSize - 4
|
||||||
|
color: Theme.primary
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DankIcon {
|
MouseArea {
|
||||||
name: "add"
|
id: widgetArea
|
||||||
size: Theme.iconSize - 4
|
|
||||||
color: Theme.primary
|
anchors.fill: parent
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
root.widgetSelected(modelData.id, root.targetSection);
|
||||||
|
root.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
Behavior on color {
|
||||||
id: widgetArea
|
ColorAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
anchors.fill: parent
|
easing.type: Theme.standardEasing
|
||||||
hoverEnabled: true
|
}
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
root.widgetSelected(modelData.id,
|
|
||||||
root.targetSection)
|
|
||||||
root.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Theme.shortDuration
|
|
||||||
easing.type: Theme.standardEasing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user