[rkward] /: Add convenience functions to create word-wrapped, and linked labels.

Thomas Friedrichsmeier null at kde.org
Sun Feb 16 11:29:52 GMT 2020


Git commit e05650359def621c8ffbbd419a04bde648e4d576 by Thomas Friedrichsmeier.
Committed on 16/02/2020 at 11:27.
Pushed by tfry into branch 'master'.

Add convenience functions to create word-wrapped, and linked labels.

Allow rkward://-style urls in <text>-elements

M  +1    -0    ChangeLog
M  +3    -3    rkward/dialogs/rkerrordialog.cpp
M  +2    -1    rkward/dialogs/rkreadlinedialog.cpp
M  +1    -4    rkward/dialogs/rkrecoverdialog.cpp
M  +2    -3    rkward/misc/editlabelsdialog.cpp
M  +15   -0    rkward/misc/rkcommonfunctions.cpp
M  +6    -0    rkward/misc/rkcommonfunctions.h
M  +3    -4    rkward/misc/rkprogresscontrol.cpp
M  +2    -2    rkward/plugin/rkpreviewbox.cpp
M  +2    -6    rkward/plugin/rkstandardcomponentgui.cpp
M  +2    -2    rkward/plugin/rktext.cpp
M  +2    -2    rkward/robjectviewer.cpp
M  +3    -5    rkward/settings/rksettingsmodulecommandeditor.cpp
M  +3    -4    rkward/settings/rksettingsmoduledebug.cpp
M  +3    -7    rkward/settings/rksettingsmodulegeneral.cpp
M  +1    -3    rkward/settings/rksettingsmoduleplugins.cpp
M  +8    -18   rkward/settings/rksettingsmoduler.cpp
M  +6    -10   rkward/settings/rksettingsmodulewatch.cpp
M  +2    -2    rkward/windows/rkcallstackviewer.cpp
M  +3    -0    rkward/windows/rkworkplace.h

https://commits.kde.org/rkward/e05650359def621c8ffbbd419a04bde648e4d576

diff --git a/ChangeLog b/ChangeLog
index 13663579..2aca6b11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 --- Version 0.7.2 - UNRELEASED
+- <text> elements in plugins may now also contain clickable links, including rkward://-scheme links
 * TODO: Bring new code hinting features to the console window!
 - On unix-systems, RKWard can now be run without installation
 - Kate addons are now supported within RKWard. Intially, search-in-files, snippets, and projects are loaded by default
diff --git a/rkward/dialogs/rkerrordialog.cpp b/rkward/dialogs/rkerrordialog.cpp
index e9705293..80f9fce4 100644
--- a/rkward/dialogs/rkerrordialog.cpp
+++ b/rkward/dialogs/rkerrordialog.cpp
@@ -35,6 +35,7 @@
 #include "../rbackend/rksessionvars.h"
 #include "../misc/rkprogresscontrol.h"
 #include "../misc/rkdialogbuttonbox.h"
+#include "../misc/rkcommonfunctions.h"
 #include "../rkglobals.h"
 #include "../rkward.h"
 #include "../version.h"
@@ -51,7 +52,7 @@ public:
 		RKBugzillaReportDialog::report_template = report_template;
 		setWindowTitle (i18n ("Reporting bugs in RKWard"));
 		QVBoxLayout *layout = new QVBoxLayout (this);
