[education/rkward/devel/workspace_output] /: Fix query when loading new workspace.

Thomas Friedrichsmeier null at kde.org
Thu Feb 17 21:21:29 GMT 2022


Git commit 193fcae36a4ac296da226e920c518f1180d93a67 by Thomas Friedrichsmeier.
Committed on 17/02/2022 at 21:21.
Pushed by tfry into branch 'devel/workspace_output'.

Fix query when loading new workspace.

M  +1    -1    ChangeLog
M  +0    -1    rkward/agents/rkloadagent.cpp
M  +6    -17   rkward/rkward.cpp
M  +0    -2    rkward/rkward.h
M  +1    -1    rkward/windows/rkworkplace.cpp

https://invent.kde.org/education/rkward/commit/193fcae36a4ac296da226e920c518f1180d93a67

diff --git a/ChangeLog b/ChangeLog
index c712d88b..1ee31fb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,7 @@ TODOS for autotests:
   - Use options(warn=1), in order to get warnings into the test?
 
 TODOS for output directories:
-  - save outputs to .rkworkplace and restore them
+  - save outputs to .rkworkplace and restore them (create default output, if there is none)
   - UI
 
 - rkwardtests library gains helper functions for checking for expected errors
diff --git a/rkward/agents/rkloadagent.cpp b/rkward/agents/rkloadagent.cpp
index ef4ef206..6ec76986 100644
--- a/rkward/agents/rkloadagent.cpp
+++ b/rkward/agents/rkloadagent.cpp
@@ -62,7 +62,6 @@ RKLoadAgent::RKLoadAgent (const QUrl &url, bool merge) {
 	RCommand *command;
 	
 	if (!merge) {
-		RKWorkplace::mainWorkplace()->closeWorkspace();
 		command = new RCommand ("remove (list=ls (all.names=TRUE))", RCommand::App | RCommand::ObjectListUpdate);
 		RKGlobals::rInterface ()->issueCommand (command);
 	}
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index d061b898..590db5ab 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -266,7 +266,8 @@ void RKWardMainWindow::doPostInit () {
 	} else {
 		StartupDialog::StartupDialogResult result = StartupDialog::getStartupAction (this, fileOpenRecentWorkspace);
 		if (!result.open_url.isEmpty ()) {
-			openWorkspace (result.open_url);
+			// setNoAskSave(true); was called earlier
+			askOpenWorkspace(result.open_url);
 		} else {
 			if (result.result == StartupDialog::ChoseFile) {
 				askOpenWorkspace (QUrl());
@@ -731,13 +732,6 @@ void RKWardMainWindow::initStatusBar () {
 	setRStatus (RInterface::Starting);
 }
 
-void RKWardMainWindow::openWorkspace (const QUrl &url) {
-	RK_TRACE (APP);
-	if (url.isEmpty ()) return;
-
-	new RKLoadAgent (url, merge_loads);
-}
-
 void RKWardMainWindow::saveOptions () {
 	RK_TRACE (APP);
 	KSharedConfig::Ptr config = KSharedConfig::openConfig ();
@@ -812,15 +806,10 @@ void RKWardMainWindow::slotNewDataFrame () {
 void RKWardMainWindow::askOpenWorkspace (const QUrl &url) {
 	RK_TRACE (APP);
 
-	if (!no_ask_save && ((!RObjectList::getGlobalEnv()->isEmpty() && workspace_modified) || !RKGlobals::rInterface()->backendIsIdle())) {
-		int res;
-		res = KMessageBox::questionYesNoCancel (this, i18n("Do you want to save the current workspace?"), i18n("Save Workspace?"));
-		if (res != KMessageBox::No) return;  // Cancel
-		if (!RKSaveAgent::saveWorkspace()) return; // Save failed
+	if (!no_ask_save && !merge_loads) {
+		if (!RKWorkplace::mainWorkplace()->closeWorkspace()) return;
 	}
 
-	slotCloseAllEditors();
-
 	slotSetStatusBarText(i18n("Opening workspace..."));
 	QUrl lurl = url;
 	if (lurl.isEmpty ()) {
@@ -828,7 +817,7 @@ void RKWardMainWindow::askOpenWorkspace (const QUrl &url) {
 	}
 	if (!lurl.isEmpty ()) {
 		RKSettingsModuleGeneral::updateLastUsedUrl("workspaces", lurl.adjusted(QUrl::RemoveFilename));
-		openWorkspace(lurl);
+		new RKLoadAgent (url, merge_loads);
 	}
 	slotSetStatusReady();
 }
@@ -986,7 +975,7 @@ void RKWardMainWindow::openAnyFile () {
 		RKWorkplace::mainWorkplace ()->openScriptEditor (url, QString (), RKCommandEditorFlags::DefaultFlags | RKCommandEditorFlags::ForceRHighlighting);
 		RKSettingsModuleGeneral::updateLastUsedUrl ("rscripts", url.adjusted (QUrl::RemoveFilename));
 	} else if (mode == 3) {
-		openWorkspace (url);
+		askOpenWorkspace(url);
 		RKSettingsModuleGeneral::updateLastUsedUrl ("workspaces", url.adjusted (QUrl::RemoveFilename));
 	}
 }
diff --git a/rkward/rkward.h b/rkward/rkward.h
index 88ebd05e..dd478e6c 100644
--- a/rkward/rkward.h
+++ b/rkward/rkward.h
@@ -141,8 +141,6 @@ private slots:
 private:
 /** Prompt for a local file to open, providing a choice of how to open the file (as R script, text, workspace, auto) */
 	void openAnyFile ();
-/** Opens a new workspace, without asking or closing anything. */
-	void openWorkspace (const QUrl &url);
 
 	QLabel* statusbar_r_status;
 	KSqueezedTextLabel* statusbar_cwd;
diff --git a/rkward/windows/rkworkplace.cpp b/rkward/windows/rkworkplace.cpp
index aab524df..9de9de9b 100644
--- a/rkward/windows/rkworkplace.cpp
+++ b/rkward/windows/rkworkplace.cpp
@@ -924,7 +924,7 @@ void RKWorkplace::saveWorkplace(const QUrl& for_url, RCommandChain *chain) {
 	if (RKSettingsModuleGeneral::workplaceSaveMode() != RKSettingsModuleGeneral::SaveWorkplaceWithWorkspace) return;
 
 	QString file_param;
-	if (!for_url.isEmpty()) file_param = QString("file=") + RObject::rQuote(for_url.toLocalFile()) + QStringLiteral(", ");
+	if (!for_url.isEmpty()) file_param = QString("file=") + RObject::rQuote(for_url.toLocalFile() + QStringLiteral(".rkworkplace")) + QStringLiteral(", ");
 	RKGlobals::rInterface()->issueCommand("rk.save.workplace(" + file_param + "description=" + RObject::rQuote (makeWorkplaceDescription().join ("\n")) + ')', RCommand::App, i18n ("Save Workplace layout"), 0, 0, chain);
 }
 


More information about the rkward-tracker mailing list