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"
|
|
|
|
|
#include "analyzeroptionspage.h"
|
2011-04-04 14:39:28 +02:00
|
|
|
#include "analyzerstartparameters.h"
|
|
|
|
|
#include "analyzerutils.h"
|
|
|
|
|
#include "ianalyzertool.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
|
|
|
|
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::Internal;
|
2011-07-04 10:50:44 +02:00
|
|
|
using namespace ProjectExplorer;
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
namespace Analyzer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
const char LAST_ACTIVE_TOOL[] = "Analyzer.Plugin.LastActiveTool";
|
2011-06-29 18:48:08 +02:00
|
|
|
const char INITIAL_DOCK_AREA[] = "initial_dock_area";
|
2011-06-29 16:04:03 +02:00
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// AnalyzerMode
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
2011-03-04 12:15:18 +01:00
|
|
|
|
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
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// AnalyzerManagerPrivate
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
class 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-06-30 19:13:55 +02:00
|
|
|
void 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-30 18:55:48 +02:00
|
|
|
void addTool(IAnalyzerTool *tool, const StartModes &modes);
|
2011-07-01 14:19:12 +02:00
|
|
|
void selectSavedTool();
|
2011-06-30 18:55:48 +02:00
|
|
|
void selectTool(IAnalyzerTool *tool, StartMode mode);
|
2011-07-04 10:50:44 +02:00
|
|
|
void handleToolStarted();
|
|
|
|
|
void handleToolFinished();
|
2011-07-01 14:19:12 +02:00
|
|
|
void saveToolSettings(IAnalyzerTool *tool, StartMode mode);
|
|
|
|
|
void loadToolSettings(IAnalyzerTool *tool);
|
|
|
|
|
QAction *actionFromToolAndMode(IAnalyzerTool *tool, StartMode mode);
|
2011-06-30 13:44:22 +02:00
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
// Convenience.
|
|
|
|
|
void startLocalTool(IAnalyzerTool *tool, StartMode mode);
|
|
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
public slots:
|
2011-06-30 13:44:22 +02:00
|
|
|
void startTool();
|
2011-07-05 17:21:43 +02:00
|
|
|
void selectToolboxAction(int);
|
|
|
|
|
void selectMenuAction();
|
2011-06-29 16:04:03 +02:00
|
|
|
void modeChanged(Core::IMode *mode);
|
|
|
|
|
void resetLayout();
|
|
|
|
|
void updateRunActions();
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
public:
|
2011-03-04 12:15:18 +01:00
|
|
|
AnalyzerManager *q;
|
|
|
|
|
AnalyzerMode *m_mode;
|
2011-07-04 10:50:44 +02:00
|
|
|
bool m_isRunning;
|
2011-03-04 12:15:18 +01:00
|
|
|
Utils::FancyMainWindow *m_mainWindow;
|
2011-06-30 13:44:22 +02:00
|
|
|
IAnalyzerTool *m_currentTool;
|
2011-06-30 18:55:48 +02:00
|
|
|
StartMode m_currentMode;
|
2011-06-30 13:44:22 +02:00
|
|
|
QHash<QAction *, IAnalyzerTool *> m_toolFromAction;
|
2011-07-01 14:19:12 +02:00
|
|
|
QHash<QAction *, StartMode> m_modeFromAction;
|
2011-04-04 14:39:28 +02:00
|
|
|
QList<IAnalyzerTool *> m_tools;
|
2011-06-30 18:55:48 +02:00
|
|
|
QList<QAction *> m_actions;
|
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-16 13:49:28 +01:00
|
|
|
Utils::StatusLabel *m_statusLabel;
|
2011-05-06 14:02:03 +02:00
|
|
|
typedef QMap<IAnalyzerTool *, FancyMainWindowSettings> MainWindowSettingsMap;
|
2011-06-30 13:44:22 +02:00
|
|
|
QHash<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-07-05 17:21:43 +02:00
|
|
|
bool m_handlingManualAction;
|
2011-03-04 12:15:18 +01:00
|
|
|
};
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
|
2011-03-04 12:15:18 +01:00
|
|
|
q(qq),
|
|
|
|
|
m_mode(0),
|
2011-07-04 10:50:44 +02:00
|
|
|
m_isRunning(false),
|
2011-03-04 12:15:18 +01:00
|
|
|
m_mainWindow(0),
|
2011-06-30 13:44:22 +02:00
|
|
|
m_currentTool(0),
|
2011-06-30 18:55:48 +02:00
|
|
|
m_currentMode(),
|
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-16 13:49:28 +01:00
|
|
|
m_statusLabel(new Utils::StatusLabel),
|
2011-07-05 17:21:43 +02:00
|
|
|
m_restartOnStop(false),
|
|
|
|
|
m_handlingManualAction(false)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-03-10 16:11:20 +01:00
|
|
|
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
|
2011-07-05 17:21:43 +02:00
|
|
|
connect(m_toolBox, SIGNAL(currentIndexChanged(int)), SLOT(selectToolboxAction(int)));
|
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*)));
|
2011-07-04 10:50:44 +02:00
|
|
|
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
2011-06-29 16:04:03 +02:00
|
|
|
connect(pe, SIGNAL(updateRunActions()), SLOT(updateRunActions()));
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
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-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::setupActions()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
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-07-05 17:21:43 +02:00
|
|
|
m_menu->appendGroup(Constants::G_ANALYZER_CONTROL);
|
2011-06-30 13:44:22 +02:00
|
|
|
m_menu->appendGroup(Constants::G_ANALYZER_TOOLS);
|
|
|
|
|
m_menu->appendGroup(Constants::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-30 13:44:22 +02:00
|
|
|
connect(m_startAction, SIGNAL(triggered()), this, SLOT(startTool()));
|
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-07-05 17:21:43 +02:00
|
|
|
m_menu->addAction(command, Constants::G_ANALYZER_CONTROL);
|
|
|
|
|
|
|
|
|
|
QAction *separatorAction1 = new QAction(m_menu);
|
|
|
|
|
separatorAction1->setSeparator(true);
|
|
|
|
|
command = am->registerAction(separatorAction1,
|
|
|
|
|
"Menu.Action.Analyzer.Tools.Separator1", globalcontext);
|
|
|
|
|
m_menu->addAction(command, Constants::G_ANALYZER_TOOLS);
|
|
|
|
|
|
|
|
|
|
QAction *separatorAction2 = new QAction(m_menu);
|
|
|
|
|
separatorAction2->setSeparator(true);
|
|
|
|
|
command = am->registerAction(separatorAction2,
|
|
|
|
|
"Menu.Action.Analyzer.Tools.Separator2", globalcontext);
|
2011-06-30 13:44:22 +02:00
|
|
|
m_menu->addAction(command, Constants::G_ANALYZER_REMOTE_TOOLS);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::delayedInit()
|
2011-03-04 16:00:03 +01:00
|
|
|
{
|
2011-06-30 19:13:55 +02:00
|
|
|
if (m_mode)
|
2011-03-04 16:00:03 +01:00
|
|
|
return;
|
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
m_mode = new AnalyzerMode(q);
|
2011-06-30 19:13:55 +02:00
|
|
|
createModeMainWindow();
|
2011-03-04 16:00:03 +01:00
|
|
|
|
2011-06-30 19:13:55 +02:00
|
|
|
// Right-side window with editor, output etc.
|
2011-03-04 12:15:18 +01:00
|
|
|
MiniSplitter *mainWindowSplitter = new MiniSplitter;
|
2011-06-30 19:13:55 +02:00
|
|
|
mainWindowSplitter->addWidget(m_mainWindow);
|
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);
|
|
|
|
|
|
2011-06-30 19:13:55 +02:00
|
|
|
// Navigation + right-side window.
|
2011-03-04 12:15:18 +01:00
|
|
|
MiniSplitter *splitter = new MiniSplitter;
|
|
|
|
|
splitter->addWidget(new NavigationWidgetPlaceHolder(m_mode));
|
|
|
|
|
splitter->addWidget(mainWindowSplitter);
|
|
|
|
|
splitter->setStretchFactor(0, 0);
|
|
|
|
|
splitter->setStretchFactor(1, 1);
|
2011-06-30 19:13:55 +02:00
|
|
|
m_mode->setWidget(splitter);
|
|
|
|
|
|
|
|
|
|
AnalyzerPlugin::instance()->addAutoReleasedObject(m_mode);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QToolButton *toolButton(QAction *action)
|
|
|
|
|
{
|
|
|
|
|
QToolButton *button = new QToolButton;
|
|
|
|
|
button->setDefaultAction(action);
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-30 19:13:55 +02:00
|
|
|
void AnalyzerManagerPrivate::createModeMainWindow()
|
2011-03-10 16:11:20 +01:00
|
|
|
{
|
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);
|
2011-07-04 10:50:44 +02:00
|
|
|
m_mainWindow->setDockActionsVisible(false);
|
|
|
|
|
//ModeManager::instance()->currentMode() cannot be us yet.
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-30 19:13:55 +02:00
|
|
|
void AnalyzerManagerPrivate::addDock(Qt::DockWidgetArea area, QDockWidget *dockWidget)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
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());
|
2011-07-01 14:19:12 +02:00
|
|
|
Command *cmd = am->registerAction(toggleViewAction,
|
|
|
|
|
QString("Analyzer." + dockWidget->objectName()), globalContext);
|
2011-03-04 12:15:18 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2011-06-30 19:13:55 +02:00
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
ActionContainer *viewsMenu =
|
|
|
|
|
am->actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS));
|
2011-06-30 19:13:55 +02:00
|
|
|
viewsMenu->addAction(cmd);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-04 14:39:28 +02:00
|
|
|
bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
|
2011-07-04 10:50:44 +02:00
|
|
|
BuildConfiguration::BuildType buildType)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
if (toolMode == IAnalyzerTool::AnyMode)
|
|
|
|
|
return true;
|
2011-07-04 10:50:44 +02:00
|
|
|
if (buildType == BuildConfiguration::Unknown)
|
2011-03-04 12:15:18 +01:00
|
|
|
return true;
|
2011-07-04 10:50:44 +02:00
|
|
|
if (buildType == BuildConfiguration::Debug
|
2011-05-19 13:43:19 +02:00
|
|
|
&& toolMode == IAnalyzerTool::DebugMode)
|
2011-03-04 12:15:18 +01:00
|
|
|
return true;
|
2011-07-04 10:50:44 +02:00
|
|
|
if (buildType == BuildConfiguration::Release
|
2011-05-19 13:43:19 +02:00
|
|
|
&& 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-06-30 19:13:55 +02:00
|
|
|
bool AnalyzerManagerPrivate::showPromptDialog(const QString &title, const QString &text,
|
|
|
|
|
const QString &stopButtonText, const QString &cancelButtonText) const
|
2011-04-04 14:39:28 +02:00
|
|
|
{
|
|
|
|
|
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-07-05 17:21:43 +02:00
|
|
|
void AnalyzerManagerPrivate::startLocalTool(IAnalyzerTool *tool, StartMode)
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-06-30 19:13:55 +02:00
|
|
|
int index = m_tools.indexOf(tool);
|
2011-06-29 18:48:08 +02:00
|
|
|
QTC_ASSERT(index >= 0, return);
|
2011-06-30 13:44:22 +02:00
|
|
|
QTC_ASSERT(index < m_tools.size(), return);
|
|
|
|
|
QTC_ASSERT(tool == m_currentTool, return);
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
// Make sure mode is shown.
|
2011-04-04 15:00:18 +02:00
|
|
|
q->showMode();
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
2011-07-04 10:50:44 +02:00
|
|
|
Project *pro = pe->startupProject();
|
|
|
|
|
const RunConfiguration *runConfig = 0;
|
|
|
|
|
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
|
2011-03-29 14:45:21 +02:00
|
|
|
if (pro) {
|
2011-07-04 10:50:44 +02:00
|
|
|
if (const Target *target = pro->activeTarget()) {
|
2011-03-29 14:45:21 +02:00
|
|
|
runConfig = target->activeRunConfiguration();
|
|
|
|
|
// Build configuration is 0 for QML projects.
|
2011-07-04 10:50:44 +02:00
|
|
|
if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration())
|
2011-03-29 14:45:21 +02:00
|
|
|
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-07-04 10:50:44 +02:00
|
|
|
if (m_isRunning) {
|
2011-04-04 14:39:28 +02:00
|
|
|
// 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>")
|
2011-07-01 14:19:12 +02:00
|
|
|
.arg(m_currentTool->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-07-04 10:50:44 +02:00
|
|
|
q->stopTool();
|
2011-04-04 14:39:28 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
IAnalyzerTool::ToolMode toolMode = tool->toolMode();
|
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)) {
|
2011-06-30 18:55:48 +02:00
|
|
|
const QString toolName = tool->displayName();
|
2011-07-04 10:50:44 +02:00
|
|
|
const QString currentMode =
|
|
|
|
|
buildType == BuildConfiguration::Debug ? tr("Debug") : tr("Release");
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
2011-07-04 10:50:44 +02:00
|
|
|
const QString configKey = QLatin1String("Analyzer.AnalyzeCorrectMode");
|
2011-03-04 12:15:18 +01:00
|
|
|
int ret;
|
|
|
|
|
if (settings->contains(configKey)) {
|
|
|
|
|
ret = settings->value(configKey, QDialog::Accepted).toInt();
|
|
|
|
|
} else {
|
2011-07-01 14:19:12 +02:00
|
|
|
QString toolModeString;
|
|
|
|
|
switch (toolMode) {
|
|
|
|
|
case IAnalyzerTool::DebugMode:
|
|
|
|
|
toolModeString = tr("Debug");
|
|
|
|
|
case IAnalyzerTool::ReleaseMode:
|
|
|
|
|
toolModeString = tr("Release");
|
|
|
|
|
case IAnalyzerTool::AnyMode:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-03-15 14:18:41 +01:00
|
|
|
const QString title = tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode);
|
2011-07-04 10:50:44 +02:00
|
|
|
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(toolModeString);
|
2011-03-15 14:18:41 +01:00
|
|
|
const QString checkBoxText = tr("&Do not ask again");
|
|
|
|
|
bool checkBoxSetting = false;
|
|
|
|
|
const QDialogButtonBox::StandardButton button =
|
2011-07-04 10:50:44 +02:00
|
|
|
Utils::CheckableMessageBox::question(Core::ICore::instance()->mainWindow(),
|
|
|
|
|
title, message, checkBoxText,
|
|
|
|
|
&checkBoxSetting, QDialogButtonBox::Yes|QDialogButtonBox::Cancel,
|
|
|
|
|
QDialogButtonBox::Cancel);
|
2011-03-15 14:18:41 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
m_isRunning = true;
|
|
|
|
|
pe->runProject(pro, tool->id());
|
2011-06-29 16:04:03 +02:00
|
|
|
updateRunActions();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::startTool()
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2011-06-30 18:55:48 +02:00
|
|
|
m_currentTool->startTool(m_currentMode);
|
2011-06-30 13:44:22 +02:00
|
|
|
}
|
2011-03-04 16:00:03 +01:00
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::modeChanged(IMode *mode)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-07-06 14:41:16 +02:00
|
|
|
if (mode && mode == m_mode) {
|
|
|
|
|
m_mainWindow->setDockActionsVisible(true);
|
|
|
|
|
static bool firstTime = true;
|
|
|
|
|
if (firstTime)
|
|
|
|
|
selectSavedTool();
|
|
|
|
|
firstTime = false;
|
|
|
|
|
updateRunActions();
|
|
|
|
|
} else {
|
|
|
|
|
m_mainWindow->setDockActionsVisible(false);
|
|
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
QAction *AnalyzerManagerPrivate::actionFromToolAndMode(IAnalyzerTool *tool, StartMode mode)
|
|
|
|
|
{
|
|
|
|
|
foreach (QAction *action, m_actions)
|
2011-07-05 17:21:43 +02:00
|
|
|
if (m_toolFromAction.value(action) == tool && m_modeFromAction[action] == mode)
|
2011-07-01 14:19:12 +02:00
|
|
|
return action;
|
|
|
|
|
QTC_ASSERT(false, /**/);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerManagerPrivate::selectSavedTool()
|
|
|
|
|
{
|
|
|
|
|
const QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
const QByteArray lastActiveAction =
|
|
|
|
|
settings->value(QLatin1String(LAST_ACTIVE_TOOL), QString()).toByteArray();
|
|
|
|
|
foreach (QAction *action, m_actions) {
|
2011-07-05 17:21:43 +02:00
|
|
|
IAnalyzerTool *tool = m_toolFromAction.value(action);
|
|
|
|
|
StartMode mode = m_modeFromAction.value(action);
|
2011-07-01 14:19:12 +02:00
|
|
|
if (tool->actionId(mode) == lastActiveAction) {
|
|
|
|
|
selectTool(tool, mode);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-05 17:21:43 +02:00
|
|
|
void AnalyzerManagerPrivate::selectMenuAction()
|
2011-07-01 14:19:12 +02:00
|
|
|
{
|
2011-07-05 17:21:43 +02:00
|
|
|
if (m_handlingManualAction)
|
|
|
|
|
return;
|
|
|
|
|
m_handlingManualAction = true;
|
|
|
|
|
QAction *action = qobject_cast<QAction *>(sender());
|
|
|
|
|
QTC_ASSERT(action, return);
|
|
|
|
|
IAnalyzerTool *tool = m_toolFromAction.value(action);
|
|
|
|
|
StartMode mode = m_modeFromAction.value(action);
|
|
|
|
|
selectTool(tool, mode);
|
|
|
|
|
tool->startTool(mode);
|
|
|
|
|
m_handlingManualAction = false;
|
2011-07-01 14:19:12 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-05 17:21:43 +02:00
|
|
|
void AnalyzerManagerPrivate::selectToolboxAction(int index)
|
2011-07-01 14:19:12 +02:00
|
|
|
{
|
2011-07-05 17:21:43 +02:00
|
|
|
if (m_handlingManualAction)
|
|
|
|
|
return;
|
|
|
|
|
m_handlingManualAction = true;
|
|
|
|
|
QAction *action = m_actions[index];
|
|
|
|
|
selectTool(m_toolFromAction.value(action), m_modeFromAction.value(action));
|
|
|
|
|
m_handlingManualAction = false;
|
2011-07-01 14:19:12 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::selectTool(IAnalyzerTool *tool, StartMode mode)
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2011-07-01 14:19:12 +02:00
|
|
|
if (m_currentTool == tool && m_currentMode == mode)
|
2011-03-04 12:15:18 +01:00
|
|
|
return;
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
QAction *action = actionFromToolAndMode(tool, mode);
|
|
|
|
|
const int actionIndex = m_actions.indexOf(action);
|
|
|
|
|
QTC_ASSERT(actionIndex >= 0, return);
|
|
|
|
|
|
|
|
|
|
saveToolSettings(m_currentTool, m_currentMode);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
// Clean up old tool.
|
|
|
|
|
if (m_currentTool) {
|
2011-03-04 12:15:18 +01:00
|
|
|
ActionManager *am = ICore::instance()->actionManager();
|
|
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
foreach (QDockWidget *widget, m_toolWidgets.value(m_currentTool)) {
|
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-07-01 14:19:12 +02:00
|
|
|
m_currentTool->toolDeselected();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
// Now change the tool.
|
2011-06-30 13:44:22 +02:00
|
|
|
m_currentTool = tool;
|
2011-06-30 18:55:48 +02:00
|
|
|
m_currentMode = mode;
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2011-06-30 13:44:22 +02:00
|
|
|
const bool firstTime = !m_defaultSettings.contains(tool);
|
2011-05-06 17:26:01 +02:00
|
|
|
if (firstTime) {
|
2011-06-30 13:44:22 +02:00
|
|
|
tool->initializeDockWidgets();
|
|
|
|
|
m_defaultSettings.insert(tool, m_mainWindow->saveSettings());
|
2011-05-06 17:26:01 +02:00
|
|
|
} else {
|
2011-06-30 13:44:22 +02:00
|
|
|
foreach (QDockWidget *widget, m_toolWidgets.value(tool))
|
2011-06-29 16:04:03 +02:00
|
|
|
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-06-30 13:44:22 +02:00
|
|
|
loadToolSettings(tool);
|
2011-06-30 18:55:48 +02:00
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
m_toolBox->setCurrentIndex(actionIndex);
|
|
|
|
|
m_controlsWidget->setCurrentIndex(actionIndex);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
updateRunActions();
|
2011-06-29 18:48:08 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::addTool(IAnalyzerTool *tool, const StartModes &modes)
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-06-30 19:30:56 +02:00
|
|
|
delayedInit(); // Make sure that there is a valid IMode instance.
|
2011-06-30 18:55:48 +02:00
|
|
|
|
|
|
|
|
const bool blocked = m_toolBox->blockSignals(true); // Do not make current.
|
2011-06-30 19:30:56 +02:00
|
|
|
m_controlsWidget->addWidget(tool->createControlWidget());
|
|
|
|
|
ActionManager *am = Core::ICore::instance()->actionManager();
|
2011-06-30 18:55:48 +02:00
|
|
|
foreach (StartMode mode, modes) {
|
|
|
|
|
QString actionName = tool->actionName(mode);
|
|
|
|
|
QString menuGroup = tool->menuGroup(mode);
|
|
|
|
|
QString actionId = tool->actionId(mode);
|
|
|
|
|
QAction *action = new QAction(actionName, 0);
|
|
|
|
|
Core::Command *command = am->registerAction(action, actionId,
|
|
|
|
|
Core::Context(Core::Constants::C_GLOBAL));
|
|
|
|
|
m_menu->addAction(command, menuGroup);
|
|
|
|
|
m_actions.append(action);
|
|
|
|
|
m_toolFromAction[action] = tool;
|
2011-07-01 14:19:12 +02:00
|
|
|
m_modeFromAction[action] = mode;
|
2011-06-30 18:55:48 +02:00
|
|
|
m_toolBox->addItem(actionName);
|
|
|
|
|
m_toolBox->blockSignals(blocked);
|
2011-07-05 17:21:43 +02:00
|
|
|
connect(action, SIGNAL(triggered()), SLOT(selectMenuAction()));
|
2011-06-30 18:55:48 +02:00
|
|
|
}
|
2011-06-30 13:44:22 +02:00
|
|
|
m_tools.append(tool);
|
2011-07-01 14:19:12 +02:00
|
|
|
m_toolBox->setEnabled(true);
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
void AnalyzerManagerPrivate::handleToolStarted()
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-07-04 10:50:44 +02:00
|
|
|
m_isRunning = true; // FIXME: Make less global.
|
2011-07-05 12:56:49 +02:00
|
|
|
updateRunActions();
|
2011-07-04 10:50:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerManagerPrivate::handleToolFinished()
|
|
|
|
|
{
|
|
|
|
|
m_isRunning = false;
|
2011-06-29 16:04:03 +02:00
|
|
|
updateRunActions();
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
if (m_restartOnStop) {
|
2011-06-30 18:55:48 +02:00
|
|
|
m_currentTool->startTool(m_currentMode);
|
2011-06-29 16:04:03 +02:00
|
|
|
m_restartOnStop = false;
|
|
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void 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-07-01 14:19:12 +02:00
|
|
|
void AnalyzerManagerPrivate::saveToolSettings(IAnalyzerTool *tool, StartMode mode)
|
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();
|
2011-07-01 14:19:12 +02:00
|
|
|
settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), tool->actionId(mode));
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::updateRunActions()
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-07-05 17:21:43 +02:00
|
|
|
static bool previousRunning = true;
|
|
|
|
|
static IAnalyzerTool *previousTool = 0;
|
|
|
|
|
if (previousRunning == m_isRunning && previousTool == m_currentTool)
|
|
|
|
|
return;
|
|
|
|
|
previousTool = m_currentTool;
|
|
|
|
|
previousRunning = m_isRunning;
|
|
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
|
|
|
|
Project *project = pe->startupProject();
|
2011-06-29 16:04:03 +02:00
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
bool startEnabled = !m_isRunning
|
|
|
|
|
&& m_currentTool && pe->canRun(project, m_currentTool->id());
|
2011-06-29 16:04:03 +02:00
|
|
|
|
|
|
|
|
QString disabledReason;
|
2011-07-04 10:50:44 +02:00
|
|
|
if (m_isRunning)
|
2011-06-29 16:04:03 +02:00
|
|
|
disabledReason = tr("An analysis is still in progress.");
|
2011-06-30 13:44:22 +02:00
|
|
|
else if (!m_currentTool)
|
2011-06-29 16:04:03 +02:00
|
|
|
disabledReason = tr("No analyzer tool selected.");
|
|
|
|
|
else
|
2011-07-04 10:50:44 +02:00
|
|
|
disabledReason = pe->cannotRunReason(project, m_currentTool->id());
|
2011-06-29 16:04:03 +02:00
|
|
|
|
|
|
|
|
m_startAction->setEnabled(startEnabled);
|
|
|
|
|
m_startAction->setToolTip(disabledReason);
|
2011-07-04 10:50:44 +02:00
|
|
|
m_toolBox->setEnabled(!m_isRunning);
|
|
|
|
|
m_stopAction->setEnabled(m_isRunning);
|
2011-07-05 17:21:43 +02:00
|
|
|
foreach (QAction *action, m_actions)
|
|
|
|
|
action->setEnabled(!m_isRunning);
|
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-30 18:55:48 +02:00
|
|
|
foreach (IAnalyzerTool *tool, d->m_tools)
|
2011-06-29 16:04:03 +02:00
|
|
|
tool->extensionsInitialized();
|
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-07-01 14:19:12 +02:00
|
|
|
d->saveToolSettings(d->m_currentTool, d->m_currentMode);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManager::addTool(IAnalyzerTool *tool, const StartModes &modes)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-30 18:55:48 +02:00
|
|
|
m_instance->d->addTool(tool, modes);
|
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-30 13:44:22 +02:00
|
|
|
QTC_ASSERT(!widget->objectName().isEmpty(), return 0);
|
|
|
|
|
AnalyzerManagerPrivate *d = m_instance->d;
|
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-30 18:55:48 +02:00
|
|
|
void AnalyzerManager::selectTool(IAnalyzerTool *tool, StartMode mode)
|
2011-06-29 18:48:08 +02:00
|
|
|
{
|
2011-06-30 18:55:48 +02:00
|
|
|
m_instance->d->selectTool(tool, mode);
|
2011-06-29 18:48:08 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManager::startTool(IAnalyzerTool *tool, StartMode mode)
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
QTC_ASSERT(tool == m_instance->d->m_currentTool, return);
|
2011-06-30 18:55:48 +02:00
|
|
|
tool->startTool(mode);
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
2011-05-26 19:57:07 +02:00
|
|
|
|
2011-06-30 13:44:22 +02:00
|
|
|
Utils::FancyMainWindow *AnalyzerManager::mainWindow()
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
return m_instance->d->m_mainWindow;
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::resetLayout()
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentTool));
|
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)
|
|
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
m_instance->d->m_statusLabel->showStatusMessage(message, timeoutMS);
|
2011-03-16 13:49:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
if (m_instance->d->m_mode)
|
|
|
|
|
ModeManager::instance()->activateMode(m_instance->d->m_mode->id());
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
void AnalyzerManager::stopTool()
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2011-07-04 10:50:44 +02:00
|
|
|
stopAction()->trigger();
|
2011-06-30 13:44:22 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-04 18:33:47 +02:00
|
|
|
void AnalyzerManager::startLocalTool(IAnalyzerTool *tool, StartMode mode)
|
|
|
|
|
{
|
|
|
|
|
m_instance->d->startLocalTool(tool, mode);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
QAction *AnalyzerManager::stopAction()
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2011-07-04 10:50:44 +02:00
|
|
|
return m_instance->d->m_stopAction;
|
2011-06-30 13:44:22 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-05 12:56:49 +02:00
|
|
|
void AnalyzerManager::handleToolStarted()
|
|
|
|
|
{
|
|
|
|
|
m_instance->d->handleToolStarted();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
void AnalyzerManager::handleToolFinished()
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2011-07-04 10:50:44 +02:00
|
|
|
m_instance->d->handleToolFinished();
|
2011-05-20 09:12:34 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
IAnalyzerTool *AnalyzerManager::toolFromId(const QByteArray &id)
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2011-06-30 13:44:22 +02:00
|
|
|
foreach (IAnalyzerTool *tool, m_instance->d->m_tools)
|
2011-07-04 10:50:44 +02:00
|
|
|
if (id.startsWith(tool->id()))
|
2011-06-30 13:44:22 +02:00
|
|
|
return tool;
|
|
|
|
|
QTC_ASSERT(false, qDebug() << "NO ANAYLYZER TOOL FOUND FOR ID" << id);
|
|
|
|
|
return 0;
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
} // namespace Analyzer
|
|
|
|
|
|
2011-03-08 13:56:52 +01:00
|
|
|
#include "analyzermanager.moc"
|