-		QLabel *label = new QLabel (i18n ("<p><b>Where should I report bugs or wishes?</b></p><p>Thank you for taking the time to help improve RKWard. To help us "
+		QLabel *label = RKCommonFunctions::wordWrappedLabel (i18n ("<p><b>Where should I report bugs or wishes?</b></p><p>Thank you for taking the time to help improve RKWard. To help us "
 		                                  "handle your request, efficiently, please submit your bug reports or wishes in the "
 		                                  "<a href=\"%1\">KDE bugtracking system</a>. Note that you need a user account for this, so that we will be able to contact you, "
 		                                  "for follow-up questions. <b>If you do not have an account, please <a href=\"%2\">create one</a>, first.</b></p>"
@@ -59,8 +60,7 @@ public:
 		                         QString ("https://bugs.kde.org"), QString ("https://bugs.kde.org/createaccount.cgi"), QString ("https://rkward.kde.org/Bugs.html"))
 		                          + i18n ("<p><b>What information should I provide, and how?</b></p>Clicking \"Report issue\" will take you to the "
 		                                  "KDE bugtracking system. After logging in, some information will already be pre-filled into the report form. Please make sure "
-		                                  "to fill in the missing bits - in English - where indicated, especially in the \"Comment\" field.</p>"), this);
-		label->setWordWrap (true);
+		                                  "to fill in the missing bits - in English - where indicated, especially in the \"Comment\" field.</p>"));
 		label->setOpenExternalLinks (true);
 		layout->addWidget (label);
 
diff --git a/rkward/dialogs/rkreadlinedialog.cpp b/rkward/dialogs/rkreadlinedialog.cpp
index d39b27fd..f8631f16 100644
--- a/rkward/dialogs/rkreadlinedialog.cpp
+++ b/rkward/dialogs/rkreadlinedialog.cpp
@@ -31,6 +31,7 @@
 
 #include "../rbackend/rcommand.h"
 #include "../misc/rkdialogbuttonbox.h"
+#include "../misc/rkcommonfunctions.h"
 
 #include "../debug.h"
 
@@ -68,7 +69,7 @@ RKReadLineDialog::RKReadLineDialog (QWidget *parent, const QString &caption, con
 		layout->setStretchFactor (output, 10);
 	}
 
-	QLabel *promptl = new QLabel (prompt, this);
+	QLabel *promptl = RKCommonFunctions::wordWrappedLabel (prompt);
 	promptl->setWordWrap (true);
 	layout->addWidget (promptl);
 
diff --git a/rkward/dialogs/rkrecoverdialog.cpp b/rkward/dialogs/rkrecoverdialog.cpp
index 65de3247..8a1c1a11 100644
--- a/rkward/dialogs/rkrecoverdialog.cpp
+++ b/rkward/dialogs/rkrecoverdialog.cpp
@@ -44,14 +44,11 @@ RKRecoverDialog::RKRecoverDialog (const QStringList &recovery_files) : QDialog (
 	const QString caption = i18n ("Crash recovery file detected");
 	setWindowTitle (caption);
 
-	QLabel *label = new QLabel (this);
 	QString text = QString ("<p><b>%1</b></p>").arg (caption);
 	text.append (i18n ("<p>It looks like RKWard has crashed, recently. We are sorry about that! However, not everything is lost, and with a bit of luck, your data has been saved in time.</p>"));
 	text.append (i18np ("<p>A workspace recovery file exists, dating from <i>%2</i>.</p>", "<p>%1 workspace recovery files exist, the most recent one of which dates from <i>%2</i>.</p>", recovery_files.count (), QFileInfo (recovery_files.first ()).lastModified ().toString (Qt::SystemLocaleShortDate)));
 	text.append (i18n ("<p>Do you want to open this file, now, save it for later (as <i>%1</i>), or discard it?</p>", saveFileFor (recovery_files.first ())));
-	label->setText (text);
-	label->setWordWrap (true);
-	layout->addWidget (label);
+	layout->addWidget (RKCommonFunctions::wordWrappedLabel (text));
 
 	RKDialogButtonBox *buttons = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Discard, this);
 	buttons->button (QDialogButtonBox::Ok)->setText (i18n ("Recover"));
