21 import org.kde.kirigami 1.0
35 z: modal ? (opened ? 100 : 99 ): 98
43 default property alias page: mainPage.data
49 property Item contentItem
56 property Item background
63 property alias opened: mainFlickable.open
75 property
int edge: Qt.LeftEdge
83 property real position: 0
90 property
bool handleVisible: typeof(applicationWindow)===typeof(Function) && applicationWindow() ? applicationWindow().controlsVisible :
true
140 mainAnim.to = drawerPage.width;
143 mainAnim.to = drawerPage.height;
151 mainAnim.running =
true;
152 mainFlickable.open =
true;
167 mainAnim.to = drawerPage.width;
170 mainAnim.to = drawerPage.height;
173 mainAnim.running =
true;
174 mainFlickable.open =
false;
184 onBackgroundChanged: {
186 background.parent = mainItem;
187 background.anchors.fill = drawerPage;
191 if (!mainFlickable.loopCheck) {
192 mainFlickable.loopCheck =
true;
193 if (!mainFlickable.flicking && !mainFlickable.dragging && !mainAnim.running) {
196 mainFlickable.contentX = drawerPage.width * position;
199 mainFlickable.contentX = drawerPage.width * (1-position);
202 mainFlickable.contentY = drawerPage.height * position;
206 mainFlickable.loopCheck =
false;
209 onContentItemChanged: {
210 contentItem.parent = drawerPage
211 contentItem.anchors.fill = drawerPage
212 if (contentItem.flickableItem !== undefined) {
213 contentItem.anchors.topMargin = 0;
214 contentItem.anchors.leftMargin = 0;
215 contentItem.anchors.bottomMargin = 0;
216 contentItem.anchors.rightMargin = 0;
218 contentItem.anchors.topMargin = root.topPadding;
219 contentItem.anchors.leftMargin = root.leftPadding;
220 contentItem.anchors.bottomMargin = root.bottomPadding;
221 contentItem.anchors.rightMargin = root.rightPadding;
229 onChildrenChanged: mainPage.children[0].anchors.fill = mainPage
235 opacity: 0.6 * mainFlickable.internalPosition
244 target: mainFlickable
245 properties: (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) ?
"contentX" :
"contentY"
247 easing.type: mainAnim.to > 0 ? Easing.InQuad : Easing.OutQuad
253 right: root.edge == Qt.LeftEdge ? undefined : parent.right
254 left: root.edge == Qt.RightEdge ? undefined : parent.left
255 top: root.edge == Qt.BottomEdge ? undefined : parent.top
256 bottom: root.edge == Qt.TopEdge ? undefined : parent.bottom
261 property int startMouseX
262 property real oldMouseX
263 property int startMouseY
264 property real oldMouseY
265 property bool startDragging:
false
267 function managePress(mouse) {
268 if (drawerPage.children.length == 0) {
269 mouse.accepted =
false;
273 speedSampler.restart();
274 mouse.accepted =
true;
275 oldMouseX = startMouseX = mouse.x;
276 oldMouseY = startMouseY = mouse.y;
277 startDragging =
false;
284 if (!root.contentItem) {
285 mouse.accepted =
false;
289 if (Math.abs(mouse.x - startMouseX) > root.width / 5 ||
290 Math.abs(mouse.y - startMouseY) > root.height / 5) {
291 startDragging =
true;
296 mainFlickable.contentX = Math.min(mainItem.width - root.width, mainFlickable.contentX + oldMouseX - mouse.x);
299 mainFlickable.contentX = Math.max(0, mainFlickable.contentX + oldMouseX - mouse.x);
302 mainFlickable.contentY = Math.min(mainItem.height - root.height, mainFlickable.contentY + oldMouseY - mouse.y);
305 mainFlickable.contentY = Math.max(0, mainFlickable.contentY + oldMouseY - mouse.y);
313 if (!startDragging) {
316 speedSampler.running =
false;
317 if (speedSampler.speed != 0) {
318 if (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) {
319 mainFlickable.flick(speedSampler.speed, 0);
321 mainFlickable.flick(0, speedSampler.speed);
324 if (mainFlickable.internalPosition > 0.5) {
337 right: root.edge == Qt.LeftEdge ? undefined : parent.right
338 left: root.edge == Qt.RightEdge ? undefined : parent.left
339 bottom: parent.bottom
340 leftMargin: root.opened ? drawerPage.width : 0
341 rightMargin: root.opened ? drawerPage.width : 0
343 visible: root.handleVisible && (root.edge == Qt.LeftEdge || root.edge == Qt.RightEdge)
346 onPressed: edgeMouse.managePress(mouse);
347 onPositionChanged: edgeMouse.positionChanged(mouse);
348 onReleased: edgeMouse.released(mouse);
349 onClicked: root.opened ? root.close() : root.open();
357 property real oldContentX
358 property real oldContentY
360 if (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) {
361 speed = (mainFlickable.contentX - oldContentX) * 10;
362 oldContentX = mainFlickable.contentX;
364 speed = (mainFlickable.contentY - oldContentY) * 10;
365 oldContentY = mainFlickable.contentY;
371 oldContentX = mainFlickable.contentX;
372 oldContentY = mainFlickable.contentY;
374 if (root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) {
375 speed = (oldContentX - mainFlickable.contentX) * 10;
377 speed = (oldContentY - mainFlickable.contentY) * 10;
386 drag.filterChildren:
true
388 if ((root.edge == Qt.LeftEdge && mouse.x < drawerPage.width) ||
389 (root.edge == Qt.RightEdge && mouse.x > drawerPage.x - mainFlickable.contentX) ||
390 (root.edge == Qt.TopEdge && mouse.y < drawerPage.height) ||
391 (root.edge == Qt.BottomEdge && mouse.y > drawerPage.y - mainFlickable.contentY)) {
397 enabled: (root.edge == Qt.LeftEdge && !mainFlickable.atXEnd) ||
398 (root.edge == Qt.RightEdge && !mainFlickable.atXBeginning) ||
399 (root.edge == Qt.TopEdge && !mainFlickable.atYEnd) ||
400 (root.edge == Qt.BottomEdge && !mainFlickable.atYBeginning) ||
407 interactive: root.modal
411 Qt.inputMethod.hide();
416 enabled: parent.enabled
417 flickableDirection: root.edge == Qt.LeftEdge || root.edge == Qt.RightEdge ? Flickable.HorizontalFlick : Flickable.VerticalFlick
418 contentWidth: mainItem.width
419 contentHeight: mainItem.height
420 boundsBehavior: Flickable.StopAtBounds
421 readonly
property real internalPosition: {
424 return mainFlickable.contentX/drawerPage.width;
426 return 1 - (mainFlickable.contentX/drawerPage.width);
428 return mainFlickable.contentY/drawerPage.height;
430 return 1 - (mainFlickable.contentY/drawerPage.height);
433 property bool loopCheck:
false
434 onInternalPositionChanged: {
437 root.position = internalPosition;
444 if (internalPosition > 0.5) {
459 width: root.width + ((root.edge == Qt.RightEdge || root.edge == Qt.LeftEdge) ? drawerPage.width : 0)
460 height: root.height + ((root.edge == Qt.TopEdge || root.edge == Qt.BottomEdge) ? drawerPage.height : 0)
462 if (root.edge == Qt.LeftEdge) {
464 mainFlickable.contentX = 0;
466 mainFlickable.contentX = drawerPage.width;
471 if (root.edge == Qt.TopEdge) {
472 mainFlickable.contentY = drawerPage.Height;
481 left: root.edge != Qt.RightEdge ? parent.left : undefined
482 right: root.edge != Qt.LeftEdge ? parent.right : undefined
483 top: root.edge != Qt.BottomEdge ? parent.top : undefined
484 bottom: root.edge != Qt.TopEdge ? parent.bottom : undefined
488 width: root.contentItem ? Math.min(root.contentItem.implicitWidth, root.width * 0.7) : 0
489 height: root.contentItem ? Math.min(root.contentItem.implicitHeight, root.height * 0.7) : 0
int smallSpacing
units.smallSpacing is the amount of spacing that should be used around smaller UI elements...
int longDuration
units.longDuration should be used for longer, screen-covering animations, for opening and closing of ...
QtObject iconSizes
units.iconSizes provides access to platform-dependent icon sizing