2011-03-04 12:15:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Author: Andreas Hartmetz, KDAB (andreas.hartmetz@kdab.com)
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-03-04 12:15:18 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2011-03-04 12:15:18 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "analyzermanager.h"
|
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
#include "analyzerconstants.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
#include "analyzerplugin.h"
|
|
|
|
|
#include "analyzerruncontrol.h"
|
2011-04-04 14:39:28 +02:00
|
|
|
#include "analyzerruncontrolfactory.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
#include "analyzeroptionspage.h"
|
2011-04-04 14:39:28 +02:00
|
|
|
#include "analyzerstartparameters.h"
|
|
|
|
|
#include "analyzerutils.h"
|
|
|
|
|
#include "ianalyzertool.h"
|
|
|
|
|
#include "startremotedialog.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-27 16:13:46 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
#include <coreplugin/findplaceholder.h>
|
2011-06-27 16:13:46 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/imode.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/modemanager.h>
|
|
|
|
|
#include <coreplugin/navigationwidget.h>
|
|
|
|
|
#include <coreplugin/outputpane.h>
|
|
|
|
|
#include <coreplugin/rightpane.h>
|
|
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
2011-06-27 16:13:46 +02:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2011-03-08 13:56:52 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/runconfiguration.h>
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
|
|
|
|
#include <projectexplorer/iprojectmanager.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/iplugin.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/fancymainwindow.h>
|
|
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
2011-03-15 14:18:41 +01:00
|
|
|
#include <utils/checkablemessagebox.h>
|
2011-03-16 13:49:28 +01:00
|
|
|
#include <utils/statuslabel.h>
|
2011-04-04 14:39:28 +02:00
|
|
|
#include <utils/ssh/sshconnection.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
|
|
|
|
|
2011-03-08 13:56:52 +01:00
|
|
|
#include <QtCore/QVariant>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtGui/QHBoxLayout>
|
|
|
|
|
#include <QtGui/QVBoxLayout>
|
|
|
|
|
#include <QtGui/QDockWidget>
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QMenu>
|
|
|
|
|
#include <QtGui/QMenuBar>
|
|
|
|
|
#include <QtGui/QToolButton>
|
|
|
|
|
#include <QtGui/QComboBox>
|
|
|
|
|
#include <QtGui/QStackedWidget>
|
|
|
|
|
#include <QtGui/QDialog>
|
|
|
|
|
#include <QtGui/QApplication>
|
|
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QCheckBox>
|
|
|
|
|
#include <QtGui/QDialogButtonBox>
|
2011-03-15 14:18:41 +01:00
|
|
|
#include <QtGui/QMainWindow>
|
2011-04-04 14:39:28 +02:00
|
|
|
#include <QtGui/QPushButton>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace Analyzer;
|
|
|
|
|
using namespace Analyzer::Internal;
|
|
|
|
|
|
|
|
|
|
namespace Analyzer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
const char lastActiveToolC[] = "Analyzer.Plugin.LastActiveTool";
|
|
|
|
|
const char G_ANALYZER_TOOLS[] = "Menu.Group.Analyzer.Tools";
|
|
|
|
|
const char G_ANALYZER_REMOTE_TOOLS[] = "Menu.Group.Analyzer.RemoteTools";
|
|
|
|
|
const char INITIAL_DOCK_AREA[] = "initial_dock_area";
|
2011-06-29 16:04:03 +02:00
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
// AnalyzerMode ////////////////////////////////////////////////////
|
|
|
|
|
|
2011-03-08 13:56:52 +01:00
|
|
|
class AnalyzerMode : public Core::IMode
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
AnalyzerMode(QObject *parent = 0)
|
|
|
|
|
: Core::IMode(parent)
|
2011-04-13 13:00:30 +02:00
|
|
|
{
|
|
|
|
|
setContext(Core::Context(
|
|
|
|
|
Core::Constants::C_EDITORMANAGER,
|
|
|
|
|
Constants::C_ANALYZEMODE,
|
|
|
|
|
Core::Constants::C_NAVIGATION_PANE));
|
2011-04-13 16:09:04 +02:00
|
|
|
setDisplayName(tr("Analyze"));
|
|
|
|
|
setIcon(QIcon(":/images/analyzer_mode.png"));
|
|
|
|
|
setPriority(Constants::P_MODE_ANALYZE);
|
|
|
|
|
setId(QLatin1String(Constants::MODE_ANALYZE));
|
|
|
|
|
setType(Core::Constants::MODE_EDIT_TYPE);
|
2011-04-13 13:00:30 +02:00
|
|
|
}
|
2011-03-08 13:56:52 +01:00
|
|
|
|
|
|
|
|
~AnalyzerMode()
|
|
|
|
|
{
|
|
|
|
|
// Make sure the editor manager does not get deleted.
|
|
|
|
|
if (m_widget) {
|
|
|
|
|
delete m_widget;
|
|
|
|
|
m_widget = 0;
|
|
|
|
|
}
|
|
|
|
|
Core::EditorManager::instance()->setParent(0);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Analyzer
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// AnalyzerManagerPrivate
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class AnalyzerManager::AnalyzerManagerPrivate : public QObject
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
public:
|
2011-04-26 13:43:08 +02:00
|
|
|
typedef QHash<QString, QVariant> FancyMainWindowSettings;
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
AnalyzerManagerPrivate(AnalyzerManager *qq);
|
|
|
|
|
~AnalyzerManagerPrivate();
|
|
|
|
|
|
2011-03-04 16:00:03 +01:00
|
|
|
/**
|
2011-06-29 16:04:03 +02:00
|
|
|
* After calling this, a proper instance of Core::IMode is initialized
|
2011-03-04 16:00:03 +01:00
|
|
|
* It is delayed since an analyzer mode makes no sense without analyzer tools
|
|
|
|
|
*
|
|
|
|
|
* \note Call this before adding a tool to the manager
|
|
|
|
|
*/
|
|
|
|
|
void delayedInit();
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
void setupActions();
|
2011-03-10 16:11:20 +01:00
|
|
|
QWidget *createModeContents();
|
|
|
|
|
QWidget *createModeMainWindow();
|
2011-06-29 16:04:03 +02:00
|
|
|
bool showPromptDialog(const QString &title, const QString &text,
|
|
|
|
|
const QString &stopButtonText, const QString &cancelButtonText) const;
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-05-20 18:47:28 +02:00
|
|
|
void addDock(Qt::DockWidgetArea area, QDockWidget *dockWidget);
|
2011-06-29 18:48:08 +02:00
|
|
|
void startAction(int tool);
|
2011-06-29 16:04:03 +02:00
|
|
|
void addTool(IAnalyzerTool *tool);
|
2011-06-29 18:48:08 +02:00
|
|
|
void addToolAction(IAnalyzerTool *tool, bool local);
|
|
|
|
|
int indexOf(IAnalyzerTool *tool) const;
|
|
|
|
|
int indexOf(QAction *action) const;
|
|
|
|
|
IAnalyzerTool *toolAt(int idx) const;
|
2011-06-29 16:04:03 +02:00
|
|
|
|
|
|
|
|
public slots:
|
2011-06-29 18:48:08 +02:00
|
|
|
void startAction() { startAction(m_currentIndex); }
|
2011-06-29 16:04:03 +02:00
|
|
|
void startToolRemote();
|
|
|
|
|
void stopTool();
|
|
|
|
|
|
|
|
|
|
void handleToolFinished();
|
2011-06-29 18:48:08 +02:00
|
|
|
void selectAction();
|
|
|
|
|
void selectAction(int);
|
|
|
|
|
void selectAction(QAction *);
|
2011-06-29 16:04:03 +02:00
|
|
|
void modeChanged(Core::IMode *mode);
|
|
|
|
|
void runControlCreated(Analyzer::AnalyzerRunControl *);
|
|
|
|
|
void resetLayout();
|
|
|
|
|
void saveToolSettings(Analyzer::IAnalyzerTool *tool);
|
|
|
|
|
void loadToolSettings(Analyzer::IAnalyzerTool *tool);
|
|
|
|
|
void updateRunActions();
|
|
|
|
|
void registerRunControlFactory(ProjectExplorer::IRunControlFactory *factory);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
public:
|
2011-06-29 18:48:08 +02:00
|
|
|
struct ToolData {
|
|
|
|
|
IAnalyzerTool *tool;
|
|
|
|
|
QAction *action;
|
|
|
|
|
bool local;
|
|
|
|
|
};
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
AnalyzerManager *q;
|
|
|
|
|
AnalyzerMode *m_mode;
|
|
|
|
|
AnalyzerRunControlFactory *m_runControlFactory;
|
|
|
|
|
ProjectExplorer::RunControl *m_currentRunControl;
|
|
|
|
|
Utils::FancyMainWindow *m_mainWindow;
|
2011-06-29 18:48:08 +02:00
|
|
|
int m_currentIndex;
|
|
|
|
|
QList<ToolData> m_actions;
|
2011-04-04 14:39:28 +02:00
|
|
|
QList<IAnalyzerTool *> m_tools;
|
2011-03-04 12:15:18 +01:00
|
|
|
QAction *m_startAction;
|
|
|
|
|
QAction *m_stopAction;
|
2011-04-04 13:03:45 +02:00
|
|
|
ActionContainer *m_menu;
|
2011-03-04 12:15:18 +01:00
|
|
|
QComboBox *m_toolBox;
|
2011-04-04 14:39:28 +02:00
|
|
|
QStackedWidget *m_controlsWidget;
|
2011-03-04 12:15:18 +01:00
|
|
|
ActionContainer *m_viewsMenu;
|
2011-03-16 13:49:28 +01:00
|
|
|
Utils::StatusLabel *m_statusLabel;
|
2011-05-06 14:02:03 +02:00
|
|
|
typedef QMap<IAnalyzerTool *, FancyMainWindowSettings> MainWindowSettingsMap;
|
2011-05-23 10:58:10 +02:00
|
|
|
QMap<IAnalyzerTool *, QList<QDockWidget *> > m_toolWidgets;
|
2011-05-06 14:02:03 +02:00
|
|
|
MainWindowSettingsMap m_defaultSettings;
|
2011-03-04 16:00:01 +01:00
|
|
|
|
|
|
|
|
// list of dock widgets to prevent memory leak
|
|
|
|
|
typedef QWeakPointer<QDockWidget> DockPtr;
|
|
|
|
|
QList<DockPtr> m_dockWidgets;
|
2011-03-04 16:00:03 +01:00
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
bool m_restartOnStop;
|
2011-03-04 16:00:03 +01:00
|
|
|
bool m_initialized;
|
2011-03-04 12:15:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
|
|
|
|
|
q(qq),
|
|
|
|
|
m_mode(0),
|
|
|
|
|
m_runControlFactory(0),
|
|
|
|
|
m_currentRunControl(0),
|
|
|
|
|
m_mainWindow(0),
|
2011-06-29 18:48:08 +02:00
|
|
|
m_currentIndex(-1),
|
2011-03-04 12:15:18 +01:00
|
|
|
m_startAction(0),
|
|
|
|
|
m_stopAction(0),
|
|
|
|
|
m_menu(0),
|
2011-03-10 16:11:20 +01:00
|
|
|
m_toolBox(new QComboBox),
|
2011-04-04 14:39:28 +02:00
|
|
|
m_controlsWidget(new QStackedWidget),
|
2011-03-04 12:15:18 +01:00
|
|
|
m_viewsMenu(0),
|
2011-03-16 13:49:28 +01:00
|
|
|
m_statusLabel(new Utils::StatusLabel),
|
2011-04-04 14:39:28 +02:00
|
|
|
m_restartOnStop(false),
|
2011-05-11 16:26:34 +02:00
|
|
|
m_initialized(false)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-03-10 16:11:20 +01:00
|
|
|
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
|
2011-06-29 18:48:08 +02:00
|
|
|
connect(m_toolBox, SIGNAL(currentIndexChanged(int)), SLOT(selectAction(int)));
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
m_runControlFactory = new AnalyzerRunControlFactory();
|
|
|
|
|
registerRunControlFactory(m_runControlFactory);
|
2011-03-10 16:11:20 +01:00
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
setupActions();
|
2011-06-29 16:04:03 +02:00
|
|
|
|
|
|
|
|
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
|
|
|
|
this, SLOT(modeChanged(Core::IMode*)));
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin *pe =
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance();
|
|
|
|
|
connect(pe, SIGNAL(updateRunActions()), SLOT(updateRunActions()));
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnalyzerManager::AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
|
|
|
|
|
{
|
2011-03-04 16:00:01 +01:00
|
|
|
// as we have to setParent(0) on dock widget that are not selected,
|
|
|
|
|
// we keep track of all and make sure we don't leak any
|
2011-05-11 16:26:34 +02:00
|
|
|
foreach (const DockPtr &ptr, m_dockWidgets) {
|
2011-03-04 16:00:01 +01:00
|
|
|
if (ptr)
|
|
|
|
|
delete ptr.data();
|
|
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::registerRunControlFactory
|
|
|
|
|
(ProjectExplorer::IRunControlFactory *factory)
|
2011-04-13 10:39:47 +02:00
|
|
|
{
|
|
|
|
|
AnalyzerPlugin::instance()->addAutoReleasedObject(factory);
|
2011-06-29 16:04:03 +02:00
|
|
|
connect(factory, SIGNAL(runControlCreated(Analyzer::AnalyzerRunControl*)),
|
|
|
|
|
this, SLOT(runControlCreated(Analyzer::AnalyzerRunControl*)));
|
2011-04-13 10:39:47 +02:00
|
|
|
}
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::setupActions()
|
|
|
|
|
{
|
|
|
|
|
Core::ICore *core = Core::ICore::instance();
|
|
|
|
|
Core::ActionManager *am = core->actionManager();
|
2011-04-04 14:39:28 +02:00
|
|
|
const Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
|
|
|
|
Core::Command *command = 0;
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
// Menus
|
2011-06-29 16:04:03 +02:00
|
|
|
m_menu = am->createMenu(Constants::M_DEBUG_ANALYZER);
|
2011-06-28 19:58:19 +02:00
|
|
|
m_menu->menu()->setTitle(tr("&Analyze"));
|
2011-04-04 13:03:45 +02:00
|
|
|
m_menu->menu()->setEnabled(true);
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
m_menu->appendGroup(G_ANALYZER_TOOLS);
|
|
|
|
|
m_menu->appendGroup(G_ANALYZER_REMOTE_TOOLS);
|
2011-04-04 13:03:45 +02:00
|
|
|
|
2011-06-28 19:58:19 +02:00
|
|
|
Core::ActionContainer *menubar =
|
|
|
|
|
am->actionContainer(Core::Constants::MENU_BAR);
|
|
|
|
|
Core::ActionContainer *mtools =
|
|
|
|
|
am->actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
menubar->addMenu(mtools, m_menu);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
m_startAction = new QAction(tr("Start"), m_menu);
|
2011-04-04 14:39:28 +02:00
|
|
|
m_startAction->setIcon(QIcon(Constants::ANALYZER_CONTROL_START_ICON));
|
2011-06-28 19:58:19 +02:00
|
|
|
command = am->registerAction(m_startAction, Constants::START, globalcontext);
|
2011-06-29 18:48:08 +02:00
|
|
|
connect(m_startAction, SIGNAL(triggered()), this, SLOT(startAction()));
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
m_stopAction = new QAction(tr("Stop"), m_menu);
|
|
|
|
|
m_stopAction->setEnabled(false);
|
2011-04-04 14:39:28 +02:00
|
|
|
m_stopAction->setIcon(QIcon(Constants::ANALYZER_CONTROL_STOP_ICON));
|
2011-03-04 12:15:18 +01:00
|
|
|
command = am->registerAction(m_stopAction, Constants::STOP, globalcontext);
|
2011-06-29 16:04:03 +02:00
|
|
|
connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stopTool()));
|
2011-04-04 13:03:45 +02:00
|
|
|
|
|
|
|
|
QAction *separatorAction = new QAction(m_menu);
|
|
|
|
|
separatorAction->setSeparator(true);
|
2011-06-29 18:48:08 +02:00
|
|
|
command = am->registerAction(separatorAction,
|
|
|
|
|
"Menu.Action.Analyzer.Tools.Separator", globalcontext);
|
|
|
|
|
m_menu->addAction(command, G_ANALYZER_REMOTE_TOOLS);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
m_viewsMenu = am->actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS));
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-04 16:00:03 +01:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::delayedInit()
|
|
|
|
|
{
|
|
|
|
|
if (m_initialized)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
m_mode = new AnalyzerMode(q);
|
|
|
|
|
m_mode->setWidget(createModeContents());
|
|
|
|
|
AnalyzerPlugin::instance()->addAutoReleasedObject(m_mode);
|
|
|
|
|
|
2011-03-04 16:00:03 +01:00
|
|
|
m_initialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 16:11:20 +01:00
|
|
|
QWidget *AnalyzerManager::AnalyzerManagerPrivate::createModeContents()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
// right-side window with editor, output etc.
|
|
|
|
|
MiniSplitter *mainWindowSplitter = new MiniSplitter;
|
2011-03-10 16:11:20 +01:00
|
|
|
mainWindowSplitter->addWidget(createModeMainWindow());
|
2011-03-04 12:15:18 +01:00
|
|
|
mainWindowSplitter->addWidget(new OutputPanePlaceHolder(m_mode, mainWindowSplitter));
|
|
|
|
|
mainWindowSplitter->setStretchFactor(0, 10);
|
|
|
|
|
mainWindowSplitter->setStretchFactor(1, 0);
|
|
|
|
|
mainWindowSplitter->setOrientation(Qt::Vertical);
|
|
|
|
|
|
|
|
|
|
// navigation + right-side window
|
|
|
|
|
MiniSplitter *splitter = new MiniSplitter;
|
|
|
|
|
splitter->addWidget(new NavigationWidgetPlaceHolder(m_mode));
|
|
|
|
|
splitter->addWidget(mainWindowSplitter);
|
|
|
|
|
splitter->setStretchFactor(0, 0);
|
|
|
|
|
splitter->setStretchFactor(1, 1);
|
|
|
|
|
return splitter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QToolButton *toolButton(QAction *action)
|
|
|
|
|
{
|
|
|
|
|
QToolButton *button = new QToolButton;
|
|
|
|
|
button->setDefaultAction(action);
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 16:11:20 +01:00
|
|
|
QWidget *AnalyzerManager::AnalyzerManagerPrivate::createModeMainWindow()
|
|
|
|
|
{
|
2011-03-04 12:15:18 +01:00
|
|
|
m_mainWindow = new Utils::FancyMainWindow();
|
2011-03-10 16:11:20 +01:00
|
|
|
m_mainWindow->setObjectName(QLatin1String("AnalyzerManagerMainWindow"));
|
2011-03-04 12:15:18 +01:00
|
|
|
m_mainWindow->setDocumentMode(true);
|
|
|
|
|
m_mainWindow->setDockNestingEnabled(true);
|
|
|
|
|
m_mainWindow->setDockActionsVisible(ModeManager::instance()->currentMode()->id() ==
|
|
|
|
|
Constants::MODE_ANALYZE);
|
2011-06-29 16:04:03 +02:00
|
|
|
connect(m_mainWindow, SIGNAL(resetLayout()), SLOT(resetLayout()));
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
QBoxLayout *editorHolderLayout = new QVBoxLayout;
|
|
|
|
|
editorHolderLayout->setMargin(0);
|
|
|
|
|
editorHolderLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
QWidget *editorAndFindWidget = new QWidget;
|
|
|
|
|
editorAndFindWidget->setLayout(editorHolderLayout);
|
|
|
|
|
editorHolderLayout->addWidget(new EditorManagerPlaceHolder(m_mode));
|
|
|
|
|
editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget));
|
|
|
|
|
|
|
|
|
|
MiniSplitter *documentAndRightPane = new MiniSplitter;
|
|
|
|
|
documentAndRightPane->addWidget(editorAndFindWidget);
|
|
|
|
|
documentAndRightPane->addWidget(new RightPanePlaceHolder(m_mode));
|
|
|
|
|
documentAndRightPane->setStretchFactor(0, 1);
|
|
|
|
|
documentAndRightPane->setStretchFactor(1, 0);
|
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
Utils::StyledBar *analyzeToolBar = new Utils::StyledBar;
|
|
|
|
|
analyzeToolBar->setProperty("topBorder", true);
|
|
|
|
|
QHBoxLayout *analyzeToolBarLayout = new QHBoxLayout(analyzeToolBar);
|
|
|
|
|
analyzeToolBarLayout->setMargin(0);
|
|
|
|
|
analyzeToolBarLayout->setSpacing(0);
|
2011-06-28 20:22:17 +02:00
|
|
|
analyzeToolBarLayout->addWidget(toolButton(m_startAction));
|
2011-04-04 14:39:28 +02:00
|
|
|
analyzeToolBarLayout->addWidget(toolButton(m_stopAction));
|
|
|
|
|
analyzeToolBarLayout->addWidget(new Utils::StyledSeparator);
|
|
|
|
|
analyzeToolBarLayout->addWidget(m_toolBox);
|
|
|
|
|
analyzeToolBarLayout->addWidget(m_controlsWidget);
|
|
|
|
|
analyzeToolBarLayout->addWidget(m_statusLabel);
|
|
|
|
|
analyzeToolBarLayout->addStretch();
|
|
|
|
|
|
|
|
|
|
QDockWidget *dock = new QDockWidget(tr("Analyzer Toolbar"));
|
|
|
|
|
dock->setObjectName(QLatin1String("Analyzer Toolbar"));
|
|
|
|
|
dock->setWidget(analyzeToolBar);
|
|
|
|
|
dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
|
dock->setProperty("managed_dockwidget", QLatin1String("true"));
|
|
|
|
|
dock->setAllowedAreas(Qt::BottomDockWidgetArea);
|
|
|
|
|
// hide title bar
|
|
|
|
|
dock->setTitleBarWidget(new QWidget(dock));
|
|
|
|
|
m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dock);
|
|
|
|
|
m_mainWindow->setToolBarDockWidget(dock);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
QWidget *centralWidget = new QWidget;
|
|
|
|
|
m_mainWindow->setCentralWidget(centralWidget);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *centralLayout = new QVBoxLayout(centralWidget);
|
|
|
|
|
centralWidget->setLayout(centralLayout);
|
|
|
|
|
centralLayout->setMargin(0);
|
|
|
|
|
centralLayout->setSpacing(0);
|
|
|
|
|
centralLayout->addWidget(documentAndRightPane);
|
|
|
|
|
centralLayout->setStretch(0, 1);
|
|
|
|
|
centralLayout->setStretch(1, 0);
|
|
|
|
|
|
|
|
|
|
return m_mainWindow;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 18:47:28 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::addDock(Qt::DockWidgetArea area,
|
2011-03-04 12:15:18 +01:00
|
|
|
QDockWidget *dockWidget)
|
|
|
|
|
{
|
|
|
|
|
dockWidget->setParent(m_mainWindow);
|
|
|
|
|
m_mainWindow->addDockWidget(area, dockWidget);
|
|
|
|
|
|
|
|
|
|
Context globalContext(Core::Constants::C_GLOBAL);
|
|
|
|
|
|
|
|
|
|
ActionManager *am = ICore::instance()->actionManager();
|
|
|
|
|
QAction *toggleViewAction = dockWidget->toggleViewAction();
|
|
|
|
|
toggleViewAction->setText(dockWidget->windowTitle());
|
|
|
|
|
Command *cmd = am->registerAction(toggleViewAction, QString("Analyzer." + dockWidget->objectName()),
|
|
|
|
|
globalContext);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
m_viewsMenu->addAction(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
|
2011-05-19 13:43:19 +02:00
|
|
|
ProjectExplorer::BuildConfiguration::BuildType buildType)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
if (toolMode == IAnalyzerTool::AnyMode)
|
|
|
|
|
return true;
|
2011-05-19 13:43:19 +02:00
|
|
|
if (buildType == ProjectExplorer::BuildConfiguration::Unknown)
|
2011-03-04 12:15:18 +01:00
|
|
|
return true;
|
2011-05-19 13:43:19 +02:00
|
|
|
if (buildType == ProjectExplorer::BuildConfiguration::Debug
|
|
|
|
|
&& toolMode == IAnalyzerTool::DebugMode)
|
2011-03-04 12:15:18 +01:00
|
|
|
return true;
|
2011-05-19 13:43:19 +02:00
|
|
|
if (buildType == ProjectExplorer::BuildConfiguration::Release
|
|
|
|
|
&& toolMode == IAnalyzerTool::ReleaseMode)
|
2011-03-04 12:15:18 +01:00
|
|
|
return true;
|
2011-05-19 13:43:19 +02:00
|
|
|
return false;
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
bool AnalyzerManager::AnalyzerManagerPrivate::showPromptDialog(const QString &title,
|
|
|
|
|
const QString &text,
|
|
|
|
|
const QString &stopButtonText,
|
|
|
|
|
const QString &cancelButtonText) const
|
|
|
|
|
{
|
|
|
|
|
Utils::CheckableMessageBox messageBox(Core::ICore::instance()->mainWindow());
|
|
|
|
|
messageBox.setWindowTitle(title);
|
|
|
|
|
messageBox.setText(text);
|
|
|
|
|
messageBox.setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::Cancel);
|
|
|
|
|
if (!stopButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Yes)->setText(stopButtonText);
|
|
|
|
|
if (!cancelButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Cancel)->setText(cancelButtonText);
|
|
|
|
|
messageBox.setDefaultButton(QDialogButtonBox::Yes);
|
|
|
|
|
messageBox.setCheckBoxVisible(false);
|
|
|
|
|
messageBox.exec();;
|
|
|
|
|
return messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::startToolRemote()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
StartRemoteDialog dlg;
|
|
|
|
|
if (dlg.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
AnalyzerStartParameters sp;
|
|
|
|
|
sp.connParams = dlg.sshParams();
|
|
|
|
|
sp.debuggee = dlg.executable();
|
|
|
|
|
sp.debuggeeArgs = dlg.arguments();
|
|
|
|
|
sp.displayName = dlg.executable();
|
|
|
|
|
sp.startMode = StartRemote;
|
|
|
|
|
sp.workingDirectory = dlg.workingDirectory();
|
|
|
|
|
|
|
|
|
|
AnalyzerRunControl *runControl = m_runControlFactory->create(sp, 0);
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(runControl, return);
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance()
|
|
|
|
|
->startRunControl(runControl, Constants::MODE_ANALYZE);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::startAction(int index)
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-06-29 18:48:08 +02:00
|
|
|
QTC_ASSERT(index >= 0, return);
|
|
|
|
|
QTC_ASSERT(index < m_actions.size(), return);
|
|
|
|
|
QTC_ASSERT(index == m_currentIndex, return);
|
|
|
|
|
|
|
|
|
|
if (!m_actions.at(index).local) {
|
|
|
|
|
startToolRemote();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-04-04 15:00:18 +02:00
|
|
|
// make sure mode is shown
|
|
|
|
|
q->showMode();
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
|
|
|
|
|
|
|
|
|
|
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
2011-03-29 14:45:21 +02:00
|
|
|
ProjectExplorer::Project *pro = pe->startupProject();
|
|
|
|
|
const ProjectExplorer::RunConfiguration *runConfig = 0;
|
|
|
|
|
ProjectExplorer::BuildConfiguration::BuildType buildType = ProjectExplorer::BuildConfiguration::Unknown;
|
|
|
|
|
if (pro) {
|
|
|
|
|
if (const ProjectExplorer::Target *target = pro->activeTarget()) {
|
|
|
|
|
runConfig = target->activeRunConfiguration();
|
|
|
|
|
// Build configuration is 0 for QML projects.
|
|
|
|
|
if (const ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration())
|
|
|
|
|
buildType = buildConfig->buildType();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!runConfig || !runConfig->isEnabled())
|
2011-03-04 12:15:18 +01:00
|
|
|
return;
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
// Check if there already is an analyzer run.
|
2011-04-04 14:39:28 +02:00
|
|
|
if (m_currentRunControl) {
|
|
|
|
|
// ask if user wants to restart the analyzer
|
2011-06-29 16:04:03 +02:00
|
|
|
const QString msg = tr("<html><head/><body><center><i>%1</i> is still running. "
|
|
|
|
|
"You have to quit the Analyzer before being able to run another instance."
|
|
|
|
|
"<center/><center>Force it to quit?</center></body></html>")
|
|
|
|
|
.arg(m_currentRunControl->displayName());
|
2011-04-04 14:39:28 +02:00
|
|
|
bool stopRequested = showPromptDialog(tr("Analyzer Still Running"), msg,
|
2011-05-11 16:26:34 +02:00
|
|
|
tr("Stop Active Run"), tr("Keep Running"));
|
2011-04-04 14:39:28 +02:00
|
|
|
if (!stopRequested)
|
|
|
|
|
return; // no restart, keep it running, do nothing
|
|
|
|
|
|
|
|
|
|
// user selected to stop the active run. stop it, activate restart on stop
|
|
|
|
|
m_restartOnStop = true;
|
2011-06-29 16:04:03 +02:00
|
|
|
stopTool();
|
2011-04-04 14:39:28 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
IAnalyzerTool *tool = toolAt(index);
|
2011-06-29 16:04:03 +02:00
|
|
|
IAnalyzerTool::ToolMode toolMode = tool->mode();
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
// Check the project for whether the build config is in the correct mode
|
|
|
|
|
// if not, notify the user and urge him to use the correct mode.
|
|
|
|
|
if (!buildTypeAccepted(toolMode, buildType)) {
|
|
|
|
|
const QString &toolName = tool->displayName();
|
|
|
|
|
const QString &toolMode = IAnalyzerTool::modeString(tool->mode());
|
2011-03-04 12:15:18 +01:00
|
|
|
const QString currentMode = buildType == ProjectExplorer::BuildConfiguration::Debug ? tr("Debug") : tr("Release");
|
|
|
|
|
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
2011-03-15 14:18:41 +01:00
|
|
|
const QString configKey = QLatin1String(Constants::MODE_ANALYZE) + QLatin1Char('/') + QLatin1String("AnalyzeCorrectMode");
|
2011-03-04 12:15:18 +01:00
|
|
|
int ret;
|
|
|
|
|
if (settings->contains(configKey)) {
|
|
|
|
|
ret = settings->value(configKey, QDialog::Accepted).toInt();
|
|
|
|
|
} else {
|
2011-03-15 14:18:41 +01:00
|
|
|
const QString title = tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode);
|
|
|
|
|
const QString message = tr("<html><head/><body><p>You are trying to run the tool '%1' on an application in %2 mode. "
|
|
|
|
|
"The tool is designed to be used in %3 mode.</p><p>"
|
|
|
|
|
"Do you want to continue and run it in %2 mode?</p></body></html>").
|
|
|
|
|
arg(toolName).arg(currentMode).arg(toolMode);
|
|
|
|
|
const QString checkBoxText = tr("&Do not ask again");
|
|
|
|
|
bool checkBoxSetting = false;
|
|
|
|
|
const QDialogButtonBox::StandardButton button =
|
|
|
|
|
Utils::CheckableMessageBox::question(Core::ICore::instance()->mainWindow(), title, message, checkBoxText,
|
|
|
|
|
&checkBoxSetting, QDialogButtonBox::Yes|QDialogButtonBox::Cancel,
|
|
|
|
|
QDialogButtonBox::Cancel);
|
|
|
|
|
ret = button == QDialogButtonBox::Yes ? QDialog::Accepted : QDialog::Rejected;
|
|
|
|
|
|
|
|
|
|
if (checkBoxSetting && ret == QDialog::Accepted)
|
2011-03-04 12:15:18 +01:00
|
|
|
settings->setValue(configKey, ret);
|
|
|
|
|
}
|
|
|
|
|
if (ret == QDialog::Rejected)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pe->runProject(pro, Constants::MODE_ANALYZE);
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
updateRunActions();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-04 16:00:03 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::stopTool()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
if (m_currentRunControl)
|
|
|
|
|
return;
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
// be sure to call handleToolFinished only once, and only when the engine is really finished
|
|
|
|
|
if (m_currentRunControl->stop() == ProjectExplorer::RunControl::StoppedSynchronously)
|
|
|
|
|
handleToolFinished();
|
|
|
|
|
// else: wait for the finished() signal to trigger handleToolFinished()
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::modeChanged(IMode *mode)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
if (!m_mainWindow)
|
2011-03-29 14:48:58 +02:00
|
|
|
return;
|
2011-03-04 16:00:03 +01:00
|
|
|
const bool makeVisible = mode->id() == Constants::MODE_ANALYZE;
|
|
|
|
|
if (!makeVisible)
|
|
|
|
|
return;
|
2011-06-29 16:04:03 +02:00
|
|
|
m_mainWindow->setDockActionsVisible(makeVisible);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::selectAction(int idx)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
QTC_ASSERT(idx >= 0, return);
|
2011-06-29 18:48:08 +02:00
|
|
|
if (m_currentIndex == idx)
|
2011-03-04 12:15:18 +01:00
|
|
|
return;
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
if (m_currentIndex != -1) {
|
|
|
|
|
IAnalyzerTool *oldTool = toolAt(m_currentIndex);
|
2011-03-04 12:15:18 +01:00
|
|
|
saveToolSettings(oldTool);
|
|
|
|
|
|
|
|
|
|
ActionManager *am = ICore::instance()->actionManager();
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
foreach (QDockWidget *widget, m_toolWidgets.value(oldTool)) {
|
2011-05-23 10:58:10 +02:00
|
|
|
QAction *toggleViewAction = widget->toggleViewAction();
|
2011-06-27 16:13:46 +02:00
|
|
|
am->unregisterAction(toggleViewAction,
|
|
|
|
|
QString("Analyzer." + widget->objectName()));
|
2011-06-29 16:04:03 +02:00
|
|
|
m_mainWindow->removeDockWidget(widget);
|
2011-06-27 16:13:46 +02:00
|
|
|
///NOTE: QMainWindow (and FancyMainWindow) just look at
|
|
|
|
|
/// @c findChildren<QDockWidget*>()
|
2011-03-04 12:15:18 +01:00
|
|
|
///if we don't do this, all kind of havoc might happen, including:
|
|
|
|
|
///- improper saveState/restoreState
|
|
|
|
|
///- improper list of qdockwidgets in popup menu
|
|
|
|
|
///- ...
|
2011-05-23 10:58:10 +02:00
|
|
|
widget->setParent(0);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
2011-06-29 16:04:03 +02:00
|
|
|
oldTool->toolDeselected();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
m_currentIndex = idx;
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
m_toolBox->setCurrentIndex(idx);
|
|
|
|
|
m_controlsWidget->setCurrentIndex(idx);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
IAnalyzerTool *newTool = toolAt(idx);
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
const bool firstTime = !m_defaultSettings.contains(newTool);
|
2011-05-06 17:26:01 +02:00
|
|
|
if (firstTime) {
|
|
|
|
|
newTool->initializeDockWidgets();
|
2011-06-29 16:04:03 +02:00
|
|
|
m_defaultSettings.insert(newTool, m_mainWindow->saveSettings());
|
2011-05-06 17:26:01 +02:00
|
|
|
} else {
|
2011-06-29 16:04:03 +02:00
|
|
|
foreach (QDockWidget *widget, m_toolWidgets.value(newTool))
|
|
|
|
|
addDock(Qt::DockWidgetArea(widget->property(INITIAL_DOCK_AREA).toInt()), widget);
|
2011-05-06 17:26:01 +02:00
|
|
|
}
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
loadToolSettings(newTool);
|
|
|
|
|
updateRunActions();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::selectAction()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 18:48:08 +02:00
|
|
|
selectAction(qobject_cast<QAction *>(sender()));
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::selectAction(QAction *action)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 18:48:08 +02:00
|
|
|
selectAction(indexOf(action));
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
int AnalyzerManager::AnalyzerManagerPrivate::indexOf(QAction *action) const
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i != m_actions.size(); ++i)
|
|
|
|
|
if (m_actions.at(i).action == action)
|
|
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AnalyzerManager::AnalyzerManagerPrivate::indexOf(IAnalyzerTool *tool) const
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i != m_actions.size(); ++i)
|
|
|
|
|
if (toolAt(i) == tool)
|
|
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IAnalyzerTool *AnalyzerManager::AnalyzerManagerPrivate::toolAt(int idx) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(idx >= 0, return 0);
|
|
|
|
|
QTC_ASSERT(idx < m_actions.size(), return 0);
|
|
|
|
|
return m_actions.at(idx).tool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::addToolAction(IAnalyzerTool *tool, bool local)
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-04-04 13:03:45 +02:00
|
|
|
ActionManager *am = Core::ICore::instance()->actionManager();
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
QString actionId = QString("Action.Analyzer.Tools.%1").arg(m_actions.size());
|
|
|
|
|
QString displayName = tool->displayName() + (local ? QString() : tr(" (Remote)"));
|
|
|
|
|
QAction *action = new QAction(displayName, 0);
|
2011-06-29 16:04:03 +02:00
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
ToolData data;
|
|
|
|
|
data.tool = tool;
|
|
|
|
|
data.local = local;
|
|
|
|
|
data.action = action;
|
|
|
|
|
m_actions.append(data);
|
2011-06-29 16:04:03 +02:00
|
|
|
|
2011-06-27 16:13:46 +02:00
|
|
|
Core::Command *command = am->registerAction(action, actionId,
|
|
|
|
|
Core::Context(Core::Constants::C_GLOBAL));
|
2011-06-29 18:48:08 +02:00
|
|
|
m_menu->addAction(command, local ? G_ANALYZER_TOOLS : G_ANALYZER_REMOTE_TOOLS);
|
|
|
|
|
connect(action, SIGNAL(triggered()), SLOT(selectAction()));
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
const bool blocked = m_toolBox->blockSignals(true); // Do not make current.
|
2011-06-29 18:48:08 +02:00
|
|
|
m_toolBox->addItem(displayName);
|
2011-06-29 16:04:03 +02:00
|
|
|
m_toolBox->blockSignals(blocked);
|
2011-06-29 18:48:08 +02:00
|
|
|
m_toolBox->setEnabled(true);
|
|
|
|
|
}
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::addTool(IAnalyzerTool *tool)
|
|
|
|
|
{
|
|
|
|
|
delayedInit(); // be sure that there is a valid IMode instance
|
|
|
|
|
m_tools.append(tool);
|
|
|
|
|
if (tool->canRunLocally())
|
|
|
|
|
addToolAction(tool, true);
|
|
|
|
|
if (tool->canRunRemotely())
|
|
|
|
|
addToolAction(tool, false);
|
2011-06-27 16:13:46 +02:00
|
|
|
// Populate controls widget.
|
2011-04-04 14:39:28 +02:00
|
|
|
QWidget *controlWidget = tool->createControlWidget(); // might be 0
|
2011-06-29 16:04:03 +02:00
|
|
|
m_controlsWidget->addWidget(controlWidget
|
2011-06-27 16:13:46 +02:00
|
|
|
? controlWidget : AnalyzerUtils::createDummyWidget());
|
2011-05-18 15:56:01 +02:00
|
|
|
tool->initialize();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::runControlCreated(AnalyzerRunControl *rc)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
QTC_ASSERT(!m_currentRunControl, /**/);
|
|
|
|
|
m_currentRunControl = rc;
|
|
|
|
|
connect(rc, SIGNAL(finished()), this, SLOT(handleToolFinished()));
|
|
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::handleToolFinished()
|
|
|
|
|
{
|
|
|
|
|
m_currentRunControl = 0;
|
|
|
|
|
updateRunActions();
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
if (m_restartOnStop) {
|
2011-06-29 18:48:08 +02:00
|
|
|
startAction(m_currentIndex);
|
2011-06-29 16:04:03 +02:00
|
|
|
m_restartOnStop = false;
|
|
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::loadToolSettings(IAnalyzerTool *tool)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
QTC_ASSERT(m_mainWindow, return);
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + tool->id());
|
|
|
|
|
if (settings->value("ToolSettingsSaved", false).toBool())
|
|
|
|
|
m_mainWindow->restoreSettings(settings);
|
|
|
|
|
settings->endGroup();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::saveToolSettings(IAnalyzerTool *tool)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
if (!tool)
|
|
|
|
|
return; // no active tool, do nothing
|
|
|
|
|
QTC_ASSERT(m_mainWindow, return);
|
|
|
|
|
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + tool->id());
|
|
|
|
|
m_mainWindow->saveSettings(settings);
|
|
|
|
|
settings->setValue("ToolSettingsSaved", true);
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
settings->setValue(QLatin1String(lastActiveToolC), tool->id());
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::updateRunActions()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
ProjectExplorer::ProjectExplorerPlugin *pe =
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance();
|
|
|
|
|
ProjectExplorer::Project *project = pe->startupProject();
|
|
|
|
|
|
|
|
|
|
bool startEnabled = !m_currentRunControl
|
|
|
|
|
&& pe->canRun(project, Constants::MODE_ANALYZE)
|
2011-06-29 18:48:08 +02:00
|
|
|
&& m_currentIndex >= 0;
|
2011-06-29 16:04:03 +02:00
|
|
|
|
|
|
|
|
QString disabledReason;
|
|
|
|
|
if (m_currentRunControl)
|
|
|
|
|
disabledReason = tr("An analysis is still in progress.");
|
2011-06-29 18:48:08 +02:00
|
|
|
else if (m_currentIndex == -1)
|
2011-06-29 16:04:03 +02:00
|
|
|
disabledReason = tr("No analyzer tool selected.");
|
|
|
|
|
else
|
|
|
|
|
disabledReason = pe->cannotRunReason(project, Constants::MODE_ANALYZE);
|
|
|
|
|
|
|
|
|
|
m_startAction->setEnabled(startEnabled);
|
|
|
|
|
m_startAction->setToolTip(disabledReason);
|
|
|
|
|
m_toolBox->setEnabled(!m_currentRunControl);
|
|
|
|
|
m_stopAction->setEnabled(m_currentRunControl);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// AnalyzerManager
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
static AnalyzerManager *m_instance = 0;
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
AnalyzerManager::AnalyzerManager(QObject *parent)
|
|
|
|
|
: QObject(parent),
|
|
|
|
|
d(new AnalyzerManagerPrivate(this))
|
|
|
|
|
{
|
|
|
|
|
m_instance = this;
|
2011-04-04 14:39:28 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
AnalyzerManager::~AnalyzerManager()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
delete d;
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::extensionsInitialized()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
if (d->m_tools.isEmpty())
|
2011-03-04 12:15:18 +01:00
|
|
|
return;
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
const QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
const QString lastActiveToolId =
|
|
|
|
|
settings->value(QLatin1String(lastActiveToolC), QString()).toString();
|
2011-06-29 18:48:08 +02:00
|
|
|
int lastAction = 0;
|
2011-06-29 16:04:03 +02:00
|
|
|
|
|
|
|
|
foreach (IAnalyzerTool *tool, d->m_tools) {
|
|
|
|
|
tool->extensionsInitialized();
|
|
|
|
|
if (tool->id() == lastActiveToolId)
|
2011-06-29 18:48:08 +02:00
|
|
|
lastAction = d->indexOf(tool);
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
d->selectAction(lastAction);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::shutdown()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 18:48:08 +02:00
|
|
|
d->saveToolSettings(d->m_actions[d->m_currentIndex].tool);
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
AnalyzerManager *AnalyzerManager::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::registerRunControlFactory(ProjectExplorer::IRunControlFactory *factory)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
d->registerRunControlFactory(factory);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::addTool(IAnalyzerTool *tool)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
d->addTool(tool);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool, const QString &title,
|
|
|
|
|
QWidget *widget, Qt::DockWidgetArea area)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
QTC_ASSERT(!widget->objectName().isEmpty(), return 0;);
|
2011-03-04 16:00:03 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
QDockWidget *dockWidget = d->m_mainWindow->addDockForWidget(widget);
|
|
|
|
|
dockWidget->setProperty(INITIAL_DOCK_AREA, int(area));
|
2011-06-29 16:20:59 +02:00
|
|
|
d->m_dockWidgets.append(AnalyzerManagerPrivate::DockPtr(dockWidget));
|
2011-06-29 16:04:03 +02:00
|
|
|
dockWidget->setWindowTitle(title);
|
|
|
|
|
d->m_toolWidgets[tool].push_back(dockWidget);
|
|
|
|
|
d->addDock(area, dockWidget);
|
|
|
|
|
return dockWidget;
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
IAnalyzerEngine *AnalyzerManager::createEngine(const AnalyzerStartParameters &sp,
|
|
|
|
|
ProjectExplorer::RunConfiguration *runConfiguration)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 18:48:08 +02:00
|
|
|
IAnalyzerTool *tool = d->toolAt(d->m_currentIndex);
|
2011-06-29 16:04:03 +02:00
|
|
|
QTC_ASSERT(tool, return 0);
|
|
|
|
|
return tool->createEngine(sp, runConfiguration);
|
|
|
|
|
}
|
2011-06-27 16:13:46 +02:00
|
|
|
|
2011-06-29 18:48:08 +02:00
|
|
|
void AnalyzerManager::selectTool(IAnalyzerTool *tool)
|
|
|
|
|
{
|
|
|
|
|
d->selectAction(d->indexOf(tool));
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::startTool(IAnalyzerTool *tool)
|
|
|
|
|
{
|
2011-06-29 18:48:08 +02:00
|
|
|
d->startAction(d->indexOf(tool));
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
2011-05-26 19:57:07 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
Utils::FancyMainWindow *AnalyzerManager::mainWindow() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_mainWindow;
|
|
|
|
|
}
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::AnalyzerManagerPrivate::resetLayout()
|
|
|
|
|
{
|
2011-06-29 18:48:08 +02:00
|
|
|
m_mainWindow->restoreSettings(m_defaultSettings.value(toolAt(m_currentIndex)));
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
2011-03-08 13:56:52 +01:00
|
|
|
|
2011-03-16 13:49:28 +01:00
|
|
|
void AnalyzerManager::showStatusMessage(const QString &message, int timeoutMS)
|
|
|
|
|
{
|
|
|
|
|
d->m_statusLabel->showStatusMessage(message, timeoutMS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerManager::showPermanentStatusMessage(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
showStatusMessage(message, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AnalyzerManager::msgToolStarted(const QString &name)
|
|
|
|
|
{
|
2011-05-19 14:42:56 +02:00
|
|
|
return tr("Tool \"%1\" started...").arg(name);
|
2011-03-16 13:49:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AnalyzerManager::msgToolFinished(const QString &name, int issuesFound)
|
|
|
|
|
{
|
|
|
|
|
return issuesFound ?
|
2011-05-19 14:42:56 +02:00
|
|
|
tr("Tool \"%1\" finished, %n issues were found.", 0, issuesFound).arg(name) :
|
|
|
|
|
tr("Tool \"%1\" finished, no issues were found.").arg(name);
|
2011-03-16 13:49:28 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-04 15:00:18 +02:00
|
|
|
void AnalyzerManager::showMode()
|
|
|
|
|
{
|
|
|
|
|
if (d->m_mode)
|
|
|
|
|
ModeManager::instance()->activateMode(d->m_mode->id());
|
2011-05-20 09:12:34 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
void AnalyzerManager::stopTool()
|
|
|
|
|
{
|
|
|
|
|
d->stopTool();
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-08 13:56:52 +01:00
|
|
|
#include "analyzermanager.moc"
|