Skip to content

Commit

Permalink
Implement input stack (#19)
Browse files Browse the repository at this point in the history
* Implement input stack

* Cleanup
  • Loading branch information
zhulik authored Jul 4, 2023
1 parent c28d6bf commit 82e8aee
Show file tree
Hide file tree
Showing 37 changed files with 821 additions and 327 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ find_package(Qt5 REQUIRED COMPONENTS Core Quick QuickControls2)
include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src/QSteamworks)

file(GLOB_RECURSE sources "src/*.cpp" "src/*.h")
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h")

set(PROJECT_SOURCES ${sources}) # qml.qrc
file(GLOB_RECURSE RESOURCES "resources/*.*")
add_custom_target(resources SOURCES ${RESOURCES})

set(PROJECT_SOURCES ${SOURCES})

add_subdirectory(tools/vdf)

Expand Down
3 changes: 0 additions & 3 deletions resources/qml/ActionLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ RowLayout {

Steamworks.ActionText {
Layout.fillHeight: parent
verticalAlignment: Text.AlignVCenter

font.pointSize: root.height - 4

name: root.name
}
Expand Down
5 changes: 3 additions & 2 deletions resources/qml/AppLoader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ Item {
}

root.loaded()

item.onClosed.connect(root.close)
if (item.onClosed) {
item.onClosed.connect(root.close)
}
}
}

Expand Down
30 changes: 18 additions & 12 deletions resources/qml/DebugOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,34 @@ import QtQuick.Layouts 1.15

import "QSteamworks" as Steamworks

import Steamworks.SteamInput 1.0

import "debug" as Debug

Item {
id: root

signal closed()
signal closed

property var deckfmSettings: ({
showCloseButton: false,
showFooter: false
"showCloseButton": false,
"showFooter": false
})

function toggle() {
root.visible = !root.visible
}

SteamInputControl {
objectName: "DebugOverlayInput"
controller: steam_input.lastController

enabled: visible

actionSet: "deckfm"
actionSetLayers: []
}

Rectangle {
anchors.fill: parent
color: "black"
Expand Down Expand Up @@ -53,17 +65,11 @@ Item {

currentIndex: bar.currentIndex

Debug.ConsoleTab {
Debug.ConsoleTab {}

}
Debug.IGATab {}

Debug.IGATab {

}

Debug.ControllersTab {

}
Debug.ControllersTab {}
}
}
}
23 changes: 15 additions & 8 deletions resources/qml/DirectoryView/DirectoryView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Qt.labs.platform 1.1
import QtQuick.Controls.Material 2.12

import DeckFM 1.0
import Steamworks.SteamInput 1.0

import "../MDI" as MDI
import ".." as Core
Expand Down Expand Up @@ -38,10 +39,14 @@ Item {
root.fileOpened(item.path)
}

