1 /**************************************************************************
2 ** This file is part of LiteIDE
3 **
4 ** Copyright (c) 2011-2019 LiteIDE. All rights reserved.
5 **
6 ** This library is free software; you can redistribute it and/or
7 ** modify it under the terms of the GNU Lesser General Public
8 ** License as published by the Free Software Foundation; either
9 ** version 2.1 of the License, or (at your option) any later version.
10 **
11 ** This library is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ** Lesser General Public License for more details.
15 **
16 ** In addition, as a special exception,  that plugins developed for LiteIDE,
17 ** are allowed to remain closed sourced and can be distributed under any license .
18 ** These rights are included in the file LGPL_EXCEPTION.txt in this package.
19 **
20 **************************************************************************/
21 // Module: litedebugplugin.cpp
22 // Creator: visualfc <visualfc@gmail.com>
23 
24 #include "litedebugplugin.h"
25 #include "litedebug.h"
26 #include "litedebugoptionfactory.h"
27 #include <QMenu>
28 #include <QLayout>
29 #include <QAction>
30 #include <QSplitter>
31 //lite_memory_check_begin
32 #if defined(WIN32) && defined(_MSC_VER) &&  defined(_DEBUG)
33      #define _CRTDBG_MAP_ALLOC
34      #include <stdlib.h>
35      #include <crtdbg.h>
36      #define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
37      #define new DEBUG_NEW
38 #endif
39 //lite_memory_check_end
40 
LiteDebugPlugin()41 LiteDebugPlugin::LiteDebugPlugin()
42 {
43 }
44 
load(LiteApi::IApplication * app)45 bool LiteDebugPlugin::load(LiteApi::IApplication *app)
46 {
47     app->optionManager()->addFactory(new LiteDebugOptionFactory(app,this));
48 
49     QSplitter *splitter = LiteApi::findExtensionObject<QSplitter*>(app,"LiteApi.QMainWindow.QSplitter");
50     if (!splitter) {
51         return false;
52     }
53 
54     m_liteDebug = new LiteDebug(app,this);
55     m_liteDebug->widget()->hide();
56     splitter->addWidget(m_liteDebug->widget());
57 
58     m_viewDebug = new QAction(tr("Debug Window"),this);
59     m_viewDebug->setCheckable(true);
60     connect(m_viewDebug,SIGNAL(triggered(bool)),m_liteDebug->widget(),SLOT(setVisible(bool)));
61     connect(m_liteDebug,SIGNAL(debugVisible(bool)),m_viewDebug,SLOT(setChecked(bool)));
62 
63     app->actionManager()->insertViewMenu(LiteApi::ViewMenuBrowserPos,m_viewDebug);
64 
65     return true;
66 }
67 
68 #if QT_VERSION < 0x050000
69 Q_EXPORT_PLUGIN2(PluginFactory,PluginFactory)
70 #endif
71