diff --git a/rkward/dialogs/rksetupwizard.cpp b/rkward/dialogs/rksetupwizard.cpp
index a7881e36..7bcc7bfa 100644
--- a/rkward/dialogs/rksetupwizard.cpp
+++ b/rkward/dialogs/rksetupwizard.cpp
@@ -1,298 +1,270 @@
/***************************************************************************
rksetupwizard - description
-------------------
begin : Fri May 25 20200
copyright : (C) 2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "rksetupwizard.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../settings/rksettingsmoduleplugins.h"
#include "../settings/rksettingsmodulegeneral.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkstandardicons.h"
#include "../dialogs/rkloadlibsdialog.h"
#include "../windows/katepluginintegration.h"
#include "../rbackend/rksessionvars.h"
#include "../rbackend/rkrinterface.h"
#include "../rkglobals.h"
#include "../rkward.h"
#include "../debug.h"
bool RKSetupWizard::has_been_run = false;
-class RKSetupWizardItem {
-public:
- enum Status {
- Error,
- Warning,
- Good
- };
- RKSetupWizardItem(const QString &shortlabel, const QString &longlabel=QString(), Status status=Good, const QString &shortstatuslabel=QString()) : status(status), shortlabel(shortlabel), longlabel(longlabel), shortstatuslabel(shortstatuslabel), box(nullptr) {};
- ~RKSetupWizardItem() {};
- void addOption(const QString &shortlabel, const QString &longlabel, std::function callback) {
- options.append(Option(shortlabel, longlabel, callback));
- }
- void setStatus(Status _status, const QString &_shortstatuslabel) { status = _status; shortstatuslabel = _shortstatuslabel; };
- void setShortLabel(const QString &label) { shortlabel = label; };
- void setLongLabel(const QString &label) { longlabel = label; };
-private:
-friend class RKSetupWizard;
- void createWidget(QGridLayout *layout, int row) {
- QString icon_id;
- if (status == Good) icon_id = QLatin1String("dialog-positive");
- else if (status == Warning) icon_id = QLatin1String("dialog-warning");
- else icon_id = QLatin1String("dialog-error");
- auto label = new QLabel();
- label->setPixmap(QIcon::fromTheme(icon_id).pixmap(32, 32)); // TODO: Correct way to not hardcode size?
- layout->addWidget(label, row, 0);
-
- layout->addWidget(new QLabel(shortlabel + ": " + shortstatuslabel), row, 1);
-
- if (options.isEmpty()) {
- layout->addWidget(new QLabel(i18n("No action needed.")), row, 2);
- } else if (options.length() == 1) {
- layout->addWidget(new QLabel(options[0].shortlabel), row, 2);
- } else {
- box = new QComboBox();
- for (int i = 0; i < options.size(); ++i) {
- box->addItem(options[i].shortlabel);
- }
- layout->addWidget(box, row, 2);
+void RKSetupWizardItem::createWidget(QGridLayout *layout, int row) {
+ QString icon_id;
+ if (status == Good) icon_id = QLatin1String("dialog-positive");
+ else if (status == Warning) icon_id = QLatin1String("dialog-warning");
+ else icon_id = QLatin1String("dialog-error");
+ auto label = new QLabel();
+ label->setPixmap(QIcon::fromTheme(icon_id).pixmap(32, 32)); // TODO: Correct way to not hardcode size?
+ layout->addWidget(label, row, 0);
+
+ layout->addWidget(new QLabel(shortlabel + ": " + shortstatuslabel), row, 1);
+
+ if (options.isEmpty()) {
+ layout->addWidget(new QLabel(i18n("No action needed.")), row, 2);
+ } else if (options.length() == 1) {
+ layout->addWidget(new QLabel(options[0].shortlabel), row, 2);
+ } else {
+ box = new QComboBox();
+ for (int i = 0; i < options.size(); ++i) {
+ box->addItem(options[i].shortlabel);
}
+ layout->addWidget(box, row, 2);
+ }
- if (!(longlabel.isEmpty() && options.isEmpty())) {
- QString details = longlabel;
- for (int i = 0; i < options.size(); ++i) {
- details += QString("%1 : %2
").arg(options[i].shortlabel).arg(options[i].longlabel);
- }
- auto info = new QPushButton();
- info->setIcon(RKStandardIcons::getIcon(RKStandardIcons::WindowHelp));
- QObject::connect(info, &QPushButton::clicked, [details, layout]() { KMessageBox::information(layout->parentWidget(), details); });
- layout->addWidget(info, row, 3);
+ if (!(longlabel.isEmpty() && options.isEmpty())) {
+ QString details = longlabel;
+ for (int i = 0; i < options.size(); ++i) {
+ details += QString("%1 : %2
").arg(options[i].shortlabel).arg(options[i].longlabel);
}
+ auto info = new QPushButton();
+ info->setIcon(RKStandardIcons::getIcon(RKStandardIcons::WindowHelp));
+ QObject::connect(info, &QPushButton::clicked, [details, layout]() { KMessageBox::information(layout->parentWidget(), details); });
+ layout->addWidget(info, row, 3);
}
- void apply(RKSetupWizard *wizard) {
- if (options.isEmpty()) return;
- int opt = 0;
- if (box) opt = box->currentIndex();
- options[opt].callback(wizard);
- };
-
- struct Option {
- Option(const QString &shortlabel, const QString &longlabel, std::function callback) : shortlabel(shortlabel), longlabel(longlabel), callback(callback) {};
- QString shortlabel;
- QString longlabel;
- std::function callback;
- };
- QList options;
- Status status;
- QString shortstatuslabel;
- QString shortlabel;
- QString longlabel;
- QComboBox *box;
+}
+
+void RKSetupWizardItem::apply(RKSetupWizard *wizard) {
+ if (options.isEmpty()) return;
+ int opt = 0;
+ if (box) opt = box->currentIndex();
+ options[opt].callback(wizard);
};
-RKSetupWizardItem* makeRPackageCheck(const QString &packagename, const QString &explanation, RKSetupWizardItem::Status status_if_missing, RKSetupWizard* wizard) {
+RKSetupWizardItem* makeRPackageCheck(const QString &packagename, const QString &explanation, RKSetupWizardItem::Status status_if_missing) {
RK_TRACE (DIALOGS);
auto ret = new RKSetupWizardItem(packagename, explanation);
if (!RKSessionVars::instance()->installedPackages().contains(packagename)) {
ret->setStatus(status_if_missing, i18n("Not installed"));
ret->addOption(i18n("Install %1", packagename), i18n("(Attempt to) install the package %1 and its dependencies for this version of R. In most cases, this requires a working internet connection.", packagename), [packagename](RKSetupWizard *wizard) { wizard->markRPackageForInstallation(packagename, true); });
ret->addOption(i18n("No change"), i18n("Proceed without the package. You will again be given the option to install the package, when the pacakge is needed."), [packagename](RKSetupWizard *wizard) { wizard->markRPackageForInstallation(packagename, false); });
} else {
ret->setStatus(RKSetupWizardItem::Good, i18n("Installed"));
}
return ret;
}
RKSetupWizard::RKSetupWizard(QWidget* parent) : KAssistantDialog(parent) {
RK_TRACE (DIALOGS);
}
RKSetupWizard::~RKSetupWizard() {
RK_TRACE (DIALOGS);
for(int i = 0; i < items.size(); ++i) {
delete items[i];
}
}
void RKSetupWizard::doAutoCheck() {
RK_TRACE (DIALOGS);
if (RKCommonFunctions::getRKWardDataDir ().isEmpty () || RKSettingsModulePlugins::pluginMaps().isEmpty() || (RKWardMainWindow::getMain()->katePluginIntegration()->knownPluginCount() == 0)) {
fullInteractiveCheck(ProblemsDetected);
} else if (RKSettingsModuleGeneral::rkwardVersionChanged()) {
fullInteractiveCheck(NewVersionRKWard);
}
// TODO: remove me
fullInteractiveCheck(ProblemsDetected);
}
void RKSetupWizard::fullInteractiveCheck(InvokationReason reason) {
RK_TRACE (DIALOGS);
if (has_been_run && reason != ManualCheck) return;
has_been_run = true;
auto wizard = new RKSetupWizard(RKWardMainWindow::getMain());
// Cover page
auto firstpage = new QWidget();
auto l = new QVBoxLayout(firstpage);
QString intro = i18n("This dialog will guide you through a quick check of the basic setup of the required (or recommended) components.
");
if (reason == NewVersionRKWard) {
intro += i18n("The setup assistant has been invoked, automatically, because a new version of RKWard has been detected.
The setup assistant has been invoked, automatically, because a new version of R has been detected.
The setup assistant has been invoked, automatically, because a problem has been detected in your setup.addWidget(RKCommonFunctions::wordWrappedLabel(intro));
auto waiting_to_start_label = RKCommonFunctions::wordWrappedLabel(i18n("Waiting for R backend... ") + "
");
l->addWidget(waiting_to_start_label);
auto firstpageref = wizard->addPage (firstpage, i18n("RKWard Setup Assistant"));
wizard->setValid(firstpageref, false);
// Basic installation page
wizard->createStandardPage();
bool reinstallation_required = false;
auto idir = new RKSetupWizardItem(i18n("Installation directory"));
if (RKCommonFunctions::getRKWardDataDir ().isEmpty ()) {
idir->setStatus(RKSetupWizardItem::Error, i18n("Not found."));
// TODO: test, whether links work, here
idir->setLongLabel("RKWard either could not find its resource files at all, or only an old version of those files. The most likely cause is that the last installation failed to place the files in the correct place. This can lead to all sorts of problems, from single missing features to complete failure to function.
You should quit RKWard, now, and fix your installation . For help with that, see http://rkward.kde.org/compiling .
");
idir->addOption(i18n("Reinstallation required"), i18n("This problem cannot be corrected, automatically. You will have to reinstall RKWard."), [](RKSetupWizard*) {});
reinstallation_required = true;
} else {
idir->setStatus(RKSetupWizardItem::Good, i18n("Found."));
}
wizard->appendItem(idir);
auto pluginmaps = new RKSetupWizardItem(i18n("RKWard plugins"));
if (RKSettingsModulePlugins::pluginMaps().isEmpty()) {
// TODO: Move to RKSettingsModulePlugins::validateSettingsInteractive
pluginmaps->setLongLabel(i18n("No plugins are enabled. This is probably not intended.
"));
pluginmaps->setStatus(RKSetupWizardItem::Warning, i18n("None selected"));
pluginmaps->addOption(i18n("Restore defaults"), i18n("Enable the default plugins"), [](RKSetupWizard*) { RKSettingsModulePlugins::registerDefaultPluginMaps(RKSettingsModulePlugins::AddIfDefault); });
pluginmaps->addOption(i18n("No change"), i18n("Proceed without plugins"), [](RKSetupWizard*) {});
// TODO: Also offer help, if a suspicioulsy small share of plugins is active? RKSettingsModulePlugins::knownUsablePluginCount();
} else {
pluginmaps->setStatus(RKSetupWizardItem::Good, i18n("Found."));
}
wizard->appendItem(pluginmaps);
auto kateplugins = new RKSetupWizardItem(i18n("Kate plugins"));
int kateplugincount = RKWardMainWindow::getMain()->katePluginIntegration()->knownPluginCount();
if (kateplugincount < 1) {
// TODO: Move to RKSettingsModuleKatePlugins::validateSettingsInteractive
kateplugins->setLongLabel(i18n("Important functionality in RKWard is provided by kate plugins. It looks like none are installed on this system. On Linux/BSD, this can usually be fixed by installing kate.
"));
kateplugins->setStatus(RKSetupWizardItem::Error, i18n("None found"));
kateplugins->addOption(i18n("(Attempt to) install kate"), i18n("Attempt to install kate using the muon package manager. If this is not available, please install kate, manuelly"), [](RKSetupWizard* wizard) { wizard->markExternalPackageForInstallation(QStringLiteral("kate"), true); });
kateplugins->addOption(i18n("No change"), i18n("Proceed without plugins"), [](RKSetupWizard* wizard) { wizard->markExternalPackageForInstallation(QStringLiteral("kate"), false); });
} else {
kateplugins->setStatus(RKSetupWizardItem::Good, i18n("Found %1 plugins.", kateplugincount));
}
wizard->appendItem(kateplugins);
wizard->current_layout->setRowStretch(++wizard->current_row, 1);
wizard->addPage(wizard->current_page, i18n("Basic installation"));
// Wait for R Interface, then start dialog
wizard->show();
while (!RKGlobals::rInterface()->backendIsIdle()) {
if (RKGlobals::rInterface()->backendIsDead()) {
waiting_to_start_label->setText(i18n("R backend has crashed. Click \"Cancel\" to exit setup assitant. "));
} else {
QApplication::processEvents(QEventLoop::AllEvents, 1000);
}
}
waiting_to_start_label->setText(i18n("R backend has started. Click \"Next\" to continue. "));
wizard->setValid(firstpageref, true);
// R packages page
// This must be created _after_ the backend has started, for obvious reasons.
wizard->createStandardPage();
- auto r2htmlpackage = makeRPackageCheck("R2HTML", i18n("The R2HTML package is used by nearly all RKWard output functions, and thus required."), RKSetupWizardItem::Error, wizard);
+ auto r2htmlpackage = makeRPackageCheck("R2HTML", i18n("The R2HTML package is used by nearly all RKWard output functions, and thus required."), RKSetupWizardItem::Error);
wizard->appendItem(r2htmlpackage);
- auto rmarkdownpackage = makeRPackageCheck("rmarkdown", i18n("The rmarkdown package is required for rendering .Rmd files (including preview rendering), which is an optional but recommended feature."), RKSetupWizardItem::Warning, wizard);
+ auto rmarkdownpackage = makeRPackageCheck("rmarkdown", i18n("The rmarkdown package is required for rendering .Rmd files (including preview rendering), which is an optional but recommended feature."), RKSetupWizardItem::Warning);
wizard->appendItem(rmarkdownpackage);
wizard->current_layout->setRowStretch(++wizard->current_row, 1);
wizard->addPage(wizard->current_layout->parentWidget(), i18n("R Packages"));
wizard->exec();
for(int i = 0; i < wizard->items.size(); ++i) {
wizard->items[i]->apply(wizard);
}
if (!wizard->packages_to_install.isEmpty()) {
RKLoadLibsDialog::showInstallPackagesModal(wizard, 0, wizard->packages_to_install);
}
+ // TODO: external software
+
delete wizard;
/* TODO
RKSettingsModulePlugins::knownUsablePluginCount();
RKWardMainWindow::getMain()->katePluginIntegration()->knownPluginCount(); */
/* TODO
* consolidate with RKSettings::validateSettingsInteractive */
}
void RKSetupWizard::createStandardPage() {
RK_TRACE (DIALOGS);
current_page = new QWidget();
current_layout = new QGridLayout(current_page);
current_layout->setColumnStretch(1, 2);
current_layout->setColumnStretch(2, 1);
current_row = -1;
}
void RKSetupWizard::appendItem(RKSetupWizardItem* item) {
RK_TRACE (DIALOGS);
item->createWidget(current_layout, ++current_row);
items.append(item);
}
void RKSetupWizard::markExternalPackageForInstallation(const QString& name, bool install) {
RK_TRACE (DIALOGS);
bool present = software_to_install.contains(name);
if (install && !present) software_to_install.append(name);
if (present && !install) software_to_install.removeAll(name);
}
void RKSetupWizard::markRPackageForInstallation(const QString& name, bool install) {
RK_TRACE (DIALOGS);
bool present = packages_to_install.contains(name);
if (install && !present) packages_to_install.append(name);
if (present && !install) packages_to_install.removeAll(name);
}
diff --git a/rkward/dialogs/rksetupwizard.h b/rkward/dialogs/rksetupwizard.h
index ce22466e..ea69a476 100644
--- a/rkward/dialogs/rksetupwizard.h
+++ b/rkward/dialogs/rksetupwizard.h
@@ -1,54 +1,89 @@
/***************************************************************************
rksetupwizard - description
-------------------
begin : Fri May 25 20200
copyright : (C) 2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETUPWIZARD_H
#define RKSETUPWIZARD_H
#include
class QGridLayout;
class RKSetupWizardItem;
class RKSetupWizard : public KAssistantDialog {
protected:
RKSetupWizard(QWidget* parent);
~RKSetupWizard();
enum InvokationReason {
ProblemsDetected,
NewVersionRKWard,
NewVersionR,
ManualCheck
};
static bool has_been_run;
public:
static void doAutoCheck();
static void fullInteractiveCheck(InvokationReason reason);
void markExternalPackageForInstallation(const QString &name, bool install);
void markRPackageForInstallation(const QString &name, bool install);
private:
QStringList software_to_install;
QStringList packages_to_install;
void createStandardPage();
QWidget *current_page;
int current_row;
QGridLayout* current_layout;
void appendItem(RKSetupWizardItem* item);
QList items;
};
+class QComboBox;
+class RKSetupWizardItem {
+public:
+ enum Status {
+ Error,
+ Warning,
+ Good
+ };
+ RKSetupWizardItem(const QString &shortlabel, const QString &longlabel=QString(), Status status=Good, const QString &shortstatuslabel=QString()) : status(status), shortlabel(shortlabel), longlabel(longlabel), shortstatuslabel(shortstatuslabel), box(nullptr) {};
+ ~RKSetupWizardItem() {};
+ void addOption(const QString &shortlabel, const QString &longlabel, std::function callback) {
+ options.append(Option(shortlabel, longlabel, callback));
+ }
+ void setStatus(Status _status, const QString &_shortstatuslabel) { status = _status; shortstatuslabel = _shortstatuslabel; };
+ void setShortLabel(const QString &label) { shortlabel = label; };
+ void setLongLabel(const QString &label) { longlabel = label; };
+private:
+friend class RKSetupWizard;
+ void createWidget(QGridLayout *layout, int row);
+ void apply(RKSetupWizard *wizard);
+
+ struct Option {
+ Option(const QString &shortlabel, const QString &longlabel, std::function callback) : shortlabel(shortlabel), longlabel(longlabel), callback(callback) {};
+ QString shortlabel;
+ QString longlabel;
+ std::function callback;
+ };
+ QList options;
+ Status status;
+ QString shortlabel;
+ QString longlabel;
+ QString shortstatuslabel;
+ QComboBox *box;
+};
+
#endif
diff --git a/rkward/settings/rksettings.cpp b/rkward/settings/rksettings.cpp
index 33a55f16..d62ba0d6 100644
--- a/rkward/settings/rksettings.cpp
+++ b/rkward/settings/rksettings.cpp
@@ -1,288 +1,276 @@
/***************************************************************************
rksettings - description
-------------------
begin : Wed Jul 28 2004
copyright : (C) 2004-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "rksettings.h"
#include
#include
#include
#include "../windows/rkworkplace.h"
// modules
#include "rksettingsmoduleplugins.h"
#include "rksettingsmodulekateplugins.h"
#include "rksettingsmoduler.h"
#include "rksettingsmodulegeneral.h"
#include "rksettingsmoduleoutput.h"
#include "rksettingsmodulegraphics.h"
#include "rksettingsmodulewatch.h"
#include "rksettingsmoduleobjectbrowser.h"
#include "rksettingsmoduleconsole.h"
#include "rksettingsmodulecommandeditor.h"
#include "rksettingsmoduledebug.h"
#include "../debug.h"
//static
RKSettings *RKSettings::settings_dialog = 0;
RKSettingsTracker *RKSettings::settings_tracker = 0;
//static
void RKSettings::configureSettings (SettingsPage page, QWidget *parent, RCommandChain *chain) {
RK_TRACE (SETTINGS);
RKSettingsModule::chain = chain;
if (!settings_dialog) {
settings_dialog = new RKSettings (parent);
}
if (page != NoPage) settings_dialog->raisePage (page);
settings_dialog->show ();
settings_dialog->raise ();
}
//static
void RKSettings::configureSettings (const QString& page, QWidget *parent, RCommandChain *chain) {
RK_TRACE (SETTINGS);
if (page == QStringLiteral ("rbackend")) {
RKSettings::configureSettings (RKSettings::PageR, parent, chain);
} else if (page == QStringLiteral ("console")) {
RKSettings::configureSettings (RKSettings::PageConsole, parent, chain);
} else if (page == QStringLiteral ("editor")) {
RKSettings::configureSettings (RKSettings::PageCommandEditor, parent, chain);
} else if (page == QStringLiteral ("graphics")) {
RKSettings::configureSettings (RKSettings::PageX11, parent, chain);
} else if (page == QStringLiteral ("browser")) {
RKSettings::configureSettings (RKSettings::PageObjectBrowser, parent, chain);
} else if (page == QStringLiteral ("rpackages")) {
RKSettings::configureSettings (RKSettings::PageRPackages, parent, chain);
} else {
RK_ASSERT(page.isEmpty());
RKSettings::configureSettings (RKSettings::NoPage, parent, chain);
}
}
//static
void RKSettings::dialogClosed () {
RK_TRACE (SETTINGS);
settings_dialog = 0;
}
RKSettings::RKSettings (QWidget *parent) : KPageDialog (parent) {
RK_TRACE (SETTINGS);
setFaceType (KPageDialog::Tree);
setWindowTitle (i18n ("Settings"));
buttonBox ()->setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
// KF5 TODO: connect buttons
button (QDialogButtonBox::Apply)->setEnabled (false);
connect (button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &RKSettings::applyAll);
connect (button(QDialogButtonBox::Help), &QPushButton::clicked, this, &RKSettings::helpClicked);
setAttribute (Qt::WA_DeleteOnClose, true);
initModules ();
connect (this, &KPageDialog::currentPageChanged, this, &RKSettings::pageChange);
pageChange (currentPage (), currentPage ()); // init
}
RKSettings::~RKSettings() {
RK_TRACE (SETTINGS);
ModuleMap::const_iterator it;
for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
delete *it;
}
modules.clear ();
dialogClosed ();
}
void RKSettings::registerPageModule(RKSettings::SettingsPage super, RKSettings::SettingsPage child) {
RK_TRACE (SETTINGS);
RKSettingsModule *childm = modules[child];
if (super == NoPage) {
pages[child] = addPage(childm, childm->caption());
} else {
pages[child] = addSubPage(pages[super], childm, childm->caption());
}
}
#include
void RKSettings::initModules () {
RK_TRACE (SETTINGS);
modules.insert (PagePlugins, new RKSettingsModulePlugins (this, 0));
modules.insert (PageKatePlugins, new RKSettingsModuleKatePlugins (this, 0));
modules.insert (PageR, new RKSettingsModuleR (this, 0));
modules.insert (PageRPackages, new RKSettingsModuleRPackages (this, 0));
modules.insert (PageGeneral, new RKSettingsModuleGeneral (this, 0));
modules.insert (PageOutput, new RKSettingsModuleOutput (this, 0));
modules.insert (PageX11, new RKSettingsModuleGraphics (this, 0));
modules.insert (PageWatch, new RKSettingsModuleWatch (this, 0));
modules.insert (PageConsole, new RKSettingsModuleConsole (this, 0));
modules.insert (PageCommandEditor, new RKSettingsModuleCommandEditor (this, 0));
modules.insert (PageObjectBrowser, new RKSettingsModuleObjectBrowser (this, 0));
modules.insert (PageDebug, new RKSettingsModuleDebug (this, 0));
QLabel *l = new QLabel(i18n("Add-ons RKWard add-ons come in a variety of forms, each with their own configuration options:
R packages Add-ons to the R language itself . These are usually downloaded from \"CRAN\". Some of these add-on packages may additionally contain RKWard plugins.
RKWard plugins Graphical dialogs to R functionality . These plugins are usually pre-installed with RKWard, or with an R package. However, they can be activated/deactivated to help keep the menus manageable. Note that it is relatively easy to create your own custom dialogs as plugins !
Kate plugins Plugins developed for Kate / KTextEditor . These provide shared functionality that is useful in the context of text editing and IDE applications. These plugins are usually found pre-installed on your system. You can configure to load the plugins that are useful to your own workflow.
"));
l->setWordWrap(true);
connect(l, &QLabel::linkActivated, [=](const QString url) { RKWorkplace::mainWorkplace()->openAnyUrl(QUrl(url)); });
pages[SuperPageAddons] = addPage(l, i18n("Add-ons"));
registerPageModule(SuperPageAddons, PageRPackages);
registerPageModule(SuperPageAddons, PagePlugins);
registerPageModule(SuperPageAddons, PageKatePlugins);
registerPageModule(NoPage, PageR);
registerPageModule(NoPage, PageGeneral);
registerPageModule(NoPage, PageOutput);
registerPageModule(NoPage, PageX11);
registerPageModule(NoPage, PageWatch);
registerPageModule(NoPage, PageConsole);
registerPageModule(NoPage, PageCommandEditor);
registerPageModule(NoPage, PageObjectBrowser);
registerPageModule(NoPage, PageDebug);
}
void RKSettings::raisePage (SettingsPage page) {
RK_TRACE (SETTINGS);
if (page != NoPage) {
setCurrentPage (pages[(int) page]);
}
}
void RKSettings::pageChange (KPageWidgetItem *current, KPageWidgetItem *) {
RK_TRACE (SETTINGS);
RKSettingsModule *new_module = dynamic_cast (current->widget ());
bool has_help;
if (!new_module) {
RK_ASSERT (false);
has_help = false;
} else {
has_help = !(new_module->helpURL ().isEmpty ());
}
button (QDialogButtonBox::Help)->setEnabled (has_help);
}
void RKSettings::done (int result) {
RK_TRACE (SETTINGS);
if (result == Accepted) applyAll ();
QDialog::done (result);
}
void RKSettings::helpClicked () {
RK_TRACE (SETTINGS);
RKSettingsModule *current_module = dynamic_cast (currentPage ()->widget ());
if (!current_module) {
RK_ASSERT (false);
return;
}
RKWorkplace::mainWorkplace ()->openHelpWindow (current_module->helpURL ());
}
void RKSettings::applyAll () {
RK_TRACE (SETTINGS);
ModuleMap::const_iterator it;
for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
if (it.value ()->hasChanges ()) {
it.value ()->applyChanges ();
it.value ()->changed = false;
it.value ()->save (KSharedConfig::openConfig ().data ());
tracker ()->signalSettingsChange (it.key ());
}
}
button (QDialogButtonBox::Apply)->setEnabled (false);
}
void RKSettings::enableApply () {
RK_TRACE (SETTINGS);
button (QDialogButtonBox::Apply)->setEnabled (true);
}
#define FOREACH_SETTINGS_MODULE(X) \
RKSettingsModuleGeneral::X; /* always handle this first (esp., when loading settings), as it contains the base path for rkward files */ \
RKSettingsModuleKatePlugins::X; \
RKSettingsModulePlugins::X; \
RKSettingsModuleR::X; \
RKSettingsModuleRPackages::X; \
RKSettingsModuleOutput::X; \
RKSettingsModuleGraphics::X; \
RKSettingsModuleWatch::X; \
RKSettingsModuleConsole::X; \
RKSettingsModuleCommandEditor::X; \
RKSettingsModuleObjectBrowser::X;
void RKSettings::loadSettings (KConfig *config) {
RK_TRACE (SETTINGS);
FOREACH_SETTINGS_MODULE(loadSettings(config));
}
void RKSettings::saveSettings (KConfig *config) {
RK_TRACE (SETTINGS);
FOREACH_SETTINGS_MODULE(saveSettings(config));
}
#include
-void RKSettings::validateSettingsInteractive () {
+QList RKSettings::validateSettingsInteractive () {
RK_TRACE (SETTINGS);
- QList interaction_pages;
- FOREACH_SETTINGS_MODULE(validateSettingsInteractive(&interaction_pages));
- if (!interaction_pages.isEmpty ()) {
- KAssistantDialog dialog ((QWidget*) 0);
- for (int i = 0; i < interaction_pages.size (); ++i) {
- dialog.addPage (interaction_pages[i], interaction_pages[i]->windowTitle ());
- }
- QPushButton *help_button = dialog.button (QDialogButtonBox::Help);
- if (help_button) help_button->hide ();
- if (dialog.exec () == QDialog::Accepted) {
- for (int i = 0; i < interaction_pages.size (); ++i) {
- interaction_pages[i]->apply ();
- }
- }
- }
+ QList interaction_items;
+ FOREACH_SETTINGS_MODULE(validateSettingsInteractive(&interaction_items));
+ return interaction_items;
}
//############ END RKSettings ##################
//############ BEGIN RKSettingsTracker ############
RKSettingsTracker::RKSettingsTracker (QObject *parent) : QObject (parent) {
RK_TRACE (SETTINGS);
}
RKSettingsTracker::~RKSettingsTracker () {
RK_TRACE (SETTINGS);
}
void RKSettingsTracker::signalSettingsChange (RKSettings::SettingsPage page) {
RK_TRACE (SETTINGS);
emit (settingsChanged (page));
}
diff --git a/rkward/settings/rksettings.h b/rkward/settings/rksettings.h
index 6575fd37..7c570184 100644
--- a/rkward/settings/rksettings.h
+++ b/rkward/settings/rksettings.h
@@ -1,106 +1,107 @@
/***************************************************************************
rksettings - description
-------------------
begin : Wed Jul 28 2004
copyright : (C) 2004-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGS_H
#define RKSETTINGS_H
#include
#include
class RKSettingsModule;
class KConfig;
class RKWardMainWindow;
class RKSettingsTracker;
class RCommandChain;
+class RKSetupWizardItem;
/**
The main settings-dialog. Contains subsections (tabs) for different modules. Use configureSettings () to invoke or raise the settings dialog
@author Thomas Friedrichsmeier
*/
class RKSettings : public KPageDialog {
Q_OBJECT
public:
enum SettingsPage {
NoPage=0,
SuperPageAddons,
PagePlugins,
PageKatePlugins,
PageR,
PageRPackages,
PageGeneral,
PageOutput,
PageX11,
PageWatch,
PageConsole,
PageCommandEditor,
PageObjectBrowser,
PageDebug,
NumPages = PageDebug + 1
};
static void configureSettings (SettingsPage page=NoPage, QWidget *parent=0, RCommandChain *chain=0);
static void configureSettings (const QString& page, QWidget *parent=0, RCommandChain *chain=0);
static void loadSettings (KConfig *config);
static void saveSettings (KConfig *config);
/** Perform any settings validation that may need user interaction (and should happen after a GUI is available, and R has started up) */
- static void validateSettingsInteractive ();
+ static QList validateSettingsInteractive ();
void enableApply ();
static RKSettingsTracker* tracker () { return settings_tracker; };
public slots:
void pageChange (KPageWidgetItem *current, KPageWidgetItem *before);
protected:
RKSettings (QWidget *parent = 0);
~RKSettings ();
void done (int result) override;
private slots:
void applyAll ();
void helpClicked ();
private:
void initModules ();
void raisePage (SettingsPage page);
static void dialogClosed ();
typedef QMap ModuleMap;
ModuleMap modules;
KPageWidgetItem *pages[NumPages];
static RKSettings *settings_dialog;
friend class RKWardMainWindow;
static RKSettingsTracker *settings_tracker;
void registerPageModule(SettingsPage super, SettingsPage child);
};
/** This class represents a very simple QObject. It's only purpose is to emit signals when certain settings have changed. Classes that need to
update themselves on certain changed settings should connect to those signals. */
class RKSettingsTracker : public QObject {
Q_OBJECT
public:
explicit RKSettingsTracker (QObject *parent);
~RKSettingsTracker ();
void signalSettingsChange (RKSettings::SettingsPage page);
signals:
void settingsChanged (RKSettings::SettingsPage);
};
#endif
diff --git a/rkward/settings/rksettingsmodule.h b/rkward/settings/rksettingsmodule.h
index e4b392b4..8b214dd9 100644
--- a/rkward/settings/rksettingsmodule.h
+++ b/rkward/settings/rksettingsmodule.h
@@ -1,155 +1,138 @@
/***************************************************************************
rksettingsmodule - description
-------------------
begin : Wed Jul 28 2004
copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULE_H
#define RKSETTINGSMODULE_H
#include
#include
#include
#include
class KConfig;
class RKSettings;
class RCommandChain;
/** Base class for RKWard config settings.
*
* Meant to reduce the amount of boilerplate code involved in defining, loading, saving config settings (and in the future probably also creating widgets and applying changes). */
class RKConfigBase {
public:
virtual void loadConfig(KConfigGroup &cg) = 0;
virtual void saveConfig(KConfigGroup &cg) const = 0;
protected:
RKConfigBase(const char* name) : name(name) {};
virtual ~RKConfigBase() {};
const char* name;
};
/** A single value stored in the RKWard config file.
*
* The value set initially (in the constructor or via setDefaultValue() represents the default value. */
template class RKConfigValue : public RKConfigBase {
public:
RKConfigValue(const char* name, const T &default_value) : RKConfigBase(name), value(default_value) {};
~RKConfigValue() {};
void loadConfig(KConfigGroup &cg) override {
value = cg.readEntry(name, value);
}
void saveConfig(KConfigGroup &cg) const override {
cg.writeEntry(name, value);
}
void setDefaultValue(const T& value) { RKConfigValue::value = value; }
operator T() const { return(value); }
RKConfigValue& operator= (const T v) { value = v; return *this; };
private:
T value;
};
#include
#include
/** A group of values stored in the RKWard config file.
*
* If a name is given and non-empty, loadConfig()/saveConfig() will load from/save to a sub config-group by that name. */
class RKConfigGroup : public RKConfigBase {
public:
RKConfigGroup(const char *name, std::initializer_list values) : RKConfigBase(name),
values(values) {};
template RKConfigGroup(const char *name, size_t count, RKConfigValue* _values) : RKConfigBase(name),
values(count) { for (size_t i = 0; i < count; ++i) values[i] = (_values + i); };
~RKConfigGroup() {};
void loadConfig(KConfigGroup &cg) override {
KConfigGroup lcg = cg;
if (name && name[0]) {
lcg = cg.group(name);
}
for (auto it = values.begin(); it != values.end(); ++it) (*it)->loadConfig(lcg);
}
void saveConfig(KConfigGroup &cg) const override {
KConfigGroup lcg = cg;
if (name && name[0]) {
lcg = cg.group(name);
}
for (auto it = values.begin(); it != values.end(); ++it) (*it)->saveConfig(lcg);
}
private:
std::vector values;
};
/**
Base class for settings modules. Provides some pure virtual calls.
@author Thomas Friedrichsmeier
*/
class RKSettingsModule : public QWidget {
public:
RKSettingsModule (RKSettings *gui, QWidget *parent);
virtual ~RKSettingsModule ();
bool hasChanges () { return changed; };
virtual void applyChanges () = 0;
virtual void save (KConfig *config) = 0;
virtual QString caption () = 0;
/** Some settings modules execute R commands on "apply". If an RCommandChain is specified for the RKSettings-dialog, those commands should
be inserted into this chain. It's safe to use this unconditionally, as if there is no chain, this will return 0, which corresponds to using the top-level chain */
RCommandChain *commandChain () { return chain; };
virtual QUrl helpURL () { return QUrl (); };
protected:
friend class RKSettingsModuleWidget;
void change ();
bool changed;
private:
RKSettings *gui;
friend class RKSettings;
static RCommandChain *chain;
};
/** Base class for UI widgets operating on an RKSettingsModule. For now this is used, only where similar settings are shared across modules (e.g. code completion). Eventually, this could be used to disentangle RKSettingsModule from QWidget. */
class RKSettingsModuleWidget : public QWidget {
public:
RKSettingsModuleWidget(QWidget *parent, RKSettingsModule *_module) : QWidget(parent), module(_module) {};
~RKSettingsModuleWidget() {};
virtual void applyChanges() = 0;
protected:
void change() { module->change(); }
private:
RKSettingsModule *module;
};
-#include
-/** Simple helper class to formalize the API of widgets used for the interactive validation of settings.
- * (For quering about settings that may need adjusting on startup. Possibly to be expanded to a "first-run-wizard", in the future). */
-class RKSettingsWizardPage : public QWidget {
-public:
- RKSettingsWizardPage (QWidget* parent=0) : QWidget (parent) {
- apply_callback = 0;
- }
- ~RKSettingsWizardPage () {};
- void apply () {
- if (apply_callback) apply_callback();
- }
- void setApplyCallback (std::function callback) {
- apply_callback = callback;
- };
-private:
- std::function apply_callback;
-};
+class RKSetupWizardItem;
#endif
diff --git a/rkward/settings/rksettingsmodulecommandeditor.h b/rkward/settings/rksettingsmodulecommandeditor.h
index d7fae4ed..cfaf7478 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.h
+++ b/rkward/settings/rksettingsmodulecommandeditor.h
@@ -1,146 +1,146 @@
/***************************************************************************
rksettingsmodulecommandeditor - description
-------------------
begin : Tue Oct 23 2007
copyright : (C) 2007-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULECOMMANDEDITOR_H
#define RKSETTINGSMODULECOMMANDEDITOR_H
#include "rksettingsmodule.h"
#include "../core/robject.h"
class RKSpinBox;
class QCheckBox;
class QLineEdit;
class QGroupBox;
class QComboBox;
class QGridLayout;
class RKCodeCompletionSettingsWidget;
class RKCodeCompletionSettings {
public:
RKCodeCompletionSettings() {};
~RKCodeCompletionSettings() {};
void loadSettings(KConfigGroup &config) { group.loadConfig(config); };
void saveSettings(KConfigGroup &config) { group.saveConfig(config); };
// NOTE: Don't insert values inbetween existing values, without also adjusting the sloppy config load/save/apply code
enum CompletionCategories {
Calltip = 0,
Arghint,
Object,
Filename,
AutoWord,
N_COMPLETION_CATEGORIES
};
/// min number of character to try code completion
int autoMinChars() const { return auto_completion_min_chars; };
int autoTimeout() const { return auto_completion_timeout; };
bool autoEnabled() const { return auto_completion_enabled; };
bool autoCursorActivated() const { return (auto_completion_enabled && auto_completion_cursor_activated); };
bool argHintingEnabled() const { return isEnabled(Arghint); }; // TODO: remove me
int options() const { return completion_options; };
bool isEnabled(CompletionCategories cat) const { return completion_type_enabled[cat]; };
bool cursorNavigatesCompletions() const { return cursor_navigates_completions; };
bool tabKeyInvokesCompletion() const { return tabkey_invokes_completion; };
private:
friend class RKCodeCompletionSettingsWidget;
friend class RKSettingsModuleConsole;
RKConfigValue auto_completion_enabled {"Completion enabled", true};
RKConfigValue auto_completion_min_chars {"Completion min chars", 2};
RKConfigValue auto_completion_timeout {"Completion timeout", 250};
RKConfigValue auto_completion_cursor_activated {"Auto completion on cursor navigation", false};
RKConfigValue tabkey_invokes_completion {"Tabkey invokes completion", false};
RKConfigValue completion_type_enabled[N_COMPLETION_CATEGORIES] {{"Calltips", true}, {"Argument completion", true}, {"Object completion", true}, {"Filename completion", true}, {"Auto word completion", true}};
RKConfigValue cursor_navigates_completions {"Cursor navigate completions", false};
RKConfigValue completion_options {"Completion option flags", (int) RObject::IncludeEnvirIfMasked};
RKConfigGroup dummyoptions = RKConfigGroup(0, N_COMPLETION_CATEGORIES, completion_type_enabled);
RKConfigGroup group {"Completion", { &dummyoptions, &auto_completion_enabled, &auto_completion_min_chars, &auto_completion_timeout, &auto_completion_cursor_activated, &tabkey_invokes_completion, &cursor_navigates_completions, &completion_options }};
};
class RKCodeCompletionSettingsWidget : public RKSettingsModuleWidget {
public:
RKCodeCompletionSettingsWidget(QWidget *parent, RKSettingsModule *module, RKCodeCompletionSettings *settings, bool show_common);
~RKCodeCompletionSettingsWidget() {};
void applyChanges() override;
private:
void makeCompletionTypeBoxes (const QStringList& labels, QGridLayout* layout);
RKSpinBox* auto_completion_min_chars_box;
RKSpinBox* auto_completion_timeout_box;
QGroupBox* auto_completion_enabled_box;
QCheckBox* auto_completion_cursor_activated_box;
QCheckBox* tabkey_invokes_completion_box;
QCheckBox* completion_type_enabled_box[RKCodeCompletionSettings::N_COMPLETION_CATEGORIES];
QComboBox* cursor_navigates_completions_box;
QComboBox* completion_list_member_operator_box;
QComboBox* completion_slot_operator_box;
QComboBox* completion_object_qualification_box;
RKCodeCompletionSettings *settings;
bool show_common;
};
/**
configuration for the Command Editor windows
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleCommandEditor : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleCommandEditor (RKSettings *gui, QWidget *parent);
~RKSettingsModuleCommandEditor ();
void applyChanges () override;
void save (KConfig *config) override;
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
QString caption () override;
static const RKCodeCompletionSettings* completionSettings() { return &completion_settings; };
static bool autosaveEnabled () { return autosave_enabled; };
static bool autosaveKeep () { return autosave_keep; };
static int autosaveInterval () { return autosave_interval; };
static QString autosaveSuffix () { return ".rkward_autosave"; };
static int maxNumRecentFiles () { return num_recent_files; };
static QString scriptFileFilter () { return script_file_filter; };
static bool matchesScriptFileFilter (const QString &filename);
public slots:
void settingChanged ();
private:
static RKCodeCompletionSettings completion_settings;
static bool autosave_enabled;
static bool autosave_keep;
static int autosave_interval;
RKCodeCompletionSettingsWidget *completion_settings_widget;
QGroupBox* autosave_enabled_box;
QCheckBox* autosave_keep_box;
RKSpinBox* autosave_interval_box;
RKSpinBox* num_recent_files_box;
QLineEdit* script_file_filter_box;
static int num_recent_files;
static QString script_file_filter;
};
#endif
diff --git a/rkward/settings/rksettingsmoduleconsole.h b/rkward/settings/rksettingsmoduleconsole.h
index 5d6fb84d..33988082 100644
--- a/rkward/settings/rksettingsmoduleconsole.h
+++ b/rkward/settings/rksettingsmoduleconsole.h
@@ -1,89 +1,89 @@
/***************************************************************************
rksettingsmoduleconsole - description
-------------------
begin : Sun Oct 16 2005
copyright : (C) 2005-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULECONSOLE_H
#define RKSETTINGSMODULECONSOLE_H
#include "rksettingsmodule.h"
#include "rksettingsmodulecommandeditor.h" // For RKCodeCompletionSettings
#include
class QCheckBox;
class QComboBox;
class QSpinBox;
/**
Settings module for the console. Allows you to configure whether to store command history, command history length. Future extensions: color for warnings/errors, etc.
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleConsole : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleConsole (RKSettings *gui, QWidget *parent);
~RKSettingsModuleConsole ();
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
void applyChanges () override;
void save (KConfig *config) override;
static bool saveHistory () { return save_history; };
static uint maxHistoryLength () { return max_history_length; };
static uint maxConsoleLines () { return max_console_lines; };
static bool pipeUserCommandsThroughConsole () { return pipe_user_commands_through_console; };
enum PipedCommandsHistoryMode {
DontAdd = 0,
AddSingleLine = 1,
AlwaysAdd = 2
};
static PipedCommandsHistoryMode addPipedCommandsToHistory () { return add_piped_commands_to_history; };
/** Given the button state, return whether the command history should be navigated context sensitive or insensitive
@param current_state the current button state
@returns true, if a the search should be context sensitive, false for a normal search */
static bool shouldDoHistoryContextSensitive (Qt::KeyboardModifiers current_state);
static const RKCodeCompletionSettings* completionSettings() { return &completion_settings; }
static QStringList loadCommandHistory ();
static void saveCommandHistory (const QStringList &list);
QString caption () override;
QUrl helpURL () override { return QUrl ("rkward://page/rkward_console#settings"); };
public slots:
void changedSetting (int);
private:
static RKCodeCompletionSettings completion_settings;
static bool save_history;
static uint max_history_length;
static uint max_console_lines;
static bool pipe_user_commands_through_console;
static PipedCommandsHistoryMode add_piped_commands_to_history;
static bool context_sensitive_history_by_default;
RKCodeCompletionSettingsWidget *completion_settings_widget;
QCheckBox *save_history_box;
QCheckBox *reverse_context_mode_box;
QCheckBox *pipe_user_commands_through_console_box;
QComboBox *add_piped_commands_to_history_box;
QSpinBox *max_history_length_spinner;
QSpinBox *max_console_lines_spinner;
};
#endif
diff --git a/rkward/settings/rksettingsmoduledebug.h b/rkward/settings/rksettingsmoduledebug.h
index 6e532fc9..d03208a6 100644
--- a/rkward/settings/rksettingsmoduledebug.h
+++ b/rkward/settings/rksettingsmoduledebug.h
@@ -1,55 +1,55 @@
/***************************************************************************
rksettingsmoduledebug - description
-------------------
begin : Tue Oct 23 2007
copyright : (C) 2007-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEDEBUG_H
#define RKSETTINGSMODULEDEBUG_H
#include "rksettingsmodule.h"
class RKSpinBox;
class QButtonGroup;
class QFile;
/**
configuration for the Command Editor windows
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleDebug : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleDebug (RKSettings *gui, QWidget *parent);
~RKSettingsModuleDebug ();
void applyChanges () override;
void save (KConfig *config) override;
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
QString caption () override;
// static members are declared in debug.h and defined in main.cpp
public slots:
void settingChanged (int);
private:
RKSpinBox* command_timeout_box;
RKSpinBox* debug_level_box;
QButtonGroup* debug_flags_group;
};
#endif
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index 1b038af9..12b0c683 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -1,145 +1,145 @@
/***************************************************************************
rksettingsmodulegeneral - description
-------------------
begin : Fri Jul 30 2004
copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEGENERALFILES_H
#define RKSETTINGSMODULEGENERALFILES_H
#include "rksettingsmodule.h"
#include "../dialogs/startupdialog.h"
class GetFileNameWidget;
class QComboBox;
class QCheckBox;
class QButtonGroup;
class RKSpinBox;
/**
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleGeneral : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleGeneral (RKSettings *gui, QWidget *parent);
~RKSettingsModuleGeneral ();
enum WorkplaceSaveMode { // don't change the int values of this enum, or you'll ruin users saved settings. Append new values at the end
SaveWorkplaceWithWorkspace=0,
SaveWorkplaceWithSession=1,
DontSaveWorkplace=2
};
enum InitialDirectory { // don't change the int values of this enum, or you'll ruin users saved settings. Append new values at the end
CurrentDirectory=0,
RKWardDirectory=1,
UserHomeDirectory=2,
LastUsedDirectory=3,
CustomDirectory=4
};
enum RKMDIFocusPolicy { // don't change the int values of this enum, or you'll ruin users saved settings. Append new values at the end
RKMDIClickFocus=0,
RKMDIFocusFollowsMouse=1
};
void applyChanges () override;
void save (KConfig *config) override;
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
QString caption () override;
/// returns the directory-name where the logfiles should reside
static QString &filesPath () { return files_path; };
static StartupDialog::Result startupAction () { return startup_action; };
static bool showHelpOnStartup () { return show_help_on_startup; };
static void setStartupAction (StartupDialog::Result action) { startup_action = action; };
static WorkplaceSaveMode workplaceSaveMode () { return workplace_save_mode; };
/** retrieve the saved workplace description. Meaningful only is workplaceSaveMode () == SaveWorkplaceWithSession */
static QString getSavedWorkplace (KConfig *config);
/** set the saved workplace description. Meaningful only is workplaceSaveMode () == SaveWorkplaceWithSession */
static void setSavedWorkplace (const QString &description, KConfig *config);
static bool cdToWorkspaceOnLoad () { return cd_to_workspace_dir_on_load; };
static unsigned long warnLargeObjectThreshold () { return warn_size_object_edit; };
static RKMDIFocusPolicy mdiFocusPolicy () { return mdi_focus_policy; }
static QString workspaceFilenameFilter () { return ("*.RData *.RDA"); };
static QString initialWorkingDirectory ();
/** get the url last used for @param thing, where thing is simply a key string.
Urls are saved and restored across sessions, _except_ for the empty key, which will keep track of the last used
"generic" url within a session (and defaults to the current working directory, while not set). */
static QUrl lastUsedUrlFor (const QString& thing);
/** update the url used for @param thing, @see lastUsedUrlFor(). */
static void updateLastUsedUrl (const QString& thing, const QUrl& new_path);
/** if the installation-path of KDE seems to have moved since the last startup, *and* the given path is relative to the
* KDE data path, adjust the given path (probably loaded from config), accordingly. @See RKCommonFunctions::getRKWardDataDir()
* TODO: similar, but not quite identical functionality in rkworkplace.cpp checkAdjustRestoredUrl(). Might be mergeable. */
static QString checkAdjustLoadedPath (const QString &localpath);
enum RKWardConfigVersion {
RKWardConfig_Pre0_5_7,
RKWardConfig_0_5_7,
RKWardConfig_0_6_1,
RKWardConfig_0_6_3,
RKWardConfig_0_6_4,
RKWardConfig_0_7_1,
RKWardConfig_Next, /**< add new configuration versions above / before this entry */
RKWardConfig_Latest = RKWardConfig_Next - 1
};
/** Which version did an existing config file appear to have?
* @return RKWardConfig_Pre0_5_7, if no config file could be read. See anyExistingConfig()
* @note Not all versions of RKWard have a config file version of their own, not even necessarily when new entries were added. Only when not-quite-compatible changes are needed, new config versions will be added. */
static RKWardConfigVersion storedConfigVersion () { return stored_config_version; };
/** Did a config file already exist? */
static bool anyExistingConfig () { return config_exists; };
/** Returns true, if the runtime version of RKWard has changed since the previous session. */
static bool rkwardVersionChanged () { return rkward_version_changed; };
/** Returns true, if rkward seems to have started from a different path than on the previous run. */
static bool installationMoved () { return installation_moved; };
public slots:
void settingChanged ();
private:
GetFileNameWidget *files_choser;
QComboBox *startup_action_choser;
QButtonGroup *workplace_save_chooser;
QCheckBox *cd_to_workspace_dir_on_load_box;
QCheckBox *show_help_on_startup_box;
RKSpinBox *warn_size_object_edit_box;
QComboBox *mdi_focus_policy_chooser;
QComboBox *initial_dir_chooser;
GetFileNameWidget *initial_dir_custom_chooser;
static StartupDialog::Result startup_action;
static QString files_path;
/** since changing the files_path can not easily be done while in an active session, the setting should only take effect on the next start. This string stores a changed setting, while keeping the old one intact as long as RKWard is running */
static QString new_files_path;
static WorkplaceSaveMode workplace_save_mode;
static bool cd_to_workspace_dir_on_load;
static bool show_help_on_startup;
static int warn_size_object_edit;
static RKMDIFocusPolicy mdi_focus_policy;
static RKWardConfigVersion stored_config_version;
static bool config_exists;
static InitialDirectory initial_dir;
static QString initial_dir_specification;
static bool rkward_version_changed;
static QString previous_rkward_data_dir;
static bool installation_moved;
static QUrl generic_filedialog_start_url;
};
#endif
diff --git a/rkward/settings/rksettingsmodulegraphics.h b/rkward/settings/rksettingsmodulegraphics.h
index 59bb317a..676b6169 100644
--- a/rkward/settings/rksettingsmodulegraphics.h
+++ b/rkward/settings/rksettingsmodulegraphics.h
@@ -1,101 +1,101 @@
/***************************************************************************
rksettingsmodulegraphics - description
-------------------
begin : Mon Sep 13 2010
copyright : (C) 2010-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEGRAPHICS_H
#define RKSETTINGSMODULEGRAPHICS_H
#include "rksettingsmodule.h"
#include
class QLineEdit;
class QGroupBox;
class RKSpinBox;
class QSpinBox;
class QCheckBox;
class QButtonGroup;
class QRadioButton;
/**
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleGraphics : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleGraphics (RKSettings *gui, QWidget *parent);
~RKSettingsModuleGraphics ();
void applyChanges () override;
void save (KConfig *config) override;
/** generate the commands needed to set the R run time options */
static QStringList makeRRunTimeOptionCommands ();
/** Configured to (attempt to) use KDE printing dialog? */
static bool kdePrintingEnabled () { return options_kde_printing; };
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
QString caption () override;
QUrl helpURL () override { return QUrl ("rkward://page/rkward_plot_history#scd_settings"); };
enum DefaultDevice {
RKDevice,
PlatformDevice,
OtherDevice
};
enum StandardDevicesMode {
ReplaceDevice,
EmbedDevice,
LeaveDevice
};
static bool plotHistoryEnabled () { return graphics_hist_enable; };
public slots:
void boxChanged ();
private:
void updateControls ();
QButtonGroup *default_device_group;
QLineEdit *default_device_other_edit;
QButtonGroup *replace_standard_devices_group;
QGroupBox *graphics_hist_box;
QSpinBox *graphics_hist_max_length_box;
QSpinBox *graphics_hist_max_plotsize_box;
RKSpinBox *graphics_height_box;
RKSpinBox *graphics_width_box;
QCheckBox *kde_printing_box;
static DefaultDevice default_device;
static QString default_device_other;
static StandardDevicesMode replace_standard_devices;
static bool graphics_hist_enable;
static int graphics_hist_max_length;
static int graphics_hist_max_plotsize;
static double graphics_height;
static double graphics_width;
static bool options_kde_printing;
};
#endif
diff --git a/rkward/settings/rksettingsmodulekateplugins.h b/rkward/settings/rksettingsmodulekateplugins.h
index d1e454e3..9e413833 100644
--- a/rkward/settings/rksettingsmodulekateplugins.h
+++ b/rkward/settings/rksettingsmodulekateplugins.h
@@ -1,50 +1,50 @@
/***************************************************************************
rksettingsmodulekateplugins - description
-------------------
begin : Thu Mar 26 2010
copyright : (C) 2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEKATEPLUGINS_H
#define RKSETTINGSMODULEKATEPLUGINS_H
#include "rksettingsmodule.h"
#include
class QTreeWidget;
/** The settings-module for kate plugin specific settings
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleKatePlugins : public RKSettingsModule {
public:
RKSettingsModuleKatePlugins(RKSettings *gui, QWidget *parent);
~RKSettingsModuleKatePlugins();
void applyChanges() override;
void save(KConfig *config) override;
static void saveSettings(KConfig *config);
static void loadSettings(KConfig *config);
- static void validateSettingsInteractive(QList*) {};
+ static void validateSettingsInteractive(QList*) {};
QString caption() override;
static QStringList pluginsToLoad() { return plugins_to_load; };
private:
QTreeWidget *plugin_table;
static QStringList plugins_to_load;
};
#endif
diff --git a/rkward/settings/rksettingsmoduleobjectbrowser.h b/rkward/settings/rksettingsmoduleobjectbrowser.h
index 84f902c6..90302cc8 100644
--- a/rkward/settings/rksettingsmoduleobjectbrowser.h
+++ b/rkward/settings/rksettingsmoduleobjectbrowser.h
@@ -1,72 +1,72 @@
/***************************************************************************
rksettingsmodule - description
-------------------
begin : Fri Apr 22 2005
copyright : (C) 2005-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEOBJECTBROWSER_H
#define RKSETTINGSMODULEOBJECTBROWSER_H
#include "rksettingsmodule.h"
#include "../misc/rkobjectlistview.h"
class QCheckBox;
class MultiStringSelector;
/** Configuration module for instances of RObjectListView
@see RKSettingsModule
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleObjectBrowser : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleObjectBrowser (RKSettings *gui, QWidget *parent);
~RKSettingsModuleObjectBrowser ();
/** applies current settings in this RKSettingsModule. This will only be called, if hasChanges () is true */
void applyChanges () override;
/** saves current changes to the given KConfig
@param config probably always RKGlobals::rkApp ()->config. But passing this as an argument is both more flexible and saves #including files.*/
void save (KConfig *config) override;
/** @returns the caption ("Workspace Browser") */
QString caption () override;
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
static bool isDefaultForWorkspace (RKObjectListViewSettings::PersistentSettings setting) { return workspace_settings[setting]; };
static bool isDefaultForVarselector (RKObjectListViewSettings::PersistentSettings setting) { return varselector_settings[setting]; };
static void setDefaultForWorkspace (RKObjectListViewSettings::PersistentSettings setting, bool state);
static void setDefaultForVarselector (RKObjectListViewSettings::PersistentSettings setting, bool state);
static bool isPackageBlacklisted (const QString &package_name);
QUrl helpURL () override { return QUrl ("rkward://page/rkward_workspace_browser#settings"); };
public slots:
/** called when a checkbox has been changed. Signals change to RKSettings dialog to enable apply button */
void boxChanged (int);
void listChanged ();
void addBlackList (QStringList *string_list);
private:
MultiStringSelector *blacklist_choser;
static QStringList getstructure_blacklist;
static bool workspace_settings[RKObjectListViewSettings::SettingsCount];
static bool varselector_settings[RKObjectListViewSettings::SettingsCount];
};
#endif
diff --git a/rkward/settings/rksettingsmoduleoutput.h b/rkward/settings/rksettingsmoduleoutput.h
index 1858835f..b17dde6c 100644
--- a/rkward/settings/rksettingsmoduleoutput.h
+++ b/rkward/settings/rksettingsmoduleoutput.h
@@ -1,115 +1,115 @@
/***************************************************************************
rksettingsmoduleoutput - description
-------------------
begin : Fri Jul 30 2004
copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEOUTPUT_H
#define RKSETTINGSMODULEOUTPUT_H
#include "rksettingsmodule.h"
#include
class QCheckBox;
class QGroupBox;
class QComboBox;
class QSpinBox;
class RCommand;
class GetFileNameWidget;
/**
Allows to configure which types of commands should be "carbon copied" to the output window. Like the RKSettingsModules classes, this class encapsulates both, the setting itself,
and a widget to configure the settings.
@author Thomas Friedrichsmeier
*/
class RKCarbonCopySettings : public QWidget {
Q_OBJECT
public:
explicit RKCarbonCopySettings (QWidget* parent);
~RKCarbonCopySettings ();
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
static bool shouldCarbonCopyCommand (const RCommand *command);
static bool includeOutputInCarbonCopy () { return (cc_globally_enabled && cc_command_output); };
public slots:
void applyChanges ();
signals:
void changed ();
private slots:
void settingChanged ();
private:
// There can be multiple instances of this widget, which need to be kept in sync.
static QList instances;
void update ();
QGroupBox *cc_globally_enabled_box;
QCheckBox *cc_console_commands_box;
QCheckBox *cc_script_commands_box;
QCheckBox *cc_app_plugin_commands_box;
QCheckBox *cc_command_output_box;
static bool cc_globally_enabled;
static bool cc_console_commands;
static bool cc_script_commands;
static bool cc_app_plugin_commands;
static bool cc_command_output;
};
/**
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleOutput : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleOutput (RKSettings *gui, QWidget *parent);
~RKSettingsModuleOutput ();
void applyChanges () override;
void save (KConfig *config) override;
/** generate the commands needed to set the R run time options */
static QStringList makeRRunTimeOptionCommands ();
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
QString caption () override;
static bool autoShow () { return auto_show; };
static bool autoRaise () { return auto_raise; };
public slots:
void boxChanged ();
private:
QCheckBox *auto_show_box;
QCheckBox *auto_raise_box;
QComboBox *graphics_type_box;
QSpinBox *graphics_width_box;
QSpinBox *graphics_height_box;
QSpinBox *graphics_jpg_quality_box;
RKCarbonCopySettings *cc_settings;
GetFileNameWidget *custom_css_file_box;
static bool auto_show;
static bool auto_raise;
static QString graphics_type;
static int graphics_width;
static int graphics_height;
static int graphics_jpg_quality;
static QString custom_css_file;
};
#endif
diff --git a/rkward/settings/rksettingsmoduleplugins.h b/rkward/settings/rksettingsmoduleplugins.h
index 5bd9e4d6..ae8ecd59 100644
--- a/rkward/settings/rksettingsmoduleplugins.h
+++ b/rkward/settings/rksettingsmoduleplugins.h
@@ -1,154 +1,154 @@
/***************************************************************************
rksettingsmoduleplugins - description
-------------------
begin : Wed Jul 28 2004
copyright : (C) 2004-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEPLUGINS_H
#define RKSETTINGSMODULEPLUGINS_H
#include "rksettingsmodule.h"
#include "../plugin/rkcomponentmeta.h"
#include
#include
#include
class RKMultiStringSelectorV2;
class RKSettingsModulePluginsModel;
class QButtonGroup;
class QCheckBox;
class RKSpinBox;
/** The settings-module for plugin specific settings
@author Thomas Friedrichsmeier
*/
class RKSettingsModulePlugins : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModulePlugins (RKSettings *gui, QWidget *parent);
~RKSettingsModulePlugins ();
void applyChanges () override;
void save (KConfig *config) override;
enum PluginPrefs { PreferDialog=0, PreferRecommended=1, PreferWizard=2 };
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
QString caption () override;
/** @returns a list of active plugin maps */
static QStringList pluginMaps ();
static int uniqueUsablePluginMapCount ();
static PluginPrefs getInterfacePreference () { return interface_pref; };
static bool showCodeByDefault () { return show_code; };
static void setShowCodeByDefault (bool shown) { show_code = shown; };
static int defaultCodeHeight () { return code_size; };
static void setDefaultCodeHeight (int new_height) { code_size = new_height; }
static int defaultSidePreviewWidth () { return side_preview_width; };
static void setDefaultSidePreviewWidth (int new_width) { side_preview_width = new_width; }
enum AddMode {
ManualAddition,
AddIfDefault,
AddIfNewAndDefault
};
/** register a list of available plugin-maps (which may or may not already be known). New maps are activated, automatically.
* @param maps Plugin maps (filenames) to add
* @param add_mode Controls whether to activate maps that have low priority, or had previously been disabled by the user
* @param force_reload If true, plugin maps are always reloaded, even if no maps were added
* @param suppress_reload If true (and force_reload is false), do not reload plugin maps, even if maps were added
*/
static void registerPluginMaps (const QStringList &maps, AddMode add_mode, bool force_reload, bool suppress_reload=false);
/** Looks for the given id among known plugin maps */
static QString findPluginMapById (const QString &id);
/** marks given map as broken (in this version), and deactivates it. @Returns false is the map was already known to be broken, true otherwise. */
static bool markPluginMapAsBroken (const QString &map);
/** marks given map as quirky (in this version). @Returns false is the map was already known to be quirky, true otherwise. */
static bool markPluginMapAsQuirky (const QString &map);
/** Clears the broken or quirky flags. E.g. after the map was loaded, successfully */
static void markPluginMapAsWorking (const QString &map);
enum PluginMapPriority { PriorityHidden = 0, PriorityLow, PriorityMedium, PriorityHigh };
/** Helper struct used by RKSettingsModulePlugins to keep track of plugin map files. */
struct PluginMapStoredInfo {
PluginMapStoredInfo (const QString &_filename) : filename (_filename), active (false), broken_in_this_version (false), quirky_in_this_version (false) {};
QString filename;
bool active;
bool broken_in_this_version;
bool quirky_in_this_version;
int priority;
QString id;
QDateTime last_modified;
};
typedef QList PluginMapList;
static PluginMapList knownPluginmaps () { return known_plugin_maps; };
static void parsePluginMapBasics (const QString &filename, QString *id, int *priority);
/** Registers the plugin maps that are shipped with RKWard.
* @param force_add All default maps are also activated, even if they were already known, and disabled by the user. */
static void registerDefaultPluginMaps (AddMode add_mode);
public slots:
void settingChanged ();
void configurePluginmaps ();
private:
QButtonGroup *button_group;
/** plugin maps which are not necessarily active, but have been encountered, before. @see plugin_maps */
static PluginMapList known_plugin_maps;
static PluginPrefs interface_pref;
static bool show_code;
static int code_size;
static int side_preview_width;
/* TODO: This one is currently unused (leftover of GHNS-based plugin installation), but might still be of interest */
static QStringList findPluginMapsRecursive (const QString &basedir);
static void fixPluginMapLists ();
friend class RKPluginMapSelectionWidget;
/** Sets the new list of plugins. Potentially removes unreadable ones, and returns the effective list. */
static PluginMapList setPluginMaps (const PluginMapList new_list);
};
class RKSettingsModulePluginsModel : public QAbstractTableModel {
Q_OBJECT
public:
explicit RKSettingsModulePluginsModel (QObject* parent);
virtual ~RKSettingsModulePluginsModel ();
/** (re-)initialize the model */
void init (const RKSettingsModulePlugins::PluginMapList &known_plugin_maps);
RKSettingsModulePlugins::PluginMapList pluginMaps () { return plugin_maps; };
public slots:
void swapRows (int rowa, int rowb);
void insertNewStrings (int above_row);
private:
RKSettingsModulePlugins::PluginMapList plugin_maps;
struct PluginMapMetaInfo {
RKComponentAboutData *about;
QList dependencies;
};
QHash plugin_map_dynamic_info;
const PluginMapMetaInfo &getPluginMapMetaInfo (const QString &pluginmapfile);
// reimplemented model functions
int rowCount (const QModelIndex &parent = QModelIndex()) const override;
int columnCount (const QModelIndex &parent = QModelIndex()) const override;
QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
bool setData (const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex ()) override;
Qt::ItemFlags flags (const QModelIndex &index) const override;
};
#endif
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index e002ae5d..450d3784 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -1,730 +1,730 @@
/***************************************************************************
rksettingsmoduler - description
-------------------
begin : Wed Jul 28 2004
copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "rksettingsmoduler.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "rksettingsmodulegeneral.h"
#include "../core/robject.h"
#include "../misc/multistringselector.h"
#include "../misc/rkprogresscontrol.h"
#include "../misc/rkcommonfunctions.h"
#include "../rbackend/rkrinterface.h"
#include "../rbackend/rksessionvars.h"
#include "../rkglobals.h"
#include "../debug.h"
// static members
QString RKSettingsModuleR::options_outdec;
int RKSettingsModuleR::options_width;
int RKSettingsModuleR::options_warn;
int RKSettingsModuleR::options_warningslength;
int RKSettingsModuleR::options_maxprint;
bool RKSettingsModuleR::options_keepsource;
bool RKSettingsModuleR::options_keepsourcepkgs;
int RKSettingsModuleR::options_expressions;
int RKSettingsModuleR::options_digits;
bool RKSettingsModuleR::options_checkbounds;
QString RKSettingsModuleR::options_editor;
QString RKSettingsModuleR::options_pager;
QString RKSettingsModuleR::options_further;
QStringList RKSettingsModuleR::options_addpaths;
// static constants
QString RKSettingsModuleR::builtin_editor = "";
// session constants
QString RKSettingsModuleR::help_base_url;
RKSettingsModuleR::RKSettingsModuleR (RKSettings *gui, QWidget *parent) : RKSettingsModule(gui, parent) {
RK_TRACE (SETTINGS);
QVBoxLayout *main_vbox = new QVBoxLayout (this);
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
main_vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("The following settings mostly affect R behavior in the console. It is generally safe to keep these unchanged.")));
QGridLayout *grid = new QGridLayout ();
main_vbox->addLayout (grid);
int row = -1;
// options (warn)
grid->addWidget (new QLabel (i18n ("Display warnings"), this), ++row, 0);
warn_input = new QComboBox (this);
warn_input->setEditable (false);
warn_input->insertItem (0, i18n ("Suppress warnings")); // do not change the order of options! See also: applyChanges ()
warn_input->insertItem (1, i18n ("Print warnings later (default)"));
warn_input->insertItem (2, i18n ("Print warnings immediately"));
warn_input->insertItem (3, i18n ("Convert warnings to errors"));
warn_input->setCurrentIndex (options_warn + 1);
connect (warn_input, static_cast(&QComboBox::activated), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (warn_input, row, 1);
// options (OutDec)
grid->addWidget (new QLabel (i18n ("Decimal character (only for printing)"), this), ++row, 0);
outdec_input = new QLineEdit (options_outdec, this);
outdec_input->setMaxLength (1);
connect (outdec_input, &QLineEdit::textChanged, this, &RKSettingsModuleR::settingChanged);
grid->addWidget (outdec_input, row, 1);
// options (width)
grid->addWidget (new QLabel (i18n ("Output width (characters)"), this), ++row, 0);
width_input = new QSpinBox(this);
width_input->setMaximum(10000);
width_input->setMinimum(10);
width_input->setSingleStep(1);
width_input->setValue(options_width);
connect (width_input, static_cast(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (width_input, row, 1);
// options (max.print)
grid->addWidget (new QLabel (i18n ("Maximum number of elements shown in print"), this), ++row, 0);
maxprint_input = new QSpinBox(this);
maxprint_input->setMaximum(INT_MAX);
maxprint_input->setMinimum(100);
maxprint_input->setSingleStep(1);
maxprint_input->setValue(options_maxprint);
connect (maxprint_input, static_cast(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (maxprint_input, row, 1);
// options (warnings.length)
grid->addWidget (new QLabel (i18n ("Maximum length of warnings/errors to print"), this), ++row, 0);
warningslength_input = new QSpinBox(this);
warningslength_input->setMaximum(8192);
warningslength_input->setMinimum(100);
warningslength_input->setSingleStep(1);
warningslength_input->setValue(options_warningslength);
connect (warningslength_input, static_cast(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (warningslength_input, row, 1);
// options (keep.source)
grid->addWidget (new QLabel (i18n ("Keep comments in functions"), this), ++row, 0);
keepsource_input = new QComboBox (this);
keepsource_input->setEditable (false);
keepsource_input->addItem (i18n ("TRUE (default)"), true);
keepsource_input->addItem (i18n ("FALSE"), false);
keepsource_input->setCurrentIndex (options_keepsource ? 0 : 1);
connect (keepsource_input, static_cast(&QComboBox::activated), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (keepsource_input, row, 1);
// options (keep.source.pkgs)
grid->addWidget (new QLabel (i18n ("Keep comments in packages"), this), ++row, 0);
keepsourcepkgs_input = new QComboBox (this);
keepsourcepkgs_input->setEditable (false);
keepsourcepkgs_input->addItem (i18n ("TRUE"), true);
keepsourcepkgs_input->addItem (i18n ("FALSE (default)"), false);
keepsourcepkgs_input->setCurrentIndex (options_keepsourcepkgs ? 0 : 1);
connect (keepsourcepkgs_input, static_cast(&QComboBox::activated), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (keepsourcepkgs_input, row, 1);
// options (expressions)
grid->addWidget (new QLabel (i18n ("Maximum level of nested expressions"), this), ++row, 0);
expressions_input = new QSpinBox(this);
expressions_input->setMaximum(500000);
expressions_input->setMinimum(25);
expressions_input->setSingleStep(1);
expressions_input->setValue(options_expressions);
connect (expressions_input, static_cast(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (expressions_input, row, 1);
// options (digits)
grid->addWidget (new QLabel (i18n ("Default decimal precision in print ()"), this), ++row, 0);
digits_input = new QSpinBox(this);
digits_input->setMaximum(22);
digits_input->setMinimum(1);
digits_input->setSingleStep(1);
digits_input->setValue(options_digits);
connect (digits_input, static_cast(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (digits_input, row, 1);
// options (check.bounds)
grid->addWidget (new QLabel (i18n ("Check vector bounds (warn)"), this), ++row, 0);
checkbounds_input = new QComboBox (this);
checkbounds_input->setEditable (false);
checkbounds_input->addItem (i18n ("TRUE"), true);
checkbounds_input->addItem (i18n ("FALSE (default)"), false);
checkbounds_input->setCurrentIndex (options_checkbounds ? 0 : 1);
connect (checkbounds_input, static_cast(&QComboBox::activated), this, &RKSettingsModuleR::settingChanged);
grid->addWidget (checkbounds_input, row, 1);
grid->addWidget (new QLabel (i18n ("Editor command"), this), ++row, 0);
editor_input = new QComboBox (this);
editor_input->setEditable (true);
editor_input->addItem (builtin_editor);
if (options_editor != builtin_editor) {
editor_input->addItem (options_editor);
editor_input->setCurrentIndex (1);
}
connect (editor_input, &QComboBox::editTextChanged, this, &RKSettingsModuleR::settingChanged);
grid->addWidget (editor_input, row, 1);
grid->addWidget (new QLabel (i18n ("Pager command"), this), ++row, 0);
pager_input = new QComboBox (this);
pager_input->setEditable (true);
pager_input->addItem (builtin_editor);
if (options_pager != builtin_editor) {
pager_input->addItem (options_pager);
pager_input->setCurrentIndex (1);
}
connect (pager_input, &QComboBox::editTextChanged, this, &RKSettingsModuleR::settingChanged);
grid->addWidget (pager_input, row, 1);
grid->addWidget (new QLabel (i18n ("Further (option) commands to run in each session"), this), ++row, 0, 1, 2);
further_input = new QTextEdit (this);
further_input->setWordWrapMode (QTextOption::NoWrap);
further_input->setAcceptRichText (false);
further_input->setPlainText (options_further);
connect (further_input, &QTextEdit::textChanged, this, &RKSettingsModuleR::settingChanged);
grid->addWidget (further_input, ++row, 0, 1, 2);
main_vbox->addStretch ();
addpaths_selector = new MultiStringSelector (i18n ("Addition search paths for utilities used by R"), this);
addpaths_selector->setValues (options_addpaths);
connect (addpaths_selector, &MultiStringSelector::listChanged, this, &RKSettingsModuleR::settingChanged);
connect (addpaths_selector, &MultiStringSelector::getNewStrings, this, &RKSettingsModuleR::addPaths);
main_vbox->addWidget (addpaths_selector);
}
RKSettingsModuleR::~RKSettingsModuleR() {
RK_TRACE (SETTINGS);
}
void RKSettingsModuleR::settingChanged () {
RK_TRACE (SETTINGS);
change ();
}
QString RKSettingsModuleR::caption () {
RK_TRACE (SETTINGS);
return (i18n ("R-Backend"));
}
void RKSettingsModuleR::applyChanges () {
RK_TRACE (SETTINGS);
options_outdec = outdec_input->text ();
options_width = width_input->value ();
options_warn = warn_input->currentIndex () - 1;
options_warningslength = warningslength_input->value ();
options_maxprint = maxprint_input->value ();
options_keepsource = keepsource_input->itemData (keepsource_input->currentIndex ()).toBool ();
options_keepsourcepkgs = keepsourcepkgs_input->itemData (keepsourcepkgs_input->currentIndex ()).toBool ();
options_expressions = expressions_input->value ();
options_digits = digits_input->value ();
options_checkbounds = checkbounds_input->itemData (checkbounds_input->currentIndex ()).toBool ();
options_editor = editor_input->currentText ();
options_pager = pager_input->currentText ();
options_further = further_input->toPlainText ();
// normalize system paths before adding
QStringList paths = addpaths_selector->getValues ();
options_addpaths.clear ();
for (int i = 0; i < paths.count (); ++i) {
QString path = QDir::cleanPath (paths[i]);
if (!options_addpaths.contains (path)) options_addpaths.append (path);
}
// apply run time options in R
QStringList commands = makeRRunTimeOptionCommands ();
for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
RKGlobals::rInterface ()->issueCommand (*it, RCommand::App, QString (), 0, 0, commandChain ());
}
}
void RKSettingsModuleR::addPaths(QStringList* string_list) {
RK_TRACE (SETTINGS);
QDialog dialog (this);
dialog.setWindowTitle (i18n ("Add System Path Directory"));
QVBoxLayout *layout = new QVBoxLayout (&dialog);
layout->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Specify or select directory to add to the system file path of the running R session")));
KUrlRequester *req = new KUrlRequester ();
req->setMode (KFile::Directory);
layout->addWidget (req);
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
buttons->button(QDialogButtonBox::Ok)->setText (i18nc ("Add directory to list", "Add"));
connect (buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
connect (buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
layout->addWidget (buttons);
if (dialog.exec () == QDialog::Accepted) {
if (!req->text ().isEmpty ()) (*string_list).append (req->text ());
}
}
//static
QStringList RKSettingsModuleR::makeRRunTimeOptionCommands () {
RK_TRACE (SETTINGS);
QStringList list;
QString tf;
list.append ("options (OutDec=\"" + options_outdec.left (1) + "\")\n");
list.append ("options (width=" + QString::number (options_width) + ")\n");
list.append ("options (warn=" + QString::number (options_warn) + ")\n");
list.append ("options (max.print=" + QString::number (options_maxprint) + ")\n");
list.append ("options (warnings.length=" + QString::number (options_warningslength) + ")\n");
if (options_keepsource) tf = "TRUE"; else tf = "FALSE";
list.append ("options (keep.source=" + tf + ")\n");
if (options_keepsourcepkgs) tf = "TRUE"; else tf = "FALSE";
list.append ("options (keep.source.pkgs=" + tf + ")\n");
list.append ("options (expressions=" + QString::number (options_expressions) + ")\n");
list.append ("options (digits=" + QString::number (options_digits) + ")\n");
if (options_checkbounds) tf = "TRUE"; else tf = "FALSE";
list.append ("options (checkbounds=" + tf + ")\n");
if (options_editor == builtin_editor) list.append ("options (editor=rk.edit.files)\n");
else list.append ("options (editor=\"" + options_editor + "\")\n");
if (options_pager == builtin_editor) list.append ("options (pager=rk.show.files)\n");
else list.append ("options (pager=\"" + options_pager + "\")\n");
if (!options_further.isEmpty ()) list.append (options_further + '\n');
if (!options_addpaths.isEmpty ()) {
QString command = "rk.adjust.system.path (add=c(";
foreach (const QString &p, options_addpaths) {
command.append (RObject::rQuote (p));
}
list.append (command + "))\n");
}
#ifdef __GNUC__
# warning TODO make the following options configurable
#endif
list.append ("options (help_type=\"html\")\n"); // for R 2.10.0 and above
list.append ("try ({options (htmlhelp=TRUE); options (chmhelp=FALSE)})\n"); // COMPAT: for R 2.9.x and below
list.append ("options (browser=rk.show.html)\n");
list.append ("options (askYesNo=rk.askYesNo)\n"); // for R 3.5.0 and above
return list;
}
void RKSettingsModuleR::save (KConfig *config) {
RK_TRACE (SETTINGS);
saveSettings (config);
}
void RKSettingsModuleR::saveSettings (KConfig *config) {
RK_TRACE (SETTINGS);
KConfigGroup cg = config->group ("R Settings");
cg.writeEntry ("OutDec", options_outdec);
cg.writeEntry ("width", options_width);
cg.writeEntry ("warn", options_warn);
cg.writeEntry ("max.print", options_maxprint);
cg.writeEntry ("warnings.length", options_warningslength);
cg.writeEntry ("keep.source", options_keepsource);
cg.writeEntry ("keep.source.pkgs", options_keepsourcepkgs);
cg.writeEntry ("expressions", options_expressions);
cg.writeEntry ("digits", options_digits);
cg.writeEntry ("check.bounds", options_checkbounds);
cg.writeEntry ("editor", options_editor);
cg.writeEntry ("pager", options_pager);
cg.writeEntry ("further init commands", options_further);
cg.writeEntry ("addsyspaths", options_addpaths);
}
void RKSettingsModuleR::loadSettings (KConfig *config) {
RK_TRACE (SETTINGS);
KConfigGroup cg = config->group ("R Settings");
options_outdec = cg.readEntry ("OutDec", ".");
options_width = cg.readEntry ("width", 80);
options_warn = cg.readEntry ("warn", 0);
options_maxprint = cg.readEntry ("max.print", 99999);
options_warningslength = cg.readEntry ("warnings.length", 1000);
options_keepsource = cg.readEntry ("keep.source", true);
options_keepsourcepkgs = cg.readEntry ("keep.source.pkgs", false);
options_expressions = cg.readEntry ("expressions", 5000);
options_digits = cg.readEntry ("digits", 7);
options_checkbounds = cg.readEntry ("check.bounds", false);
options_editor = cg.readEntry ("editor", builtin_editor);
options_pager = cg.readEntry ("pager", builtin_editor);
options_further = cg.readEntry ("further init commands", QString ());
options_addpaths = cg.readEntry ("addsyspaths", QStringList ());
}
//#################################################
//############### RKSettingsModuleRPackages ################
//#################################################
// static members
QStringList RKSettingsModuleRPackages::liblocs;
QStringList RKSettingsModuleRPackages::defaultliblocs;
QString RKSettingsModuleRPackages::r_libs_user;
bool RKSettingsModuleRPackages::archive_packages;
bool RKSettingsModuleRPackages::source_packages;
QStringList RKSettingsModuleRPackages::package_repositories;
QString RKSettingsModuleRPackages::essential_packages = QString ("base\nmethods\nutils\ngrDevices\ngraphics\nrkward");
QString RKSettingsModuleRPackages::cran_mirror_url;
RKSettingsModuleRPackages::RKSettingsModuleRPackages (RKSettings *gui, QWidget *parent) : RKSettingsModule(gui, parent), RCommandReceiver () {
RK_TRACE (SETTINGS);
QVBoxLayout *main_vbox = new QVBoxLayout (this);
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
main_vbox->addWidget (new QLabel (i18n ("CRAN download mirror (leave empty to be prompted once each session):"), this));
QHBoxLayout* hbox = new QHBoxLayout ();
main_vbox->addLayout (hbox);
cran_mirror_input = new QLineEdit (cran_mirror_url, this);
if (cran_mirror_url == "@CRAN@") cran_mirror_input->clear ();
connect (cran_mirror_input, &QLineEdit::textChanged, this, &RKSettingsModuleRPackages::settingChanged);
hbox->addWidget (cran_mirror_input);
QPushButton* cran_mirror_button = new QPushButton (i18n ("Select mirror"), this);
connect (cran_mirror_button, &QPushButton::clicked, this, &RKSettingsModuleRPackages::selectCRANMirror);
hbox->addWidget (cran_mirror_button);
repository_selector = new MultiStringSelector (i18n ("Additional package repositories (where libraries are downloaded from)"), this);
repository_selector->setValues (package_repositories);
connect (repository_selector, &MultiStringSelector::listChanged, this, &RKSettingsModuleRPackages::settingChanged);
connect (repository_selector, &MultiStringSelector::getNewStrings, this, &RKSettingsModuleRPackages::addRepository);
main_vbox->addWidget (repository_selector);
archive_packages_box = new QCheckBox (i18n ("Archive downloaded packages"), this);
archive_packages_box->setChecked (archive_packages);
connect (archive_packages_box, &QCheckBox::stateChanged, this, &RKSettingsModuleRPackages::settingChanged);
main_vbox->addWidget (archive_packages_box);
#if defined Q_OS_WIN || defined Q_OS_MACOS
source_packages_box = new QCheckBox (i18n ("Build packages from source"), this);
source_packages_box->setChecked (source_packages);
#else
source_packages_box = new QCheckBox (i18n ("Build packages from source (not configurable on this platform)"), this);
source_packages_box->setChecked (true);
source_packages_box->setEnabled (false);
#endif
RKCommonFunctions::setTips (QString ("%1
").arg (i18n ("Installing packages from pre-compiled binaries (if available) is generally faster, and does not require an installation of development tools and libraries. On the other hand, building packages from source provides best compatibility. On Mac OS X and Linux, building packages from source is currently recommended.")), source_packages_box);
connect (source_packages_box, &QCheckBox::stateChanged, this, &RKSettingsModuleRPackages::settingChanged);
main_vbox->addWidget (source_packages_box);
main_vbox->addStretch ();
libloc_selector = new MultiStringSelector (i18n ("R Library locations (where libraries get installed to, locally)"), this);
libloc_selector->setValues (liblocs);
connect (libloc_selector, &MultiStringSelector::listChanged, this, &RKSettingsModuleRPackages::settingChanged);
connect (libloc_selector, &MultiStringSelector::getNewStrings, this, &RKSettingsModuleRPackages::addLibLoc);
main_vbox->addWidget (libloc_selector);
QLabel *label = new QLabel (i18n ("Note: The startup defaults will always be used in addition to the locations you specify in this list"), this);
main_vbox->addWidget (label);
main_vbox->addStretch ();
}
RKSettingsModuleRPackages::~RKSettingsModuleRPackages () {
RK_TRACE (SETTINGS);
}
void RKSettingsModuleRPackages::addLibraryLocation (const QString& new_loc, RCommandChain *chain) {
RK_TRACE (SETTINGS);
if (!libraryLocations ().contains (new_loc)) liblocs.prepend (new_loc);
// update the backend in any case. User might have changed liblocs, there.
RKGlobals::rInterface ()->issueCommand (".libPaths (unique (c (" + RObject::rQuote (new_loc) + ", .libPaths ())))", RCommand::App | RCommand::Sync, QString (), 0, 0, chain);
}
QStringList expandLibLocs (const QStringList &in) {
QStringList ret;
for (int i = 0; i < in.size (); ++i) {
QString dummy = in[i];
ret.append (dummy.replace (QLatin1String ("%v"), RKSessionVars::RVersion (true)));
}
return ret;
}
QString RKSettingsModuleRPackages::userLibraryLocation () {
if (!r_libs_user.isEmpty()) return r_libs_user;
return QDir (RKSettingsModuleGeneral::filesPath ()).absoluteFilePath ("library/" + RKSessionVars::RVersion (true));
}
QStringList RKSettingsModuleRPackages::libraryLocations () {
return (QStringList (userLibraryLocation ()) + expandLibLocs (liblocs + defaultliblocs));
}
QStringList RKSettingsModuleRPackages::addUserLibLocTo (const QStringList& liblocs) {
if (!liblocs.contains(userLibraryLocation ())) return (QStringList (userLibraryLocation ()) + liblocs);
return liblocs;
}
void RKSettingsModuleRPackages::settingChanged () {
RK_TRACE (SETTINGS);
change ();
}
void RKSettingsModuleRPackages::addLibLoc (QStringList *string_list) {
RK_TRACE (SETTINGS);
QDialog dialog (this);
dialog.setWindowTitle (i18n ("Add R Library Directory"));
QVBoxLayout *layout = new QVBoxLayout (&dialog);
layout->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Specify or select library location to add.\nNote that locations may contain a '%v', which will expand to the first "
"two components of the R version number (e.g. to 3.5), automatically. Including this is recommended, because R packages "
"compiled for one version of R will often fail to work correctly in a different version of R.")));
KUrlRequester *req = new KUrlRequester ();
req->setText (QDir (RKSettingsModuleGeneral::filesPath ()).absoluteFilePath ("library/%v"));
req->setMode (KFile::Directory);
layout->addWidget (req);
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
buttons->button(QDialogButtonBox::Ok)->setText (i18nc ("Add file to list", "Add"));
connect (buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
connect (buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
layout->addWidget (buttons);
if (dialog.exec () == QDialog::Accepted) {
if (!req->text ().isEmpty ()) (*string_list).append (req->text ());
}
}
void RKSettingsModuleRPackages::addRepository (QStringList *string_list) {
RK_TRACE (SETTINGS);
bool ok;
QString new_string = QInputDialog::getText (this, i18n ("Add repository"), i18n ("Add URL of new repository"), QLineEdit::Normal, QString (), &ok);
if (ok) (*string_list).append (new_string);
}
QString RKSettingsModuleRPackages::caption () {
RK_TRACE (SETTINGS);
return (i18n ("R-Packages"));
}
#define SELECT_CRAN_MIRROR_COMMAND 123
void RKSettingsModuleRPackages::selectCRANMirror () {
RK_TRACE (SETTINGS);
QString title = i18n ("Select CRAN mirror");
RCommand* command = new RCommand ("rk.select.CRAN.mirror()\n", RCommand::App | RCommand::GetStringVector, title, this, SELECT_CRAN_MIRROR_COMMAND);
RKProgressControl* control = new RKProgressControl (this, title, title, RKProgressControl::CancellableProgress);
control->addRCommand (command, true);
RKGlobals::rInterface ()->issueCommand (command, commandChain ());
control->doModal (true);
}
void RKSettingsModuleRPackages::rCommandDone (RCommand *command) {
RK_TRACE (SETTINGS);
if (command->getFlags () == SELECT_CRAN_MIRROR_COMMAND) {
if (command->succeeded ()) {
RK_ASSERT (command->getDataLength () >= 1);
cran_mirror_input->setText (command->stringVector ().value (0));
}
} else {
RK_ASSERT (false);
}
}
QString RKSettingsModuleRPackages::libLocsCommand () {
RK_TRACE (SETTINGS);
QString command = ".libPaths (unique (c (";
bool first = true;
QStringList ll = libraryLocations ();
foreach (const QString& libloc, ll) {
if (first) first = false;
else command.append (", ");
command.append (RObject::rQuote (libloc));
}
command.append (")))");
return command;
}
//static
QString RKSettingsModuleRPackages::pkgTypeOption () {
QString ret;
#if defined Q_OS_WIN || defined Q_OS_MACOS
ret.append ("options (pkgType=\"");
if (source_packages) ret.append ("source");
else if (RKSessionVars::compareRVersion ("3.1.3") <= 0) ret.append ("binary"); // "automatically select appropriate binary", unfortunately it's only available from R 3.1.3. onwards.
# if defined Q_OS_WIN
else ret.append ("win.binary");
# else
else if (RKSessionVars::compareRVersion ("3.0.0") > 0) {
ret.append ("mac.binary.leopard");
} else {
// OS X binary packages have switched repo locations and package type in R >= 3.0.0
ret.append ("mac.binary");
}
# endif
ret.append ("\")\n");
#endif
return ret;
}
//static
QStringList RKSettingsModuleRPackages::makeRRunTimeOptionCommands () {
RK_TRACE (SETTINGS);
QStringList list;
// package repositories
QString command = "options (repos=c (CRAN=" + RObject::rQuote (cran_mirror_url);
for (QStringList::const_iterator it = package_repositories.begin (); it != package_repositories.end (); ++it) {
command.append (", " + RObject::rQuote (*it));
}
list.append (command + "))\n");
#if defined Q_OS_WIN || defined Q_OS_MACOS
list.append (pkgTypeOption ());
#endif
// library locations
list.append (libLocsCommand ());
return list;
}
void RKSettingsModuleRPackages::applyChanges () {
RK_TRACE (SETTINGS);
cran_mirror_url = cran_mirror_input->text ();
if (cran_mirror_url.isEmpty ()) cran_mirror_url = "@CRAN@";
archive_packages = archive_packages_box->isChecked ();
source_packages = source_packages_box->isChecked ();
package_repositories = repository_selector->getValues ();
liblocs = libloc_selector->getValues ();
// apply options in R
QStringList commands = makeRRunTimeOptionCommands ();
for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
RKGlobals::rInterface ()->issueCommand (*it, RCommand::App, QString (), 0, 0, commandChain ());
}
}
void RKSettingsModuleRPackages::save (KConfig *config) {
RK_TRACE (SETTINGS);
saveSettings (config);
}
void RKSettingsModuleRPackages::saveSettings (KConfig *config) {
RK_TRACE (SETTINGS);
KConfigGroup cg = config->group ("R Settings");
cg.writeEntry ("CRAN mirror url", cran_mirror_url);
cg.writeEntry ("archive packages", archive_packages);
cg.writeEntry ("source_packages", source_packages);
cg.writeEntry ("Repositories", package_repositories);
cg.writeEntry ("LibraryLocations", liblocs);
}
void RKSettingsModuleRPackages::loadSettings (KConfig *config) {
RK_TRACE (SETTINGS);
KConfigGroup cg = config->group ("R Settings");
cran_mirror_url = cg.readEntry ("CRAN mirror url", "@CRAN@");
const QString rkward_repo ("http://files.kde.org/rkward/R/");
package_repositories = cg.readEntry ("Repositories", QStringList (rkward_repo));
if (RKSettingsModuleGeneral::storedConfigVersion () <= RKSettingsModuleGeneral::RKWardConfig_Pre0_5_7) {
package_repositories.removeAll ("@CRAN@"); // COMPAT: Cran mirror was part of this list before 0.5.3
if (package_repositories.isEmpty ()) package_repositories.append (rkward_repo);
} else if (RKSettingsModuleGeneral::storedConfigVersion () < RKSettingsModuleGeneral::RKWardConfig_0_6_3) {
package_repositories.removeAll ("http://rkward.sf.net/R");
package_repositories.append (rkward_repo);
}
liblocs = cg.readEntry ("LibraryLocations", QStringList ());
archive_packages = cg.readEntry ("archive packages", false);
#if defined Q_OS_WIN || defined Q_OS_MACOS
# if defined USE_BINARY_PACKAGES
# define USE_SOURCE_PACKAGES false
# else
# define USE_SOURCE_PACKAGES true
#endif
source_packages = cg.readEntry ("source packages", USE_SOURCE_PACKAGES);
if (USE_SOURCE_PACKAGES && (RKSettingsModuleGeneral::storedConfigVersion () < RKSettingsModuleGeneral::RKWardConfig_0_6_1)) {
// revert default on MacOSX, even if a previous stored setting exists
source_packages = true;
}
#else
source_packages = true;
#endif
}
#include
#include
-void RKSettingsModuleRPackages::validateSettingsInteractive (QList* pages) {
+void RKSettingsModuleRPackages::validateSettingsInteractive (QList* items) {
RK_TRACE (SETTINGS);
if (RKSettingsModuleGeneral::storedConfigVersion () < RKSettingsModuleGeneral::RKWardConfig_0_7_1) {
QString legacy_libloc = QDir (RKSettingsModuleGeneral::filesPath ()).absoluteFilePath ("library");
if (liblocs.contains (legacy_libloc)) {
RKSettingsWizardPage *page = new RKSettingsWizardPage ();
page->setWindowTitle (i18n ("Unversioned library location"));
QVBoxLayout *layout = new QVBoxLayout (page);
layout->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("The configured library locations (where R packages will be installed on this system) contains the directory '%1', "
"which was suggested as a default library location in earlier versions of RKWard. Use of this directory is no longer "
"recommended, as it is not accessible to R sessions outside of RKWard (unless configured, explicitly). Also due to the lack "
"of an R version number in the directory name, it offers no protection against using packages built for an incompatible "
"version of R.")));
// D'uh. QRadioButton supports neither wordwrap nor formatting. Why?
QGroupBox *group = new QGroupBox (i18n ("What do you want to do?"));
QRadioButton *removebutton = new QRadioButton ();
QLabel *removelabel = RKCommonFunctions::wordWrappedLabel (i18n ("Remove this location from the configuration (it will not be deleted on disk). You will have to "
"re-install any packages that you want to keep."));
QRadioButton *renamebutton = new QRadioButton ();
QLabel *renamelabel = RKCommonFunctions::wordWrappedLabel (i18n ("Rename this location to include the version number of the currently running R. Packages will continue "
"to work (if they are compatible with this version of R)."));
QRadioButton *keepbutton = new QRadioButton ();
QLabel *keeplabel = RKCommonFunctions::wordWrappedLabel (i18n ("Keep this location (do not change anything)."));
QGridLayout *group_layout = new QGridLayout (group);
group_layout->addWidget (removebutton, 0, 0);
group_layout->addWidget (removelabel, 0, 1);
group_layout->addWidget (renamebutton, 1, 0);
group_layout->addWidget (renamelabel, 1, 1);
group_layout->addWidget (keepbutton, 2, 0);
group_layout->addWidget (keeplabel, 2, 1);
group_layout->setColumnStretch (1, 1);
renamebutton->setChecked (true);
layout->addWidget (group);
page->setApplyCallback([keepbutton, renamebutton, legacy_libloc]() {
if (keepbutton->isChecked ()) return;
liblocs.removeAll (legacy_libloc);
if (renamebutton->isChecked ()) {
QString new_loc = legacy_libloc + '-' + RKSessionVars::RVersion (true);
RKGlobals::rInterface ()->issueCommand (QString ("file.rename(%1, %2)\n").arg (RObject::rQuote (legacy_libloc)).arg (RObject::rQuote (new_loc)), RCommand::App);
liblocs.prepend (legacy_libloc + QStringLiteral ("-%v"));
}
RKGlobals::rInterface ()->issueCommand (libLocsCommand(), RCommand::App);
});
pages->append (page);
}
}
}
diff --git a/rkward/settings/rksettingsmoduler.h b/rkward/settings/rksettingsmoduler.h
index e3f6f367..5d3aa20d 100644
--- a/rkward/settings/rksettingsmoduler.h
+++ b/rkward/settings/rksettingsmoduler.h
@@ -1,165 +1,165 @@
/***************************************************************************
rksettingsmoduler - description
-------------------
begin : Wed Jul 28 2004
copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULER_H
#define RKSETTINGSMODULER_H
#include "rksettingsmodule.h"
#include
#include
class QCheckBox;
class QComboBox;
class QLineEdit;
class MultiStringSelector;
class QSpinBox;
class QTextEdit;
/**
Configure the R-backend
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleR : public RKSettingsModule {
Q_OBJECT
public:
RKSettingsModuleR (RKSettings *gui, QWidget *parent);
~RKSettingsModuleR ();
void applyChanges () override;
void save (KConfig *config) override;
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
QString caption () override;
/** generate the commands needed to set the R run time options */
static QStringList makeRRunTimeOptionCommands ();
/** retrieve the (probable) base url of help pages. May change across R sessions */
static QString helpBaseUrl () { return help_base_url; };
static int getDefaultWidth () { return options_width; };
public slots:
void settingChanged ();
private slots:
void addPaths (QStringList *string_list);
private:
QLineEdit *outdec_input;
QSpinBox *width_input;
QComboBox *warn_input;
QSpinBox *warningslength_input;
QSpinBox *maxprint_input;
QComboBox *keepsource_input;
QComboBox *keepsourcepkgs_input;
QSpinBox *expressions_input;
QSpinBox *digits_input;
QComboBox *checkbounds_input;
QComboBox *editor_input;
QComboBox *pager_input;
QTextEdit *further_input;
MultiStringSelector *addpaths_selector;
static QString options_outdec;
static int options_width;
static int options_warn;
static int options_warningslength;
static int options_maxprint;
static bool options_keepsource;
static bool options_keepsourcepkgs;
static int options_expressions;
static int options_digits;
static bool options_checkbounds;
static QString options_editor;
static QString options_pager;
static QString options_further;
static QStringList options_addpaths;
// constants
static QString builtin_editor;
// session constants
friend class RInterface;
static QString help_base_url;
};
#include "../rbackend/rcommandreceiver.h"
/**
Configure packages and library paths
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleRPackages : public RKSettingsModule, public RCommandReceiver {
Q_OBJECT
public:
RKSettingsModuleRPackages (RKSettings *gui, QWidget *parent);
~RKSettingsModuleRPackages ();
void applyChanges () override;
void save (KConfig *config) override;
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*);
+ static void validateSettingsInteractive (QList*);
/** generate the commands needed to set the R run time options */
static QStringList makeRRunTimeOptionCommands ();
static bool archivePackages () { return archive_packages; }
static QString pkgTypeOption ();
static void addLibraryLocation (const QString& new_loc, RCommandChain *chain);
static QStringList libraryLocations ();
/** Add a reasonable user writable path to the given library locations. */
static QStringList addUserLibLocTo (const QStringList &liblocs);
static QString userLibraryLocation ();
/** returns the list of packages which are essential to rkward. This is hard-coded. */
static QStringList essentialPackages () { return essential_packages.split ("\n"); };
QString caption () override;
public slots:
void settingChanged ();
void addLibLoc (QStringList *string_list);
void addRepository (QStringList *string_list);
void selectCRANMirror ();
protected:
void rCommandDone (RCommand *command) override;
private:
static QString libLocsCommand ();
MultiStringSelector *libloc_selector;
QCheckBox *archive_packages_box;
QCheckBox *source_packages_box;
MultiStringSelector *repository_selector;
QLineEdit* cran_mirror_input;
static QString cran_mirror_url;
static QStringList liblocs;
static bool archive_packages;
static bool source_packages;
static QStringList package_repositories;
friend class RInterface;
static QString r_libs_user;
static QStringList defaultliblocs;
static QString essential_packages;
};
#endif
diff --git a/rkward/settings/rksettingsmodulewatch.h b/rkward/settings/rksettingsmodulewatch.h
index 33603000..f0a28d43 100644
--- a/rkward/settings/rksettingsmodulewatch.h
+++ b/rkward/settings/rksettingsmodulewatch.h
@@ -1,85 +1,85 @@
/***************************************************************************
rksettingsmodulewatch - description
-------------------
begin : Thu Aug 26 2004
copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSETTINGSMODULEWATCH_H
#define RKSETTINGSMODULEWATCH_H
#include "rksettingsmodule.h"
class RCommand;
class QCheckBox;
class QGridLayout;
class QSpinBox;
/**
Settings module for the RInterface-watch. Allows you to configure what kind of commands you would like to see/hide.
@author Thomas Friedrichsmeier
*/
class RKSettingsModuleWatch : public RKSettingsModule
{
Q_OBJECT
public:
RKSettingsModuleWatch (RKSettings *gui, QWidget *parent);
~RKSettingsModuleWatch ();
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
- static void validateSettingsInteractive (QList*) {};
+ static void validateSettingsInteractive (QList*) {};
void applyChanges () override;
void save (KConfig *config) override;
void validateGUI ();
static bool shouldShowInput (RCommand *command);
static bool shouldShowOutput (RCommand *command);
static bool shouldShowError (RCommand *command);
static bool shouldRaiseWindow (RCommand *command);
static uint maxLogLines () { return max_log_lines; };
QString caption () override;
public slots:
void changedSetting (int);
private:
enum FilterType { ShowInput=1, ShowOutput=2, ShowError=4, RaiseWindow=8 };
static int plugin_filter;
static int app_filter;
static int sync_filter;
static int user_filter;
struct FilterBoxes {
QCheckBox *input;
QCheckBox *output;
QCheckBox *error;
QCheckBox *raise;
};
FilterBoxes *plugin_filter_boxes;
FilterBoxes *app_filter_boxes;
FilterBoxes *sync_filter_boxes;
FilterBoxes *user_filter_boxes;
int getFilterSettings (FilterBoxes *boxes);
FilterBoxes *addFilterSettings (QWidget *parent, QGridLayout *layout, int row, const QString &label, int state);
static uint max_log_lines;
QSpinBox *max_log_lines_spinner;
};
#endif