File indexing completed on 2024-12-08 03:46:48
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_CLASS_WITH_JSON(cVarViewerPlugin, "varviewerplugin.json") 0036 0037 struct cVarViewerPluginPrivate 0038 { 0039 dlgVarViewer *viewer; 0040 QAction *viewAction; 0041 }; 0042 0043 cVarViewerPlugin::cVarViewerPlugin (QObject *, const QVariantList &) 0044 { 0045 d = new cVarViewerPluginPrivate; 0046 0047 KMainWindow *mainWindow = cActionManager::self()->mainWindow (); 0048 d->viewer = new dlgVarViewer (mainWindow); 0049 d->viewer->hide (); 0050 d->viewer->setObjectName ("varviewer"); 0051 mainWindow->addDockWidget (Qt::RightDockWidgetArea, d->viewer); 0052 d->viewer->setFloating (true); 0053 0054 KActionCollection *acol = cActionManager::self()->getACol (); 0055 d->viewAction = d->viewer->toggleViewAction (); 0056 acol->addAction ("ShowVariables", d->viewAction); 0057 0058 // plug things into the menu 0059 cMenuManager *menu = cMenuManager::self(); 0060 menu->plug (d->viewAction, "view-global"); 0061 0062 } 0063 0064 cVarViewerPlugin::~cVarViewerPlugin() 0065 { 0066 KMainWindow *mainWindow = cActionManager::self()->mainWindow (); 0067 mainWindow->removeDockWidget (d->viewer); 0068 0069 cMenuManager *menu = cMenuManager::self(); 0070 menu->unplug (d->viewAction); 0071 0072 delete d->viewer; 0073 delete d; 0074 } 0075 0076 0077 #include "varviewerplugin.moc"