[education/rkward] rkward: Actually store the selected R version
Thomas Friedrichsmeier
null at kde.org
Sat Jun 8 23:21:01 BST 2024
Git commit b39d3a95fb74dfa3416120329078173686c2b8a8 by Thomas Friedrichsmeier.
Committed on 08/06/2024 at 22:10.
Pushed by tfry into branch 'master'.
Actually store the selected R version
M +6 -1 rkward/dialogs/rksetupwizard.cpp
M +4 -0 rkward/rbackend/rkfrontendtransmitter.cpp
M +6 -1 rkward/rbackend/rksessionvars.cpp
M +2 -0 rkward/settings/rksettingsmoduler.cpp
M +4 -1 rkward/settings/rksettingsmoduler.h
https://invent.kde.org/education/rkward/-/commit/b39d3a95fb74dfa3416120329078173686c2b8a8
diff --git a/rkward/dialogs/rksetupwizard.cpp b/rkward/dialogs/rksetupwizard.cpp
index c1610073d..f5a8fd26d 100644
--- a/rkward/dialogs/rksetupwizard.cpp
+++ b/rkward/dialogs/rksetupwizard.cpp
@@ -201,7 +201,7 @@ public:
}
auto button = group->button(0);
if (RInterface::instance()->backendIsDead()) button->setText(i18n("Attempt to restart R at %1", RKSessionVars::RBinary()));
- else button->setText(i18n("Keep current version"));
+ else button->setText(i18n("Keep current version (%1)", RKSessionVars::RBinary()));
button->setChecked(true);
}
QRadioButton *addButton(const QString &text, int index) {
@@ -524,6 +524,7 @@ void RKSetupWizard::fullInteractiveCheck(InvokationReason reason, const QList<RK
if (has_been_run && reason != ManualCheck) return;
has_been_run = true;
+ QString old_r_binary = RKSessionVars::RBinary();
auto wizard = new RKSetupWizard(RKWardMainWindow::getMain(), reason, settings_items);
auto res = wizard->exec();
@@ -543,6 +544,10 @@ void RKSetupWizard::fullInteractiveCheck(InvokationReason reason, const QList<RK
for(int i = 0; i < wizard->r_commands_to_run.size(); ++i) {
RInterface::issueCommand(wizard->r_commands_to_run[i], RCommand::App);
}
+
+ if (!RInterface::instance()->backendIsDead() && (RKSessionVars::RBinary() != old_r_binary)) {
+ RKSettingsModuleR::options_r_binary = RKSessionVars::RBinary();
+ }
}
delete wizard;
diff --git a/rkward/rbackend/rkfrontendtransmitter.cpp b/rkward/rbackend/rkfrontendtransmitter.cpp
index 10a80d371..f78fb6c6a 100644
--- a/rkward/rbackend/rkfrontendtransmitter.cpp
+++ b/rkward/rbackend/rkfrontendtransmitter.cpp
@@ -12,6 +12,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "rksessionvars.h"
#include "../misc/rkcommandlineargs.h"
#include "../settings/rksettingsmodulegeneral.h"
+#include "../settings/rksettingsmoduler.h"
#include <KLocalizedString>
#include <krandom.h>
@@ -137,6 +138,9 @@ void RKFrontendTransmitter::detectAndCheckRBinary() {
QString r_exe = RKCommandLineArgs::get(RKCommandLineArgs::RExecutable).toString();
if (!r_exe.isEmpty()) {
RK_DEBUG(APP, DL_DEBUG, "Using R as specified on command line");
+ } else if (!RKSettingsModuleR::userConfiguredRBinary().isEmpty()) {
+ RK_DEBUG(APP, DL_DEBUG, "Using R as previously user-configured");
+ r_exe = RKSettingsModuleR::userConfiguredRBinary();
} else {
QDir frontend_path = qApp->applicationDirPath();
QFileInfo rkward_ini_file(frontend_path.absoluteFilePath("rkward.ini"));
diff --git a/rkward/rbackend/rksessionvars.cpp b/rkward/rbackend/rksessionvars.cpp
index 1b0f9b14f..6fa776680 100644
--- a/rkward/rbackend/rksessionvars.cpp
+++ b/rkward/rbackend/rksessionvars.cpp
@@ -10,6 +10,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "rkrinterface.h"
#include "../settings/rksettingsmoduledebug.h"
#include "../settings/rksettingsmodulegeneral.h"
+#include "../settings/rksettingsmoduler.h"
#include "../version.h"
#include <kcoreaddons_version.h>
@@ -153,6 +154,10 @@ QStringList RKSessionVars::findRInstallations() {
#endif
// On Unix, but also, if R was not found in the default locations try to find R in the system path.
QString r = QStandardPaths::findExecutable("R");
- if (!(r.isNull() || ret.contains(r))) ret.append(r);
+ if (!(r.isEmpty() || ret.contains(r))) ret.append(r);
+ // NOTE: in a default start, the configured R binary takes precedence over all the others, *but*
+ // --r-executable auto was specified, we want to detect as if from scratch. Thus appending, rather than prepending
+ r = RKSettingsModuleR::userConfiguredRBinary();
+ if (!(r.isEmpty() || ret.contains(r))) ret.append(r);
return ret;
}
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index b77fcbfcf..971a2abc4 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -57,6 +57,7 @@ RKConfigValue<QString> RKSettingsModuleR::options_editor {"editor", builtin_edit
RKConfigValue<QString> RKSettingsModuleR::options_pager {"pager", builtin_editor};
RKConfigValue<QString> RKSettingsModuleR::options_further {"further init commands", QString()};
RKConfigValue<QStringList> RKSettingsModuleR::options_addpaths {"addsyspaths", QStringList()};
+RKConfigValue<QString> RKSettingsModuleR::options_r_binary {"user configured R binary", QString()};
RKSettingsModuleR::RKSettingsModuleR (RKSettings *gui, QWidget *parent) : RKSettingsModule(gui, parent) {
RK_TRACE (SETTINGS);
@@ -284,6 +285,7 @@ void RKSettingsModuleR::syncConfig(KConfig *config, RKConfigBase::ConfigSyncActi
options_pager.syncConfig(cg, a);
options_further.syncConfig(cg, a);
options_addpaths.syncConfig(cg, a);
+ options_r_binary.syncConfig(cg, a);
}
//#################################################
diff --git a/rkward/settings/rksettingsmoduler.h b/rkward/settings/rksettingsmoduler.h
index 737f8f6ba..365d0ff59 100644
--- a/rkward/settings/rksettingsmoduler.h
+++ b/rkward/settings/rksettingsmoduler.h
@@ -1,6 +1,6 @@
/*
rksettingsmoduler - This file is part of the RKWard project. Created: Wed Jul 28 2004
-SPDX-FileCopyrightText: 2004-2022 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2004-2024 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -44,6 +44,7 @@ public:
static QString helpBaseUrl () { return help_base_url; };
static int getDefaultWidth () { return options_width; };
+ static QString userConfiguredRBinary() { return options_r_binary; };
public Q_SLOTS:
void settingChanged ();
private Q_SLOTS:
@@ -69,6 +70,8 @@ private:
static RKConfigValue<QString> options_pager;
static RKConfigValue<QString> options_further;
static RKConfigValue<QStringList> options_addpaths;
+friend class RKSetupWizard;
+ static RKConfigValue<QString> options_r_binary;
// constants
static QString builtin_editor;
More information about the rkward-tracker
mailing list