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        text: em.pty+qsTr("Use the file dialog to select a destination location.")
40        color: colour.bg_label
41        font.bold: true
42        font.pointSize: 20
43    }
44
45    PFileDialog {
46        id: filedialog
47        onAccepted:
48            copyFile(file)
49        onRejected: {
50            if(management_top.current === "cp")
51                management_top.hide()
52        }
53    }
54
55    Connections {
56        target: container
57        onItemShown:
58            filedialog.getFilename(em.pty+qsTr("Copy Image to..."), variables.currentDir + "/" +  variables.currentFile)
59        onItemHidden:
60            filedialog.close()
61    }
62
63    function copyFile(file) {
64        verboseMessage("FileManagement/Copy", "copyFile(): " + file)
65        getanddostuff.copyImage(variables.currentDir + "/" + variables.currentFile, file)
66        if(getanddostuff.removeFilenameFromPath(file) === variables.currentDir) {
67            Handle.loadFile(file, variables.filter, true)
68        }
69        management_top.hide()
70    }
71
72}
73