1/**************************************************************************
2 **                                                                      **
3 ** Copyright (C) 2018 Lukas Spies                                       **
4 ** Contact: http://photoqt.org                                          **
5 **                                                                      **
6 ** This file is part of PhotoQt.                                        **
7 **                                                                      **
8 ** PhotoQt is free software: you can redistribute it and/or modify      **
9 ** it under the terms of the GNU General Public License as published by **
10 ** the Free Software Foundation, either version 2 of the License, or    **
11 ** (at your option) any later version.                                  **
12 **                                                                      **
13 ** PhotoQt is distributed in the hope that it will be useful,           **
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of       **
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        **
16 ** GNU General Public License for more details.                         **
17 **                                                                      **
18 ** You should have received a copy of the GNU General Public License    **
19 ** along with PhotoQt. If not, see <http://www.gnu.org/licenses/>.      **
20 **                                                                      **
21 **************************************************************************/
22
23import QtQuick 2.5
24import PFileDialog 1.0
25import "../handlestuff.js" as Handle
26
27Item {
28
29    x: 0
30    y: (container.height-height-110)/2
31    width: container.width-110
32    height: container.height
33
34    Text {
35        width: parent.width
36        height: parent.height
37        verticalAlignment: Qt.AlignVCenter
38        horizontalAlignment: Qt.AlignHCenter
39        //: The destination location is a location on the computer to move a file to
40        text: em.pty+qsTr("Use the file dialog to select a destination location.")
41        color: colour.bg_label
42        font.bold: true
43        font.pointSize: 20
44    }
45
46    PFileDialog {
47        id: filedialog
48        onAccepted:
49            moveFile(file)
50        onRejected: {
51            if(management_top.current === "mv")
52                management_top.hide()
53        }
54    }
55
56    Connections {
57        target: container
58        onItemShown:
59            filedialog.getFilename(em.pty+qsTr("Move Image to..."), variables.currentDir + "/" +  variables.currentFile)
60        onItemHidden:
61            filedialog.close()
62    }
63
64    function moveFile(file) {
65        verboseMessage("FileManagement/Move", "moveFile(): " + file)
66        getanddostuff.moveImage(variables.currentDir + "/" + variables.currentFile, file)
67        if(getanddostuff.removeFilenameFromPath(file) === variables.currentDir) {
68            Handle.loadFile(file, variables.filter, true)
69            management_top.hide()
70        }
71    }
72
73}
74