mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
added keyboard layout widget (niri only)
This commit is contained in:
@@ -140,6 +140,11 @@ Item {
|
|||||||
"icon": "network_check",
|
"icon": "network_check",
|
||||||
"warning": !DgopService.dgopAvailable ? "Requires 'dgop' tool" : undefined,
|
"warning": !DgopService.dgopAvailable ? "Requires 'dgop' tool" : undefined,
|
||||||
"enabled": DgopService.dgopAvailable
|
"enabled": DgopService.dgopAvailable
|
||||||
|
}, {
|
||||||
|
"id": "keyboard_layout_name",
|
||||||
|
"text": "Keyboard Layout Name",
|
||||||
|
"description": "Displays the active keyboard layout and allows switching",
|
||||||
|
"icon": "keyboard",
|
||||||
}]
|
}]
|
||||||
property var defaultLeftWidgets: [{
|
property var defaultLeftWidgets: [{
|
||||||
"id": "launcherButton",
|
"id": "launcherButton",
|
||||||
|
|||||||
@@ -138,6 +138,11 @@ Item {
|
|||||||
"icon": "network_check",
|
"icon": "network_check",
|
||||||
"warning": !DgopService.dgopAvailable ? "Requires 'dgop' tool" : undefined,
|
"warning": !DgopService.dgopAvailable ? "Requires 'dgop' tool" : undefined,
|
||||||
"enabled": DgopService.dgopAvailable
|
"enabled": DgopService.dgopAvailable
|
||||||
|
}, {
|
||||||
|
"id": "keyboard_layout_name",
|
||||||
|
"text": "Keyboard Layout Name",
|
||||||
|
"description": "Displays the active keyboard layout and allows switching",
|
||||||
|
"icon": "keyboard",
|
||||||
}]
|
}]
|
||||||
property var defaultLeftWidgets: [{
|
property var defaultLeftWidgets: [{
|
||||||
"id": "launcherButton",
|
"id": "launcherButton",
|
||||||
|
|||||||
56
Modules/TopBar/KeyboardLayoutName.qml
Normal file
56
Modules/TopBar/KeyboardLayoutName.qml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import qs.Common
|
||||||
|
import qs.Services
|
||||||
|
import qs.Widgets
|
||||||
|
import qs.Modules.ProcessList
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property real horizontalPadding: SettingsData.topBarNoBackground ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetHeight / 30))
|
||||||
|
|
||||||
|
width: contentRow.implicitWidth + horizontalPadding * 2
|
||||||
|
height: widgetHeight
|
||||||
|
radius: SettingsData.topBarNoBackground ? 0 : Theme.cornerRadius
|
||||||
|
|
||||||
|
color: {
|
||||||
|
if (SettingsData.topBarNoBackground) return "transparent"
|
||||||
|
const baseColor = mouseArea.containsMouse ? Theme.primaryPressed : Theme.secondaryHover
|
||||||
|
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b,
|
||||||
|
baseColor.a * Theme.widgetTransparency)
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mouseArea
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
NiriService.cycleKeyboardLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: contentRow
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: NiriService.getCurrentKeyboardLayoutName()
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceText
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -337,6 +337,8 @@ PanelWindow {
|
|||||||
return true
|
return true
|
||||||
case "network_speed_monitor":
|
case "network_speed_monitor":
|
||||||
return DgopService.dgopAvailable
|
return DgopService.dgopAvailable
|
||||||
|
case "keyboard_layout_name":
|
||||||
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -386,6 +388,8 @@ PanelWindow {
|
|||||||
return separatorComponent
|
return separatorComponent
|
||||||
case "network_speed_monitor":
|
case "network_speed_monitor":
|
||||||
return networkComponent
|
return networkComponent
|
||||||
|
case "keyboard_layout_name":
|
||||||
|
return keyboardLayoutNameComponent
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -1109,6 +1113,12 @@ PanelWindow {
|
|||||||
opacity: 0.3
|
opacity: 0.3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: keyboardLayoutNameComponent
|
||||||
|
|
||||||
|
KeyboardLayoutName {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ Singleton {
|
|||||||
// Overview state
|
// Overview state
|
||||||
property bool inOverview: false
|
property bool inOverview: false
|
||||||
|
|
||||||
|
// Keyboard layout state
|
||||||
|
property int currentKeyboardLayoutIndex: 0
|
||||||
|
property var keyboardLayoutNames: []
|
||||||
|
|
||||||
// Internal state (not exposed to external components)
|
// Internal state (not exposed to external components)
|
||||||
property string configValidationOutput: ""
|
property string configValidationOutput: ""
|
||||||
property bool hasInitialConnection: false
|
property bool hasInitialConnection: false
|
||||||
@@ -191,6 +195,10 @@ Singleton {
|
|||||||
handleOverviewChanged(event.OverviewOpenedOrClosed)
|
handleOverviewChanged(event.OverviewOpenedOrClosed)
|
||||||
} else if (event.ConfigLoaded) {
|
} else if (event.ConfigLoaded) {
|
||||||
handleConfigLoaded(event.ConfigLoaded)
|
handleConfigLoaded(event.ConfigLoaded)
|
||||||
|
} else if (event.KeyboardLayoutsChanged) {
|
||||||
|
handleKeyboardLayoutsChanged(event.KeyboardLayoutsChanged)
|
||||||
|
} else if (event.KeyboardLayoutSwitched) {
|
||||||
|
handleKeyboardLayoutSwitched(event.KeyboardLayoutSwitched)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,6 +381,15 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleKeyboardLayoutsChanged(data) {
|
||||||
|
keyboardLayoutNames = data.keyboard_layouts.names
|
||||||
|
currentKeyboardLayoutIndex = data.keyboard_layouts.current_idx
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKeyboardLayoutSwitched(data) {
|
||||||
|
currentKeyboardLayoutIndex = data.idx
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: validateProcess
|
id: validateProcess
|
||||||
command: ["niri", "validate"]
|
command: ["niri", "validate"]
|
||||||
@@ -441,7 +458,25 @@ Singleton {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentKeyboardLayoutName() {
|
||||||
|
if (currentKeyboardLayoutIndex >= 0
|
||||||
|
&& currentKeyboardLayoutIndex < keyboardLayoutNames.length) {
|
||||||
|
return keyboardLayoutNames[currentKeyboardLayoutIndex]
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cycleKeyboardLayout() {
|
||||||
|
return send({
|
||||||
|
"Action": {
|
||||||
|
"SwitchLayout": {
|
||||||
|
"layout": "Next"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function quit() {
|
function quit() {
|
||||||
return send({
|
return send({
|
||||||
|
|||||||
Reference in New Issue
Block a user