feat: input mgr
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import "../"
|
||||
|
||||
import "topbar"
|
||||
|
||||
@@ -8,6 +9,8 @@ Item {
|
||||
implicitWidth: 1312
|
||||
implicitHeight: 182
|
||||
|
||||
property var manager: ShellStateManager
|
||||
|
||||
anchors.centerIn: parent
|
||||
|
||||
property var iconSources: ["item.png", "equip.png", "power.png", "config.png"]
|
||||
@@ -28,6 +31,32 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: overlayKeyHandler
|
||||
function handle(key) {
|
||||
if (key === Qt.Key_Left) {
|
||||
moveSelection(-1);
|
||||
return true;
|
||||
}
|
||||
if (key === Qt.Key_Right) {
|
||||
moveSelection(1);
|
||||
return true;
|
||||
}
|
||||
if (key === Qt.Key_Return || key === Qt.Key_Enter || key === Qt.Key_Z) {
|
||||
if (iconSources[selectedIndex] === "config.png") {
|
||||
ShellStateManager.openQuickSettings({
|
||||
source: "Topbar"
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Component.onCompleted: ShellInputManager.registerHandler("topbar", handle)
|
||||
Component.onDestruction: ShellInputManager.unregisterHandler("topbar")
|
||||
}
|
||||
|
||||
DarkDollarsDisplay {}
|
||||
|
||||
Image {
|
||||
@@ -35,40 +64,37 @@ Item {
|
||||
x: -64
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: focusScope
|
||||
focus: true
|
||||
anchors.fill: parent
|
||||
Keys.onLeftPressed: topbar.moveSelection(-1)
|
||||
Keys.onRightPressed: topbar.moveSelection(1)
|
||||
Component.onCompleted: forceActiveFocus()
|
||||
Row {
|
||||
id: iconRow
|
||||
spacing: 76
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: 45
|
||||
anchors.horizontalCenterOffset: -38
|
||||
|
||||
Row {
|
||||
id: iconRow
|
||||
spacing: 76
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: 45
|
||||
anchors.horizontalCenterOffset: -38
|
||||
Repeater {
|
||||
model: topbar.iconSources
|
||||
|
||||
Repeater {
|
||||
model: topbar.iconSources
|
||||
delegate: Item {
|
||||
id: repeatitem
|
||||
required property int index
|
||||
width: 149
|
||||
height: 108
|
||||
|
||||
delegate: Item {
|
||||
id: repeatitem
|
||||
required property int index
|
||||
width: 149
|
||||
height: 108
|
||||
TopbarSettingIcon {
|
||||
anchors.centerIn: parent
|
||||
selected: topbar.selectedIndex == repeatitem.index
|
||||
iconSource: topbar.iconSources[repeatitem.index]
|
||||
showSoul: !topbar.manager.quickSettingsOpen
|
||||
}
|
||||
|
||||
TopbarSettingIcon {
|
||||
anchors.centerIn: parent
|
||||
selected: topbar.selectedIndex == repeatitem.index
|
||||
iconSource: topbar.iconSources[repeatitem.index]
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
topbar.selectedIndex = repeatitem.index;
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
topbar.selectedIndex = repeatitem.index;
|
||||
if (topbar.iconSources[repeatitem.index] === "config.png") {
|
||||
ShellStateManager.openQuickSettings({
|
||||
source: "Topbar"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user