[education/rkward] rkward: Move number of recent files settings option to general settings
Thomas Friedrichsmeier
null at kde.org
Wed Apr 20 14:02:40 BST 2022
Git commit 1213cf18ec73c506026fd04bacc5ba2070ef7e7b by Thomas Friedrichsmeier.
Committed on 20/04/2022 at 12:52.
Pushed by tfry into branch 'master'.
Move number of recent files settings option to general settings
M +4 -3 rkward/pages/rkward_help.css
M +2 -2 rkward/settings/rkrecenturls.cpp
M +6 -16 rkward/settings/rksettingsmodulecommandeditor.cpp
M +0 -2 rkward/settings/rksettingsmodulecommandeditor.h
M +10 -1 rkward/settings/rksettingsmodulegeneral.cpp
M +3 -1 rkward/settings/rksettingsmodulegeneral.h
https://invent.kde.org/education/rkward/commit/1213cf18ec73c506026fd04bacc5ba2070ef7e7b
diff --git a/rkward/pages/rkward_help.css b/rkward/pages/rkward_help.css
index 7c3db260..315bf281 100644
--- a/rkward/pages/rkward_help.css
+++ b/rkward/pages/rkward_help.css
@@ -30,6 +30,7 @@ a:link {
margin: auto;
display: flex;
flex-flow: row wrap;
+ justify-content: center;
}
#rkward_welcome #main h1 {
@@ -41,9 +42,9 @@ a:link {
}
#rkward_welcome div {
- width: 40%;
- margin: 0% 2.5%;
- padding: 1em;
+ width: 45%;
+ margin: 1em;
+ padding: 0em 1em;
}
#rkward_welcome div div {
diff --git a/rkward/settings/rkrecenturls.cpp b/rkward/settings/rkrecenturls.cpp
index cf054597..b1e3a93d 100644
--- a/rkward/settings/rkrecenturls.cpp
+++ b/rkward/settings/rkrecenturls.cpp
@@ -14,7 +14,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <KRecentFilesAction>
#include <kconfigwidgets_version.h>
-#include "rksettingsmodulecommandeditor.h"
+#include "rksettingsmodulegeneral.h"
#include "../rkward.h"
#include "../debug.h"
@@ -117,7 +117,7 @@ KRecentFilesAction * RKRecentUrls::action(const QString& id) {
auto cg = config();
auto act = new KRecentFilesAction(nullptr);
if (!id.isEmpty()) act->loadEntries(cg.group(id));
- act->setMaxItems(RKSettingsModuleCommandEditor::maxNumRecentFiles()); // TODO: Move setting somewhere else
+ act->setMaxItems(RKSettingsModuleGeneral::maxNumRecentFiles()); // TODO: Move setting somewhere else
QObject::connect(act, &QObject::destroyed, [id]() { RKRecentUrls::actions.remove(id); });
QObject::connect(act, &KRecentFilesAction::recentListCleared, &RKRecentUrls::notifyChangeProxy);
actions.insert(id, act);
diff --git a/rkward/settings/rksettingsmodulecommandeditor.cpp b/rkward/settings/rksettingsmodulecommandeditor.cpp
index 6597071e..bc065ba5 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.cpp
+++ b/rkward/settings/rksettingsmodulecommandeditor.cpp
@@ -34,7 +34,6 @@ RKCodeCompletionSettings RKSettingsModuleCommandEditor::completion_settings;
RKConfigValue<bool> RKSettingsModuleCommandEditor::autosave_enabled { "Autosave enabled", true };
RKConfigValue<bool> RKSettingsModuleCommandEditor::autosave_keep { "Autosave keep saves", false };
RKConfigValue<int> RKSettingsModuleCommandEditor::autosave_interval {"Autosave interval", 5 };
-RKConfigValue<int> RKSettingsModuleCommandEditor::num_recent_files { "Max number of recent files", 10 };
RKConfigValue<QString> RKSettingsModuleCommandEditor::script_file_filter { "Script file filter", "*.R *.S *.q *.Rhistory" };
RKCodeCompletionSettingsWidget::RKCodeCompletionSettingsWidget(QWidget *parent, RKSettingsModule *module, RKCodeCompletionSettings *settings, bool show_common) : RKSettingsModuleWidget(parent, module), settings(settings) {
@@ -136,20 +135,12 @@ RKSettingsModuleCommandEditor::RKSettingsModuleCommandEditor (RKSettings *gui, Q
main_vbox->addSpacing (2 * RKStyle::spacingHint ());
- group = new QGroupBox (i18n ("Opening script files"), this);
- form_layout = new QFormLayout (group);
-
- auto num_recent_files_box = num_recent_files.makeSpinBox(1, INT_MAX, this);
- RKCommonFunctions::setTips (i18n ("<p>The number of recent files to remember (in the Open Recent R Script File menu).</p>") + RKCommonFunctions::noteSettingsTakesEffectAfterRestart (), num_recent_files_box, group);
- form_layout->addRow (i18n ("Number of scripts in recent file lists (*)"), num_recent_files_box);
-
- script_file_filter_box = new QLineEdit (group);
- script_file_filter_box->setText (script_file_filter);
- RKCommonFunctions::setTips (i18n ("<p>A list of filters (file name extensions) that should be treated as R script files. Most importantly, files matching one of these filters will always be opened with R syntax highlighting.</p><p>Filters are case insensitive.</p>"), script_file_filter_box);
- connect (script_file_filter_box, &QLineEdit::textChanged, this, &RKSettingsModule::change);
- form_layout->addRow (i18n ("R script file filters (separated by spaces)"), script_file_filter_box);
-
- main_vbox->addWidget (group);
+ script_file_filter_box = new QLineEdit();
+ script_file_filter_box->setText(script_file_filter);
+ RKCommonFunctions::setTips(i18n("<p>A list of filters (file name extensions) that should be treated as R script files. Most importantly, files matching one of these filters will always be opened with R syntax highlighting.</p><p>Filters are case insensitive.</p>"), script_file_filter_box);
+ connect(script_file_filter_box, &QLineEdit::textChanged, this, &RKSettingsModule::change);
+ main_vbox->addWidget(new QLabel(i18n("R script file filters (separated by spaces)")));
+ main_vbox->addWidget(script_file_filter_box);
main_vbox->addStretch ();
}
@@ -196,7 +187,6 @@ void RKSettingsModuleCommandEditor::syncConfig(KConfig* config, RKConfigBase::Co
autosave_keep.syncConfig(cg, a);
autosave_interval.syncConfig(cg, a);
- num_recent_files.syncConfig(cg, a);
script_file_filter.syncConfig(cg, a);
}
diff --git a/rkward/settings/rksettingsmodulecommandeditor.h b/rkward/settings/rksettingsmodulecommandeditor.h
index 7fe3f213..12c862c2 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.h
+++ b/rkward/settings/rksettingsmodulecommandeditor.h
@@ -113,7 +113,6 @@ public:
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);
@@ -128,7 +127,6 @@ private:
QGroupBox* autosave_enabled_box;
QLineEdit* script_file_filter_box;
- static RKConfigValue<int> num_recent_files;
static RKConfigValue<QString> script_file_filter;
};
diff --git a/rkward/settings/rksettingsmodulegeneral.cpp b/rkward/settings/rksettingsmodulegeneral.cpp
index 98a266db..8d647b10 100644
--- a/rkward/settings/rksettingsmodulegeneral.cpp
+++ b/rkward/settings/rksettingsmodulegeneral.cpp
@@ -50,7 +50,7 @@ RKConfigValue<QString> RKSettingsModuleGeneral::initial_dir_specification { "ini
bool RKSettingsModuleGeneral::rkward_version_changed;
bool RKSettingsModuleGeneral::installation_moved = false;
QString RKSettingsModuleGeneral::previous_rkward_data_dir;
-QUrl RKSettingsModuleGeneral::generic_filedialog_start_url;
+RKConfigValue<int> RKSettingsModuleGeneral::num_recent_files { "Max number of recent files", 8 };
QVariantMap RKSettingsModuleGeneral::startup_options;
@@ -75,6 +75,10 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
main_vbox->addWidget(startup_action_choser);
main_vbox->addWidget(show_help_on_startup.makeCheckbox(i18n("Show RKWard Help on Startup"), this));
+ auto num_recent_files_box = num_recent_files.makeSpinBox(1, INT_MAX, this);
+ RKCommonFunctions::setTips (i18n ("<p>The number of recent files to remember (in the Open Recent R Script File menu).</p>") + RKCommonFunctions::noteSettingsTakesEffectAfterRestart (), num_recent_files_box, num_recent_files_box);
+ main_vbox->addWidget(new QLabel(i18n("Maximum number of files to remember per category (*)")));
+ main_vbox->addWidget(num_recent_files_box);
QGroupBox* group_box = new QGroupBox (i18n ("Initial working directory (*)"), this);
QHBoxLayout *hlayout = new QHBoxLayout (group_box);
@@ -188,6 +192,7 @@ void RKSettingsModuleGeneral::syncConfig(KConfig *config, RKConfigBase::ConfigSy
}
startup_action.syncConfig(cg, a);
show_help_on_startup.syncConfig(cg, a);
+ num_recent_files.syncConfig(cg, a);
initial_dir.syncConfig(cg, a);
if ((a == RKConfigBase::SaveConfig) && (initial_dir == LastUsedDirectory)) {
cg.writeEntry(initial_dir_specification.key(), QDir::currentPath());
@@ -213,6 +218,10 @@ void RKSettingsModuleGeneral::syncConfig(KConfig *config, RKConfigBase::ConfigSy
cg.writeEntry("config file version", (int) RKWardConfig_Latest);
cg.writeEntry("previous runtime version", QString(RKWARD_VERSION));
}
+
+ if ((a == RKConfigBase::LoadConfig) && (stored_config_version < RKWardConfig_0_7_4)) {
+ show_help_on_startup = true;
+ }
}
QString RKSettingsModuleGeneral::getSavedWorkplace (KConfig *config) {
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index 8c27c97e..942ef35a 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -66,6 +66,7 @@ public:
static RKMDIFocusPolicy mdiFocusPolicy () { return mdi_focus_policy; }
static QString workspaceFilenameFilter () { return ("*.RData *.RDA"); };
static QString initialWorkingDirectory ();
+ static int maxNumRecentFiles () { return num_recent_files; };
/** 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. */
@@ -79,6 +80,7 @@ public:
RKWardConfig_0_6_4,
RKWardConfig_0_7_1,
RKWardConfig_0_7_3,
+ RKWardConfig_0_7_4,
RKWardConfig_Next, /**< add new configuration versions above / before this entry */
RKWardConfig_Latest = RKWardConfig_Next - 1
};
@@ -117,7 +119,7 @@ private:
static bool rkward_version_changed;
static bool config_exists;
static bool installation_moved;
- static QUrl generic_filedialog_start_url;
+ static RKConfigValue<int> num_recent_files;
static QVariantMap startup_options;
};
More information about the rkward-tracker
mailing list