• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • active
  • app
  • package
  • contents
  • ui
Browser.qml
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Marco Martin <mart@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 import QtQuick 1.1
21 import org.kde.plasma.components 0.1 as PlasmaComponents
22 import org.kde.plasma.extras 0.1 as PlasmaExtras
23 import org.kde.plasma.core 0.1 as PlasmaCore
24 import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
25 import org.kde.qtextracomponents 0.1
26 import org.kde.okular 0.1 as Okular
27 
28 
29 MobileComponents.OverlayDrawer {
30  id: resourceBrowser
31  property string currentUdi
32  anchors.fill: parent
33 
34  MouseEventListener {
35  id: pageArea
36  anchors.fill: parent
37  //enabled: !delegate.interactive
38  property Item delegate: delegate1
39  property Item oldDelegate: delegate2
40  property bool incrementing: delegate.delta > 0
41  Connections {
42  target: pageArea.delegate
43  onDeltaChanged: {
44  pageArea.oldDelegate.delta = pageArea.delegate.delta
45  if (pageArea.delegate.delta > 0) {
46  pageArea.oldDelegate.visible = true
47  pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber + 1
48  documentItem.currentPage = pageArea.oldDelegate.pageNumber
49  pageArea.oldDelegate.visible = !(pageArea.delegate.pageNumber == documentItem.pageCount-1)
50  } else if (pageArea.delegate.delta < 0) {
51  pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber - 1
52  documentItem.currentPage = pageArea.oldDelegate.pageNumber
53 
54  pageArea.oldDelegate.visible = pageArea.delegate.pageNumber != 0
55  }
56  }
57  }
58 
59  property int startMouseScreenX
60  property int startMouseScreenY
61  onPressed: {
62  startMouseScreenX = mouse.screenX
63  startMouseScreenY = mouse.screenY
64  }
65  onPositionChanged: {
66  if (Math.abs(mouse.screenX - startMouseScreenX) > width/5) {
67  delegate.pageSwitchEnabled = true
68  }
69  }
70  onReleased: {
71  delegate.pageSwitchEnabled = false
72  if (Math.abs(mouse.screenX - startMouseScreenX) < 20 &&
73  Math.abs(mouse.screenY - startMouseScreenY) < 20) {
74  if (browserFrame.state == "Closed") {
75  browserFrame.state = "Hidden"
76  } else {
77  browserFrame.state = "Closed"
78  }
79 
80  } else if (oldDelegate.visible && delegate.delta != 0 &&
81  (Math.abs(mouse.screenX - startMouseScreenX) > width/5) &&
82  Math.abs(mouse.screenX - startMouseScreenX) > Math.abs(mouse.screenY - startMouseScreenY)) {
83  oldDelegate = delegate
84  delegate = (delegate == delegate1) ? delegate2 : delegate1
85  switchAnimation.running = true
86  }
87  }
88  FullScreenDelegate {
89  id: delegate2
90  width: parent.width
91  height: parent.height
92  }
93  FullScreenDelegate {
94  id: delegate1
95  width: parent.width
96  height: parent.height
97  Component.onCompleted: pageNumber = documentItem.currentPage
98  }
99 
100  SequentialAnimation {
101  id: switchAnimation
102  NumberAnimation {
103  target: pageArea.oldDelegate
104  properties: "x"
105  to: pageArea.incrementing ? -pageArea.oldDelegate.width : pageArea.oldDelegate.width
106  easing.type: Easing.InQuad
107  duration: 250
108  }
109  ScriptAction {
110  script: {
111  pageArea.oldDelegate.z = 0
112  pageArea.delegate.z = 10
113  pageArea.oldDelegate.x = 0
114  pageArea.delegate.x = 0
115  }
116  }
117  ScriptAction {
118  script: delegate1.delta = delegate2.delta = 0
119  }
120  }
121  }
122  PlasmaComponents.ScrollBar {
123  flickableItem: pageArea.delegate.flickable
124  orientation: Qt.Vertical
125  anchors {
126  right: pageArea.right
127  top: pageArea.top
128  bottom: pageArea.bottom
129  left: undefined
130  }
131  }
132  PlasmaComponents.ScrollBar {
133  flickableItem: pageArea.delegate.flickable
134  orientation: Qt.Horizontal
135  anchors {
136  left: pageArea.left
137  right: pageArea.right
138  bottom: pageArea.bottom
139  top: undefined
140  }
141  }
142 
143  drawer: Item {
144  id: browserFrame
145  anchors.fill: parent
146  state: "Hidden"
147 
148 
149  PlasmaComponents.ToolBar {
150  id: mainToolBar
151 
152  y: pageStack.currentPage.contentY <= 0 ? 0 : -height
153  transform: Translate {
154  y: Math.max(0, -pageStack.currentPage.contentY)
155  }
156  tools: pageStack.currentPage.tools
157  Behavior on y {
158  NumberAnimation {
159  duration: 250
160  }
161  }
162  anchors {
163  left: parent.left
164  right: parent.right
165  }
166  }
167 
168 
169  PlasmaComponents.PageStack {
170  id: pageStack
171  anchors {
172  left: parent.left
173  top: mainToolBar.bottom
174  right: parent.right
175  bottom: parent.bottom
176  }
177  clip: true
178  toolBar: mainToolBar
179  }
180 
181  Connections {
182  id: scrollConnection
183  property int oldContentY:0
184  target: pageStack.currentPage
185 
186  onContentYChanged: {
187 
188  if (pageStack.currentPage.contentHeight <= pageStack.height ||
189  (scrollConnection.oldContentY < pageStack.currentPage.contentY &&
190  pageStack.currentPage.contentY > 0)) {
191  tabsToolbar.y = tabsToolbar.parent.height - tabsToolbar.height
192  } else {
193  tabsToolbar.y = tabsToolbar.parent.height
194  }
195  scrollConnection.oldContentY = pageStack.currentPage.contentY
196  }
197  }
198 
199  PlasmaComponents.ToolBar {
200  id: tabsToolbar
201  y: parent.height
202  anchors {
203  top: undefined
204  bottom: undefined
205  left: parent.left
206  right: parent.right
207  }
208  tools: Item {
209  width: parent.width
210  height: childrenRect.height
211  PlasmaComponents.TabBar {
212  id: mainTabBar
213  anchors.horizontalCenter: parent.horizontalCenter
214  PlasmaComponents.TabButton {
215  id: thumbnailsButton
216  text: i18n("Thumbnails")
217  onCheckedChanged: {
218  if (checked) {
219  pageStack.replace(Qt.createComponent("Thumbnails.qml"))
220  }
221  }
222  }
223  PlasmaComponents.TabButton {
224  id: tocButton
225  enabled: documentItem.tableOfContents.count > 0
226  text: i18n("Table of contents")
227  onCheckedChanged: {
228  if (checked) {
229  pageStack.replace(Qt.createComponent("TableOfContents.qml"))
230  }
231  }
232  }
233  PlasmaComponents.TabButton {
234  id: bookmarksButton
235  enabled: documentItem.bookmarkedPages.length > 0
236  text: i18n("Bookmarks")
237  onCheckedChanged: {
238  if (checked) {
239  pageStack.replace(Qt.createComponent("Bookmarks.qml"))
240  }
241  }
242  }
243  }
244  }
245  Behavior on y {
246  NumberAnimation {
247  duration: 250
248  }
249  }
250  }
251  }
252 }
253 
MouseEventListener
FullScreenDelegate
Definition: FullScreenDelegate.qml:26
FullScreenDelegate::delta
int delta
Definition: FullScreenDelegate.qml:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal