revamp shortcuts
This commit is contained in:
1 parent
c9e07a5c8a
commit
ba2f7207d8
3 files changed
+100
-2
No files matched your search
@@ -101,6 +101,7 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
ReaderPage {
|
||||
id: readerPage
|
||||
anchors.fill: parent
|
||||
visible: window.currentPage === "reader"
|
||||
}
|
||||
@@ -130,14 +131,81 @@ ApplicationWindow {
|
||||
z: 3000
|
||||
}
|
||||
|
||||
// Global keyboard shortcuts - work regardless of focus
|
||||
Shortcut {
|
||||
sequence: "F"
|
||||
context: Qt.ApplicationShortcut
|
||||
onActivated: window.visibility = (window.visibility === Window.FullScreen) ? Window.Windowed : Window.FullScreen
|
||||
}
|
||||
Shortcut {
|
||||
sequence: "F11"
|
||||
context: Qt.ApplicationShortcut
|
||||
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 {
|
||||
target: bookController
|
||||
|
||||
@@ -5,8 +5,32 @@ import Asteria
|
||||
Rectangle {
|
||||
focus: true
|
||||
|
||||
Keys.onLeftPressed: readingModel.previousChapter()
|
||||
Keys.onRightPressed: readingModel.nextChapter()
|
||||
// Public methods for global keyboard navigation
|
||||
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 {
|
||||
GradientStop { position: 0.0; color: Theme.gradientTop }
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import QtQuick
|
||||
import Asteria
|
||||
|
||||
Item {
|
||||
id: readerPage
|
||||
property alias pageView: internalPageView
|
||||
|
||||
PageView {
|
||||
id: internalPageView
|
||||
anchors.fill: parent
|
||||
focus: visible
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user