diff --git a/rkward/dialogs/rksetupwizard.cpp b/rkward/dialogs/rksetupwizard.cpp
index 123ec3ec..541db93e 100644
--- a/rkward/dialogs/rksetupwizard.cpp
+++ b/rkward/dialogs/rksetupwizard.cpp
@@ -1,242 +1,288 @@
/***************************************************************************
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 %1: %2
"); l->addWidget(waiting_to_start_label); auto firstpageref = wizard->addPage (firstpage, i18n("RKWard Setup Assistant")); wizard->setValid(firstpageref, false); - auto page = new QWidget(); - auto layout = new QGridLayout(page); - int row = -1; - layout->setColumnStretch(1, 2); - layout->setColumnStretch(2, 1); - + // Basic installation page + wizard->createStandardPage(); bool reinstallation_required = false; RKSetupWizardItem idir(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."), []() {}); + 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.")); } - idir.createWidget(layout, ++row); + wizard->appendItem(idir); RKSetupWizardItem pluginmaps(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"), []() { RKSettingsModulePlugins::registerDefaultPluginMaps(RKSettingsModulePlugins::AddIfDefault); }); - pluginmaps.addOption(i18n("No change"), i18n("Proceed without plugins"), []() {}); + 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.")); } - pluginmaps.createWidget(layout, ++row); + wizard->appendItem(pluginmaps); RKSetupWizardItem kateplugins(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"), []() {}); // TODO - kateplugins.addOption(i18n("No change"), i18n("Proceed without plugins"), []() {}); + 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)); } - kateplugins.createWidget(layout, ++row); + wizard->appendItem(kateplugins); - layout->setRowStretch(++row, 1); - wizard->addPage(page, i18n("Basic installation")); + 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(); + + RKSetupWizardItem r2htmlpackage = makeRPackageCheck("R2HTML", i18n("The R2HTML package is used by nearly all RKWard output functions, and thus required."), RKSetupWizardItem::Error, wizard); + wizard->appendItem(r2htmlpackage); + RKSetupWizardItem 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); + wizard->appendItem(rmarkdownpackage); + + wizard->current_layout->setRowStretch(++wizard->current_row, 1); + wizard->addPage(wizard->current_layout->parentWidget(), i18n("R Packages")); + wizard->exec(); - // TODO: apply all - pluginmaps.apply(); + // TODO: apply all, not just this + pluginmaps.apply(wizard); 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); +} + +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 7e063ac1..f96646e9 100644 --- a/rkward/dialogs/rksetupwizard.h +++ b/rkward/dialogs/rksetupwizard.h @@ -1,40 +1,53 @@ /*************************************************************************** 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