[education/rkward/devel/workspace_output] /: Add output migration check to setup wizard

Thomas Friedrichsmeier null at kde.org
Mon Mar 7 20:43:55 GMT 2022


Git commit 77dd876f22d5dda95537227f0a636aeab70095ca by Thomas Friedrichsmeier.
Committed on 07/03/2022 at 20:43.
Pushed by tfry into branch 'devel/workspace_output'.

Add output migration check to setup wizard

M  +2    -2    ChangeLog
M  +18   -1    rkward/dialogs/rksetupwizard.cpp
M  +1    -0    rkward/dialogs/rksetupwizard.h
M  +1    -0    rkward/settings/rksettingsmodulegeneral.h

https://invent.kde.org/education/rkward/commit/77dd876f22d5dda95537227f0a636aeab70095ca

diff --git a/ChangeLog b/ChangeLog
index b30b59bd..235dff44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,9 +3,9 @@ TODOS for autotests:
   - Use options(warn=1), in order to get warnings into the test?
 
 TODOS for output directories:
-  - migration support (existing old standard output should be converted to "default.rko"; setting, when opening workspace with no attached active output file:
+  - setting, when opening workspace with no attached active output file:
     - create new empty file
-    - open "default.rko" <- default setting?)
+    - open "default.rko" <- default setting?
 
 - Fixed: Cursor navigation in completion list
 - rkwardtests library gains helper functions for checking for expected errors
diff --git a/rkward/dialogs/rksetupwizard.cpp b/rkward/dialogs/rksetupwizard.cpp
index 11bb80dc..520a410b 100644
--- a/rkward/dialogs/rksetupwizard.cpp
+++ b/rkward/dialogs/rksetupwizard.cpp
@@ -26,10 +26,11 @@
 #include <QIcon>
 #include <QPushButton>
 #include <QTimer>
+#include <QFileInfo>
+#include <QStandardPaths>
 
 #include <KLocalizedString>
 #include <KMessageBox>
-#include <QStandardPaths>
 
 #include "../settings/rksettingsmoduleplugins.h"
 #include "../settings/rksettingsmodulegeneral.h"
@@ -182,6 +183,19 @@ RKSetupWizard::RKSetupWizard(QWidget* parent, InvokationReason reason, const QLi
 	}
 	appendItem(kateplugins);
 
+	// TODO: Remove, eventually
+	auto legacy_output = new RKSetupWizardItem(i18n("Pre 0.7.3 output file"));
+	QString legacy_output_path = RKSettingsModuleGeneral::filesPath() + "rk_out.html";
+	if (QFileInfo(legacy_output_path).exists()) {
+		legacy_output->setStatus(RKSetupWizardItem::Warning, i18n("Exists"));
+		legacy_output->setLongLabel(QString("<p>An output file from before RKWard version 0.7.3 was found (%1). You will probably want to convert this to the new format. Alternatively, if it is no longer needed, you can delete it, manually.</p>").arg(legacy_output_path));
+		legacy_output->addOption(i18n("Import"), i18n("Import to the session, so you can save in the new output format."), [](RKSetupWizard* wizard) { wizard->r_commands_to_run.append("rk.import.legacy.output()\n"); });
+		legacy_output->addOption(i18n("No action"), i18n("Ignore (and keep) the file. You can import it manually, at any time, using rk.import.legacy.output()"), [](RKSetupWizard*) {});
+	} else {
+		legacy_output->setStatus(RKSetupWizardItem::Good, i18n("Found."));
+	}
+	appendItem(legacy_output);
+
 	for (int i = 0; i < settings_items.size(); ++i) {
 		appendItem(settings_items[i]);
 	}
@@ -327,6 +341,9 @@ void RKSetupWizard::fullInteractiveCheck(InvokationReason reason, const QList<RK
 			}
 		}
 #endif
+		for(int i = 0; i < wizard->r_commands_to_run.size(); ++i) {
+			RKGlobals::rInterface()->issueCommand(wizard->r_commands_to_run[i], RCommand::App);
+		}
 	}
 
 	delete wizard;
diff --git a/rkward/dialogs/rksetupwizard.h b/rkward/dialogs/rksetupwizard.h
index e66ea315..44edfb0f 100644
--- a/rkward/dialogs/rksetupwizard.h
+++ b/rkward/dialogs/rksetupwizard.h
@@ -52,6 +52,7 @@ private:
 	QStringList software_to_install;
 	QStringList software_to_install_urls;
 	QStringList packages_to_install;
+	QStringList r_commands_to_run;
 	void createStandardPage();
 	QWidget *current_page;
 	int current_row;
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index 12b0c683..9ed16a32 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -96,6 +96,7 @@ public:
 		RKWardConfig_0_6_3,
 		RKWardConfig_0_6_4,
 		RKWardConfig_0_7_1,
+		RKWardConfig_0_7_3,
 		RKWardConfig_Next,		/**< add new configuration versions above / before this entry */
 		RKWardConfig_Latest = RKWardConfig_Next - 1
 	};


More information about the rkward-tracker mailing list