[education/rkward] rkward/settings: Next step in simplifying settings: spinboxes
Thomas Friedrichsmeier
null at kde.org
Sat Mar 12 23:15:38 GMT 2022
Git commit 8b35af96db69d24f34dd20ac182def548add75e2 by Thomas Friedrichsmeier.
Committed on 12/03/2022 at 21:54.
Pushed by tfry into branch 'master'.
Next step in simplifying settings: spinboxes
M +31 -0 rkward/settings/rksettingsmodule.cpp
M +2 -0 rkward/settings/rksettingsmodule.h
M +5 -19 rkward/settings/rksettingsmodulecommandeditor.cpp
M +1 -5 rkward/settings/rksettingsmodulecommandeditor.h
M +5 -24 rkward/settings/rksettingsmoduleconsole.cpp
M +0 -4 rkward/settings/rksettingsmoduleconsole.h
M +19 -50 rkward/settings/rksettingsmodulegeneral.cpp
M +0 -6 rkward/settings/rksettingsmodulegeneral.h
M +9 -29 rkward/settings/rksettingsmodulegraphics.cpp
M +0 -5 rkward/settings/rksettingsmodulegraphics.h
M +4 -22 rkward/settings/rksettingsmoduleoutput.cpp
M +1 -3 rkward/settings/rksettingsmoduleoutput.h
M +19 -53 rkward/settings/rksettingsmoduler.cpp
M +0 -5 rkward/settings/rksettingsmoduler.h
M +3 -11 rkward/settings/rksettingsmodulewatch.cpp
M +0 -2 rkward/settings/rksettingsmodulewatch.h
https://invent.kde.org/education/rkward/commit/8b35af96db69d24f34dd20ac182def548add75e2
diff --git a/rkward/settings/rksettingsmodule.cpp b/rkward/settings/rksettingsmodule.cpp
index 70808c94..2f6abce7 100644
--- a/rkward/settings/rksettingsmodule.cpp
+++ b/rkward/settings/rksettingsmodule.cpp
@@ -19,6 +19,7 @@
#include "../rkward.h"
#include "../debug.h"
#include "rksettings.h"
+#include "../misc/rkspinbox.h"
#include <QCheckBox>
#include <QComboBox>
@@ -57,6 +58,33 @@ template<typename TT, typename std::enable_if<std::is_same<TT, bool>::value>::ty
return ret;
}
+template<>
+RKSpinBox* RKConfigValue<double, double>::makeSpinBox(double min, double max, RKSettingsModuleWidget* module) {
+ RKSpinBox* ret = new RKSpinBox();
+ ret->setRealMode(min, max, value, 1, 2);
+ QObject::connect(ret, QOverload<int>::of(&QSpinBox::valueChanged), module, &RKSettingsModuleWidget::change);
+ QObject::connect(module, &RKSettingsModuleWidget::apply, [ret, this]() { this->value = ret->realValue(); });
+ return ret;
+}
+
+template<>
+RKSpinBox* RKConfigValue<int, int>::makeSpinBox(int min, int max, RKSettingsModuleWidget* module) {
+ RKSpinBox* ret = new RKSpinBox();
+ ret->setIntMode(min, max, value);
+ QObject::connect(ret, QOverload<int>::of(&QSpinBox::valueChanged), module, &RKSettingsModuleWidget::change);
+ QObject::connect(module, &RKSettingsModuleWidget::apply, [ret, this]() { this->value = ret->intValue(); });
+ return ret;
+}
+// Hmm... Boring dupe of the above
+template<>
+RKSpinBox* RKConfigValue<uint, uint>::makeSpinBox(uint min, uint max, RKSettingsModuleWidget* module) {
+ RKSpinBox* ret = new RKSpinBox();
+ ret->setIntMode(min, max, value);
+ QObject::connect(ret, QOverload<int>::of(&QSpinBox::valueChanged), module, &RKSettingsModuleWidget::change);
+ QObject::connect(module, &RKSettingsModuleWidget::apply, [ret, this]() { this->value = ret->intValue(); });
+ return ret;
+}
+
QComboBox* RKConfigBase::makeDropDownHelper(const LabelList &entries, RKSettingsModuleWidget* module, int initial, std::function<void(int)> setter) {
RK_TRACE(SETTINGS);
@@ -80,4 +108,7 @@ QComboBox* RKConfigBase::makeDropDownHelper(const LabelList &entries, RKSettings
void linkHelperDummy() {
RKConfigValue<bool>("", true).makeCheckbox(QString(), nullptr);
+ RKConfigValue<int>("", 0).makeSpinBox(0, 1, nullptr);
+ RKConfigValue<uint>("", 0).makeSpinBox(0, 1, nullptr);
+ RKConfigValue<double>("", 0.0).makeSpinBox(0.0, 1.0, nullptr);
}
diff --git a/rkward/settings/rksettingsmodule.h b/rkward/settings/rksettingsmodule.h
index 5052d4e7..e9a98b6c 100644
--- a/rkward/settings/rksettingsmodule.h
+++ b/rkward/settings/rksettingsmodule.h
@@ -30,6 +30,7 @@ class QComboBox;
class RKSettingsModule;
class RKSettingsModuleWidget;
class RKSetupWizardItem;
+class RKSpinBox;
/** Base class for RKWard config settings.
*
@@ -93,6 +94,7 @@ public:
return makeDropDownHelper(entries, _module, (std::is_same<STORAGE_T, bool>::value && value) ? 1 : (int) value, [this](int val){this->value = (T) val;});
}
}
+ RKSpinBox* makeSpinBox(T min, T max, RKSettingsModuleWidget* _module);
private:
T value;
};
diff --git a/rkward/settings/rksettingsmodulecommandeditor.cpp b/rkward/settings/rksettingsmodulecommandeditor.cpp
index 02d38286..271b62a7 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.cpp
+++ b/rkward/settings/rksettingsmodulecommandeditor.cpp
@@ -62,14 +62,10 @@ RKCodeCompletionSettingsWidget::RKCodeCompletionSettingsWidget(QWidget *parent,
box_layout->addWidget (auto_completion_enabled_box);
QFormLayout* form_layout = new QFormLayout (auto_completion_enabled_box);
- auto_completion_min_chars_box = new RKSpinBox (auto_completion_enabled_box);
- auto_completion_min_chars_box->setIntMode (1, INT_MAX, settings->auto_completion_min_chars);
- connect (auto_completion_min_chars_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKCodeCompletionSettingsWidget::change);
+ auto auto_completion_min_chars_box = settings->auto_completion_min_chars.makeSpinBox(1, INT_MAX, this);
form_layout->addRow (i18n("Minimum number of characters"), auto_completion_min_chars_box);
- auto_completion_timeout_box = new RKSpinBox (auto_completion_enabled_box);
- auto_completion_timeout_box->setIntMode (0, INT_MAX, settings->auto_completion_timeout);
- connect (auto_completion_timeout_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKCodeCompletionSettingsWidget::change);
+ auto auto_completion_timeout_box = settings->auto_completion_timeout.makeSpinBox(0, INT_MAX, this);
form_layout->addRow (i18n ("Timeout (milliseconds)"), auto_completion_timeout_box);
form_layout->addRow(i18n("(Attempt to) start completion whenever the cursor position changes"), settings->auto_completion_cursor_activated.makeCheckbox(QString(), this));
@@ -111,8 +107,6 @@ RKCodeCompletionSettingsWidget::RKCodeCompletionSettingsWidget(QWidget *parent,
void RKCodeCompletionSettingsWidget::applyChanges() {
settings->auto_completion_enabled = auto_completion_enabled_box->isChecked ();
- settings->auto_completion_min_chars = auto_completion_min_chars_box->intValue ();
- settings->auto_completion_timeout = auto_completion_timeout_box->intValue ();
}
void RKCodeCompletionSettingsWidget::makeCompletionTypeBoxes(const QStringList& labels, QGridLayout* layout) {
@@ -140,10 +134,7 @@ RKSettingsModuleCommandEditor::RKSettingsModuleCommandEditor (RKSettings *gui, Q
connect (autosave_enabled_box, &QGroupBox::toggled, this, &RKSettingsModule::change);
QFormLayout *form_layout = new QFormLayout (group);
- autosave_interval_box = new RKSpinBox (group);
- autosave_interval_box->setIntMode (1, INT_MAX, autosave_interval);
- connect (autosave_interval_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModule::change);
- form_layout->addRow (i18n ("Autosave interval (minutes)"), autosave_interval_box);
+ form_layout->addRow(i18n("Autosave interval (minutes)"), autosave_interval.makeSpinBox(1, INT_MAX, this));
form_layout->addRow(autosave_keep.makeCheckbox(i18n("Keep autosave file after manual save"), this));
@@ -153,10 +144,9 @@ RKSettingsModuleCommandEditor::RKSettingsModuleCommandEditor (RKSettings *gui, Q
group = new QGroupBox (i18n ("Opening script files"), this);
form_layout = new QFormLayout (group);
- num_recent_files_box = new RKSpinBox (group);
- num_recent_files_box->setIntMode (1, INT_MAX, num_recent_files);
+
+ 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);
- connect (num_recent_files_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModule::change);
form_layout->addRow (i18n ("Number of scripts in recent file lists (*)"), num_recent_files_box);
script_file_filter_box = new QLineEdit (group);
@@ -183,11 +173,7 @@ void RKSettingsModuleCommandEditor::applyChanges () {
RK_TRACE (SETTINGS);
completion_settings_widget->applyChanges ();
-
autosave_enabled = autosave_enabled_box->isChecked ();
- autosave_interval = autosave_interval_box->intValue ();
-
- num_recent_files = num_recent_files_box->intValue ();
script_file_filter = script_file_filter_box->text ();
}
diff --git a/rkward/settings/rksettingsmodulecommandeditor.h b/rkward/settings/rksettingsmodulecommandeditor.h
index 1dab15ac..63bb77e8 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.h
+++ b/rkward/settings/rksettingsmodulecommandeditor.h
@@ -77,8 +77,6 @@ public:
private:
void makeCompletionTypeBoxes (const QStringList& labels, QGridLayout* layout);
- RKSpinBox* auto_completion_min_chars_box;
- RKSpinBox* auto_completion_timeout_box;
QGroupBox* auto_completion_enabled_box;
RKCodeCompletionSettings *settings;
@@ -121,10 +119,8 @@ private:
RKCodeCompletionSettingsWidget *completion_settings_widget;
QGroupBox* autosave_enabled_box;
- RKSpinBox* autosave_interval_box;
-
- RKSpinBox* num_recent_files_box;
QLineEdit* script_file_filter_box;
+
static RKConfigValue<int> num_recent_files;
static RKConfigValue<QString> script_file_filter;
};
diff --git a/rkward/settings/rksettingsmoduleconsole.cpp b/rkward/settings/rksettingsmoduleconsole.cpp
index bb24af33..e97e17ae 100644
--- a/rkward/settings/rksettingsmoduleconsole.cpp
+++ b/rkward/settings/rksettingsmoduleconsole.cpp
@@ -25,9 +25,9 @@
#include <qlabel.h>
#include <QVBoxLayout>
#include <QComboBox>
-#include <QSpinBox>
#include "../rbackend/rcommand.h"
+#include "../misc/rkspinbox.h"
#include "../rkglobals.h"
#include "../debug.h"
@@ -51,24 +51,12 @@ RKSettingsModuleConsole::RKSettingsModuleConsole (RKSettings *gui, QWidget *pare
vbox->addWidget (save_history.makeCheckbox(i18n("Load/Save command history"), this));
- vbox->addWidget (new QLabel (i18n ("Maximum length of command history"), this));
- max_history_length_spinner = new QSpinBox(this);
- max_history_length_spinner->setMaximum(10000);
- max_history_length_spinner->setMinimum(0);
- max_history_length_spinner->setSingleStep(10);
- max_history_length_spinner->setValue(max_history_length);
- max_history_length_spinner->setSpecialValueText (i18n ("Unlimited"));
- connect (max_history_length_spinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleConsole::changedSetting);
+ vbox->addWidget (new QLabel (i18n ("Maximum length of command history (0 for no limit)"), this));
+ auto max_history_length_spinner = max_history_length.makeSpinBox(0, 10000, this);
vbox->addWidget (max_history_length_spinner);
- vbox->addWidget (new QLabel (i18n ("Maximum number of paragraphs/lines to display in the console"), this));
- max_console_lines_spinner = new QSpinBox(this);
- max_console_lines_spinner->setMaximum(10000);
- max_console_lines_spinner->setMinimum(0);
- max_console_lines_spinner->setSingleStep(10);
- max_console_lines_spinner->setValue(max_console_lines);
- max_console_lines_spinner->setSpecialValueText (i18n ("Unlimited"));
- connect (max_console_lines_spinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleConsole::changedSetting);
+ vbox->addWidget (new QLabel (i18n ("Maximum number of paragraphs/lines to display in the console (0 for not limit)"), this));
+ auto max_console_lines_spinner = max_console_lines.makeSpinBox(0, 10000, this);
vbox->addWidget (max_console_lines_spinner);
vbox->addSpacing (2*RKGlobals::spacingHint ());
@@ -95,11 +83,6 @@ RKSettingsModuleConsole::~RKSettingsModuleConsole () {
RK_TRACE (SETTINGS);
}
-void RKSettingsModuleConsole::changedSetting (int) {
- RK_TRACE (SETTINGS);
- change ();
-}
-
//static
bool RKSettingsModuleConsole::shouldDoHistoryContextSensitive (Qt::KeyboardModifiers current_state) {
RK_TRACE (SETTINGS);
@@ -148,8 +131,6 @@ void RKSettingsModuleConsole::applyChanges () {
RK_TRACE (SETTINGS);
completion_settings_widget->applyChanges();
- max_history_length = max_history_length_spinner->value ();
- max_console_lines = max_console_lines_spinner->value ();
}
QString RKSettingsModuleConsole::caption () {
diff --git a/rkward/settings/rksettingsmoduleconsole.h b/rkward/settings/rksettingsmoduleconsole.h
index 8b04d753..70db82b8 100644
--- a/rkward/settings/rksettingsmoduleconsole.h
+++ b/rkward/settings/rksettingsmoduleconsole.h
@@ -63,8 +63,6 @@ public:
QString caption () override;
QUrl helpURL () override { return QUrl ("rkward://page/rkward_console#settings"); };
-public slots:
- void changedSetting (int);
private:
static RKCodeCompletionSettings completion_settings;
static RKConfigValue<bool> save_history;
@@ -75,8 +73,6 @@ private:
static RKConfigValue<bool> context_sensitive_history_by_default;
RKCodeCompletionSettingsWidget *completion_settings_widget;
- QSpinBox *max_history_length_spinner;
- QSpinBox *max_console_lines_spinner;
};
#endif
diff --git a/rkward/settings/rksettingsmodulegeneral.cpp b/rkward/settings/rksettingsmodulegeneral.cpp
index 0d346cfa..2a03d2b5 100644
--- a/rkward/settings/rksettingsmodulegeneral.cpp
+++ b/rkward/settings/rksettingsmodulegeneral.cpp
@@ -70,40 +70,29 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
files_choser = new GetFileNameWidget (this, GetFileNameWidget::ExistingDirectory, true, i18n ("Directory where rkward may store files (*)"), QString (), new_files_path);
- connect (files_choser, &GetFileNameWidget::locationChanged, this, &RKSettingsModuleGeneral::settingChanged);
+ connect (files_choser, &GetFileNameWidget::locationChanged, this, &RKSettingsModuleGeneral::change);
main_vbox->addWidget (files_choser);
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
- main_vbox->addWidget (new QLabel (i18n ("Startup Action (*)"), this));
- startup_action_choser = new QComboBox (this);
- startup_action_choser->setEditable (false);
- startup_action_choser->addItem (i18n ("Start with an empty workspace"), (int) StartupDialog::EmptyWorkspace);
- startup_action_choser->addItem (i18n ("Load .RData-file from current directory, if available (R option '--restore')"), (int) StartupDialog::RestoreFromWD);
- startup_action_choser->addItem (i18n ("Start with an empty table"), (int) StartupDialog::EmptyTable);
- startup_action_choser->addItem (i18n ("Ask for a file to open"), (int) StartupDialog::ChoseFile);
- startup_action_choser->addItem (i18n ("Show selection dialog (default)"), (int) StartupDialog::NoSavedSetting);
- startup_action_choser->setCurrentIndex (startup_action_choser->findData (startup_action.get()));
- connect (startup_action_choser, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &RKSettingsModuleGeneral::settingChanged);
- main_vbox->addWidget (startup_action_choser);
+ main_vbox->addWidget(new QLabel(i18n("Startup Action (*)")));
+ auto startup_action_choser = startup_action.makeDropDown(RKConfigBase::LabelList(
+ {{StartupDialog::EmptyWorkspace, i18n("Start with an empty workspace")}, {StartupDialog::RestoreFromWD, i18n("Load .RData-file from current directory, if available (R option '--restore')")}, {StartupDialog::EmptyTable, i18n("Start with an empty table")}, {StartupDialog::ChoseFile, i18n("Ask for a file to open")}, {StartupDialog::NoSavedSetting, i18n("Show selection dialog (default)")}}
+ ), this);
+ main_vbox->addWidget(startup_action_choser);
main_vbox->addWidget(show_help_on_startup.makeCheckbox(i18n("Show RKWard Help on Startup"), this));
QGroupBox* group_box = new QGroupBox (i18n ("Initial working directory (*)"), this);
QHBoxLayout *hlayout = new QHBoxLayout (group_box);
- initial_dir_chooser = new QComboBox (group_box);
- initial_dir_chooser->setEditable (false);
- initial_dir_chooser->addItem (i18n ("Do not change current directory on startup"), (int) CurrentDirectory);
- initial_dir_chooser->addItem (i18n ("RKWard files directory (as specified, above)"), (int) RKWardDirectory);
- initial_dir_chooser->addItem (i18n ("User home directory"), (int) UserHomeDirectory);
- initial_dir_chooser->addItem (i18n ("Last used directory"), (int) LastUsedDirectory);
- initial_dir_chooser->addItem (i18n ("The following directory (please specify):"), (int) CustomDirectory);
- initial_dir_chooser->setCurrentIndex (initial_dir_chooser->findData ((int) initial_dir));
- connect (initial_dir_chooser, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &RKSettingsModuleGeneral::settingChanged);
+ auto initial_dir_chooser = initial_dir.makeDropDown(RKConfigBase::LabelList(
+ {{CurrentDirectory, i18n("Do not change current directory on startup")}, {RKWardDirectory, i18n("RKWard files directory (as specified, above)")}, {UserHomeDirectory, i18n("User home directory")}, {LastUsedDirectory, i18n("Last used directory")}, {CustomDirectory, i18n("The following directory (please specify):")}}
+ ), this);
hlayout->addWidget (initial_dir_chooser);
initial_dir_custom_chooser = new GetFileNameWidget (group_box, GetFileNameWidget::ExistingDirectory, true, QString(), i18n ("Initial working directory"), initial_dir_specification);
initial_dir_custom_chooser->setEnabled (initial_dir == CustomDirectory);
- connect (initial_dir_custom_chooser, &GetFileNameWidget::locationChanged, this, &RKSettingsModuleGeneral::settingChanged);
+ connect (initial_dir_custom_chooser, &GetFileNameWidget::locationChanged, this, &RKSettingsModuleGeneral::change);
+ connect(initial_dir_chooser, QOverload<int>::of(&QComboBox::currentIndexChanged), [initial_dir_chooser, this]() { this->initial_dir_custom_chooser->setEnabled(initial_dir_chooser->currentData()==CustomDirectory); });
hlayout->addWidget (initial_dir_custom_chooser);
RKCommonFunctions::setTips (i18n ("<p>The initial working directory to use. Note that if you are loading a workspace on startup, and you have configured RKWard to change to the directory of loaded workspaces, that directory will take precedence.</p>"), group_box, initial_dir_chooser, initial_dir_custom_chooser);
main_vbox->addWidget (group_box);
@@ -127,7 +116,7 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
group_layout->addWidget (button);
workplace_save_chooser->addButton (button, DontSaveWorkplace);
if ((button = workplace_save_chooser->button (workplace_save_mode))) button->setChecked (true);
- connect (workplace_save_chooser, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKSettingsModuleGeneral::settingChanged);
+ connect (workplace_save_chooser, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKSettingsModuleGeneral::change);
main_vbox->addWidget (group_box);
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
@@ -136,25 +125,16 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
- QLabel* label = new QLabel (i18n ("Warn when editing objects with more than this number of fields (0 for no limit):"), this);
- warn_size_object_edit_box = new RKSpinBox (this);
- warn_size_object_edit_box->setIntMode (0, INT_MAX, warn_size_object_edit);
- warn_size_object_edit_box->setSpecialValueText (i18n ("No limit"));
- connect (warn_size_object_edit_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleGeneral::settingChanged);
- main_vbox->addWidget (label);
- main_vbox->addWidget (warn_size_object_edit_box);
+ main_vbox->addWidget (new QLabel(i18n("Warn when editing objects with more than this number of fields (0 for no limit):")));
+ main_vbox->addWidget (warn_size_object_edit.makeSpinBox(0, INT_MAX, this));
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
- label = new QLabel (i18n ("MDI window focus behavior"), this);
- mdi_focus_policy_chooser = new QComboBox (this);
- mdi_focus_policy_chooser->setEditable (false);
- mdi_focus_policy_chooser->insertItem (RKMDIClickFocus, i18n ("Click to focus"));
- mdi_focus_policy_chooser->insertItem (RKMDIFocusFollowsMouse, i18n ("Focus follows mouse"));
- mdi_focus_policy_chooser->setCurrentIndex (mdi_focus_policy);
- connect (mdi_focus_policy_chooser, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &RKSettingsModuleGeneral::settingChanged);
- main_vbox->addWidget (label);
- main_vbox->addWidget (mdi_focus_policy_chooser);
+ main_vbox->addWidget(new QLabel(i18n("MDI window focus behavior"), this));
+ auto mdi_focus_policy_chooser = mdi_focus_policy.makeDropDown(RKConfigBase::LabelList(
+ {{RKMDIClickFocus, i18n("Click to focus")}, {RKMDIFocusFollowsMouse, i18n("Focus follows mouse")}}
+ ), this);
+ main_vbox->addWidget(mdi_focus_policy_chooser);
main_vbox->addStretch ();
}
@@ -192,13 +172,6 @@ void RKSettingsModuleGeneral::updateLastUsedUrl (const QString& thing, const QUr
}
}
-void RKSettingsModuleGeneral::settingChanged () {
- RK_TRACE (SETTINGS);
- int dummy = initial_dir_chooser->itemData (initial_dir_chooser->currentIndex ()).toInt ();
- initial_dir_custom_chooser->setEnabled (dummy == CustomDirectory);
- change ();
-}
-
QString RKSettingsModuleGeneral::caption () {
RK_TRACE (SETTINGS);
return (i18n ("General"));
@@ -207,11 +180,7 @@ QString RKSettingsModuleGeneral::caption () {
void RKSettingsModuleGeneral::applyChanges () {
RK_TRACE (SETTINGS);
new_files_path = files_choser->getLocation ();
- startup_action = static_cast<StartupDialog::Result> (startup_action_choser->itemData (startup_action_choser->currentIndex ()).toInt ());
workplace_save_mode = static_cast<WorkplaceSaveMode> (workplace_save_chooser->checkedId ());
- warn_size_object_edit = warn_size_object_edit_box->intValue ();
- mdi_focus_policy = static_cast<RKMDIFocusPolicy> (mdi_focus_policy_chooser->currentIndex ());
- initial_dir = static_cast<InitialDirectory> (initial_dir_chooser->itemData (initial_dir_chooser->currentIndex ()).toInt ());
initial_dir_specification = initial_dir_custom_chooser->getLocation ();
}
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index 188d8a32..06d2258f 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -107,15 +107,9 @@ public:
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;
- RKSpinBox *warn_size_object_edit_box;
- QComboBox *mdi_focus_policy_chooser;
- QComboBox *initial_dir_chooser;
GetFileNameWidget *initial_dir_custom_chooser;
static RKConfigValue<StartupDialog::Result, int> startup_action;
diff --git a/rkward/settings/rksettingsmodulegraphics.cpp b/rkward/settings/rksettingsmodulegraphics.cpp
index f5073b6e..028a9631 100644
--- a/rkward/settings/rksettingsmodulegraphics.cpp
+++ b/rkward/settings/rksettingsmodulegraphics.cpp
@@ -110,17 +110,13 @@ RKSettingsModuleGraphics::RKSettingsModuleGraphics (RKSettings *gui, QWidget *pa
connect (replace_standard_devices_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKSettingsModuleGraphics::boxChanged);
h_layout1->addWidget (group);
- group = new QGroupBox (i18n ("Default window size (for RK(), or embedded device windows)"), this);
- group_layout = new QVBoxLayout (group);
- group_layout->addWidget (new QLabel (i18n ("Default width (inches):"), group));
- group_layout->addWidget (graphics_width_box = new RKSpinBox (group));
- graphics_width_box->setRealMode (1, 100.0, graphics_width, 1, 3);
- group_layout->addSpacing (2*RKGlobals::spacingHint ());
- group_layout->addWidget (new QLabel (i18n ("Default height (inches)"), group));
- group_layout->addWidget (graphics_height_box = new RKSpinBox (group));
- graphics_height_box->setRealMode (1, 100.0, graphics_height, 1, 3);
- connect (graphics_width_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleGraphics::boxChanged);
- connect (graphics_height_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleGraphics::boxChanged);
+ group = new QGroupBox(i18n("Default window size (for RK(), or embedded device windows)"));
+ group_layout = new QVBoxLayout(group);
+ group_layout->addWidget(new QLabel(i18n("Default width (inches):")));
+ group_layout->addWidget(graphics_width.makeSpinBox(1, 100.0, this));
+ group_layout->addSpacing(2*RKGlobals::spacingHint());
+ group_layout->addWidget(new QLabel(i18n("Default height (inches)")));
+ group_layout->addWidget(graphics_height.makeSpinBox(1, 100.0, this));
main_vbox->addWidget (group);
main_vbox->addWidget(options_kde_printing.makeCheckbox(i18n("Use KDE printer dialog for printing devices (if available)"), this));
@@ -133,22 +129,11 @@ RKSettingsModuleGraphics::RKSettingsModuleGraphics (RKSettings *gui, QWidget *pa
h_layout = new QHBoxLayout ();
group_layout->addLayout (h_layout);
h_layout->addWidget (new QLabel (i18n ("Maximum number of recorded plots:"), graphics_hist_box));
- h_layout->addWidget (graphics_hist_max_length_box = new QSpinBox(graphics_hist_box));
- graphics_hist_max_length_box->setMaximum(200);
- graphics_hist_max_length_box->setMinimum(1);
- graphics_hist_max_length_box->setSingleStep(1);
- graphics_hist_max_length_box->setValue(graphics_hist_max_length);
+ h_layout->addWidget (graphics_hist_max_length.makeSpinBox(1, 200, this));
h_layout = new QHBoxLayout ();
group_layout->addLayout (h_layout);
h_layout->addWidget (new QLabel (i18n ("Maximum size of a single recorded plot (in KB):"), graphics_hist_box));
- h_layout->addWidget (graphics_hist_max_plotsize_box = new QSpinBox(graphics_hist_box));
- graphics_hist_max_plotsize_box->setMaximum(50000);
- graphics_hist_max_plotsize_box->setMinimum(4);
- graphics_hist_max_plotsize_box->setSingleStep(4);
- graphics_hist_max_plotsize_box->setValue(graphics_hist_max_plotsize);
- connect (graphics_hist_max_length_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleGraphics::boxChanged);
- connect (graphics_hist_max_plotsize_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleGraphics::boxChanged);
-
+ h_layout->addWidget (graphics_hist_max_plotsize.makeSpinBox(4, 50000, this));
main_vbox->addWidget (graphics_hist_box);
main_vbox->addStretch ();
@@ -184,13 +169,8 @@ void RKSettingsModuleGraphics::applyChanges () {
default_device = (DefaultDevice) default_device_group->checkedId ();
default_device_other = default_device_other_edit->text ();
replace_standard_devices = (StandardDevicesMode) replace_standard_devices_group->checkedId ();
-
- graphics_width = graphics_width_box->realValue ();
- graphics_height = graphics_height_box->realValue ();
graphics_hist_enable = graphics_hist_box->isChecked ();
- graphics_hist_max_length = graphics_hist_max_length_box->value ();
- graphics_hist_max_plotsize = graphics_hist_max_plotsize_box->value ();
QStringList commands = makeRRunTimeOptionCommands ();
for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
diff --git a/rkward/settings/rksettingsmodulegraphics.h b/rkward/settings/rksettingsmodulegraphics.h
index 396427a5..9425c2af 100644
--- a/rkward/settings/rksettingsmodulegraphics.h
+++ b/rkward/settings/rksettingsmodulegraphics.h
@@ -74,11 +74,6 @@ private:
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;
static RKConfigValue<DefaultDevice, int> default_device;
static RKConfigValue<QString> default_device_other;
diff --git a/rkward/settings/rksettingsmoduleoutput.cpp b/rkward/settings/rksettingsmoduleoutput.cpp
index 45597613..0527b471 100644
--- a/rkward/settings/rksettingsmoduleoutput.cpp
+++ b/rkward/settings/rksettingsmoduleoutput.cpp
@@ -26,11 +26,11 @@
#include <QCheckBox>
#include <QVBoxLayout>
#include <QComboBox>
-#include <QSpinBox>
#include "../rkglobals.h"
#include "../misc/getfilenamewidget.h"
#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkspinbox.h"
#include "../rbackend/rkrinterface.h"
#include "../debug.h"
@@ -158,33 +158,18 @@ RKSettingsModuleOutput::RKSettingsModuleOutput (RKSettings *gui, QWidget *parent
connect (graphics_type_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &RKSettingsModuleOutput::boxChanged);
h_layout->addSpacing (2*RKGlobals::spacingHint ());
h_layout->addWidget (new QLabel (i18n ("JPG quality"), group));
- h_layout->addWidget (graphics_jpg_quality_box = new QSpinBox(group));
- graphics_jpg_quality_box->setMaximum(100);
- graphics_jpg_quality_box->setMinimum(1);
- graphics_jpg_quality_box->setSingleStep(1);
- graphics_jpg_quality_box->setValue(graphics_jpg_quality);
+ h_layout->addWidget (graphics_jpg_quality_box = graphics_jpg_quality.makeSpinBox(1, 100, this));
graphics_jpg_quality_box->setEnabled (graphics_type == "\"JPG\"");
- connect (graphics_jpg_quality_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleOutput::boxChanged);
h_layout->addStretch ();
h_layout = new QHBoxLayout ();
group_layout->addLayout (h_layout);
h_layout->addWidget (new QLabel (i18n ("Width:"), group));
- h_layout->addWidget (graphics_width_box = new QSpinBox(group));
- graphics_width_box->setMaximum(INT_MAX);
- graphics_width_box->setMinimum(1);
- graphics_width_box->setSingleStep(1);
- graphics_width_box->setValue(graphics_width);
+ h_layout->addWidget (graphics_width.makeSpinBox(1, INT_MAX, this));
h_layout->addSpacing (2*RKGlobals::spacingHint ());
h_layout->addWidget (new QLabel (i18n ("Height:"), group));
- h_layout->addWidget (graphics_height_box = new QSpinBox(group));
- graphics_height_box->setMaximum(INT_MAX);
- graphics_height_box->setMinimum(1);
- graphics_height_box->setSingleStep(1);
- graphics_height_box->setValue(graphics_height);
+ h_layout->addWidget (graphics_height.makeSpinBox(1, INT_MAX, this));
h_layout->addStretch ();
- connect (graphics_width_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleOutput::boxChanged);
- connect (graphics_height_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleOutput::boxChanged);
main_vbox->addWidget (group);
@@ -215,9 +200,6 @@ void RKSettingsModuleOutput::applyChanges () {
custom_css_file = custom_css_file_box->getLocation ();
graphics_type = graphics_type_box->itemData (graphics_type_box->currentIndex ()).toString ();
- graphics_width = graphics_width_box->value ();
- graphics_height = graphics_height_box->value ();
- graphics_jpg_quality = graphics_jpg_quality_box->value ();
QStringList commands = makeRRunTimeOptionCommands ();
for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
diff --git a/rkward/settings/rksettingsmoduleoutput.h b/rkward/settings/rksettingsmoduleoutput.h
index 0efb9e48..4f8b8c2d 100644
--- a/rkward/settings/rksettingsmoduleoutput.h
+++ b/rkward/settings/rksettingsmoduleoutput.h
@@ -90,9 +90,7 @@ public slots:
void boxChanged ();
private:
QComboBox *graphics_type_box;
- QSpinBox *graphics_width_box;
- QSpinBox *graphics_height_box;
- QSpinBox *graphics_jpg_quality_box;
+ RKSpinBox *graphics_jpg_quality_box;
RKCarbonCopySettings *cc_settings;
GetFileNameWidget *custom_css_file_box;
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index afa23d30..dc38c1ee 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -39,6 +39,7 @@
#include "../misc/multistringselector.h"
#include "../misc/rkprogresscontrol.h"
#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkspinbox.h"
#include "../rbackend/rkrinterface.h"
#include "../rbackend/rksessionvars.h"
#include "../rkglobals.h"
@@ -78,11 +79,11 @@ RKSettingsModuleR::RKSettingsModuleR (RKSettings *gui, QWidget *parent) : RKSett
int row = -1;
// options (warn)
- grid->addWidget (new QLabel (i18n ("Display warnings"), this), ++row, 0);
+ grid->addWidget(new QLabel(i18n("Display warnings")), ++row, 0);
auto warn_input = options_warn.makeDropDown(RKConfigBase::LabelList(
{{-1, i18n("Suppress warnings")}, {0, i18n("Print warnings later (default)")}, {1, i18n("Print warnings immediately")}, {2, i18n ("Convert warnings to errors")}}
), this);
- grid->addWidget (warn_input, row, 1);
+ grid->addWidget(warn_input, row, 1);
// options (OutDec)
grid->addWidget (new QLabel (i18n ("Decimal character (only for printing)"), this), ++row, 0);
@@ -92,69 +93,39 @@ RKSettingsModuleR::RKSettingsModuleR (RKSettings *gui, QWidget *parent) : RKSett
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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
- grid->addWidget (width_input, row, 1);
+ grid->addWidget(new QLabel(i18n("Output width (characters)")), ++row, 0);
+ grid->addWidget(options_width.makeSpinBox(10, 10000, this), 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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
- grid->addWidget (maxprint_input, row, 1);
+ grid->addWidget(new QLabel(i18n("Maximum number of elements shown in print")), ++row, 0);
+ grid->addWidget(options_maxprint.makeSpinBox(100, INT_MAX, this), 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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
- grid->addWidget (warningslength_input, row, 1);
+ grid->addWidget(new QLabel(i18n("Maximum length of warnings/errors to print")), ++row, 0);
+ grid->addWidget(options_warningslength.makeSpinBox(100, 8192, this), row, 1);
// options (keep.source)
- grid->addWidget (new QLabel (i18n ("Keep comments in functions"), this), ++row, 0);
+ grid->addWidget(new QLabel(i18n("Keep comments in functions")), ++row, 0);
auto keepsource_input = options_keepsource.makeDropDown(RKConfigBase::LabelList({{1, i18n("TRUE (default)")}, {0, i18n("FALSE")}}), this);
- grid->addWidget (keepsource_input, row, 1);
+ grid->addWidget(keepsource_input, row, 1);
// options (keep.source.pkgs)
- grid->addWidget (new QLabel (i18n ("Keep comments in packages"), this), ++row, 0);
+ grid->addWidget(new QLabel(i18n("Keep comments in packages")), ++row, 0);
auto keepsourcepkgs_input = options_keepsourcepkgs.makeDropDown(RKConfigBase::LabelList({{1, i18n("TRUE")}, {0, i18n("FALSE (default)")}}), this);
- grid->addWidget (keepsourcepkgs_input, row, 1);
+ 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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
- grid->addWidget (expressions_input, row, 1);
+ grid->addWidget(new QLabel(i18n("Maximum level of nested expressions")), ++row, 0);
+ grid->addWidget(options_expressions.makeSpinBox(25, 500000, this), 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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleR::settingChanged);
- grid->addWidget (digits_input, row, 1);
+ grid->addWidget(new QLabel(i18n("Default decimal precision in print ()")), ++row, 0);
+ grid->addWidget(options_digits.makeSpinBox(1, 22, this), row, 1);
// options (check.bounds)
- grid->addWidget (new QLabel (i18n ("Check vector bounds (warn)"), this), ++row, 0);
+ grid->addWidget(new QLabel(i18n("Check vector bounds (warn)")), ++row, 0);
auto checkbounds_input = options_checkbounds.makeDropDown(RKConfigBase::LabelList({{1, i18n("TRUE")}, {0, i18n("FALSE (default)")}}), this);
- grid->addWidget (checkbounds_input, row, 1);
+ grid->addWidget(checkbounds_input, row, 1);
grid->addWidget (new QLabel (i18n ("Editor command"), this), ++row, 0);
editor_input = new QComboBox (this);
@@ -213,11 +184,6 @@ void RKSettingsModuleR::applyChanges () {
RK_TRACE (SETTINGS);
options_outdec = outdec_input->text ();
- options_width = width_input->value ();
- options_warningslength = warningslength_input->value ();
- options_maxprint = maxprint_input->value ();
- options_expressions = expressions_input->value ();
- options_digits = digits_input->value ();
options_editor = editor_input->currentText ();
options_pager = pager_input->currentText ();
options_further = further_input->toPlainText ();
diff --git a/rkward/settings/rksettingsmoduler.h b/rkward/settings/rksettingsmoduler.h
index c5ebf66a..e668a235 100644
--- a/rkward/settings/rksettingsmoduler.h
+++ b/rkward/settings/rksettingsmoduler.h
@@ -59,11 +59,6 @@ private slots:
void addPaths (QStringList *string_list);
private:
QLineEdit *outdec_input;
- QSpinBox *width_input;
- QSpinBox *warningslength_input;
- QSpinBox *maxprint_input;
- QSpinBox *expressions_input;
- QSpinBox *digits_input;
QComboBox *editor_input;
QComboBox *pager_input;
QTextEdit *further_input;
diff --git a/rkward/settings/rksettingsmodulewatch.cpp b/rkward/settings/rksettingsmodulewatch.cpp
index 0965b1da..67bcc276 100644
--- a/rkward/settings/rksettingsmodulewatch.cpp
+++ b/rkward/settings/rksettingsmodulewatch.cpp
@@ -28,6 +28,7 @@
#include "../rbackend/rcommand.h"
#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkspinbox.h"
#include "rksettings.h"
#include "../rkglobals.h"
@@ -144,15 +145,8 @@ RKSettingsModuleWatch::RKSettingsModuleWatch (RKSettings *gui, QWidget *parent)
vbox->addSpacing (2*RKGlobals::spacingHint ());
- vbox->addWidget (new QLabel (i18n ("Maximum number of paragraphs/lines to display in the Command Log"), this));
- max_log_lines_spinner = new QSpinBox(this);
- max_log_lines_spinner->setMaximum(10000);
- max_log_lines_spinner->setMinimum(0);
- max_log_lines_spinner->setSingleStep(10);
- max_log_lines_spinner->setValue(max_log_lines);
- max_log_lines_spinner->setSpecialValueText (i18n ("Unlimited"));
- connect (max_log_lines_spinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleWatch::changedSetting);
- vbox->addWidget (max_log_lines_spinner);
+ vbox->addWidget(new QLabel(i18n("Maximum number of paragraphs/lines to display in the Command Log (0 for no limit)")));
+ vbox->addWidget(max_log_lines.makeSpinBox(0, INT_MAX, this));
vbox->addStretch ();
@@ -245,8 +239,6 @@ void RKSettingsModuleWatch::applyChanges () {
plugin_filter = getFilterSettings (plugin_filter_boxes);
app_filter = getFilterSettings (app_filter_boxes);
sync_filter = getFilterSettings (sync_filter_boxes);
-
- max_log_lines = max_log_lines_spinner->value ();
}
QString RKSettingsModuleWatch::caption () {
diff --git a/rkward/settings/rksettingsmodulewatch.h b/rkward/settings/rksettingsmodulewatch.h
index 1459df60..6fede98e 100644
--- a/rkward/settings/rksettingsmodulewatch.h
+++ b/rkward/settings/rksettingsmodulewatch.h
@@ -77,8 +77,6 @@ private:
FilterBoxes *addFilterSettings (QWidget *parent, QGridLayout *layout, int row, const QString &label, int state);
static RKConfigValue<uint> max_log_lines;
-
- QSpinBox *max_log_lines_spinner;
};
#endif
More information about the rkward-tracker
mailing list