[rkward-cvs] [rkward/development/plugin_management_to_loadlibs] rkward: Move pluginmap management to the load libs dialog for good.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Dec 31 21:02:48 UTC 2014


Git commit 55da894fc726f903d84f54ccf70ed909a62fffdf by Thomas Friedrichsmeier.
Committed on 31/12/2014 at 20:56.
Pushed by tfry into branch 'development/plugin_management_to_loadlibs'.

Move pluginmap management to the load libs dialog for good.

M  +41   -16   rkward/dialogs/rkloadlibsdialog.cpp
M  +5    -0    rkward/dialogs/rkloadlibsdialog.h
M  +17   -15   rkward/settings/rksettingsmoduleplugins.cpp
M  +4    -2    rkward/settings/rksettingsmoduleplugins.h

http://commits.kde.org/rkward/55da894fc726f903d84f54ccf70ed909a62fffdf

diff --git a/rkward/dialogs/rkloadlibsdialog.cpp b/rkward/dialogs/rkloadlibsdialog.cpp
index 63c6078..fd6df3d 100644
--- a/rkward/dialogs/rkloadlibsdialog.cpp
+++ b/rkward/dialogs/rkloadlibsdialog.cpp
@@ -64,13 +64,13 @@ RKLoadLibsDialog::RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool
 	setButtons (KDialog::Ok | KDialog::Apply | KDialog::Cancel);
 
 	LoadUnloadWidget *luwidget = new LoadUnloadWidget (this);
-	addPage (luwidget, i18n ("Local packages"));
+	addChild (luwidget, i18n ("Local packages"));
 	connect (this, SIGNAL (installedPackagesChanged()), luwidget, SLOT (updateInstalledPackages()));
 
 	install_packages_widget = new InstallPackagesWidget (this);
-	install_packages_pageitem = addPage (install_packages_widget, i18n ("Install / Update / Remove"));
+	install_packages_pageitem = addChild (install_packages_widget, i18n ("Install / Update / Remove"));
 
-	addPage (new RKPluginMapSelectionWidget (this), i18n ("Manage Plugins"));
+	configure_pluginmaps_pageitem = addChild (new RKPluginMapSelectionWidget (this), i18n ("Manage Plugins"));
 
 	connect (this, SIGNAL (currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)), this, SLOT (slotPageChanged()));
 	QTimer::singleShot (0, this, SLOT (slotPageChanged()));
@@ -87,6 +87,16 @@ RKLoadLibsDialog::~RKLoadLibsDialog () {
 	else KPageDialog::reject ();
 }
 