diff --git a/rkward/misc/editlabelsdialog.cpp b/rkward/misc/editlabelsdialog.cpp
index 6924e8ac..2a414c10 100644
--- a/rkward/misc/editlabelsdialog.cpp
+++ b/rkward/misc/editlabelsdialog.cpp
@@ -31,6 +31,7 @@
 #include "../core/rkvariable.h"
 #include "../dataeditor/rktextmatrix.h"
 #include "../misc/rkdialogbuttonbox.h"
+#include "../misc/rkcommonfunctions.h"
 #include "celleditor.h"
 
 #include "../debug.h"
@@ -213,9 +214,7 @@ EditLabelsDialog::EditLabelsDialog (QWidget *parent, const RObject::ValueLabels&
 	setWindowTitle (i18n ("Levels / Value labels for '%1'", varname));
 
 	QVBoxLayout *layout = new QVBoxLayout (this);
-	QLabel *label = new QLabel (i18n ("Levels can be assigned only to consecutive integers starting with 1 (the index column is read only). To remove levels at the end of the list, just set them to empty."), this);
-	label->setWordWrap (true);
-	layout->addWidget (label);
+	layout->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Levels can be assigned only to consecutive integers starting with 1 (the index column is read only). To remove levels at the end of the list, just set them to empty.")));
 
 	table = new RKVarLevelsTable (this, labels);
 	layout->addWidget (table);
diff --git a/rkward/misc/rkcommonfunctions.cpp b/rkward/misc/rkcommonfunctions.cpp
index 3d19c111..ecf8d5ba 100644
--- a/rkward/misc/rkcommonfunctions.cpp
+++ b/rkward/misc/rkcommonfunctions.cpp
@@ -22,11 +22,13 @@
 #include <QDir>
 #include <QStandardPaths>
 #include <QCoreApplication>
+#include <QLabel>
 
 #include <KLocalizedString>
 #include <kxmlguiclient.h>
 
 #include "../settings/rksettingsmodulegeneral.h"
+#include "../windows/rkworkplace.h"
 #include "../version.h"
 #include "../debug.h"
 
@@ -279,4 +281,17 @@ namespace RKCommonFunctions {
 		return orig;
 #endif
 	}
+
+	QLabel* wordWrappedLabel (const QString& text) {
+		QLabel* ret = new QLabel (text);
+		ret->setWordWrap (true);
+		return ret;
+	}
+
+	QLabel* linkedWrappedLabel (const QString& text) {
+		QLabel* ret = wordWrappedLabel (text);
+		QObject::connect (ret, &QLabel::linkActivated, RKWorkplace::mainWorkplace (), &RKWorkplace::openAnyUrlString);
+		return ret;
+	}
+
 }	// namespace
diff --git a/rkward/misc/rkcommonfunctions.h b/rkward/misc/rkcommonfunctions.h
index 650cd16c..eb1b9031 100644
--- a/rkward/misc/rkcommonfunctions.h
+++ b/rkward/misc/rkcommonfunctions.h
@@ -24,6 +24,7 @@ class QString;
 class QDomNode;
 class KXMLGUIClient;
 class QWidget;
+class QLabel;
 
 /** Some common static helper functions that don't really belong to any class in particular. If ever we have more than a dozen or so functions in here,
 we should probably split this file up. Until then, there's no real need.
@@ -61,6 +62,11 @@ namespace RKCommonFunctions {
 	QString noteSettingsTakesEffectAfterRestart ();
 /** Passing commands as part of arguments to windows shell scripts will fail miserably for paths with spaces or special characters. Transform to short path names for safety. No-op on sane platforms.*/
 	QString windowsShellScriptSafeCommand (const QString &orig);
+
+/** create a QLabel that has wordwarp enabled, in a single line of code. */
+	QLabel* wordWrappedLabel (const QString &text);
+/** create a QLabel that has wordwarp enabled, *and* clickable links (opened inside RKWard), in a single line of code. */
+	QLabel* linkedWrappedLabel (const QString &text);
 };
 
 #endif
