From 8925eb58a83e1d0f8cb2ab57f00cec95a19fd21f Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Sun, 23 Jan 2022 17:31:34 +0100 Subject: [PATCH] Unsaved changes dialog, trying to start translating properties (not working yet). --- LogarithmPlotter/i18n/lp_de.ts | 157 ++++++++++++------ LogarithmPlotter/i18n/lp_en.ts | 157 ++++++++++++------ LogarithmPlotter/i18n/lp_es.ts | 157 ++++++++++++------ LogarithmPlotter/i18n/lp_fr.ts | 157 ++++++++++++------ LogarithmPlotter/i18n/lp_hu.ts | 157 ++++++++++++------ LogarithmPlotter/i18n/lp_nb_NO.ts | 157 ++++++++++++------ LogarithmPlotter/i18n/lp_template.ts | 157 ++++++++++++------ LogarithmPlotter/logarithmplotter.py | 2 +- .../eu/ad5001/LogarithmPlotter/AppMenuBar.qml | 22 ++- .../eu/ad5001/LogarithmPlotter/FileDialog.qml | 1 - .../eu/ad5001/LogarithmPlotter/History.qml | 9 + .../LogarithmPlotter/LogarithmPlotter.qml | 12 +- .../ObjectLists/EditorDialog.qml | 19 ++- .../eu/ad5001/LogarithmPlotter/Settings.qml | 1 + .../LogarithmPlotter/js/objs/function.js | 32 ++-- .../ad5001/LogarithmPlotter/js/parameters.js | 13 ++ 16 files changed, 823 insertions(+), 387 deletions(-) diff --git a/LogarithmPlotter/i18n/lp_de.ts b/LogarithmPlotter/i18n/lp_de.ts index dc3fef2..9fe9b7d 100644 --- a/LogarithmPlotter/i18n/lp_de.ts +++ b/LogarithmPlotter/i18n/lp_de.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter Über LogarithmPlotter @@ -28,95 +28,105 @@ AppMenuBar - + &File &Datei - + &Load... &Laden… - + &Save &Speichern - + Save &As... Speichern &Unter… - + &Quit &Ausfahrt - + &Edit &Bearbeiten - + &Undo &Lösen - + &Redo &Wiederherstellen - + &Copy plot Grafik &Kopieren - + &Create &Erstellen - + &Settings &Einstellungen - + Check for updates on startup Beim Starten auf Updates prüfen - + Reset redo stack automaticly Wiederherstellen-Stapel automatisch zurücksetzen - + &Help &Hilfe - + &Source code &Quellcode - + &Report a bug Fehler &Melden - + &Help translating! &Hilfe beim Übersetzen! - + &About &Übrigens + + + Save unsaved changes? + + + + + This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue? + + EditorDialog @@ -131,28 +141,28 @@ Name - + Label content Etikett - + null leer - + name Name - + name + value Name + Wert - - + + + Create new %1 + Neues %1objekt erstellen @@ -246,42 +256,42 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" Gespeicherte Grafik auf '%1'. - + Loading file '%1'. Laden der Datei '%1'. - + Unknown object type: %1. Unbekannter Objekttyp: %1. - + Invalid file provided. Ungültige Datei angegeben. - + Could not save file: Die Datei konnte nicht gespeichert werden: - + Loaded file '%1'. Geladene Datei '%1'. - + Copied plot screenshot to clipboard! Grafik in die Zwischenablage kopiert! - + &Update &Aktualisieren - + &Update LogarithmPlotter LogarithmPlotter &aktualisieren @@ -348,97 +358,97 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" Settings - + X Zoom Zoom auf X - + Y Zoom Zoom auf Y - + Min X Minimum X - + Max Y Maximum Y - + Max X Maximum X - + Min Y Minimum Y - + X Axis Step X-Achsen-Schritt - + Y Axis Step Y-Achsen-Schritt - + Line width Linienbreite - + Text size (px) Textgröße (px) - + X Label Label der X-Achse - + Y Label Label der Y-Achse - + X Log scale Logarithmische Skala in X - + Show X graduation X-Teilung anzeigen - + Show Y graduation Y-Teilung anzeigen - + Copy to clipboard Kopieren in die Zwischenablage - + Save plot Grafik speichern - + Save plot as Grafik speichern unter - + Load plot Grafik laden @@ -507,6 +517,49 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" %1 %2 ausgeblendet. + + parameters + + + above + + + + + below + + + + + left + + + + + right + + + + + above-left + + + + + above-right + + + + + below-left + + + + + below-right + + + phasebode diff --git a/LogarithmPlotter/i18n/lp_en.ts b/LogarithmPlotter/i18n/lp_en.ts index cc6e318..7f43098 100644 --- a/LogarithmPlotter/i18n/lp_en.ts +++ b/LogarithmPlotter/i18n/lp_en.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter About LogarithmPlotter @@ -28,95 +28,105 @@ AppMenuBar - + &File &File - + &Load... &Load… - + &Save &Save - + Save &As... Save &As… - + &Quit &Quit - + &Edit &Edit - + &Undo &Undo - + &Redo &Redo - + &Copy plot &Copy plot - + &Create &Create - + &Settings &Settings - + Check for updates on startup Check for updates on startup - + Reset redo stack automaticly Reset redo stack automatically - + &Help &Help - + &Source code &Source code - + &Report a bug &Report a bug - + &Help translating! &Help translating! - + &About &About + + + Save unsaved changes? + + + + + This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue? + + EditorDialog @@ -131,28 +141,28 @@ Name - + Label content Label content - + null null - + name name - + name + value name + value - - + + + Create new %1 + Create new %1 @@ -246,42 +256,42 @@ These settings can be changed at any time from the "Settings" menu.Saved plot to '%1'. - + Loading file '%1'. Loading file '%1'. - + Unknown object type: %1. Unknown object type: %1. - + Invalid file provided. Invalid file provided. - + Could not save file: Could not save file: - + Loaded file '%1'. Loaded file '%1'. - + Copied plot screenshot to clipboard! Copied plot screenshot to clipboard! - + &Update &Update - + &Update LogarithmPlotter &Update LogarithmPlotter @@ -348,97 +358,97 @@ These settings can be changed at any time from the "Settings" menu. Settings - + X Zoom X Zoom - + Y Zoom Y Zoom - + Min X Min X - + Max Y Max Y - + Max X Max X - + Min Y Min Y - + X Axis Step X Axis Step - + Y Axis Step Y Axis Step - + Line width Line width - + Text size (px) Text size (px) - + X Label X Label - + Y Label Y Label - + X Log scale X Log scale - + Show X graduation Show X graduation - + Show Y graduation Show Y graduation - + Copy to clipboard Copy to clipboard - + Save plot Save plot - + Save plot as Save plot as - + Load plot Load plot @@ -507,6 +517,49 @@ These settings can be changed at any time from the "Settings" menu.%1 %2 hidden. + + parameters + + + above + + + + + below + + + + + left + + + + + right + + + + + above-left + + + + + above-right + + + + + below-left + + + + + below-right + + + phasebode diff --git a/LogarithmPlotter/i18n/lp_es.ts b/LogarithmPlotter/i18n/lp_es.ts index 23732d7..3c31b1b 100644 --- a/LogarithmPlotter/i18n/lp_es.ts +++ b/LogarithmPlotter/i18n/lp_es.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter @@ -28,95 +28,105 @@ AppMenuBar - + &File - + &Load... - + &Save - + Save &As... - + &Quit - + &Edit - + &Undo - + &Redo - + &Copy plot - + &Create - + &Settings - + Check for updates on startup - + Reset redo stack automaticly - + &Help - + &Source code - + &Report a bug - + &Help translating! - + &About + + + Save unsaved changes? + + + + + This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue? + + EditorDialog @@ -131,28 +141,28 @@ - + Label content - + null - + name - + name + value - - + + + Create new %1 @@ -245,42 +255,42 @@ These settings can be changed at any time from the "Settings" menu. - + Loading file '%1'. - + Unknown object type: %1. - + Invalid file provided. - + Could not save file: - + Loaded file '%1'. - + Copied plot screenshot to clipboard! - + &Update - + &Update LogarithmPlotter @@ -347,97 +357,97 @@ These settings can be changed at any time from the "Settings" menu. Settings - + X Zoom - + Y Zoom - + Min X - + Max Y - + Max X - + Min Y - + X Axis Step - + Y Axis Step - + Line width - + Text size (px) - + X Label - + Y Label - + X Log scale - + Show X graduation - + Show Y graduation - + Copy to clipboard - + Save plot - + Save plot as - + Load plot @@ -506,6 +516,49 @@ These settings can be changed at any time from the "Settings" menu. + + parameters + + + above + + + + + below + + + + + left + + + + + right + + + + + above-left + + + + + above-right + + + + + below-left + + + + + below-right + + + phasebode diff --git a/LogarithmPlotter/i18n/lp_fr.ts b/LogarithmPlotter/i18n/lp_fr.ts index 3ef8845..2ec8da5 100644 --- a/LogarithmPlotter/i18n/lp_fr.ts +++ b/LogarithmPlotter/i18n/lp_fr.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter À propos de LogarithmPlotter @@ -28,96 +28,106 @@ AppMenuBar - + &File &Fichier - + &Load... &Ouvrir… - + &Save &Sauvegarder - + Save &As... Sauvegarde &Sous… - + &Quit &Quitter - + &Edit &Édition - + &Undo &Annuler - + &Redo &Rétablir - + &Copy plot &Copier le graphe - + &Create &Créer - + &Settings &Paramètres - + Check for updates on startup Vérifier la présence de mise à jour au démarrage - + Reset redo stack automaticly Légèrement long, et pas forcément très compréhensible. Réinitialiser la pile d'action "Rétablir" automatiquement - + &Help &Aide - + &Source code &Code source - + &Report a bug Rapport de bug - + &Help translating! &Aider à la traduction ! - + &About &À propos + + + Save unsaved changes? + + + + + This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue? + + EditorDialog @@ -132,28 +142,28 @@ Nom - + Label content Étiquette - + null vide - + name nom - + name + value nom + valeur - - + + + Create new %1 Traduction non litéralle pour éviter les problèmes de genre. + Créer un nouvel objet %1 @@ -254,42 +264,42 @@ These settings can always be changed at any time from the "Settings" m Graphe sauvegardé dans '%1'. - + Loading file '%1'. Chargement du fichier '%1'. - + Unknown object type: %1. Type d'objet inconnu : %1. - + Invalid file provided. Fichier fourni invalide. - + Could not save file: Impossible de sauvegarder le fichier : - + Loaded file '%1'. Fichier '%1' chargé. - + Copied plot screenshot to clipboard! Image du graphe copiée dans le presse-papiers ! - + &Update &Mise à jour - + &Update LogarithmPlotter &Mettre à jour LogarithmPlotter @@ -356,97 +366,97 @@ These settings can always be changed at any time from the "Settings" m Settings - + X Zoom Zoom en X - + Y Zoom Zoom en Y - + Min X Min X - + Max Y Max Y - + Max X Max X - + Min Y Min Y - + X Axis Step Pas de l'axe X - + Y Axis Step Pas de l'axe Y - + Line width Taille des lignes - + Text size (px) Taille du texte (px) - + X Label Label de l'axe X - + Y Label Label de l'axe Y - + X Log scale Échelle logarithmique en X - + Show X graduation Montrer la graduation de l'axe X - + Show Y graduation Montrer la graduation de l'axe Y - + Copy to clipboard Copier vers le presse-papiers - + Save plot Sauvegarder le graphe - + Save plot as Sauvegarder le graphe sous - + Load plot Charger un graphe @@ -515,6 +525,49 @@ These settings can always be changed at any time from the "Settings" m %1 %2 cachée(e). + + parameters + + + above + + + + + below + + + + + left + + + + + right + + + + + above-left + + + + + above-right + + + + + below-left + + + + + below-right + + + phasebode diff --git a/LogarithmPlotter/i18n/lp_hu.ts b/LogarithmPlotter/i18n/lp_hu.ts index d1ab6d2..9022215 100644 --- a/LogarithmPlotter/i18n/lp_hu.ts +++ b/LogarithmPlotter/i18n/lp_hu.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter @@ -28,95 +28,105 @@ AppMenuBar - + &File - + &Load... - + &Save - + Save &As... - + &Quit - + &Edit - + &Undo - + &Redo - + &Copy plot - + &Create - + &Settings - + Check for updates on startup - + Reset redo stack automaticly - + &Help - + &Source code - + &Report a bug - + &Help translating! - + &About + + + Save unsaved changes? + + + + + This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue? + + EditorDialog @@ -131,28 +141,28 @@ - + Label content - + null - + name - + name + value - - + + + Create new %1 @@ -245,42 +255,42 @@ These settings can be changed at any time from the "Settings" menu. - + Loading file '%1'. - + Unknown object type: %1. - + Invalid file provided. - + Could not save file: - + Loaded file '%1'. - + Copied plot screenshot to clipboard! - + &Update - + &Update LogarithmPlotter @@ -347,97 +357,97 @@ These settings can be changed at any time from the "Settings" menu. Settings - + X Zoom - + Y Zoom - + Min X - + Max Y - + Max X - + Min Y - + X Axis Step - + Y Axis Step - + Line width - + Text size (px) - + X Label - + Y Label - + X Log scale - + Show X graduation - + Show Y graduation - + Copy to clipboard - + Save plot - + Save plot as - + Load plot @@ -506,6 +516,49 @@ These settings can be changed at any time from the "Settings" menu. + + parameters + + + above + + + + + below + + + + + left + + + + + right + + + + + above-left + + + + + above-right + + + + + below-left + + + + + below-right + + + phasebode diff --git a/LogarithmPlotter/i18n/lp_nb_NO.ts b/LogarithmPlotter/i18n/lp_nb_NO.ts index 2e52427..545dfc5 100644 --- a/LogarithmPlotter/i18n/lp_nb_NO.ts +++ b/LogarithmPlotter/i18n/lp_nb_NO.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter Om @@ -28,95 +28,105 @@ AppMenuBar - + &File &Fil - + &Load... &Last inn … - + &Save &Lagre - + Save &As... Lagre &som … - + &Quit &Avslutt - + &Edit &Rediger - + &Undo &Angre - + &Redo &Gjenta - + &Copy plot &Kopier plott - + &Create &Opprett - + &Settings &Innstillinger - + Check for updates on startup Se etter nye versjoner ved programstart - + Reset redo stack automaticly Tilbakestill angrehistorikk automatisk - + &Help &Hjelp - + &Source code - + &Report a bug - + &Help translating! - + &About &Om + + + Save unsaved changes? + + + + + This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue? + + EditorDialog @@ -131,28 +141,28 @@ Navn - + Label content Etikett-innhold - + null NULL - + name navn - + name + value navn + veri - - + + + Create new %1 + Opprett nytt %1 @@ -246,42 +256,42 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.Lagret plott i «%1». - + Loading file '%1'. Laster inn «%1»-fil. - + Unknown object type: %1. Ukjent objekttype: %1. - + Invalid file provided. Ugyldig fil angitt. - + Could not save file: Kunne ikke lagre fil: - + Loaded file '%1'. Lastet inn filen «%1». - + Copied plot screenshot to clipboard! Kopierte plott-skjermavbildning til utklippstavlen! - + &Update &Oppdater - + &Update LogarithmPlotter &Installer ny versjon av LogartimePlotter @@ -348,97 +358,97 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. Settings - + X Zoom X-forstørrelse - + Y Zoom Y-forstørrelse - + Min X Min. X - + Max Y Maks. Y - + Max X Maks. X - + Min Y Min. Y - + X Axis Step X-aksesteg - + Y Axis Step Y-aksesteg - + Line width Linjebredde - + Text size (px) Tekststørrelse (piksler) - + X Label Navn på X-akse - + Y Label Navn på Y-akse - + X Log scale Logaritmisk skala i x - + Show X graduation Vis X-inndeling - + Show Y graduation Vis Y-inndeling - + Copy to clipboard Kopier til utklippstavle - + Save plot Lagre plott - + Save plot as Lagre plott som - + Load plot Last inn plott @@ -507,6 +517,49 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.%1 %2 skjult. + + parameters + + + above + + + + + below + + + + + left + + + + + right + + + + + above-left + + + + + above-right + + + + + below-left + + + + + below-right + + + phasebode diff --git a/LogarithmPlotter/i18n/lp_template.ts b/LogarithmPlotter/i18n/lp_template.ts index 041b785..689d033 100644 --- a/LogarithmPlotter/i18n/lp_template.ts +++ b/LogarithmPlotter/i18n/lp_template.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter @@ -28,95 +28,105 @@ AppMenuBar - + &File - + &Load... - + &Save - + Save &As... - + &Quit - + &Edit - + &Undo - + &Redo - + &Copy plot - + &Create - + &Settings - + Check for updates on startup - + Reset redo stack automaticly - + &Help - + &Source code - + &Report a bug - + &Help translating! - + &About + + + Save unsaved changes? + + + + + This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue? + + EditorDialog @@ -131,28 +141,28 @@ - + Label content - + null - + name - + name + value - - + + + Create new %1 @@ -245,42 +255,42 @@ These settings can be changed at any time from the "Settings" menu. - + Loading file '%1'. - + Unknown object type: %1. - + Invalid file provided. - + Could not save file: - + Loaded file '%1'. - + Copied plot screenshot to clipboard! - + &Update - + &Update LogarithmPlotter @@ -347,97 +357,97 @@ These settings can be changed at any time from the "Settings" menu. Settings - + X Zoom - + Y Zoom - + Min X - + Max Y - + Max X - + Min Y - + X Axis Step - + Y Axis Step - + Line width - + Text size (px) - + X Label - + Y Label - + X Log scale - + Show X graduation - + Show Y graduation - + Copy to clipboard - + Save plot - + Save plot as - + Load plot @@ -506,6 +516,49 @@ These settings can be changed at any time from the "Settings" menu. + + parameters + + + above + + + + + below + + + + + left + + + + + right + + + + + above-left + + + + + above-right + + + + + below-left + + + + + below-right + + + phasebode diff --git a/LogarithmPlotter/logarithmplotter.py b/LogarithmPlotter/logarithmplotter.py index 9859813..bdb09e6 100644 --- a/LogarithmPlotter/logarithmplotter.py +++ b/LogarithmPlotter/logarithmplotter.py @@ -103,7 +103,7 @@ class Helper(QObject): QMessageBox.warning(None, 'LogarithmPlotter', QCoreApplication.translate('main','Could not open file: "{}"\nFile does not exist.').format(filename), QMessageBox.Ok) # Cannot parse file chdir(path.dirname(path.realpath(__file__))) return data - + @Slot(result=str) def gettmpfile(self): global tmpfile diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/AppMenuBar.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/AppMenuBar.qml index 7bcca41..bce122e 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/AppMenuBar.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/AppMenuBar.qml @@ -17,6 +17,7 @@ */ import QtQuick 2.12 +import QtQuick.Dialogs 1.3 import eu.ad5001.MixedMenu 1.1 import "js/objects.js" as Objects import "js/historylib.js" as HistoryLib @@ -49,7 +50,13 @@ MenuBar { Action { text: qsTr("&Quit") shortcut: StandardKey.Quit - onTriggered: Qt.quit() + onTriggered: { + if(settings.saved) + Qt.quit() + else + saveUnsavedChangesDialog.visible = true; + } + icon.name: 'application-exit' } } @@ -149,4 +156,17 @@ MenuBar { onTriggered: about.open() } } + + MessageDialog { + id: saveUnsavedChangesDialog + title: qsTr("Save unsaved changes?") + icon: StandardIcon.Question + text: qsTr("This plot contains unsaved changes. By doing this, all unsaved data will be lost. Continue?") + standardButtons: StandardButton.Yes | StandardButton.No + onYes: Qt.quit() + } + + function showSaveUnsavedChangesDialog() { + saveUnsavedChangesDialog.visible = true + } } diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/FileDialog.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/FileDialog.qml index e9fb19d..c2f4530 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/FileDialog.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/FileDialog.qml @@ -28,5 +28,4 @@ D.FileDialog { folder: shortcuts.documents selectExisting: !exportMode - } diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History.qml index df2b772..b6deebb 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History.qml @@ -29,6 +29,8 @@ Item { property int redoCount: 0 property var undoStack: [] property var redoStack: [] + // Only true when no modification was done to the current working file. + property bool saved: true function clear() { undoStack = [] @@ -71,6 +73,7 @@ Item { redoStack = [] redoCount = 0 } + saved = false } } @@ -82,6 +85,7 @@ Item { redoStack.push(action) undoCount--; redoCount++; + saved = false } } @@ -93,17 +97,22 @@ Item { undoStack.push(action) undoCount++; redoCount--; + saved = false } } function undoMultipleDefered(toUndoCount) { undoTimer.toUndoCount = toUndoCount; undoTimer.start() + if(toUndoCount > 0) + saved = false } function redoMultipleDefered(toRedoCount) { redoTimer.toRedoCount = toRedoCount; redoTimer.start() + if(toRedoCount > 0) + saved = false } Timer { diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogarithmPlotter.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogarithmPlotter.qml index 749df05..3c13c2d 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogarithmPlotter.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogarithmPlotter.qml @@ -34,7 +34,7 @@ ApplicationWindow { width: 1000 height: 500 color: sysPalette.window - title: "LogarithmPlotter " + (settings.saveFilename != "" ? " - " + settings.saveFilename.split('/').pop() : "") + title: "LogarithmPlotter " + (settings.saveFilename != "" ? " - " + settings.saveFilename.split('/').pop() : "") + (history.saved ? "" : "*") SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active } SystemPalette { id: sysPaletteIn; colorGroup: SystemPalette.Disabled } @@ -195,6 +195,7 @@ ApplicationWindow { "type": "logplotv1" })) alert.show(qsTr("Saved plot to '%1'.").arg(filename.split("/").pop())) + history.saved = true } function loadDiagram(filename) { @@ -258,9 +259,11 @@ ApplicationWindow { console.log(error) alert.show(qsTr("Could not save file: ") + error) // TODO: Error handling + return } drawCanvas.requestPaint() alert.show(qsTr("Loaded file '%1'.").arg(basename)) + history.saved = true } Timer { @@ -277,6 +280,13 @@ ApplicationWindow { onTriggered: Qt.quit() // Quit after paint on test build } + onClosing: { + if(!history.saved) { + close.accepted = false + appMenu.showSaveUnsavedChangesDialog() + } + } + function copyDiagramToClipboard() { var file = Helper.gettmpfile() drawCanvas.save(file) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml index b7e45d0..7990ac0 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/EditorDialog.qml @@ -65,7 +65,6 @@ D.Dialog { var newName = Utils.parseName(newValue) if(newName != '' && objEditor.obj.name != newName) { if(Objects.getObjectByName(newName) != null) { - console.log(Objects.getObjectByName(newName).name, newName) newName = ObjectsCommons.getNewName(newName) } history.addToHistory(new HistoryLib.NameChanged( @@ -181,23 +180,25 @@ D.Dialog { // True to select an object of type, false for enums. property bool selectObjMode: paramTypeIn(modelData[1], ['ObjectType']) - model: visible ? + property var baseModel: visible ? (selectObjMode ? Objects.getObjectsName(modelData[1].objType).concat([qsTr("+ Create new %1").arg(Objects.types[modelData[1].objType].displayType())]) : modelData[1].values) : [] + // Translate the model if necessary. + model: selectObjMode ? baseModel : baseModel.map(x => qsTr(x)) visible: paramTypeIn(modelData[1], ['ObjectType', 'Enum']) - currentIndex: model.indexOf(selectObjMode ? objEditor.obj[modelData[0]].name : objEditor.obj[modelData[0]]) + currentIndex: baseModel.indexOf(selectObjMode ? objEditor.obj[modelData[0]].name : objEditor.obj[modelData[0]]) onActivated: function(newIndex) { if(selectObjMode) { // This is only done when what we're selecting are Objects. // Setting object property. - var selectedObj = Objects.getObjectByName(model[newIndex], modelData[1].objType) + var selectedObj = Objects.getObjectByName(baseModel[newIndex], modelData[1].objType) if(selectedObj == null) { // Creating new object. selectedObj = Objects.createNewRegisteredObject(modelData[1].objType) history.addToHistory(new HistoryLib.CreateNewObject(selectedObj.name, modelData[1].objType, selectedObj.export())) - model = Objects.getObjectsName(modelData[1].objType).concat([qsTr("+ Create new %1").arg(Objects.types[modelData[1].objType].displayType())]) - currentIndex = model.indexOf(selectedObj.name) + baseModel = Objects.getObjectsName(modelData[1].objType).concat([qsTr("+ Create new %1").arg(Objects.types[modelData[1].objType].displayType())]) + currentIndex = baseModel.indexOf(selectedObj.name) } //Objects.currentObjects[objEditor.objType][objEditor.objIndex].requiredBy = objEditor.obj[modelData[0]].filter((obj) => objEditor.obj.name != obj.name) objEditor.obj.requiredBy = objEditor.obj.requiredBy.filter((obj) => objEditor.obj.name != obj.name) @@ -207,13 +208,13 @@ D.Dialog { objEditor.obj[modelData[0]], selectedObj )) objEditor.obj[modelData[0]] = selectedObj - } else if(model[newIndex] != objEditor.obj[modelData[0]]) { + } else if(baseModel[newIndex] != objEditor.obj[modelData[0]]) { // Ensuring new property is different to not add useless history entries. history.addToHistory(new HistoryLib.EditedProperty( objEditor.obj.name, objEditor.objType, modelData[0], - objEditor.obj[modelData[0]], model[newIndex] + objEditor.obj[modelData[0]], baseModel[newIndex] )) - objEditor.obj[modelData[0]] = model[newIndex] + objEditor.obj[modelData[0]] = baseModel[newIndex] } // Refreshing Objects.currentObjects[objEditor.objType][objEditor.objIndex].update() diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml index b701dd0..0903271 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml @@ -18,6 +18,7 @@ import QtQuick.Controls 2.12 import QtQuick 2.12 +import QtQuick.Dialogs 1.1 import "js/utils.js" as Utils ScrollView { diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js index 182c2dd..09b8701 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js @@ -29,17 +29,29 @@ class Function extends Common.ExecutableObject { static displayType(){return qsTr('Function')} static displayTypeMultiple(){return qsTr('Functions')} static properties() {return { - 'expression': 'Expression', - 'definitionDomain': 'Domain', - 'destinationDomain': 'Domain', - 'comment1': 'Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5}', - 'labelPosition': new P.Enum('above', 'below', 'left', 'right', 'above-left', 'above-right', 'below-left', 'below-right'), - 'displayMode': new P.Enum('application', 'function'), - 'labelX': 'number', - 'comment2': 'The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...)', - 'drawPoints': 'boolean', - 'drawDashedLines': 'boolean' + 'expression': 'Expression', + 'definitionDomain': 'Domain', + 'destinationDomain': 'Domain', + 'comment1': 'Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5}', + 'labelPosition': P.Enum.Position, + 'displayMode': new P.Enum('application', 'function'), + 'labelX': 'number', + 'comment2': 'The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...)', + 'drawPoints': 'boolean', + 'drawDashedLines': 'boolean' }} + /*static properties() {return { + [QT_TR_NOOP('expression')]: 'Expression', + [QT_TR_NOOP('definitionDomain')]: 'Domain', + [QT_TR_NOOP('destinationDomain')]: 'Domain', + 'comment1': 'Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5}', + [QT_TR_NOOP('labelPosition')]: P.Enum.Position, + [QT_TR_NOOP('displayMode')]: new P.Enum('application', 'function'), + [QT_TR_NOOP('labelX')]: 'number', + 'comment2': 'The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...)', + [QT_TR_NOOP('drawPoints')]: 'boolean', + [QT_TR_NOOP('drawDashedLines')]: 'boolean' + }}*/ constructor(name = null, visible = true, color = null, labelContent = 'name + value', expression = 'x', definitionDomain = 'RPE', destinationDomain = 'R', diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/parameters.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/parameters.js index 710a3f7..b9d6690 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/parameters.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/parameters.js @@ -54,3 +54,16 @@ class Dictionary { this.forbidAdding = forbidAdding } } + +// Common parameters of them: + +Enum.Position = new Enum( + QT_TR_NOOP('above'), + QT_TR_NOOP('below'), + QT_TR_NOOP('left'), + QT_TR_NOOP('right'), + QT_TR_NOOP('above-left'), + QT_TR_NOOP('above-right'), + QT_TR_NOOP('below-left'), + QT_TR_NOOP('below-right') +)