+KPageWidgetItem* RKLoadLibsDialog::addChild (QWidget *child_page, const QString &caption) {
+	RK_TRACE (DIALOGS);
+
+	connect (this, SIGNAL (okClicked()), child_page, SLOT (ok()));
+	connect (this, SIGNAL (applyClicked()), child_page, SLOT (apply()));
+	connect (this, SIGNAL (cancelClicked()), child_page, SLOT (cancel()));
+	connect (child_page, SIGNAL (destroyed()), this, SLOT (childDeleted()));
+	return addPage (child_page, caption);
+}
+
 void RKLoadLibsDialog::slotPageChanged () {
 	RK_TRACE (DIALOGS);
 
@@ -106,6 +116,15 @@ void RKLoadLibsDialog::showInstallPackagesModal (QWidget *parent, RCommandChain
 	RK_TRACE (DIALOGS);
 }
 
+// static
+void RKLoadLibsDialog::showPluginmapConfig (QWidget* parent, RCommandChain* chain) {
+	RK_TRACE (DIALOGS);
+
+	RKLoadLibsDialog *dialog = new RKLoadLibsDialog (parent, chain, false);
+	dialog->setCurrentPage (dialog->configure_pluginmaps_pageitem);
+	dialog->show ();
+}
+
 void RKLoadLibsDialog::automatedInstall () {
 	RK_TRACE (DIALOGS);
 
@@ -429,11 +448,6 @@ LoadUnloadWidget::LoadUnloadWidget (RKLoadLibsDialog *dialog) : QWidget (0) {
 	connect (loaded_view, SIGNAL (itemSelectionChanged()), this, SLOT (updateButtons()));
 	connect (installed_view, SIGNAL (itemSelectionChanged()), this, SLOT (updateButtons()));
 
-	connect (dialog, SIGNAL (okClicked()), this, SLOT (ok()));
-	connect (dialog, SIGNAL (applyClicked()), this, SLOT (apply()));
-	connect (dialog, SIGNAL (cancelClicked()), this, SLOT (cancel()));
-	connect (this, SIGNAL (destroyed()), dialog, SLOT (childDeleted()));
-
 	updateInstalledPackages ();
 	updateButtons ();
 }
@@ -674,11 +688,6 @@ InstallPackagesWidget::InstallPackagesWidget (RKLoadLibsDialog *dialog) : QWidge
 	buttonvbox->addStretch (1);
 	buttonvbox->addWidget (install_params);
 	buttonvbox->addStretch (1);
-
-	connect (dialog, SIGNAL (okClicked()), this, SLOT (ok()));
-	connect (dialog, SIGNAL (applyClicked()), this, SLOT (apply()));
-	connect (dialog, SIGNAL (cancelClicked()), this, SLOT (cancel()));
-	connect (this, SIGNAL (destroyed()), dialog, SLOT (childDeleted()));
 }
 
 InstallPackagesWidget::~InstallPackagesWidget () {
@@ -1207,6 +1216,7 @@ void RKRPackageInstallationStatusSortFilterModel::setRKWardOnly (bool only) {
 RKPluginMapSelectionWidget::RKPluginMapSelectionWidget (RKLoadLibsDialog* dialog) : QWidget (dialog) {
 	RK_TRACE (DIALOGS);
 	model = 0;
+	changes_pending = false;
 
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
@@ -1226,21 +1236,36 @@ void RKPluginMapSelectionWidget::activated () {
 		model = new RKSettingsModulePluginsModel (this);
 		model->init (RKSettingsModulePlugins::knownPluginmaps ());
 		selector->setModel (model, 1);
+		connect (selector, SIGNAL (insertNewStrings(int)), model, SLOT (insertNewStrings(int)));
+		connect (selector, SIGNAL (swapRows(int,int)), model, SLOT (swapRows(int,int)));
+		connect (selector, SIGNAL (listChanged()), this, SLOT (changed()));
 	}
 }
 
 void RKPluginMapSelectionWidget::apply () {
+	RK_TRACE (DIALOGS);
 
+	if (!changes_pending) return;
+	RK_ASSERT (model);
+	RKSettingsModulePlugins::PluginMapList new_list = RKSettingsModulePlugins::setPluginMaps (model->pluginMaps ());
+	selector->setModel (0); // we don't want any extra change notification for this
+	model->init (new_list);
+	selector->setModel (model, 1);
+	changes_pending = false;
 }
 
 void RKPluginMapSelectionWidget::cancel () {
-
+	RK_TRACE (DIALOGS);
+	deleteLater ();
 }
 
 void RKPluginMapSelectionWidget::ok () {
+	RK_TRACE (DIALOGS);
 
+	if (!changes_pending) return;
+	RK_ASSERT (model);
+	RKSettingsModulePlugins::setPluginMaps (model->pluginMaps ());
+	deleteLater ();
 }
 
-
 #include "rkloadlibsdialog.moc"
-
diff --git a/rkward/dialogs/rkloadlibsdialog.h b/rkward/dialogs/rkloadlibsdialog.h
index d8cbc25..3809363 100644
--- a/rkward/dialogs/rkloadlibsdialog.h
+++ b/rkward/dialogs/rkloadlibsdialog.h
@@ -63,6 +63,7 @@ public:
 @param chain RCommandChain to run the necessary commands in
 @param package_name name of the required package */
 	static void showInstallPackagesModal (QWidget *parent, RCommandChain *chain, const QString &package_name);
+	static void showPluginmapConfig (QWidget *parent=0, RCommandChain *chain=0);
 	QStringList currentLibraryLocations ()  const { return library_locations; };
 signals:
 	void downloadComplete ();
@@ -87,12 +88,14 @@ private:
 	void addLibraryLocation (const QString &new_loc);
 	void tryDestruct ();
 	void runInstallationCommand (const QString& command, bool as_root, const QString& message, const QString& title);
+	KPageWidgetItem* addChild (QWidget *child_page, const QString &caption);
 friend class LoadUnloadWidget;
 friend class InstallPackagesWidget;
 	RCommandChain *chain;
 
 	InstallPackagesWidget *install_packages_widget;	// needed for automated installation
 	KPageWidgetItem *install_packages_pageitem;
+	KPageWidgetItem *configure_pluginmaps_pageitem;
 
 	QStringList library_locations;
 
@@ -297,9 +300,11 @@ public slots:
 	void apply ();
 	void cancel ();
 	void activated ();
+	void changed () { changes_pending = true; };
 private:
 	RKMultiStringSelectorV2* selector;
 	RKSettingsModulePluginsModel* model;
+	bool changes_pending;
 };
 
 #endif
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 0d6ca52..9f9ea79 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -22,9 +22,6 @@
 #include <kmessagebox.h>
 #include <khbox.h>
 #include <kdeversion.h>
-#include <ktar.h>
-#include <kzip.h>
-#include <kio/deletejob.h>
 
 #include <qlayout.h>
 #include <qlabel.h>
@@ -42,6 +39,7 @@
 #include "../misc/rkspinbox.h"
 #include "../misc/xmlhelper.h"
 #include "../plugin/rkcomponentmap.h"
+#include "../dialogs/rkloadlibsdialog.h"
 #include "rksettingsmodulegeneral.h"
 
 #include "../debug.h"
@@ -107,15 +105,11 @@ RKSettingsModulePlugins::RKSettingsModulePlugins (RKSettings *gui, QWidget *pare
 
 	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
 
+	QPushButton *pluginmap_config_button = new QPushButton (i18n ("Configure Active Plugins"), this);
+	connect (pluginmap_config_button, SIGNAL (clicked()), this, SLOT (configurePluginmaps()));
+	main_vbox->addWidget (pluginmap_config_button);
 
-	map_choser = new RKMultiStringSelectorV2 (i18n ("Select .pluginmap file(s)"), this);
-	map_model = new RKSettingsModulePluginsModel (this);
-	map_model->init (known_plugin_maps);
-	map_choser->setModel (map_model, 1);
-	connect (map_choser, SIGNAL (insertNewStrings(int)), map_model, SLOT (insertNewStrings(int)));
-	connect (map_choser, SIGNAL (swapRows(int,int)), map_model, SLOT (swapRows(int,int)));
-	connect (map_choser, SIGNAL (listChanged()), this, SLOT (settingChanged()));
-	main_vbox->addWidget (map_choser);
+	main_vbox->addStretch ();
 }
 
 RKSettingsModulePlugins::~RKSettingsModulePlugins() {
@@ -135,16 +129,24 @@ QString RKSettingsModulePlugins::caption () {
 void RKSettingsModulePlugins::applyChanges () {
 	RK_TRACE (SETTINGS);
 
-	known_plugin_maps = map_model->pluginMaps ();
 	interface_pref = static_cast<PluginPrefs> (button_group->checkedId ());
 	show_code = show_code_box->isChecked ();
 	code_size = code_size_box->intValue ();
+}
+
+RKSettingsModulePlugins::PluginMapList RKSettingsModulePlugins::setPluginMaps (const RKSettingsModulePlugins::PluginMapList new_list) {
+	RK_TRACE (SETTINGS);
 
+	known_plugin_maps = new_list;
 	fixPluginMapLists ();
 	RKWardMainWindow::getMain ()->initPlugins();
-	map_choser->setModel (0);	// we don't want any extra change notification for this
-	map_model->init (known_plugin_maps);
-	map_choser->setModel (map_model, 1);
+	return known_plugin_maps;
+}
+
+void RKSettingsModulePlugins::configurePluginmaps () {
+	RK_TRACE (SETTINGS);
+
+	RKLoadLibsDialog::showPluginmapConfig (this, commandChain ());
 }
 
 void RKSettingsModulePlugins::save (KConfig *config) {
diff --git a/rkward/settings/rksettingsmoduleplugins.h b/rkward/settings/rksettingsmoduleplugins.h
index 91998ce..7f690ea 100644
--- a/rkward/settings/rksettingsmoduleplugins.h
+++ b/rkward/settings/rksettingsmoduleplugins.h
@@ -87,9 +87,8 @@ public:
 	static void parsePluginMapBasics (const QString &filename, QString *id, int *priority);
 public slots:
 	void settingChanged ();
+	void configurePluginmaps ();
 private:
-	RKMultiStringSelectorV2 *map_choser;
-	RKSettingsModulePluginsModel *map_model;
 	QButtonGroup *button_group;
 	QCheckBox *show_code_box;
 	RKSpinBox *code_size_box;
@@ -104,6 +103,9 @@ private:
 /* TODO: This one is currently unused (leftover of GHNS-based plugin installation), but might still be of interest */
 	static QStringList findPluginMapsRecursive (const QString &basedir);
 	static void fixPluginMapLists ();
+friend class RKPluginMapSelectionWidget;
+/** Sets the new list of plugins. Potentially removes unreadable ones, and returns the effective list. */
+	static PluginMapList setPluginMaps (const PluginMapList new_list);
 };
 
 class RKSettingsModulePluginsModel : public QAbstractTableModel {





More information about the rkward-tracker mailing list