summaryrefslogtreecommitdiffstats
path: root/kommander/pluginmanager/mainwindow.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kommander/pluginmanager/mainwindow.cpp
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kommander/pluginmanager/mainwindow.cpp')
-rw-r--r--kommander/pluginmanager/mainwindow.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/kommander/pluginmanager/mainwindow.cpp b/kommander/pluginmanager/mainwindow.cpp
new file mode 100644
index 00000000..4cc67d62
--- /dev/null
+++ b/kommander/pluginmanager/mainwindow.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+ mainwindow.cpp - Kommander plugin manager mainwindow class implementation
+ -------------------
+ begin : Tue Aug 13 09:31:50 EST 2002
+ copyright : (C) 2004 by Marc Britton
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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 "mainwindow.h"
+#include "pluginmanager.h"
+
+#include <ktoolbar.h>
+#include <klistbox.h>
+#include <kconfig.h>
+#include <kfiledialog.h>
+#include <klibloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+
+MainWindow::MainWindow( QWidget* parent, const char *name, WFlags f )
+ : KMainWindow( parent, name, f )
+{
+ KToolBar *toolBar = new KToolBar( this );
+ toolBar->insertButton("fileopen", Add, true, i18n("Add") );
+ toolBar->insertButton("no", Remove, true, i18n("Remove") );
+ toolBar->insertButton("reload", Refresh, true, i18n("Refresh") );
+ connect( toolBar, SIGNAL(clicked(int)), this, SLOT(toolButton(int)) );
+
+ m_list = new KListBox( this );
+ setCentralWidget(m_list);
+
+ m_pluginManager = new PluginManager;
+ m_list->insertStringList(m_pluginManager->items());
+}
+
+MainWindow::~MainWindow()
+{
+ delete m_pluginManager;
+}
+
+void MainWindow::toolButton( int id )
+{
+ switch (id)
+ {
+ case Add:
+ add();
+ break;
+ case Remove:
+ remove();
+ break;
+ case Refresh:
+ verify();
+ break;
+ }
+}
+
+void MainWindow::add()
+{
+ QString libDir = KGlobal::dirs()->findResourceDir("lib", "libkommanderplugin");
+ QString plugin = KFileDialog::getOpenFileName(libDir, "lib*", this,
+ i18n("Add Kommander Plugin"));
+ add(plugin);
+}
+
+void MainWindow::add(const QString &plugin)
+{
+ if (!m_pluginManager->add(plugin))
+ {
+ QString errMsg = i18n("<qt>Unable to load Kommander plugin<br><b>%1</b></qt>").arg(plugin);
+ KMessageBox::error(this, errMsg, i18n("Cannot add plugin"));
+ }
+ else
+ refresh();
+}
+
+void MainWindow::remove()
+{
+ QString plugin = m_list->currentText();
+ if (m_pluginManager->remove(plugin))
+ refresh();
+}
+
+void MainWindow::refresh()
+{
+ m_list->clear();
+ m_list->insertStringList(m_pluginManager->items());
+}
+
+void MainWindow::verify()
+{
+ m_pluginManager->verify();
+ refresh();
+}
+
+#include "mainwindow.moc"