mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
dankbar/vpn: right click to quick connect
This commit is contained in:
@@ -9,3 +9,7 @@ This file is more of a quick reference so I know what to account for before next
|
|||||||
- Add monitor configurator (niri, Hyprland, MangoWC)
|
- Add monitor configurator (niri, Hyprland, MangoWC)
|
||||||
- **BREAKING** ghostty theme changed to ~/.config/ghostty/themes/danktheme
|
- **BREAKING** ghostty theme changed to ~/.config/ghostty/themes/danktheme
|
||||||
- requires intervention and doc update
|
- requires intervention and doc update
|
||||||
|
- Added desktop widget plugins
|
||||||
|
- dev guidance available
|
||||||
|
- builtin clock & dgop widgets
|
||||||
|
- Initial RTL support/i18n
|
||||||
|
|||||||
@@ -13,30 +13,30 @@ Item {
|
|||||||
|
|
||||||
readonly property bool active: expandedSection !== ""
|
readonly property bool active: expandedSection !== ""
|
||||||
|
|
||||||
Behavior on height {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.mediumDuration
|
|
||||||
easing.type: Easing.OutCubic
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.topMargin: Theme.spacingS
|
anchors.topMargin: Theme.spacingS
|
||||||
sourceComponent: {
|
sourceComponent: {
|
||||||
if (!root.active) return null
|
if (!root.active)
|
||||||
|
return null;
|
||||||
|
|
||||||
if (expandedSection.startsWith("diskUsage_")) {
|
if (expandedSection.startsWith("diskUsage_")) {
|
||||||
return diskUsageDetailComponent
|
return diskUsageDetailComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (expandedSection) {
|
switch (expandedSection) {
|
||||||
case "wifi": return networkDetailComponent
|
case "wifi":
|
||||||
case "bluetooth": return bluetoothDetailComponent
|
return networkDetailComponent;
|
||||||
case "audioOutput": return audioOutputDetailComponent
|
case "bluetooth":
|
||||||
case "audioInput": return audioInputDetailComponent
|
return bluetoothDetailComponent;
|
||||||
case "battery": return batteryDetailComponent
|
case "audioOutput":
|
||||||
default: return null
|
return audioOutputDetailComponent;
|
||||||
|
case "audioInput":
|
||||||
|
return audioInputDetailComponent;
|
||||||
|
case "battery":
|
||||||
|
return batteryDetailComponent;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,18 +72,18 @@ Item {
|
|||||||
currentMountPath: root.expandedWidgetData?.mountPath || "/"
|
currentMountPath: root.expandedWidgetData?.mountPath || "/"
|
||||||
instanceId: root.expandedWidgetData?.instanceId || ""
|
instanceId: root.expandedWidgetData?.instanceId || ""
|
||||||
|
|
||||||
onMountPathChanged: (newMountPath) => {
|
onMountPathChanged: newMountPath => {
|
||||||
if (root.expandedWidgetData && root.expandedWidgetData.id === "diskUsage") {
|
if (root.expandedWidgetData && root.expandedWidgetData.id === "diskUsage") {
|
||||||
const widgets = SettingsData.controlCenterWidgets || []
|
const widgets = SettingsData.controlCenterWidgets || [];
|
||||||
const newWidgets = widgets.map(w => {
|
const newWidgets = widgets.map(w => {
|
||||||
if (w.id === "diskUsage" && w.instanceId === root.expandedWidgetData.instanceId) {
|
if (w.id === "diskUsage" && w.instanceId === root.expandedWidgetData.instanceId) {
|
||||||
const updatedWidget = Object.assign({}, w)
|
const updatedWidget = Object.assign({}, w);
|
||||||
updatedWidget.mountPath = newMountPath
|
updatedWidget.mountPath = newMountPath;
|
||||||
return updatedWidget
|
return updatedWidget;
|
||||||
}
|
}
|
||||||
return w
|
return w;
|
||||||
})
|
});
|
||||||
SettingsData.set("controlCenterWidgets", newWidgets)
|
SettingsData.set("controlCenterWidgets", newWidgets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Modules.Plugins
|
import qs.Modules.Plugins
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -20,21 +19,21 @@ BasePill {
|
|||||||
|
|
||||||
readonly property real minTooltipY: {
|
readonly property real minTooltipY: {
|
||||||
if (!parentScreen || !isVerticalOrientation) {
|
if (!parentScreen || !isVerticalOrientation) {
|
||||||
return 0
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAutoHideBar) {
|
if (isAutoHideBar) {
|
||||||
return 0
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentScreen.y > 0) {
|
if (parentScreen.y > 0) {
|
||||||
return barThickness + barSpacing
|
return barThickness + barSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
signal toggleVpnPopup()
|
signal toggleVpnPopup
|
||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
Item {
|
Item {
|
||||||
@@ -72,56 +71,63 @@ BasePill {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: DMSNetworkService.isBusy ? Qt.BusyCursor : Qt.PointingHandCursor
|
cursorShape: DMSNetworkService.isBusy ? Qt.BusyCursor : Qt.PointingHandCursor
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
enabled: !DMSNetworkService.isBusy
|
enabled: !DMSNetworkService.isBusy
|
||||||
onPressed: {
|
onPressed: event => {
|
||||||
root.toggleVpnPopup()
|
switch (event.button) {
|
||||||
|
case Qt.RightButton:
|
||||||
|
DMSNetworkService.toggleVpn();
|
||||||
|
return;
|
||||||
|
case Qt.LeftButton:
|
||||||
|
root.toggleVpnPopup();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (!root.parentScreen || (popoutTarget?.shouldBeVisible)) return
|
if (!root.parentScreen || (popoutTarget?.shouldBeVisible))
|
||||||
|
return;
|
||||||
tooltipLoader.active = true
|
tooltipLoader.active = true;
|
||||||
if (!tooltipLoader.item) return
|
if (!tooltipLoader.item)
|
||||||
|
return;
|
||||||
let tooltipText = ""
|
let tooltipText = "";
|
||||||
if (!DMSNetworkService.connected) {
|
if (!DMSNetworkService.connected) {
|
||||||
tooltipText = "VPN Disconnected"
|
tooltipText = "VPN Disconnected";
|
||||||
} else {
|
} else {
|
||||||
const names = DMSNetworkService.activeNames || []
|
const names = DMSNetworkService.activeNames || [];
|
||||||
if (names.length <= 1) {
|
if (names.length <= 1) {
|
||||||
const name = names[0] || ""
|
const name = names[0] || "";
|
||||||
const maxLength = 25
|
const maxLength = 25;
|
||||||
const displayName = name.length > maxLength ? name.substring(0, maxLength) + "..." : name
|
const displayName = name.length > maxLength ? name.substring(0, maxLength) + "..." : name;
|
||||||
tooltipText = "VPN Connected • " + displayName
|
tooltipText = "VPN Connected • " + displayName;
|
||||||
} else {
|
} else {
|
||||||
const name = names[0]
|
const name = names[0];
|
||||||
const maxLength = 20
|
const maxLength = 20;
|
||||||
const displayName = name.length > maxLength ? name.substring(0, maxLength) + "..." : name
|
const displayName = name.length > maxLength ? name.substring(0, maxLength) + "..." : name;
|
||||||
tooltipText = "VPN Connected • " + displayName + " +" + (names.length - 1)
|
tooltipText = "VPN Connected • " + displayName + " +" + (names.length - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.isVerticalOrientation) {
|
if (root.isVerticalOrientation) {
|
||||||
const globalPos = mapToGlobal(width / 2, height / 2)
|
const globalPos = mapToGlobal(width / 2, height / 2);
|
||||||
const currentScreen = root.parentScreen || Screen
|
const currentScreen = root.parentScreen || Screen;
|
||||||
const screenX = currentScreen ? currentScreen.x : 0
|
const screenX = currentScreen ? currentScreen.x : 0;
|
||||||
const screenY = currentScreen ? currentScreen.y : 0
|
const screenY = currentScreen ? currentScreen.y : 0;
|
||||||
const relativeY = globalPos.y - screenY
|
const relativeY = globalPos.y - screenY;
|
||||||
const adjustedY = relativeY + root.minTooltipY
|
const adjustedY = relativeY + root.minTooltipY;
|
||||||
const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (currentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS)
|
const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (currentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||||
const isLeft = root.axis?.edge === "left"
|
const isLeft = root.axis?.edge === "left";
|
||||||
tooltipLoader.item.show(tooltipText, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft)
|
tooltipLoader.item.show(tooltipText, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft);
|
||||||
} else {
|
} else {
|
||||||
const globalPos = mapToGlobal(width / 2, height)
|
const globalPos = mapToGlobal(width / 2, height);
|
||||||
const tooltipY = root.barThickness + root.barSpacing + Theme.spacingXS
|
const tooltipY = root.barThickness + root.barSpacing + Theme.spacingXS;
|
||||||
tooltipLoader.item.show(tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false)
|
tooltipLoader.item.show(tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
if (tooltipLoader.item) {
|
if (tooltipLoader.item) {
|
||||||
tooltipLoader.item.hide()
|
tooltipLoader.item.hide();
|
||||||
}
|
}
|
||||||
tooltipLoader.active = false
|
tooltipLoader.active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user