kateconfigplugindialogpage.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kateconfigplugindialogpage.h"
00021 #include "kateconfigplugindialogpage.moc"
00022
00023 #include "katepluginmanager.h"
00024 #include "kateconfigdialog.h"
00025 #include <klistbox.h>
00026 #include "kateapp.h"
00027 #include <qstringlist.h>
00028 #include <qhbox.h>
00029 #include <qlabel.h>
00030 #include <klocale.h>
00031 #include <qpushbutton.h>
00032 #include <qtooltip.h>
00033 #include <kiconloader.h>
00034 #include <qwhatsthis.h>
00035
00036 class KatePluginListItem : public QCheckListItem
00037 {
00038 public:
00039 KatePluginListItem(bool checked, KatePluginInfo *info, QListView *parent);
00040 KatePluginInfo *info() const { return mInfo; }
00041
00042 protected:
00043 void stateChange(bool);
00044
00045 private:
00046 KatePluginInfo *mInfo;
00047 bool silentStateChange;
00048 };
00049
00050 KatePluginListItem::KatePluginListItem(bool checked, KatePluginInfo *info, QListView *parent)
00051 : QCheckListItem(parent, info->service->name(), CheckBox)
00052 , mInfo(info)
00053 , silentStateChange(false)
00054 {
00055 silentStateChange = true;
00056 setOn(checked);
00057 silentStateChange = false;
00058 }
00059
00060 void KatePluginListItem::stateChange(bool b)
00061 {
00062 if(!silentStateChange)
00063 static_cast<KatePluginListView *>(listView())->stateChanged(this, b);
00064 }
00065
00066 KatePluginListView::KatePluginListView(QWidget *parent, const char *name)
00067 : KListView(parent, name)
00068 {
00069 }
00070
00071 void KatePluginListView::stateChanged(KatePluginListItem *item, bool b)
00072 {
00073 emit stateChange(item, b);
00074 }
00075
00076 KateConfigPluginPage::KateConfigPluginPage(QWidget *parent, KateConfigDialog *dialog):QVBox(parent)
00077 {
00078 myDialog=dialog;
00079
00080 KatePluginListView* listView = new KatePluginListView(this);
00081 listView->addColumn(i18n("Name"));
00082 listView->addColumn(i18n("Comment"));
00083 QWhatsThis::add(listView,i18n("Here you can see all available Kate plugins. Those with a check mark are loaded, and will be loaded again the next time Kate is started."));
00084
00085 connect(listView, SIGNAL(stateChange(KatePluginListItem *, bool)), this, SLOT(stateChange(KatePluginListItem *, bool)));
00086
00087 for (uint i=0; i<KatePluginManager::self()->pluginList().count(); i++)
00088 {
00089 KatePluginListItem *item = new KatePluginListItem(KatePluginManager::self()->pluginList().at(i)->load, KatePluginManager::self()->pluginList().at(i), listView);
00090 item->setText(0, KatePluginManager::self()->pluginList().at(i)->service->name());
00091 item->setText(1, KatePluginManager::self()->pluginList().at(i)->service->comment());
00092 }
00093 }
00094
00095 void KateConfigPluginPage::stateChange(KatePluginListItem *item, bool b)
00096 {
00097 if(b)
00098 loadPlugin(item);
00099 else
00100 unloadPlugin(item);
00101
00102 emit changed();
00103 }
00104
00105 void KateConfigPluginPage::loadPlugin (KatePluginListItem *item)
00106 {
00107 KatePluginManager::self()->loadPlugin (item->info());
00108 KatePluginManager::self()->enablePluginGUI (item->info());
00109 myDialog->addPluginPage (item->info()->plugin);
00110
00111 item->setOn(true);
00112 }
00113
00114 void KateConfigPluginPage::unloadPlugin (KatePluginListItem *item)
00115 {
00116 myDialog->removePluginPage (item->info()->plugin);
00117 KatePluginManager::self()->unloadPlugin (item->info());
00118
00119 item->setOn(false);
00120 }
This file is part of the documentation for kate Library Version 3.4.0.