Warning, /graphics/krita/libs/libqml/qml/OpenImagePage.qml is written in an unsupported language. File is not indexed.

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2012 Boudewijn Rempt <boud@kogmbh.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.3
0008 import org.krita.sketch 1.0 as Krita
0009 import org.krita.sketch.components 1.0
0010 
0011 Page {
0012     id: base;
0013     signal finished(string file);
0014 
0015     Rectangle {
0016         anchors.fill: parent;
0017         color: Settings.theme.color("pages/open/background");
0018     }
0019 
0020     Header {
0021         id: header;
0022 
0023         anchors {
0024             top: parent.top;
0025             left: parent.left;
0026             right: parent.right;
0027         }
0028 
0029         text: qsTr("Open Image");
0030 
0031         background: "images/header_krita_sketch.png";
0032 
0033         leftArea: Button {
0034             width: Krita.Constants.GridWidth;
0035             height: Krita.Constants.GridHeight;
0036             image: Settings.theme.icon("close");
0037             onClicked: mainWindow.hideFileOpenDialog();
0038         }
0039 
0040         rightArea: Button {
0041             width: Krita.Constants.GridWidth;
0042             height: Krita.Constants.GridHeight;
0043             image: Settings.theme.icon("up");
0044             onClicked: view.model.path = view.model.parentFolder;
0045         }
0046 
0047         Label {
0048             id: location;
0049 
0050             anchors.bottom: parent.bottom;
0051             anchors.horizontalCenter: parent.horizontalCenter;
0052 
0053             color: Settings.theme.color("pages/open/location");
0054             text: view.model.path;
0055         }
0056     }
0057 
0058     Shadow {
0059         anchors {
0060             top: header.bottom;
0061             left: parent.left;
0062             right: parent.right;
0063         }
0064         z: 5;
0065     }
0066 
0067     GridView {
0068         id: view;
0069         function startNavigation(path) {
0070             navigating = true;
0071             model.path = path;
0072             navigationTimer.start();
0073         }
0074         Timer {
0075             id: navigationTimer;
0076             interval: 150; running: false; repeat: false;
0077             onTriggered: view.navigating = false;
0078         }
0079         property bool navigating: false;
0080         anchors {
0081             top: header.bottom;
0082             left: parent.left;
0083             right: parent.right;
0084             bottom: parent.bottom;
0085         }
0086 
0087         // TODO: get filter from code, to get all supported types
0088         model: Krita.FileSystemModel { filter: "*.png *.jpg *.jpeg *.bmp *.kra *.psd *.ora *.tif *.tiff *.exr" }
0089         delegate: delegate;
0090 
0091         cellWidth: Krita.Constants.GridWidth * 4;
0092         cellHeight: Krita.Constants.GridHeight * 1.75;
0093 
0094         clip: true;
0095 
0096         ScrollDecorator { }
0097     }
0098 
0099     Component {
0100         id: delegate;
0101 
0102         ListItem {
0103             id: delegateBase;
0104 
0105             width: GridView.view.cellWidth;
0106 
0107             property bool directory: model.icon === "inode/directory";
0108 
0109             imageShadow: directory ? false : true;
0110             image.source: directory ? Settings.theme.icon("fileopen-black") : model.icon;
0111             image.fillMode: directory ? Image.PreserveAspectFit : Image.PreserveAspectCrop;
0112             image.smooth: true;
0113 
0114             title: model.fileName;
0115             //description: model.icon !== "inode/directory" ? model.date : "";
0116 
0117             onClicked: {
0118                 if ( GridView.view.navigating ) {
0119                     return;
0120                 }
0121                 if ( model.icon === "inode/directory" ) {
0122                     view.startNavigation(model.path);
0123                 } else {
0124                     //base.finished(model.path);
0125                     mainWindow.slotOpenImage(model.path)
0126                 }
0127             }
0128         }
0129     }
0130 }