revamp shortcuts

This commit is contained in:
Agel committed 2026-03-29 23:20:46 +02:00
1 parent c9e07a5c8a
commit ba2f7207d8
3 files changed
+103 -5

No files matched your search

+68
View File
@@ -101,6 +101,7 @@ ApplicationWindow {
} }
ReaderPage { ReaderPage {
id: readerPage
anchors.fill: parent anchors.fill: parent
visible: window.currentPage === "reader" visible: window.currentPage === "reader"
} }
@@ -130,14 +131,81 @@ ApplicationWindow {
z: 3000 z: 3000
} }
// Global keyboard shortcuts - work regardless of focus
Shortcut { Shortcut {
sequence: "F" sequence: "F"
context: Qt.ApplicationShortcut
onActivated: window.visibility = (window.visibility === Window.FullScreen) ? Window.Windowed : Window.FullScreen onActivated: window.visibility = (window.visibility === Window.FullScreen) ? Window.Windowed : Window.FullScreen
} }
Shortcut { Shortcut {
sequence: "F11" sequence: "F11"
context: Qt.ApplicationShortcut
onActivated: window.visibility = (window.visibility === Window.FullScreen) ? Window.Windowed : Window.FullScreen onActivated: window.visibility = (window.visibility === Window.FullScreen) ? Window.Windowed : Window.FullScreen
} }
Shortcut {
sequence: "Up"
context: Qt.ApplicationShortcut
onActivated: {
if (currentPage === "reader" && readerPage?.pageView) {
readerPage.pageView.handleScrollUp();
}
}
}
Shortcut {
sequence: "Down"
context: Qt.ApplicationShortcut
onActivated: {
if (currentPage === "reader" && readerPage?.pageView) {
readerPage.pageView.handleScrollDown();
}
}
}
Shortcut {
sequence: "PgUp"
context: Qt.ApplicationShortcut
onActivated: {
if (currentPage === "reader" && readerPage?.pageView) {
readerPage.pageView.handlePageUp();
}
}
}
Shortcut {
sequence: "PgDown"
context: Qt.ApplicationShortcut
onActivated: {
if (currentPage === "reader" && readerPage?.pageView) {
readerPage.pageView.handlePageDown();
}
}
}
// Fallback shortcuts using alternative key names
Shortcut {
sequence: "Prior"
context: Qt.ApplicationShortcut
onActivated: {
if (currentPage === "reader" && readerPage?.pageView) {
readerPage.pageView.handlePageUp();
}
}
}
Shortcut {
sequence: "Next"
context: Qt.ApplicationShortcut
onActivated: {
if (currentPage === "reader" && readerPage?.pageView) {
readerPage.pageView.handlePageDown();
}
}
}
Shortcut {
sequence: "Space"
context: Qt.ApplicationShortcut
onActivated: {
if (currentPage === "reader" && readerPage) {
readerPage.pageView.handlePageDown();
}
}
}
Connections { Connections {
target: bookController target: bookController
+26 -2
View File
@@ -5,8 +5,32 @@ import Asteria
Rectangle { Rectangle {
focus: true focus: true
Keys.onLeftPressed: readingModel.previousChapter() // Public methods for global keyboard navigation
Keys.onRightPressed: readingModel.nextChapter() function handlePageUp() {
var scrollAmount = chunkListView.height * 0.95;
chunkListView.contentY = Math.max(0, chunkListView.contentY - scrollAmount);
}
function handlePageDown() {
var scrollAmount = chunkListView.height * 0.95;
var maxY = Math.max(0, chunkListView.contentHeight - chunkListView.height);
chunkListView.contentY = Math.min(maxY, chunkListView.contentY + scrollAmount);
}
function handleScrollUp() {
// Scroll up by approximately 2-3 lines
var lineHeight = appState.fontSize * appState.lineSpacing;
var scrollAmount = lineHeight * 3; // ~2-3 lines
chunkListView.contentY = Math.max(0, chunkListView.contentY - scrollAmount);
}
function handleScrollDown() {
// Scroll down by approximately 2-3 lines
var lineHeight = appState.fontSize * appState.lineSpacing;
var scrollAmount = lineHeight * 3; // ~2-3 lines
var maxY = Math.max(0, chunkListView.contentHeight - chunkListView.height);
chunkListView.contentY = Math.min(maxY, chunkListView.contentY + scrollAmount);
}
gradient: Gradient { gradient: Gradient {
GradientStop { position: 0.0; color: Theme.gradientTop } GradientStop { position: 0.0; color: Theme.gradientTop }
+9 -3
View File
@@ -1,7 +1,13 @@
import QtQuick import QtQuick
import Asteria import Asteria
PageView { Item {
anchors.fill: parent id: readerPage
focus: visible property alias pageView: internalPageView
PageView {
id: internalPageView
anchors.fill: parent
focus: visible
}
} }