import QtQuick 1.0 import QtMobility.gallery 1.1 import com.nokia.symbian 1.0 Page { id: fileSavePage anchors.fill: parent property int fileNameRectangleHeight: 48 property string fileUrlPath: "" signal fileSelected(string fileUrl) signal saveCancelled() onStatusChanged: { if (status === PageStatus.Activating) { imageGridView.visible = false; waitRectangle.visible = true; } else if (status === PageStatus.Active) { imageGridView.currentIndex = -1; documentGalleryModel.reload(); } } function setFileUrl(file_url) { var urlPathNameRegexp = /^(.+)\/([^/]+)$/; var urlPathNameArr; if ((urlPathNameArr = urlPathNameRegexp.exec(file_url)) !== null) { fileUrlPath = urlPathNameArr[1]; fileNameTextField.text = urlPathNameArr[2]; } else { fileUrlPath = ""; fileNameTextField.text = ""; } } function normalizeFileUrl(file_url) { var fileUrlRegexp = /^file:\/\/\/.+$/; if (fileUrlRegexp.exec(file_url) !== null) { return file_url; } else { return "file:///" + file_url; } } Rectangle { id: gridViewBackground anchors.top: parent.top anchors.bottom: fileNameRectangle.top anchors.left: parent.left anchors.right: parent.right color: "black" GridView { id: imageGridView anchors.fill: parent cellWidth: width > height ? Math.floor(width / 5) : Math.floor(width / 3) cellHeight: height > width ? Math.floor(height / 5) : Math.floor(height / 3) model: documentGalleryModel delegate: documentGalleryDelegate visible: false onCurrentIndexChanged: { if (currentIndex !== -1) { fileSavePage.setFileUrl(fileSavePage.normalizeFileUrl(documentGalleryModel.property(imageGridView.currentIndex, "url"))); } } DocumentGalleryModel { id: documentGalleryModel rootType: DocumentGallery.Image autoUpdate: true properties: ["url"] sortProperties: ["-lastModified"] onStatusChanged: { if (status == DocumentGalleryModel.Finished || status === DocumentGalleryModel.Idle) { waitRectangle.visible = false; imageGridView.visible = true; } } } Component { id: documentGalleryDelegate Rectangle { id: galleryItemRectangle width: imageGridView.cellWidth - border.width height: imageGridView.cellHeight - border.width color: "transparent" border.color: GridView.isCurrentItem ? "white" : "steelblue" border.width: 2 MouseArea { id: galleryItemMouseArea anchors.fill: parent onClicked: { imageGridView.currentIndex = index; } Image { id: galleryItemImage anchors.centerIn: parent width: parent.width - galleryItemRectangle.border.width height: parent.height - galleryItemRectangle.border.width source: url sourceSize.width: width asynchronous: true fillMode: Image.PreserveAspectFit smooth: false } } } } } Rectangle { id: waitRectangle anchors.fill: parent color: "transparent" MouseArea { id: waitRectangleMouseArea anchors.fill: parent Image { id: waitBusyIndicatorImage anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source: "qrc:/resources/images/busy_indicator.png" NumberAnimation on rotation { running: waitRectangle.visible from: 0 to: 360 loops: Animation.Infinite } } } } } Rectangle { id: fileNameRectangle anchors.bottom: bottomToolBar.top anchors.left: parent.left anchors.right: parent.right height: fileSavePage.fileNameRectangleHeight z: 1 color: "black" TextField { id: fileNameTextField anchors.fill: parent } } ToolBar { id: bottomToolBar anchors.bottom: parent.bottom z: 1 tools: ToolBarLayout { ButtonRow { id: bottomToolBarButtonRow exclusive: false ToolButton { id: saveToolButton iconSource: "qrc:/resources/images/save.png" flat: true enabled: fileSavePage.fileUrlPath !== "" && fileNameTextField.text !== "" onClicked: { if (fileSavePage.fileUrlPath !== "" && fileNameTextField.text !== "") { fileSavePage.fileSelected(fileSavePage.fileUrlPath + "/" + fileNameTextField.text); } } } ToolButton { id: saveCancelToolButton iconSource: "qrc:/resources/images/cancel.png" flat: true onClicked: { fileSavePage.saveCancelled(); } } } } } }