diff --git a/rkward/misc/rkprogresscontrol.cpp b/rkward/misc/rkprogresscontrol.cpp
index a761c5b4..8fc3c726 100644
--- a/rkward/misc/rkprogresscontrol.cpp
+++ b/rkward/misc/rkprogresscontrol.cpp
@@ -30,6 +30,7 @@
 #include "../rkglobals.h"
 #include "../rbackend/rkrinterface.h"
 #include "../settings/rksettingsmoduler.h"
+#include "../misc/rkcommonfunctions.h"
 
 #include "../debug.h"
 
@@ -249,9 +250,7 @@ RKProgressControlDialog::RKProgressControlDialog (const QString &text, const QSt
 	mainbox->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
 	mainboxlayout->setContentsMargins (0, 0, 0, 0);
 
-	QLabel *label = new QLabel (text, mainbox);
-	label->setWordWrap (true);
-	mainboxlayout->addWidget (label);
+	mainboxlayout->addWidget (RKCommonFunctions::linkedWrappedLabel (text));
 
 	error_indicator = new QLabel (i18n ("<b>There have been errors and / or warnings. See below for a transcript</b>"), mainbox);
 	QPalette palette = error_indicator->palette ();
@@ -272,7 +271,7 @@ RKProgressControlDialog::RKProgressControlDialog (const QString &text, const QSt
 		output_button_text = i18n ("Errors / Warnings");
 		ocaption = i18n ("Errors / Warnings:");
 	}
-	label = new QLabel (ocaption, detailsbox);
+	QLabel* label = new QLabel (ocaption, detailsbox);
 	detailsboxlayout->addWidget (label);
 
 	output_text = new QTextEdit (detailsbox);
diff --git a/rkward/plugin/rkpreviewbox.cpp b/rkward/plugin/rkpreviewbox.cpp
index 34499201..3c4b2575 100644
--- a/rkward/plugin/rkpreviewbox.cpp
+++ b/rkward/plugin/rkpreviewbox.cpp
@@ -28,6 +28,7 @@
 #include "../rbackend/rkrinterface.h"
 #include "../misc/xmlhelper.h"
 #include "../misc/rkxmlguipreviewarea.h"
+#include "../misc/rkcommonfunctions.h"
 #include "../windows/rkwindowcatcher.h"
 #include "../windows/rkworkplace.h"
 #include "rkstandardcomponent.h"
@@ -64,8 +65,7 @@ RKPreviewBox::RKPreviewBox (const QDomElement &element, RKComponent *parent_comp
 	connect (toggle_preview_box, &QCheckBox::stateChanged, this, &RKPreviewBox::changedStateFromUi);
 
 	// status label
-	status_label = new QLabel (QString (), this);
-	status_label->setWordWrap (true);
+	status_label = RKCommonFunctions::wordWrappedLabel (QString ());
 	vbox->addWidget (status_label);
 
 	// prepare placement
diff --git a/rkward/plugin/rkstandardcomponentgui.cpp b/rkward/plugin/rkstandardcomponentgui.cpp
index f5f071c9..ad955418 100644
--- a/rkward/plugin/rkstandardcomponentgui.cpp
+++ b/rkward/plugin/rkstandardcomponentgui.cpp
@@ -532,14 +532,10 @@ void RKStandardComponentWizard::finalize () {
 		vbox->setContentsMargins (0, 0, 0, 0);
 		if (previews.size () < 2) {
 			RK_ASSERT (previews.size () == 1);
-			QLabel *label = new QLabel (i18n ("Below you can preview the R commands corresponding to the settings you made. Click 'Submit' to run the commands."), last_page);
-			label->setWordWrap (true);
-			vbox->addWidget (label);
+			vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Below you can preview the R commands corresponding to the settings you made. Click 'Submit' to run the commands.")));
 			vbox->addWidget (code_display);
 		} else {
-			QLabel *label = new QLabel (i18n ("Below you can preview the result of your settings, and the R commands to be run. Click 'Submit' to run the commands."), last_page);
-			label->setWordWrap (true);
-			vbox->addWidget (label);
+			vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Below you can preview the result of your settings, and the R commands to be run. Click 'Submit' to run the commands.")));
 			QTabWidget *previews_widget = new QTabWidget (last_page);
 			vbox->addWidget (previews_widget);
 			for (int i = 0; i < previews.size (); ++i) {
diff --git a/rkward/plugin/rktext.cpp b/rkward/plugin/rktext.cpp
index 4896ca3c..9fa71cbd 100644
--- a/rkward/plugin/rktext.cpp
+++ b/rkward/plugin/rktext.cpp
@@ -25,6 +25,7 @@
 
 #include "../rkglobals.h"
 #include "../misc/xmlhelper.h"
+#include "../misc/rkcommonfunctions.h"
 #include "../debug.h"
 
 RKText::RKText (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
@@ -37,8 +38,7 @@ RKText::RKText (const QDomElement &element, RKComponent *parent_component, QWidg
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	label = new QLabel (QString (), this);
-	label->setWordWrap (true);
+	label = RKCommonFunctions::linkedWrappedLabel (QString ());
 	vbox->addWidget (label);
 
 	int type = xml->getMultiChoiceAttribute (element, "type", "normal;warning;error", 0, DL_INFO);
diff --git a/rkward/robjectviewer.cpp b/rkward/robjectviewer.cpp
index 9deeb631..adc0ed9b 100644
--- a/rkward/robjectviewer.cpp
+++ b/rkward/robjectviewer.cpp
@@ -31,6 +31,7 @@
 #include "rkglobals.h"
 #include "core/robject.h"
 #include "misc/rkdummypart.h"
+#include "../misc/rkcommonfunctions.h"
 
 #include "debug.h"
 
@@ -47,8 +48,7 @@ RObjectViewer::RObjectViewer (QWidget *parent, RObject *object, ViewerPage initi
 	QVBoxLayout *layout = new QVBoxLayout (this);
 	layout->setContentsMargins (0, 0, 0, 0);
 
-	description_label = new QLabel (this);
-	description_label->setWordWrap (true);
+	description_label = RKCommonFunctions::wordWrappedLabel (QString ());
 	layout->addWidget (description_label);
 	status_label = new QLabel (this);
 	status_label->hide ();
diff --git a/rkward/settings/rksettingsmodulecommandeditor.cpp b/rkward/settings/rksettingsmodulecommandeditor.cpp
index 9cf1c93b..f1a940b0 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.cpp
+++ b/rkward/settings/rksettingsmodulecommandeditor.cpp
@@ -53,9 +53,7 @@ RKSettingsModuleCommandEditor::RKSettingsModuleCommandEditor (RKSettings *gui, Q
 	RK_TRACE (SETTINGS);
 
 	QVBoxLayout* main_vbox = new QVBoxLayout (this);
-	QLabel *label = new QLabel (i18n ("Settings marked with (*) do not take effect until you restart RKWard"), this);
-	label->setWordWrap (true);
-	main_vbox->addWidget (label);
+	main_vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Settings marked with (*) do not take effect until you restart RKWard")));
 	main_vbox->addSpacing (2 * RKGlobals::spacingHint ());
 
 	QGroupBox* group = new QGroupBox (i18n ("Code Completion / Code Hints"), this);
@@ -149,13 +147,13 @@ RKSettingsModuleCommandEditor::RKSettingsModuleCommandEditor (RKSettings *gui, Q
 	form_layout = new QFormLayout (group);
 	num_recent_files_box = new RKSpinBox (group);
 	num_recent_files_box->setIntMode (1, INT_MAX, num_recent_files);
-	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, label);
+	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, &RKSettingsModuleCommandEditor::settingChanged);
 	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, label);
+	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, &RKSettingsModuleCommandEditor::settingChanged);
 	form_layout->addRow (i18n ("R script file filters (separated by spaces)"), script_file_filter_box);
 
diff --git a/rkward/settings/rksettingsmoduledebug.cpp b/rkward/settings/rksettingsmoduledebug.cpp
index fc6acd30..b0260bd3 100644
--- a/rkward/settings/rksettingsmoduledebug.cpp
+++ b/rkward/settings/rksettingsmoduledebug.cpp
@@ -29,6 +29,7 @@
 #include <QTemporaryFile>
 
 #include "../misc/rkspinbox.h"
+#include "../misc/rkcommonfunctions.h"
 #include "../rkglobals.h"
 #include "../debug.h"
 
@@ -37,13 +38,11 @@ RKSettingsModuleDebug::RKSettingsModuleDebug (RKSettings *gui, QWidget *parent)
 
 	QVBoxLayout* main_vbox = new QVBoxLayout (this);
 
-	QLabel* label = new QLabel (i18n ("<b>These settings are for debugging purposes, only.</b> It is safe to leave them untouched. Also, these settings will only apply to the current session, and will not be saved."), this);
-	label->setWordWrap (true);
-	main_vbox->addWidget (label);
+	main_vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("<b>These settings are for debugging purposes, only.</b> It is safe to leave them untouched. Also, these settings will only apply to the current session, and will not be saved.")));
 
 	main_vbox->addSpacing (2 * RKGlobals::spacingHint ());
 
-	label = new QLabel (i18n ("Debug level"), this);
+	QLabel* label = new QLabel (i18n ("Debug level"), this);
 	debug_level_box = new RKSpinBox (this);
 	debug_level_box->setIntMode (DL_TRACE, DL_FATAL, DL_FATAL - RK_Debug::RK_Debug_Level);
 	connect (debug_level_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RKSettingsModuleDebug::settingChanged);
diff --git a/rkward/settings/rksettingsmodulegeneral.cpp b/rkward/settings/rksettingsmodulegeneral.cpp
index 57759727..464239d6 100644
--- a/rkward/settings/rksettingsmodulegeneral.cpp
+++ b/rkward/settings/rksettingsmodulegeneral.cpp
@@ -59,9 +59,7 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
 	RK_TRACE (SETTINGS);
 
 	QVBoxLayout *main_vbox = new QVBoxLayout (this);
-	QLabel *label = new QLabel (i18n ("Settings marked with (*) do not take effect until you restart RKWard"), this);
-	label->setWordWrap (true);
-	main_vbox->addWidget (label);
+	main_vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Settings marked with (*) do not take effect until you restart RKWard")));
 
 	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
 
@@ -109,9 +107,7 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
 
 	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
 
-	label = new QLabel (i18n ("The workplace layout (i.e. which script-, data-, help-windows are open) may be saved (and loaded) per R workspace, or independent of the R workspace. Which do you prefer?"), this);
-	label->setWordWrap (true);
-	main_vbox->addWidget (label);
+	main_vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("The workplace layout (i.e. which script-, data-, help-windows are open) may be saved (and loaded) per R workspace, or independent of the R workspace. Which do you prefer?")));
 
 	workplace_save_chooser = new QButtonGroup (this);
 	group_box = new QGroupBox (this);
@@ -140,7 +136,7 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
 
 	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
 
-	label = new QLabel (i18n ("Warn when editing objects with more than this number of fields (0 for no limit):"), this);
+	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"));
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 6aa28e9f..7aa90037 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -57,9 +57,7 @@ RKSettingsModulePlugins::RKSettingsModulePlugins (RKSettings *gui, QWidget *pare
 	
 	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
 	
-	QLabel *label = new QLabel (i18n ("Some plugins are available with both, a wizard-like interface and a traditional dialog interface. If both are available, which mode of presentation do you prefer?"), this);
-	label->setWordWrap (true);
-	main_vbox->addWidget (label);
+	main_vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Some plugins are available with both, a wizard-like interface and a traditional dialog interface. If both are available, which mode of presentation do you prefer?")));
 
 
 	QGroupBox* button_box = new QGroupBox (this);
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index 638a9ec9..88edf357 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -70,9 +70,7 @@ RKSettingsModuleR::RKSettingsModuleR (RKSettings *gui, QWidget *parent) : RKSett
 
 	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
 
-	QLabel *label = new QLabel (i18n ("The following settings mostly affect R behavior in the console. It is generally safe to keep these unchanged."), this);
-	label->setWordWrap (true);
-	main_vbox->addWidget (label);
+	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);
@@ -267,9 +265,7 @@ void RKSettingsModuleR::addPaths(QStringList* string_list) {
 	QDialog dialog (this);
 	dialog.setWindowTitle (i18n ("Add System Path Directory"));
 	QVBoxLayout *layout = new QVBoxLayout (&dialog);
-	QLabel *label = new QLabel (i18n ("Specify or select directory to add to the system file path of the running R session"));
-	label->setWordWrap (true);
-	layout->addWidget (label);
+	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);
@@ -490,11 +486,9 @@ void RKSettingsModuleRPackages::addLibLoc (QStringList *string_list) {
 	QDialog dialog (this);
 	dialog.setWindowTitle (i18n ("Add R Library Directory"));
 	QVBoxLayout *layout = new QVBoxLayout (&dialog);
-	QLabel *label = new QLabel (i18n ("Specify or select library location to add.\nNote that locations may contain a '%v', which will expand to the first "
+	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."));
-	label->setWordWrap (true);
-	layout->addWidget (label);
+	                                  "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"));
@@ -691,13 +685,11 @@ void RKSettingsModuleRPackages::validateSettingsInteractive (QList<RKSettingsWiz
 			RKSettingsWizardPage *page = new RKSettingsWizardPage ();
 			page->setWindowTitle (i18n ("Unversioned library location"));
 			QVBoxLayout *layout = new QVBoxLayout (page);
-			QLabel *label = new QLabel (i18n ("The configured library locations (where R packages will be installed on this system) contains the directory '%1', "
+			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 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.", legacy_libloc));
-			label->setWordWrap (true);
-			layout->addWidget (label);
+			                                  "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 ();
@@ -705,12 +697,10 @@ void RKSettingsModuleRPackages::validateSettingsInteractive (QList<RKSettingsWiz
 			                                        "re-install any packages that you want to keep."));
 			removelabel->setWordWrap (true);
 			QRadioButton *renamebutton = new QRadioButton ();
-			QLabel *renamelabel = new QLabel (i18n ("<b>Rename</b> this location to include the version number of the currently running R. Packages will continue "
+			QLabel *renamelabel = RKCommonFunctions::wordWrappedLabel (i18n ("<b>Rename</b> 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)."));
-			renamelabel->setWordWrap (true);
 			QRadioButton *keepbutton = new QRadioButton ();
-			QLabel *keeplabel = new QLabel (i18n ("<b>Keep</b> this location (do not change anything)."));
-			keeplabel->setWordWrap (true);
+			QLabel *keeplabel = RKCommonFunctions::wordWrappedLabel (i18n ("<b>Keep</b> this location (do not change anything)."));
 			QGridLayout *group_layout = new QGridLayout (group);
 			group_layout->addWidget (removebutton, 0, 0);
 			group_layout->addWidget (removelabel, 0, 1);
diff --git a/rkward/settings/rksettingsmodulewatch.cpp b/rkward/settings/rksettingsmodulewatch.cpp
index af0e43ed..94277015 100644
--- a/rkward/settings/rksettingsmodulewatch.cpp
+++ b/rkward/settings/rksettingsmodulewatch.cpp
@@ -27,6 +27,7 @@
 #include <QSpinBox>
 
 #include "../rbackend/rcommand.h"
+#include "../misc/rkcommonfunctions.h"
 #include "rksettings.h"
 #include "../rkglobals.h"
 
@@ -120,25 +121,20 @@ RKSettingsModuleWatch::RKSettingsModuleWatch (RKSettings *gui, QWidget *parent)
 
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 
-	QLabel *label = new QLabel (i18n ("For now, settings only apply to new commands. All previous commands remain visible/invisible."), this);
-	label->setWordWrap (true);
+	QLabel *label = RKCommonFunctions::wordWrappedLabel (i18n ("For now, settings only apply to new commands. All previous commands remain visible/invisible."));
 	vbox->addWidget (label);
 	vbox->addSpacing (10);
 	
 	QGridLayout *grid = new QGridLayout ();
 	vbox->addLayout (grid);
 
-	label = new QLabel (i18n ("always show command"), this);
-	label->setWordWrap (true);
+	label = RKCommonFunctions::wordWrappedLabel (i18n ("always show command"));
 	grid->addWidget (label, 0, 1);
-	label = new QLabel (i18n ("always show result"), this);
-	label->setWordWrap (true);
+	label = RKCommonFunctions::wordWrappedLabel (i18n ("always show result"));
 	grid->addWidget (label, 0, 2);
-	label = new QLabel (i18n ("show errors"), this);
-	label->setWordWrap (true);
+	label = RKCommonFunctions::wordWrappedLabel (i18n ("show errors"));
 	grid->addWidget (label, 0, 3);
-	label = new QLabel (i18n ("show/raise window"), this);
-	label->setWordWrap (true);
+	label = RKCommonFunctions::wordWrappedLabel (i18n ("show/raise window"));
 	grid->addWidget (label, 0, 4);
 	
 	user_filter_boxes = addFilterSettings (this, grid, 1, i18n ("User commands"), user_filter);
diff --git a/rkward/windows/rkcallstackviewer.cpp b/rkward/windows/rkcallstackviewer.cpp
index 17e520ad..190c463d 100644
--- a/rkward/windows/rkcallstackviewer.cpp
+++ b/rkward/windows/rkcallstackviewer.cpp
@@ -26,6 +26,7 @@
 #include <QTextDocument>
 
 #include "../misc/rkdummypart.h"
+#include "../misc/rkcommonfunctions.h"
 #include "../agents/rkdebughandler.h"
 #include "rkcommandeditorwindow.h"
 
@@ -106,8 +107,7 @@ RKCallstackViewerWidget::RKCallstackViewerWidget (QWidget *parent) : QWidget (pa
 	h_layout->addLayout (v_layout);
 	h_layout->setStretchFactor (v_layout, 2);
 
-	frame_info = new QLabel (this);
-	frame_info->setWordWrap (true);
+	frame_info = RKCommonFunctions::wordWrappedLabel (QString ());
 	v_layout->addWidget (frame_info);
 
 	frame_source = new RKCommandEditorWindow (this, QUrl (), QString (), RKCommandEditorFlags::DefaultToRHighlighting | RKCommandEditorFlags::ReadOnly);
diff --git a/rkward/windows/rkworkplace.h b/rkward/windows/rkworkplace.h
index 52ec1c53..3efc63e3 100644
--- a/rkward/windows/rkworkplace.h
+++ b/rkward/windows/rkworkplace.h
@@ -114,6 +114,9 @@ public:
 
 /** Opens the given url in the appropriate way. */
 	bool openAnyUrl (const QUrl &url, const QString &known_mimetype = QString (), bool force_external=false);
+/** Convenience alternative to openAnyUrl. You will usually use openAnyUrl, unless
+ *  connecting to signals that pass the url as string. */
+	bool openAnyUrlString (const QString &urlstring) { return openAnyUrl (QUrl (urlstring)); };
 
 /** Opens a new script editor
 @param url URL to load. Default option is to open an empty document



More information about the rkward-tracker mailing list