File indexing completed on 2023-11-26 10:51:21
0001 // 0002 // C++ Implementation: varviewerplugin 0003 // 0004 // Description: Variable Viewer plugin. 0005 // 0006 /* 0007 Copyright 2008-2011 Tomas Mecir <kmuddy@kmuddy.com> 0008 0009 This program is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU General Public License as 0011 published by the Free Software Foundation; either version 2 of 0012 the License, or (at your option) any later version. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #include "varviewerplugin.h" 0024 0025 #include "dlgvarviewer.h" 0026 0027 #include "cactionmanager.h" 0028 #include "cmenumanager.h" 0029 0030 #include <kactioncollection.h> 0031 #include <kmainwindow.h> 0032 #include <kpluginfactory.h> 0033 #include <kpluginloader.h> 0034 0035 K_PLUGIN_FACTORY (cVarViewerPluginFactory, registerPlugin<cVarViewerPlugin>();) 0036 K_EXPORT_PLUGIN (cVarViewerPluginFactory("kmuddy")) 0037 0038 struct cVarViewerPluginPrivate 0039 { 0040 dlgVarViewer *viewer; 0041 QAction *viewAction; 0042 }; 0043 0044 cVarViewerPlugin::cVarViewerPlugin (QObject *, const QVariantList &) 0045 { 0046 d = new cVarViewerPluginPrivate; 0047 0048 KMainWindow *mainWindow = cActionManager::self()->mainWindow (); 0049 d->viewer = new dlgVarViewer (mainWindow); 0050 d->viewer->hide (); 0051 d->viewer->setObjectName ("varviewer"); 0052 mainWindow->addDockWidget (Qt::RightDockWidgetArea, d->viewer); 0053 d->viewer->setFloating (true); 0054 0055 KActionCollection *acol = cActionManager::self()->getACol (); 0056 d->viewAction = d->viewer->toggleViewAction (); 0057 acol->addAction ("ShowVariables", d->viewAction); 0058 0059 // plug things into the menu 0060 cMenuManager *menu = cMenuManager::self(); 0061 menu->plug (d->viewAction, "view-global"); 0062 0063 } 0064 0065 cVarViewerPlugin::~cVarViewerPlugin() 0066 { 0067 KMainWindow *mainWindow = cActionManager::self()->mainWindow (); 0068 mainWindow->removeDockWidget (d->viewer); 0069 0070 cMenuManager *menu = cMenuManager::self(); 0071 menu->unplug (d->viewAction); 0072 0073 delete d->viewer; 0074 delete d; 0075 } 0076 0077 0078 #include "varviewerplugin.moc"