added adaptive quickshell

This commit is contained in:
wt committed 2026-11-17 18:15:16 +07:00
1 parent 6eb56d2065
commit 5b33a73fd8
189 files changed
+8678 -15

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import "../services"
Button {
id: control
implicitHeight: 48
implicitWidth: Math.max(48, label.implicitWidth + leftPadding + rightPadding)
leftPadding: 14
rightPadding: 14
topInset: 0
bottomInset: 0
hoverEnabled: true
contentItem: Text {
id: label
text: control.text
color: control.enabled ? (control.checked ? Theme.onPrimaryContainer : Theme.foreground) : Theme.outline
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
textFormat: Text.PlainText
}
background: Rectangle {
radius: control.checked ? 16 : 24
color: control.checked ? Theme.primaryContainer : control.down ? Theme.secondaryContainer : control.hovered ? Theme.surfaceHigh : Theme.surfaceLow
border.width: control.activeFocus || control.checked ? 2 : 0
border.color: Theme.primary
}
}
+68
View File
@@ -0,0 +1,68 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell.Networking
import "../services"
ColumnLayout {
id: card
required property var network
required property var device
required property var controller
property bool active: false
property bool credentials: false
readonly property bool wifi: device?.type === DeviceType.Wifi
readonly property bool pskSupported: wifi && [WifiSecurityType.WpaPsk, WifiSecurityType.Wpa2Psk, WifiSecurityType.Sae].includes(network?.security)
readonly property bool directConnect: !wifi || network?.known === true || pskSupported || [WifiSecurityType.Open, WifiSecurityType.Owe].includes(network?.security)
signal editRequested()
function clearSecret() { if (password) password.clear(); credentials = false; }
onActiveChanged: if (!active) clearSecret()
Connections {
target: card.controller
function onNeedsSecret(network) { if (network === card.network && card.pskSupported && card.active) card.credentials = true; }
}
Connections {
target: card.network
function onConnectedChanged() { if (card.network?.connected) card.clearSecret(); }
}
Label {
Layout.fillWidth: true
text: (card.network?.name || "") + (card.network?.connected ? " · Подключено" : "") + (card.wifi ? " · " + Math.round(card.network?.signalStrength * 100) + "%" : "")
wrapMode: Text.Wrap; color: Theme.foreground; textFormat: Text.PlainText
}
Label { visible: card.wifi && !!card.network; text: card.wifi && card.network ? WifiSecurityType.toString(card.network.security) : ""; color: Theme.outline }
ActionButton {
visible: !!card.network && !card.network.connected
text: card.directConnect ? "Подключиться" : "Настроить подключение…"
enabled: card.controller?.busy === false && card.device?.nmManaged === true
onClicked: {
if (!card.directConnect) card.editRequested();
else if (!card.network?.known && card.pskSupported) card.credentials = true;
else card.controller.requestConnect(card.network);
}
}
TextField {
id: password
objectName: "networkPassword"
visible: card.credentials
Layout.fillWidth: true
placeholderText: "Пароль Wi-Fi"
echoMode: TextInput.Password
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
selectByMouse: false
onAccepted: if (text.length && card.controller?.busy === false) {
card.controller.requestConnect(card.network, text);
clear(); card.credentials = false;
}
}
RowLayout {
visible: card.credentials
ActionButton {
text: "Подключить"
enabled: password.text.length > 0 && card.controller?.busy === false
onClicked: { card.controller.requestConnect(card.network, password.text); card.clearSecret(); }
}
ActionButton { text: "Отмена"; onClicked: card.clearSecret() }
}
}
@@ -0,0 +1,47 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "../services"
Rectangle {
id: card
property var notification: null
property var record: null
readonly property var entry: notification || record
implicitHeight: content.implicitHeight + 28
color: Theme.surfaceHigh
radius: Theme.radius
ColumnLayout {
id: content
anchors { top: parent.top; left: parent.left; right: parent.right; margins: 14 }
spacing: 8
Label {
Layout.fillWidth: true
visible: card.record !== null
text: card.record ? Qt.formatDateTime(new Date(card.record.time), "dd.MM HH:mm") + " · История" : ""
color: Theme.outline
}
Label { Layout.fillWidth: true; text: card.entry?.summary || ""; color: Theme.foreground; wrapMode: Text.Wrap; font.bold: true; textFormat: Text.PlainText }
Label { Layout.fillWidth: true; text: card.entry?.body || ""; color: Theme.foreground; wrapMode: Text.Wrap; textFormat: Text.PlainText }
Image {
source: card.notification?.image || ""
visible: source !== ""
Layout.preferredWidth: 160; Layout.preferredHeight: 100
sourceSize: Qt.size(512, 512)
fillMode: Image.PreserveAspectFit
}
Flow {
Layout.fillWidth: true
spacing: 8
Repeater {
model: card.notification?.actions || []
ActionButton { required property var modelData; text: modelData.text; onClicked: modelData.invoke() }
}
ActionButton {
text: "Удалить"
onClicked: card.notification ? Notifications.dismiss(card.notification.id) : Notifications.removeHistory(card.record.key)
}
}
}
}