[rkward] rkward: WIP: Add settings page for kate plugins.
Thomas Friedrichsmeier
null at kde.org
Sat Mar 28 08:14:08 GMT 2020
Git commit 00a0aa8e5d24a93847c96ead26de7fb241ce2e36 by Thomas Friedrichsmeier.
Committed on 28/03/2020 at 08:13.
Pushed by tfry into branch 'master'.
WIP: Add settings page for kate plugins.
Add settings links in some labels.
M +0 -1 rkward/dialogs/rkreadlinedialog.cpp
M +2 -1 rkward/settings/CMakeLists.txt
M +33 -6 rkward/settings/rksettings.cpp
M +5 -1 rkward/settings/rksettings.h
A +89 -0 rkward/settings/rksettingsmodulekateplugins.cpp [License: GPL (v2+)]
A +53 -0 rkward/settings/rksettingsmodulekateplugins.h [License: GPL (v2+)]
M +2 -2 rkward/settings/rksettingsmoduleplugins.cpp
M +1 -2 rkward/settings/rksettingsmoduler.cpp
M +1 -0 rkward/windows/katepluginintegration.h
M +3 -1 rkward/windows/rkhtmlwindow.cpp
https://commits.kde.org/rkward/00a0aa8e5d24a93847c96ead26de7fb241ce2e36
diff --git a/rkward/dialogs/rkreadlinedialog.cpp b/rkward/dialogs/rkreadlinedialog.cpp
index f8631f16..89178766 100644
--- a/rkward/dialogs/rkreadlinedialog.cpp
+++ b/rkward/dialogs/rkreadlinedialog.cpp
@@ -70,7 +70,6 @@ RKReadLineDialog::RKReadLineDialog (QWidget *parent, const QString &caption, con
}
QLabel *promptl = RKCommonFunctions::wordWrappedLabel (prompt);
- promptl->setWordWrap (true);
layout->addWidget (promptl);
input = new QLineEdit (QString (), this);
diff --git a/rkward/settings/CMakeLists.txt b/rkward/settings/CMakeLists.txt
index c091e63b..951114dd 100644
--- a/rkward/settings/CMakeLists.txt
+++ b/rkward/settings/CMakeLists.txt
@@ -9,6 +9,7 @@ SET(settings_STAT_SRCS
rksettingsmodulegeneral.cpp
rksettingsmoduleoutput.cpp
rksettingsmodulegraphics.cpp
+ rksettingsmodulekateplugins.cpp
rksettingsmoduleplugins.cpp
rksettingsmoduler.cpp
rksettingsmodulewatch.cpp
@@ -28,4 +29,4 @@ IF (WIN32 OR USE_BINARY_PACKAGES)
ENDIF (WIN32 OR USE_BINARY_PACKAGES)
ADD_LIBRARY(settings STATIC ${settings_STAT_SRCS})
-TARGET_LINK_LIBRARIES(settings Qt5::Widgets KF5::WidgetsAddons Qt5::Xml KF5::ConfigCore KF5::Parts)
+TARGET_LINK_LIBRARIES(settings Qt5::Widgets KF5::WidgetsAddons Qt5::Xml KF5::ConfigCore KF5::Parts KF5::TextEditor)
diff --git a/rkward/settings/rksettings.cpp b/rkward/settings/rksettings.cpp
index 8f85cc37..9270cadc 100644
--- a/rkward/settings/rksettings.cpp
+++ b/rkward/settings/rksettings.cpp
@@ -2,7 +2,7 @@
rksettings - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004-2018 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -25,6 +25,7 @@
// modules
#include "rksettingsmoduleplugins.h"
+#include "rksettingsmodulekateplugins.h"
#include "rksettingsmoduler.h"
#include "rksettingsmodulegeneral.h"
#include "rksettingsmoduleoutput.h"
@@ -93,10 +94,24 @@ RKSettings::~RKSettings() {
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 <QLabel>
+
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));
@@ -108,17 +123,29 @@ void RKSettings::initModules () {
modules.insert (PageObjectBrowser, new RKSettingsModuleObjectBrowser (this, 0));
modules.insert (PageDebug, new RKSettingsModuleDebug (this, 0));
- ModuleMap::const_iterator it;
- for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
- pages[it.key ()-1] = addPage (it.value (), it.value ()->caption ());
- }
+ QLabel *l = new QLabel(i18n("<h1>Add-ons</h1><p>RKWard add-ons come in a variety of forms, each with their own configuration options:</p><h2>R packages</h2><p><a href=\"rkward://settings/rpackages\">Add-ons to the R language itself</a>. These are usually downloaded from \"CRAN\". Some of these add-on packages may additionally contain RKWard plugins.</p><h2>RKWard plugins</h2><p><a href=\"rkward://settings/plugins\">Graphical dialogs to R functionality</a>. 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 <a href=\"https://api.kde.org/doc/rkwardplugins/\">create your own custom dialogs as plugins</a>!</p><h2>Kate plugins</h2><p><a href=\"rkward://settings/kateplugins\">Plugins developed for Kate / KTextEditor</a>. 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.</p>"));
+ 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 - 1]);
+ setCurrentPage (pages[(int) page]);
}
}
diff --git a/rkward/settings/rksettings.h b/rkward/settings/rksettings.h
index d7fba4db..a15cba3f 100644
--- a/rkward/settings/rksettings.h
+++ b/rkward/settings/rksettings.h
@@ -2,7 +2,7 @@
rksettings - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004-2018 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -37,7 +37,9 @@ class RKSettings : public KPageDialog {
public:
enum SettingsPage {
NoPage=0,
+ SuperPageAddons,
PagePlugins,
+ PageKatePlugins,
PageR,
PageRPackages,
PageGeneral,
@@ -83,6 +85,8 @@ private:
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
diff --git a/rkward/settings/rksettingsmodulekateplugins.cpp b/rkward/settings/rksettingsmodulekateplugins.cpp
new file mode 100644
index 00000000..dd6e105c
--- /dev/null
+++ b/rkward/settings/rksettingsmodulekateplugins.cpp
@@ -0,0 +1,89 @@
+/***************************************************************************
+ rksettingsmodulekateplugins - description
+ -------------------
+ begin : Thu Mar 26 2010
+ copyright : (C) 2020 by Thomas Friedrichsmeier
+ email : thomas.friedrichsmeier at 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 "rksettingsmodulekateplugins.h"
+
+#include <QTreeWidget>
+#include <QVBoxLayout>
+#include <KPluginMetaData>
+#include <KLocalizedString>
+#include <QLabel>
+
+#include "../windows/katepluginintegration.h"
+#include "../misc/rkcommonfunctions.h"
+#include "../rkward.h"
+
+#include "../debug.h"
+
+QStringList RKSettingsModuleKatePlugins::plugins_to_load;
+
+RKSettingsModuleKatePlugins::RKSettingsModuleKatePlugins (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
+ RK_TRACE (SETTINGS);
+
+ QVBoxLayout *vbox = new QVBoxLayout (this);
+ vbox->setContentsMargins (0, 0, 0, 0);
+ vbox->addWidget (RKCommonFunctions::wordWrappedLabel (i18n ("Kate plugins to load in RKWard. Note that some loaded plugins will not become visible until certain conditions are met, e.g. you are loading a version controlled file for the <i>Project</i> plugin. Also, not all plugins listed here may make much sense in the context of RKWard.")));
+
+ plugin_table = new QTreeWidget ();
+ plugin_table->setHeaderLabels (QStringList () << QString () << i18n ("Name") << i18n ("Description"));
+ KatePluginIntegrationApp *pluginapp = RKWardMainWindow::getMain()->katePluginIntegration ();
+ foreach (const QString &key, pluginapp->known_plugins.keys()) {
+ QTreeWidgetItem *item = new QTreeWidgetItem();
+ KPluginMetaData plugindata = pluginapp->known_plugins.value (key).data;
+ item->setData (1, Qt::DisplayRole, plugindata.name ());
+ item->setData (2, Qt::DisplayRole, plugindata.description ());
+ item->setData (1, Qt::DecorationRole, QIcon::fromTheme (plugindata.iconName ()));
+ item->setFlags (Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
+ item->setCheckState (0, plugins_to_load.contains (key) ? Qt::Checked : Qt::Unchecked);
+ plugin_table->addTopLevelItem (item);
+ }
+ plugin_table->resizeColumnToContents (0);
+ plugin_table->resizeColumnToContents (1);
+ vbox->addWidget (plugin_table);
+}
+
+RKSettingsModuleKatePlugins::~RKSettingsModuleKatePlugins () {
+ RK_TRACE (SETTINGS);
+}
+
+void RKSettingsModuleKatePlugins::applyChanges () {
+ RK_TRACE (SETTINGS);
+}
+
+void RKSettingsModuleKatePlugins::save (KConfig *config) {
+ RK_TRACE (SETTINGS);
+}
+
+void RKSettingsModuleKatePlugins::saveSettings (KConfig *config) {
+ RK_TRACE (SETTINGS);
+}
+
+void RKSettingsModuleKatePlugins::loadSettings (KConfig *config) {
+ RK_TRACE (SETTINGS);
+}
+
+QString RKSettingsModuleKatePlugins::caption () {
+ RK_TRACE (SETTINGS);
+
+ return i18n ("Kate Plugins");
+}
+
+void RKSettingsModuleKatePlugins::settingChanged () {
+ RK_TRACE (SETTINGS);
+ change ();
+}
+
diff --git a/rkward/settings/rksettingsmodulekateplugins.h b/rkward/settings/rksettingsmodulekateplugins.h
new file mode 100644
index 00000000..f9eb51a9
--- /dev/null
+++ b/rkward/settings/rksettingsmodulekateplugins.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ rksettingsmodulekateplugins - description
+ -------------------
+ begin : Thu Mar 26 2010
+ copyright : (C) 2020 by Thomas Friedrichsmeier
+ email : thomas.friedrichsmeier at 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 <QStringList>
+
+class QTreeWidget;
+
+/** The settings-module for kate plugin specific settings
+ at author Thomas Friedrichsmeier
+*/
+class RKSettingsModuleKatePlugins : public RKSettingsModule {
+ Q_OBJECT
+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<RKSettingsWizardPage*>*) {};
+
+ QString caption () override;
+
+ static QStringList pluginsToLoad () { return plugins_to_load; };
+public slots:
+ void settingChanged ();
+private:
+ QTreeWidget *plugin_table;
+
+ static QStringList plugins_to_load;
+};
+
+#endif
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 7aa90037..6f891ec8 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -2,7 +2,7 @@
rksettingsmoduleplugins - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004-2018 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -99,7 +99,7 @@ void RKSettingsModulePlugins::settingChanged () {
QString RKSettingsModulePlugins::caption () {
RK_TRACE (SETTINGS);
- return (i18n ("Plugins"));
+ return (i18n ("RKWard Plugins"));
}
void RKSettingsModulePlugins::applyChanges () {
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index 88edf357..fbada29f 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -693,9 +693,8 @@ void RKSettingsModuleRPackages::validateSettingsInteractive (QList<RKSettingsWiz
// 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 = new QLabel (i18n ("<b>Remove</b> this location from the configuration (it will not be deleted on disk). You will have to "
+ QLabel *removelabel = RKCommonFunctions::wordWrappedLabel (i18n ("<b>Remove</b> 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."));
- removelabel->setWordWrap (true);
QRadioButton *renamebutton = new QRadioButton ();
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)."));
diff --git a/rkward/windows/katepluginintegration.h b/rkward/windows/katepluginintegration.h
index f3abb307..aa948dfb 100644
--- a/rkward/windows/katepluginintegration.h
+++ b/rkward/windows/katepluginintegration.h
@@ -54,6 +54,7 @@ friend class KatePluginIntegrationWindow;
bool closeDocuments(const QList<KTextEditor::Document *> &documents);
KTextEditor::Plugin *plugin(const QString &name);
private:
+friend class RKSettingsModuleKatePlugins;
KatePluginIntegrationWindow *window; // For now, only one main window
KTextEditor::Application *app;
/** Provides a hidden dummy view (created on the fly as needed), for plugins that assume there is always at least one view/document around. */
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index d1b15541..ccb88b1b 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -2,7 +2,7 @@
rkhtmlwindow - description
-------------------
begin : Wed Oct 12 2005
- copyright : (C) 2005-2018 by Thomas Friedrichsmeier
+ copyright : (C) 2005-2020 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -347,6 +347,8 @@ bool RKHTMLWindow::handleRKWardURL (const QUrl &url, RKHTMLWindow *window) {
RKSettings::configureSettings (RKSettings::PageX11);
} else if (path == QStringLiteral ("browser")) {
RKSettings::configureSettings (RKSettings::PageObjectBrowser);
+ } else if (path == QStringLiteral ("rpackages")) {
+ RKSettings::configureSettings (RKSettings::PageRPackages);
} else {
RKSettings::configureSettings (RKSettings::NoPage);
}
More information about the rkward-tracker
mailing list