[Tux4kids-commits] r1153 - tux4kids-admin/trunk/tux4kids-admin/src

Michał Świtakowski swistakers-guest at alioth.debian.org
Tue Jul 7 09:35:39 UTC 2009


Author: swistakers-guest
Date: 2009-07-07 09:35:37 +0000 (Tue, 07 Jul 2009)
New Revision: 1153

Modified:
   tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h
   tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h
Log:
improved usability of plugin manager dialog

Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp	2009-07-07 00:40:23 UTC (rev 1152)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp	2009-07-07 09:35:37 UTC (rev 1153)
@@ -81,3 +81,8 @@
 	return result;
 }
 
+QPluginLoader &PluginManager::operator[](int i)
+{
+	return *plugins[i];
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h	2009-07-07 00:40:23 UTC (rev 1152)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h	2009-07-07 09:35:37 UTC (rev 1153)
@@ -22,6 +22,7 @@
 	void setPluginsPath(QString pluginsPath);
 	bool load(int pluginIndex);
 	bool unload(int pluginIndex);
+	QPluginLoader &operator[](int i);
 
 private:
 	QString m_pluginsPath;

Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp	2009-07-07 00:40:23 UTC (rev 1152)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp	2009-07-07 09:35:37 UTC (rev 1153)
@@ -9,6 +9,9 @@
 
 	m_ui->pluginsList->setModel(m_pluginManager);
 
+	setButtons();
+
+	connect(m_ui->pluginsList->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(pluginSelectionChanged(QItemSelection,QItemSelection)));
 	connect(m_ui->loadButton, SIGNAL(clicked()), this, SLOT(loadClicked()));
 	connect(m_ui->unloadButton, SIGNAL(clicked()), this, SLOT(unloadClicked()));
 }
@@ -36,6 +39,7 @@
 	if (!m_pluginManager->load(index)) {
 		//report error
 	}
+	setButtons();
 }
 
 void PluginManagerDialog::unloadClicked()
@@ -44,5 +48,28 @@
 	if (!m_pluginManager->unload(index)) {
 		//report error
 	}
+	setButtons();
 }
 
+void PluginManagerDialog::pluginSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
+{
+	setButtons();
+}
+
+void PluginManagerDialog::setButtons()
+{
+	if (m_ui->pluginsList->selectionModel()->selectedIndexes().empty()) {
+		m_ui->loadButton->setEnabled(false);
+		m_ui->unloadButton->setEnabled(false);
+	} else {
+		int index = m_ui->pluginsList->selectionModel()->selectedIndexes().first().row();
+		if ((*m_pluginManager)[index].isLoaded()) {
+			m_ui->loadButton->setEnabled(false);
+			m_ui->unloadButton->setEnabled(true);
+		} else {
+			m_ui->loadButton->setEnabled(true);
+			m_ui->unloadButton->setEnabled(false);
+		}
+	}
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h	2009-07-07 00:40:23 UTC (rev 1152)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h	2009-07-07 09:35:37 UTC (rev 1153)
@@ -2,6 +2,7 @@
 #define PLUGINMANAGERDIALOG_H
 
 #include <QtGui/QDialog>
+#include <QItemSelection>
 
 #include "pluginManager.h"
 
@@ -24,10 +25,12 @@
 	Ui::PluginManagerDialog *m_ui;
 	PluginManager *m_pluginManager;
 
+	void setButtons();
+
 private slots:
 	void loadClicked();
 	void unloadClicked();
-
+	void pluginSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
 };
 
 #endif // PLUGINMANAGERDIALOG_H




More information about the Tux4kids-commits mailing list