-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.qml
More file actions
230 lines (199 loc) · 7.13 KB
/
main.qml
File metadata and controls
230 lines (199 loc) · 7.13 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import QtQuick
import QtCore
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import org.qfield
import org.qgis
import Theme
import "."
import "plugins"
Item {
id: mainLauncher
property var mainWindow: iface.mainWindow()
// Variable pour distinguer le clic du long press
property bool wasLongPress: false
// -----------------------------------------------------------
// 0. SYSTEME DE TRADUCTION
// -----------------------------------------------------------
function tr(text) {
var isFrench = Qt.locale().name.substring(0, 2) === "fr"
var dictionary = {
// Titres et labels
"Plugin Box": "Boîte à plugins",
"Tip: Long press on plugin icon to delete all filters\n or long press on FILTERS button": "Astuce : Appui long sur l'icône du plugin\npour supprimer tous les filtres\nou restez appuyez sur le bouton FILTRES",
// Boutons (avec Emojis)
"FILTERS": "🔍 FILTRES",
"Customize Position": "🎨 Personnaliser Position",
"Update .qgz": "🔄 Mise à jour .qgz",
"Manage Plugins": "🛠️ Gérer les Plugins", // NOUVEAU LIBELLE
// Messages Toast
"Filters cleared": "Filtres supprimés"
}
if (isFrench && dictionary[text] !== undefined) return dictionary[text]
// Fallback Anglais
if (text === "FILTERS") return "🔍 FILTERS"
if (text === "Customize Position") return "🎨 Customize Position"
if (text === "Update .qgz") return "🔄 Update .qgz"
if (text === "Manage Plugins") return "🛠️ Manage Plugins"
return text
}
// -----------------------------------------------------------
// 1. INSTANCIATION DES PLUGINS ENFANTS
// -----------------------------------------------------------
PositionSettings {
id: positionTool
}
FilterTool {
id: filterTool
}
PluginUpdateTool {
id: pluginUpdateTool
}
UpdateTool {
id: updateTool
}
// -----------------------------------------------------------
// 2. LOGIQUE DU LONG PRESS (TIMER)
// -----------------------------------------------------------
Timer {
id: longPressTimer
interval: 800
repeat: false
onTriggered: {
mainLauncher.wasLongPress = true
filterTool.removeAllFilters()
launcherBtn.opacity = 0.5
mainWindow.displayToast(tr("Filters cleared"))
restoreOpacityTimer.start()
}
}
Timer {
id: restoreOpacityTimer
interval: 200
onTriggered: launcherBtn.opacity = 1.0
}
// -----------------------------------------------------------
// 3. INTERFACE UTILISATEUR (BOUTON & MENU)
// -----------------------------------------------------------
QfToolButton {
id: launcherBtn
iconSource: 'icon.svg'
iconColor: Theme.mainColor
bgcolor: Theme.darkGray
round: true
onPressed: {
mainLauncher.wasLongPress = false
longPressTimer.start()
}
onReleased: {
if (longPressTimer.running) {
longPressTimer.stop()
launcherDialog.open()
}
}
}
Dialog {
id: launcherDialog
modal: true
visible: false
parent: mainLauncher.mainWindow.contentItem
anchors.centerIn: parent
width: Math.min(300, parent.width * 0.8)
background: Rectangle {
color: Theme.mainBackgroundColor
radius: 8
border.color: Theme.mainColor
border.width: 2
}
contentItem: ColumnLayout {
spacing: 15
Layout.margins: 15
Label {
text: tr("Plugin Box")
font.bold: true
font.pixelSize: 18
color: Theme.mainTextColor
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 10
}
// --- BOUTON 1 : FILTRES ---
Button {
text: tr("FILTERS")
Layout.fillWidth: true
Layout.preferredHeight: 50
font.bold: true
onClicked: {
launcherDialog.close()
filterTool.openFilterUI()
}
// 2. Appui long : Supprime les filtres (comme le bouton principal)
onPressAndHold: {
launcherDialog.close() // On ferme le menu pour valider l'action visuellement
filterTool.removeAllFilters() // Action de nettoyage
}
}
// --- BOUTON 2 : POSITION ---
Button {
text: tr("Customize Position")
Layout.fillWidth: true
Layout.preferredHeight: 50
font.bold: true
onClicked: {
launcherDialog.close()
positionTool.openSettings()
}
}
// --- BOUTON 3 : MISE A JOUR PROJET ---
Button {
text: tr("Update .qgz")
Layout.fillWidth: true
Layout.preferredHeight: 50
font.bold: true
contentItem: Text {
text: parent.text
color: "#1976D2" // Bleu
font: parent.font
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: {
launcherDialog.close()
updateTool.openUpdateUI()
}
}
// --- BOUTON 4 : MISE A JOUR DES PLUGINS (Remplacement) ---
Button {
text: tr("Manage Plugins")
Layout.fillWidth: true
Layout.preferredHeight: 50
font.bold: true
contentItem: Text {
text: parent.text
color: "#D32F2F" // Conserve le rouge pour le style
font: parent.font
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: {
launcherDialog.close()
// Appel de la nouvelle fonction du plugin annexe
pluginUpdateTool.openPluginUpdateUI()
}
}
// Petit texte d'aide
Label {
text: tr("Tip: Long press on plugin icon to delete all filters\n or long press on FILTERS button")
color: Theme.secondaryTextColor
font.pixelSize: 10
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
Layout.topMargin: 10
Layout.bottomMargin: 5
}
}
}
Component.onCompleted: {
iface.addItemToPluginsToolbar(launcherBtn);
}
}