diff options
| author | Dan Leinir Turthra Jensen <admin@leinir.dk> | 2017-08-16 12:37:45 (GMT) |
|---|---|---|
| committer | Dan Leinir Turthra Jensen <admin@leinir.dk> | 2017-08-16 12:37:45 (GMT) |
| commit | aed2256a1e5c8a46122f9ec5a10c770239d02ec5 (patch) | |
| tree | 23e85545cb0f34e611896b2f5aad5b044344b3d7 | |
| parent | cc1b7204ac153abb3ca3a2a7d0bf6f29834b90e7 (diff) | |
Up Kirigami requirement to 5.37 for PageRow layers
This finally gets rid of the awkward messing about with the PageRow
which was needed to make the layout stay intact when we wanted to
have the book take over the layout once opened. Layers implements
this explicitly, and much more pleasantly. Solid stuff.
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/app/qml/Book.qml | 64 | ||||
| -rw-r--r-- | src/app/qml/PeruseContextDrawer.qml | 12 | ||||
| -rw-r--r-- | src/app/qml/PeruseMain.qml | 2 |
4 files changed, 25 insertions, 55 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5690071..77fe863 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ set_package_properties(KF5NewStuffQuick PROPERTIES TYPE RUNTIME ) -find_package(KF5Kirigami2 2.1.0) +find_package(KF5Kirigami2 5.37.0) set_package_properties(KF5Kirigami2 PROPERTIES PURPOSE "Required at runtime to display the GUI" TYPE RUNTIME diff --git a/src/app/qml/Book.qml b/src/app/qml/Book.qml index 93dd7f6..b0a63f5 100644 --- a/src/app/qml/Book.qml +++ b/src/app/qml/Book.qml @@ -33,7 +33,6 @@ Kirigami.Page { id: root; objectName: "bookViewer"; clip: true; - implicitWidth: applicationWindow().width; // Remove all the padding when we've hidden controls. Content is king! topPadding: applicationWindow().controlsVisible ? (applicationWindow() && applicationWindow().header ? applicationWindow().header.height : 0) : 0; @@ -50,9 +49,9 @@ Kirigami.Page { // Perhaps we should store and restore this? property bool showControls: true; - property Item pageStackItem: applicationWindow().pageStack.currentItem; + property Item pageStackItem: applicationWindow().pageStack.layers.currentItem; onPageStackItemChanged: { - if(applicationWindow().pageStack.currentItem == root) { + if(applicationWindow().pageStack.layers.currentItem == root) { applicationWindow().controlsVisible = root.showControls; } else { @@ -93,7 +92,7 @@ Kirigami.Page { applicationWindow().contextDrawer.close(); // also for storing current page (otherwise postponed a bit after page change, done here as well to ensure it really happens) applicationWindow().controlsVisible = true; - applicationWindow().pageStack.pop(); + applicationWindow().pageStack.layers.pop(); applicationWindow().globalDrawer.open(); } @@ -153,19 +152,6 @@ Kirigami.Page { else { applicationWindow().visibility = Window.AutomaticVisibility; } - restoreViewLayoutStuff.start(); - } - Timer { - id: restoreViewLayoutStuff; - interval: applicationWindow().animationDuration * 2; - running: false; - repeat: false; - onTriggered: { - if(viewLoader.item.restoreCurrentPage !== undefined) { - viewLoader.item.restoreCurrentPage(); - } - applicationWindow().pageStack.currentIndex = applicationWindow().pageStack.depth - 1; - } } property list<QtObject> mobileActions: [ @@ -173,14 +159,14 @@ Kirigami.Page { text: applicationWindow().visibility !== Window.FullScreen ? i18nc("Enter full screen mode on a touch-based device", "Go full screen") : i18nc("Exit full sceen mode on a touch based device", "Exit full screen"); iconName: "view-fullscreen"; onTriggered: toggleFullscreen(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypePhone; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypePhone; }, Kirigami.Action { text: i18nc("Action used on touch devices to close the currently open book and return to whatever page was most recently shown", "Close book"); shortcut: (bookInfo.sheetOpen ? "" : "Esc"); iconName: "dialog-close"; onTriggered: closeBook(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypePhone; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypePhone; } ] property list<QtObject> desktopActions: [ @@ -194,14 +180,14 @@ Kirigami.Page { text: "Left to Right" iconName: "format-text-direction-ltr"; shortcut: rtlMode ? "r" : ""; - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.rtlMode === true; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.rtlMode === true; onTriggered: { root.rtlMode = false; } } Kirigami.Action { text: "Right to Left" iconName: "format-text-direction-rtl"; shortcut: rtlMode ? "" : "r"; - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.rtlMode === false; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.rtlMode === false; onTriggered: { root.rtlMode = true; } } QtObject {} @@ -211,19 +197,19 @@ Kirigami.Page { // Kirigami.Action { // text: "Fit full page" // iconName: "zoom-fit-best"; -// enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.zoomMode !== Peruse.Config.ZoomFull; +// enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.zoomMode !== Peruse.Config.ZoomFull; // onTriggered: { root.zoomMode = Peruse.Config.ZoomFull; } // } // Kirigami.Action { // text: "Fit width" // iconName: "zoom-fit-width"; -// enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.zoomMode !== Peruse.Config.ZoomFitWidth; +// enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.zoomMode !== Peruse.Config.ZoomFitWidth; // onTriggered: { root.zoomMode = Peruse.Config.ZoomFitWidth; } // } // Kirigami.Action { // text: "Fit height" // iconName: "zoom-fit-height"; -// enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.zoomMode !== Peruse.Config.ZoomFitHeight; +// enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop && root.zoomMode !== Peruse.Config.ZoomFitHeight; // onTriggered: { root.zoomMode = Peruse.Config.ZoomFitHeight; } // } // QtObject {} @@ -233,28 +219,28 @@ Kirigami.Page { shortcut: bookInfo.sheetOpen ? "" : StandardKey.MoveToPreviousChar; iconName: "go-previous"; onTriggered: previousPage(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; }, Kirigami.Action { text: i18nc("Go to the next page in the book", "Next page"); shortcut: bookInfo.sheetOpen ? "" : StandardKey.MoveToNextChar; iconName: "go-next"; onTriggered: nextPage(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; }, Kirigami.Action { text: applicationWindow().visibility !== Window.FullScreen ? i18nc("Enter full screen mode on a non-touch-based device", "Go full screen") : i18nc("Exit full sceen mode on a non-touch based device", "Exit full screen"); shortcut: (applicationWindow().visibility === Window.FullScreen) ? (bookInfo.sheetOpen ? "" : "Esc") : "f"; iconName: "view-fullscreen"; onTriggered: toggleFullscreen(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; }, Kirigami.Action { text: i18nc("Action used on non-touch devices to close the currently open book and return to whatever page was most recently shown", "Close book"); shortcut: (applicationWindow().visibility === Window.FullScreen) ? "" : (bookInfo.sheetOpen ? "" : "Esc"); iconName: "dialog-close"; onTriggered: closeBook(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; }, // Invisible actions, for use in bookInfo @@ -262,19 +248,19 @@ Kirigami.Page { visible: false; shortcut: bookInfo.sheetOpen ? StandardKey.MoveToPreviousChar : ""; onTriggered: bookInfo.previousBook(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; }, Kirigami.Action { visible: false; shortcut: bookInfo.sheetOpen ? StandardKey.MoveToNextChar : ""; onTriggered: bookInfo.nextBook(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; }, Kirigami.Action { visible: false; shortcut: bookInfo.sheetOpen ? "Return" : ""; onTriggered: bookInfo.openSelected(); - enabled: applicationWindow().pageStack.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; + enabled: applicationWindow().pageStack.layers.currentItem == root && applicationWindow().deviceType === applicationWindow().deviceTypeDesktop; } ] actions { @@ -286,7 +272,7 @@ Kirigami.Page { text: applicationWindow().visibility !== Window.FullScreen ? i18n("Enter full screen mode on any device type", "Go full screen") : i18nc("Exit full screen mode on any device type", "Exit full screen"); iconName: "view-fullscreen"; onTriggered: toggleFullscreen(); - enabled: applicationWindow().pageStack.currentItem == root; + enabled: applicationWindow().pageStack.layers.currentItem == root; } Kirigami.Action { id: bookInfoAction; @@ -294,7 +280,7 @@ Kirigami.Page { shortcut: bookInfo.sheetOpen ? "Esc" : ""; iconName: "dialog-cancel"; onTriggered: bookInfo.close(); - enabled: applicationWindow().pageStack.currentItem == root; + enabled: applicationWindow().pageStack.layers.currentItem == root; } Item { @@ -324,15 +310,6 @@ Kirigami.Page { item.file = root.file; } } - Timer { - id: drawerTimer; - interval: applicationWindow().animationDuration * 3; - running: false; - repeat: false; - onTriggered: { - applicationWindow().globalDrawer.close(); - } - } Binding { target: viewLoader.item; property: "rtlMode"; @@ -361,8 +338,7 @@ Kirigami.Page { viewLoader.item.currentPage = root.currentPage; viewLoader.loadingCompleted = true; root.title = viewLoader.item.title; - drawerTimer.start(); - restoreViewLayoutStuff.start(); + applicationWindow().globalDrawer.close(); } } onCurrentPageChanged: { diff --git a/src/app/qml/PeruseContextDrawer.qml b/src/app/qml/PeruseContextDrawer.qml index efba184..b5b88b9 100644 --- a/src/app/qml/PeruseContextDrawer.qml +++ b/src/app/qml/PeruseContextDrawer.qml @@ -43,7 +43,9 @@ OverlayDrawer { * This can be any type of object that a ListView can accept as model. * It expects items compatible with either QAction or Kirigami Action */ - property var actions: pageStack.currentItem ? pageStack.currentItem.contextualActions : null + property var actions: pageStack.layers.depth > 1 + ? pageStack.layers.currentItem.contextualActions + : (pageStack.currentItem ? pageStack.currentItem.contextualActions : null) enabled: actions !== undefined && actions.length > 0; edge: Qt.RightEdge drawerOpen: false @@ -55,14 +57,6 @@ OverlayDrawer { handleVisible: applicationWindow == undefined || applicationWindow().wideScreen == true ? false : applicationWindow().controlsVisible - Connections { - target: pageStack - onCurrentItemChanged: { - if (pageStack.currentItem) - actions = pageStack.currentItem.contextualActions - } - } - contentItem: QtControls.StackView { id: sidebarStack; implicitWidth: Units.gridUnit * 20 diff --git a/src/app/qml/PeruseMain.qml b/src/app/qml/PeruseMain.qml index db3615f..317e224 100644 --- a/src/app/qml/PeruseMain.qml +++ b/src/app/qml/PeruseMain.qml @@ -47,7 +47,7 @@ Kirigami.ApplicationWindow { if(mainWindow.pageStack.lastItem.objectName === "bookViewer") { mainWindow.pageStack.pop(); } - mainWindow.pageStack.push(bookViewer, { focus: true, file: filename, currentPage: currentPage }) + mainWindow.pageStack.layers.push(bookViewer, { focus: true, file: filename, currentPage: currentPage }) peruseConfig.bookOpened(filename); } |