Steamworks.SteamInputScope {
enabled: parent.activeFocus
SteamInputControl {
objectName: "DirectoryView"
controller: steam_input.lastController

enabled: visible

actionSet: "deckfm"
// actionSetLayer: "file_manager"
actionSetLayers: ["file_manager"]

pressHandlers: {
"down": view.moveCurrentIndexDown,
Expand All @@ -57,8 +62,8 @@ Item {

analogHandlers: {
"scroll": e => {
if ((e.analogY <= 0 && view.atYEnd) ||
(e.analogY >= 0 && view.atYBeginning)) {
if ((e.analogY <= 0 && view.atYEnd) || (e.analogY >= 0
&& view.atYBeginning)) {
view.stopScrollMomentum()
return
}
Expand All @@ -72,7 +77,7 @@ Item {

if (scrollPos > 70) {
scrollPos = 0
view.scrollHaptic()
view.scrollHaptic()
}
view.contentY -= e.analogY
view.returnToBounds()
Expand Down Expand Up @@ -173,7 +178,8 @@ Item {
return
}

const a = steam_input.lastController.actionSet.actionByName("scroll", false)
const a = steam_input.lastController.actionSet.actionByName(
"scroll", false)
steam_input.lastController.stopAnalogActionMomentum(a)
}

Expand All @@ -182,7 +188,8 @@ Item {
return
}

steam_input.lastController.triggerRepeatedHapticPulse(2900, 1200, 2)
steam_input.lastController.triggerRepeatedHapticPulse(2900,
1200, 2)
}

function scrollHaptic() {
Expand Down
21 changes: 14 additions & 7 deletions resources/qml/DirectoryView/FileDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ItemDelegate {

RowLayout {
anchors.fill: parent
anchors.margins: 5
spacing: 5

MDI.Icon {
name: fileIcon
Expand All @@ -28,20 +30,25 @@ ItemDelegate {
elide: Text.ElideMiddle
}

RowLayout {

Label {
text: fileSizeString
Layout.fillWidth: parent
color: Material.accent
font.pointSize: 8
}
}

Label {
text: fileMime
elide: Text.ElideMiddle
color: Material.accent
Layout.alignment: Qt.AlignVCenter
font.pointSize: 8
Label {
text: fileMime
elide: Text.ElideMiddle
color: Material.accent
Layout.alignment: Qt.AlignVCenter
font.pointSize: 8
}
}
}


}
}
4 changes: 2 additions & 2 deletions resources/qml/Footer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ ToolBar {
}

RowLayout {
spacing: 10
spacing: 20
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 11
anchors.rightMargin: 10

Item {
Layout.fillWidth: parent
Expand Down
12 changes: 11 additions & 1 deletion resources/qml/Header.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ ToolBar {
Layout.fillWidth: parent
}

FPSCounter {
FPSCounter {}

ToolSeparator {}

MDI.Button {
iconName: "bug"
Layout.alignment: Qt.AlignRight
onClicked: {
console.log(qmlEngine)
}
}

ToolSeparator {}


MDI.Button {
iconName: "windowClose"
Layout.alignment: Qt.AlignRight
Expand Down
105 changes: 58 additions & 47 deletions resources/qml/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Qt.labs.settings 1.0
import QtQuick.Controls.Material 2.12

import Steamworks 1.0
import Steamworks.SteamInput 1.0

import "./DirectoryView" as DirView

Expand All @@ -32,6 +33,20 @@ ApplicationWindow {
width: 1280
height: 720

header: Header {
id: header
onMenuClicked: drawer.visible = !drawer.visible
onLogoClicked: globalMenu.popup()
onExitClicked: mainWindow.close()

visible: stackView.depth == 1
}

footer: Footer {
visible: stackView.currentItem.showFooter
hintActions: stackView.currentItem.hintActions
}

SteamUtils {
id: steamUtils
}
Expand All @@ -46,15 +61,6 @@ ApplicationWindow {
}
}

header: Header {
id: header
onMenuClicked: drawer.visible = !drawer.visible
onLogoClicked: globalMenu.popup()
onExitClicked: mainWindow.close()

visible: stackView.depth == 1
}

Shortcut {
sequence: "F1"
context: Qt.ApplicationShortcut
Expand Down Expand Up @@ -84,57 +90,62 @@ ApplicationWindow {
onActivated: Qt.quit()
}

Steamworks.SteamInputScope {
pressHandlers: {
"debug": debugOverlay.toggle,
}
}
SteamInputScope {
id: steam_input_scope

Drawer {
id: drawer
y: header.height
width: Math.max(parent.width * 0.3, 450)
height: parent.height - header.height - footer.height
}
anchors.fill: parent

footer: Footer {
visible: stackView.currentItem.showFooter
hintActions: stackView.currentItem.hintActions
}
SteamInputControl {
objectName: "global"
global: true

StackView {
id: stackView
focus: true
controller: steam_input.lastController

anchors.fill: parent
pressHandlers: {
"debug": debugOverlay.toggle
}
}
Drawer {
id: drawer
y: header.height
width: Math.max(parent.width * 0.3, 450)
height: parent.height - header.height - footer.height
}

StackView {
id: stackView
focus: true

anchors.fill: parent

initialItem: directoryView
initialItem: directoryView

DirView.DirectoryView {
id: directoryView
DirView.DirectoryView {
id: directoryView

onFileOpened: JS.openFile(path)
onFileOpened: JS.openFile(path)
}
}
}

GlobalMenu {
id: globalMenu
GlobalMenu {
id: globalMenu

onExitClicked: mainWindow.close()
}
onExitClicked: mainWindow.close()
}

DebugOverlay {
id: debugOverlay
visible: true
DebugOverlay {
id: debugOverlay
visible: false

x: 0
y: 0
width: parent.width - x
height: parent.height - y
}
x: 0
y: 0
width: parent.width - x
height: parent.height - y
}

Settings {
property alias path: directoryView.path
Settings {
property alias path: directoryView.path
}
}

onOpenFileChanged: JS.openFile(openFile)
Expand Down
Loading

0 comments on commit 82e8aee

Please sign in to comment.