2 import Sailfish.Silica 1.0
3 import harbour.file.browser.FileInfo 1.0
4 import QtMultimedia 5.0
5 import "functions.js" as Functions
10 //allowedOrientations: Orientation.All
11 property string file: "/"
17 // called when open command exits
20 notificationPanel.showTextWithTimer(qsTr("Open successful"),
21 qsTr("Sometimes the application stays in the background"));
22 } else if (exitCode === 1) {
23 notificationPanel.showTextWithTimer(qsTr("Internal error"),
24 "xdg-open exit code 1");
25 } else if (exitCode === 2) {
26 notificationPanel.showTextWithTimer(qsTr("File not found"),
28 } else if (exitCode === 3) {
29 notificationPanel.showTextWithTimer(qsTr("No application to open the file"),
30 qsTr("xdg-open found no preferred application (3)"));
31 } else if (exitCode === 4) {
32 notificationPanel.showTextWithTimer(qsTr("Action failed"),
33 "xdg-open exit code 4");
34 } else if (exitCode === -88888) {
35 notificationPanel.showTextWithTimer(qsTr("xdg-open not found"), "");
37 } else if (exitCode === -99999) {
38 notificationPanel.showTextWithTimer(qsTr("xdg-open crash?"), "");
41 notificationPanel.showTextWithTimer(qsTr("xdg-open error"), "exit code: "+exitCode);
49 contentHeight: column.height
50 VerticalScrollDecorator { flickable: flickable }
53 enabled: !fileInfo.isDir
54 visible: !fileInfo.isDir
58 visible: !fileInfo.isDir
59 onClicked: Functions.fileSelect(page.file)
62 text: qsTr("View Contents")
63 visible: !fileInfo.isDir
64 onClicked: pageStack.push(Qt.resolvedUrl("ViewPage.qml"),
68 // file type specific menu items
71 text: qsTr("Go to Target")
72 visible: fileInfo.icon === "folder-link"
73 onClicked: Functions.goToFolder(fileInfo.symLinkTarget);
79 anchors.left: parent.left
80 anchors.right: parent.right
81 anchors.leftMargin: Theme.paddingLarge
82 anchors.rightMargin: Theme.paddingLarge
85 title: Functions.formatPathForTitle(fileInfo.absolutePath) + " " +
86 Functions.unicodeBlackDownPointingTriangle()
89 onClicked: dirPopup.show();
93 // file info texts, visible if error is not set
95 visible: fileInfo.errorMessage === ""
96 anchors.left: parent.left
97 anchors.right: parent.right
99 Image { // preview of image, max height 400
101 visible: isImageFile(fileInfo)
102 source: visible ? fileInfo.file : "" // access the source only if img is visible
103 anchors.left: parent.left
104 anchors.right: parent.right
105 height: implicitHeight < 400 && implicitHeight != 0 ? implicitHeight : 400
107 fillMode: Image.PreserveAspectFit
112 visible: isAudioFile(fileInfo)
113 icon.source: audioPlayer.playbackState !== MediaPlayer.PlayingState ?
114 "image://theme/icon-l-play" :
115 "image://theme/icon-l-pause"
116 anchors.horizontalCenter: parent.horizontalCenter
117 onClicked: playAudio();
118 MediaPlayer { // prelisten of audio
123 Spacer { height: 10; visible: playButton.visible } // fix to playButton height
124 // clickable icon and filename
128 height: openArea.height
129 onClicked: openFile()
133 color: Theme.highlightColor
135 visible: openButton.pressed
143 anchors.horizontalCenter: parent.horizontalCenter
144 source: "../images/large-"+fileInfo.icon+".png"
145 visible: !imagePreview.visible && !playButton.visible
147 Spacer { // spacing if image or play button is visible
150 visible: imagePreview.visible || playButton.visible
157 horizontalAlignment: Text.AlignHCenter
160 visible: fileInfo.symLinkTarget !== ""
162 text: Functions.unicodeArrow()+" "+fileInfo.symLinkTarget
164 horizontalAlignment: Text.AlignHCenter
165 font.pixelSize: Theme.fontSizeExtraSmall
167 Spacer { height: 20 }
170 Spacer { height: 20 }
173 visible: fileInfo.suffix === "apk" || fileInfo.suffix === "rpm" && !fileInfo.isDir
175 text: qsTr("Installable packages may contain malware.")
177 font.pixelSize: Theme.fontSizeExtraSmall
178 horizontalAlignment: Text.AlignHCenter
182 visible: fileInfo.suffix === "apk" || fileInfo.suffix === "rpm" && !fileInfo.isDir
187 label: qsTr("Location")
188 value: fileInfo.absolutePath
195 label: qsTr("Permissions")
196 value: fileInfo.permissions
200 value: fileInfo.owner
204 value: fileInfo.group
207 label: qsTr("Last modified")
208 value: fileInfo.modified
211 label: qsTr("Created")
212 value: fileInfo.created
216 // error label, visible if error message is set
218 visible: fileInfo.errorMessage !== ""
219 anchors.left: parent.left
220 anchors.right: parent.right
221 horizontalAlignment: Text.AlignHCenter
222 text: fileInfo.errorMessage
223 color: Theme.highlightColor
236 id: notificationPanel
240 function isImageFile(fileInfo)
242 if (fileInfo.isDir) return false;
243 return fileInfo.suffix === "jpg" || fileInfo.suffix === "jpeg" ||
244 fileInfo.suffix === "png" || fileInfo.suffix === "gif";
247 function isAudioFile(fileInfo)
249 if (fileInfo.isDir) return false;
250 return fileInfo.suffix === "wav" || fileInfo.suffix === "mp3" ||
251 fileInfo.suffix === "ogg" || fileInfo.suffix === "flac" ||
252 fileInfo.suffix === "aac" || fileInfo.suffix === "m4a";
255 function isVideoFile(fileInfo)
257 if (fileInfo.isDir) return false;
258 return fileInfo.suffix === "mp4" || fileInfo.suffix === "m4v";
261 function isMediaFile(fileInfo)
263 if (fileInfo.isDir) return false;
264 return isAudioFile(fileInfo) | isVideoFile(fileInfo);
269 // perform action depending on file type
270 if (fileInfo.icon === "folder-link") {
271 Functions.goToFolder(fileInfo.symLinkTarget);
273 } else if (fileInfo.isDir) {
274 Functions.goToFolder(fileInfo.file);
276 } else if (isAudioFile(fileInfo)) {
279 } else if (isImageFile(fileInfo) || isVideoFile(fileInfo)) {
280 fileInfo.executeCommand("xdg-open", [ page.file ])
283 pageStack.push(Qt.resolvedUrl("ViewPage.qml"), { path: page.file });
289 if (audioPlayer.playbackState !== MediaPlayer.PlayingState) {
290 audioPlayer.source = fileInfo.file;