-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.qml
141 lines (124 loc) · 2.97 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import QtQuick
import Painter 1.0
import QtQuick.Layouts
import QtQuick.Dialogs
import QtQuick.Controls
import AlgWidgets 2.0
import AlgWidgets.Style 2.0
import "photoshop.js" as Photoshop
PainterPlugin {
Component.onCompleted: {
// default value settings
if (!alg.settings.contains("launchPhotoshop")) {
if (Qt.platform.os == "windows" || Qt.platform.os == "osx") {
alg.settings.setValue("launchPhotoshop", true);
} else {
alg.settings.setValue("launchPhotoshop", false);
}
alg.settings.setValue("padding", false);
}
var sendtoAction = alg.ui.addAction(alg.ui.AppMenu.SendTo, qsTr("Export to Photoshop"), qsTr("Export to Photoshop"), Qt.resolvedUrl("icons/Photoshop_idle.svg"), Qt.resolvedUrl("icons/Photoshop_idle.svg"));
sendtoAction.triggered.connect(internal.sendToTriggered);
}
onConfigure: {
// open the configuration panel
configurePanel.open()
}
ConfigurePanel {
id: configurePanel
}
QtObject {
property bool loading: false
id: internal
function updateProgressWindow(text) {
progressText.text = text
}
function launchExportDialog() {
exportDialog.open()
}
function launchExport() {
try {
loading = true;
progressWindow.open()
Photoshop.importPainterDocument(updateProgressWindow);
}
catch (e) {
alg.log.warn(e.message)
}
finally {
progressWindow.close()
loading = false;
}
}
function sendToTriggered() {
if (!internal.loading) {
if (!alg.settings.contains("photoshopPath") && alg.settings.value("launchPhotoshop", false)) {
fileDialog.open();
} else {
internal.launchExportDialog()
}
}
}
}
ExportDialog {
id: exportDialog
onAccepted: {
close()
internal.launchExport()
}
}
AlgWindow {
id: progressWindow
minimumWidth: 400
minimumHeight: 125
maximumWidth: 400
maximumHeight: 125
title: qsTr("Export to Photoshop")
flags: Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
function reload() {
progressText.text = qsTr("Export in progress...")
}
Rectangle {
id: content
color: "transparent"
anchors.fill: parent
anchors.margins: 12
ColumnLayout {
spacing: 18
anchors.fill: parent
Rectangle {
color: "transparent"
Layout.fillWidth: true
AlgTextEdit {
id: progressText
anchors.centerIn: parent
width: parent.width
wrapMode: TextEdit.Wrap
clip: true
readOnly: true
}
}
Rectangle {
color: "transparent"
Layout.fillWidth: true
AlgProgressBar {
id: progressBar
anchors.centerIn: parent
width: parent.width
indeterminate: true
}
}
}
}
}
FileDialog {
id: fileDialog
title: qsTr("Please locate Photoshop...")
nameFilters: [ "Executable file (*.exe *.app)", "All files (*)" ]
selectedNameFilter.index : 0
onAccepted: {
alg.settings.setValue("photoshopPath", alg.fileIO.urlToLocalFile(fileDialog.selectedFile.toString()));
internal.launchExportDialog()
}
}
}