Changeset View
Changeset View
Standalone View
Standalone View
src/app/qml/viewers/ImageBrowser.qml
Show All 17 Lines | |||||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | * | 19 | * | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | import QtQuick 2.3 | 22 | import QtQuick 2.3 | ||
23 | // import QtQuick.Layouts 1.1 | 23 | // import QtQuick.Layouts 1.1 | ||
24 | // import QtQuick.Controls 1.0 as QtControls | 24 | // import QtQuick.Controls 1.0 as QtControls | ||
25 | 25 | | |||
26 | /** | ||||
27 | * @brief The image viewer used by the CBR and Folder Viewer Base classes. | ||||
28 | * | ||||
29 | * It handles drawing the image and the different zoom modes. | ||||
30 | */ | ||||
26 | ListView { | 31 | ListView { | ||
27 | id: root | 32 | id: root | ||
28 | signal goNextPage(); | 33 | signal goNextPage(); | ||
29 | signal goPreviousPage(); | 34 | signal goPreviousPage(); | ||
30 | 35 | | |||
31 | property int imageWidth | 36 | property int imageWidth | ||
32 | property int imageHeight | 37 | property int imageHeight | ||
33 | 38 | | |||
34 | orientation: ListView.Horizontal | 39 | orientation: ListView.Horizontal | ||
35 | snapMode: ListView.SnapOneItem | 40 | snapMode: ListView.SnapOneItem | ||
36 | cacheBuffer: 3000 | 41 | cacheBuffer: 3000 | ||
37 | 42 | | |||
38 | // This ensures that the current index is always up to date, which we need to ensure we can track the current page | 43 | // This ensures that the current index is always up to date, which we need to ensure we can track the current page | ||
39 | // as required by the thumbnail navigator, and the resume-reading-from functionality | 44 | // as required by the thumbnail navigator, and the resume-reading-from functionality | ||
40 | onMovementEnded: { | 45 | onMovementEnded: { | ||
41 | var indexHere = indexAt(contentX + width / 2, contentY + height / 2); | 46 | var indexHere = indexAt(contentX + width / 2, contentY + height / 2); | ||
42 | if(currentIndex !== indexHere) { | 47 | if(currentIndex !== indexHere) { | ||
43 | currentIndex = indexHere; | 48 | currentIndex = indexHere; | ||
44 | } | 49 | } | ||
45 | } | 50 | } | ||
46 | 51 | /** | |||
52 | * An interactive area with an image. | ||||
53 | * | ||||
54 | * Clicking once on the image will hide all other controls from view. | ||||
55 | * Clicking twice will instead zoom in. | ||||
56 | * | ||||
57 | * Pinch will zoom in as well. | ||||
58 | */ | ||||
47 | delegate: Flickable { | 59 | delegate: Flickable { | ||
48 | id: flick | 60 | id: flick | ||
49 | width: imageWidth | 61 | width: imageWidth | ||
50 | height: imageHeight | 62 | height: imageHeight | ||
51 | contentWidth: imageWidth | 63 | contentWidth: imageWidth | ||
52 | contentHeight: imageHeight | 64 | contentHeight: imageHeight | ||
53 | interactive: contentWidth > width || contentHeight > height | 65 | interactive: contentWidth > width || contentHeight > height | ||
54 | onInteractiveChanged: root.interactive = !interactive; | 66 | onInteractiveChanged: root.interactive = !interactive; | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |