2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2011-03-04 12:15:18 +01:00
|
|
|
** Author: Andreas Hartmetz, KDAB (andreas.hartmetz@kdab.com)
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-03-04 12:15:18 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include "analyzermanager.h"
|
|
|
|
|
|
|
|
|
|
#include "analyzerplugin.h"
|
2011-04-04 14:39:28 +02:00
|
|
|
#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/modemanager.h>
|
|
|
|
|
#include <coreplugin/navigationwidget.h>
|
|
|
|
|
#include <coreplugin/outputpane.h>
|
|
|
|
|
#include <coreplugin/rightpane.h>
|
2011-06-27 16:13:46 +02:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2011-03-08 13:56:52 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2013-09-05 11:46:07 +02:00
|
|
|
#include <projectexplorer/session.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
#include <projectexplorer/target.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-03-04 12:15:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QStackedWidget>
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
#include <QDialogButtonBox>
|
2012-09-24 13:48:18 +02:00
|
|
|
#include <QPointer>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPushButton>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
using namespace Core;
|
2013-08-30 15:31:03 +02:00
|
|
|
using namespace Utils;
|
2012-01-19 23:44:35 +01:00
|
|
|
using namespace Core::Constants;
|
2011-03-04 12:15:18 +01:00
|
|
|
using namespace Analyzer::Internal;
|
2012-01-19 23:44:35 +01:00
|
|
|
using namespace Analyzer::Constants;
|
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
|
|
|
|
2012-01-19 23:44:35 +01:00
|
|
|
class AnalyzerMode : public IMode
|
2011-03-08 13:56:52 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
AnalyzerMode(QObject *parent = 0)
|
2012-01-19 23:44:35 +01:00
|
|
|
: IMode(parent)
|
2011-04-13 13:00:30 +02:00
|
|
|
{
|
2014-07-01 13:20:53 +02:00
|
|
|
setContext(Context(C_ANALYZEMODE, C_NAVIGATION_PANE));
|
2011-04-13 16:09:04 +02:00
|
|
|
setDisplayName(tr("Analyze"));
|
2012-01-25 17:39:50 +01:00
|
|
|
setIcon(QIcon(QLatin1String(":/images/analyzer_mode.png")));
|
2012-01-19 23:44:35 +01:00
|
|
|
setPriority(P_MODE_ANALYZE);
|
2012-05-07 18:28:03 +02:00
|
|
|
setId(MODE_ANALYZE);
|
2011-04-13 13:00:30 +02:00
|
|
|
}
|
2011-03-08 13:56:52 +01:00
|
|
|
|
|
|
|
|
~AnalyzerMode()
|
|
|
|
|
{
|
2012-01-19 23:44:35 +01:00
|
|
|
delete m_widget;
|
|
|
|
|
m_widget = 0;
|
2011-03-08 13:56:52 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
/**
|
2012-01-19 23:44:35 +01:00
|
|
|
* After calling this, a proper instance of 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-07-06 16:28:02 +02:00
|
|
|
void activateDock(Qt::DockWidgetArea area, QDockWidget *dockWidget);
|
|
|
|
|
void deactivateDock(QDockWidget *dockWidget);
|
2013-08-07 19:47:30 +02:00
|
|
|
void addAction(AnalyzerAction *action);
|
2011-07-01 14:19:12 +02:00
|
|
|
void selectSavedTool();
|
2013-08-07 19:47:30 +02:00
|
|
|
void selectAction(AnalyzerAction *action);
|
2011-07-04 10:50:44 +02:00
|
|
|
void handleToolStarted();
|
|
|
|
|
void handleToolFinished();
|
2013-08-07 19:47:30 +02:00
|
|
|
void saveToolSettings(AnalyzerAction *action);
|
|
|
|
|
void loadToolSettings(AnalyzerAction *action);
|
2011-06-30 13:44:22 +02:00
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
// Convenience.
|
2013-08-07 19:47:30 +02:00
|
|
|
bool isActionRunnable(AnalyzerAction *action) const;
|
2011-06-30 18:55:48 +02:00
|
|
|
|
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();
|
2015-02-03 23:56:02 +02:00
|
|
|
void modeChanged(IMode *mode);
|
2011-06-29 16:04:03 +02:00
|
|
|
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;
|
2013-08-30 15:31:03 +02:00
|
|
|
FancyMainWindow *m_mainWindow;
|
2013-08-07 19:47:30 +02:00
|
|
|
AnalyzerAction *m_currentAction;
|
|
|
|
|
QList<AnalyzerAction *> 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-07-06 16:28:02 +02:00
|
|
|
QStackedWidget *m_controlsStackWidget;
|
2013-08-30 15:31:03 +02:00
|
|
|
StatusLabel *m_statusLabel;
|
2015-02-18 14:35:20 +01:00
|
|
|
typedef QMap<Id, FancyMainWindowSettings> MainWindowSettingsMap;
|
|
|
|
|
QHash<Id, QList<QDockWidget *> > m_toolWidgets;
|
|
|
|
|
QHash<Id, QWidget *> m_controlsWidgetFromTool;
|
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
|
2012-09-24 13:48:18 +02:00
|
|
|
typedef QPointer<QDockWidget> DockPtr;
|
2011-03-04 16:00:01 +01:00
|
|
|
QList<DockPtr> m_dockWidgets;
|
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-11-29 13:03:29 +01:00
|
|
|
m_currentAction(0),
|
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-07-06 16:28:02 +02:00
|
|
|
m_controlsStackWidget(new QStackedWidget),
|
2013-08-30 15:31:03 +02:00
|
|
|
m_statusLabel(new StatusLabel)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-03-10 16:11:20 +01:00
|
|
|
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
|
2014-10-16 18:45:14 +02:00
|
|
|
connect(m_toolBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
|
|
|
|
|
this, &AnalyzerManagerPrivate::selectToolboxAction);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
setupActions();
|
2011-06-29 16:04:03 +02:00
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
2014-10-16 18:45:14 +02:00
|
|
|
connect(pe, &ProjectExplorerPlugin::updateRunActions, this, &AnalyzerManagerPrivate::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
|
|
|
{
|
2012-01-19 23:44:35 +01:00
|
|
|
const Context globalcontext(C_GLOBAL);
|
|
|
|
|
Command *command = 0;
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
// Menus
|
2014-10-16 18:45:14 +02:00
|
|
|
m_menu = ActionManager::createMenu(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);
|
|
|
|
|
|
2012-01-19 23:44:35 +01:00
|
|
|
m_menu->appendGroup(G_ANALYZER_CONTROL);
|
|
|
|
|
m_menu->appendGroup(G_ANALYZER_TOOLS);
|
|
|
|
|
m_menu->appendGroup(G_ANALYZER_REMOTE_TOOLS);
|
|
|
|
|
m_menu->appendGroup(G_ANALYZER_OPTIONS);
|
2011-04-04 13:03:45 +02:00
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
ActionContainer *menubar = ActionManager::actionContainer(MENU_BAR);
|
|
|
|
|
ActionContainer *mtools = ActionManager::actionContainer(M_TOOLS);
|
2011-06-28 19:58:19 +02:00
|
|
|
menubar->addMenu(mtools, m_menu);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
m_startAction = new QAction(tr("Start"), m_menu);
|
2012-01-25 17:39:50 +01:00
|
|
|
m_startAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_START_ICON)));
|
2014-10-16 18:45:14 +02:00
|
|
|
ActionManager::registerAction(m_startAction, "Analyzer.Start", globalcontext);
|
|
|
|
|
connect(m_startAction, &QAction::triggered, this, &AnalyzerManagerPrivate::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);
|
2012-01-25 17:39:50 +01:00
|
|
|
m_stopAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_STOP_ICON)));
|
2014-10-16 18:45:14 +02:00
|
|
|
command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop", globalcontext);
|
2012-01-19 23:44:35 +01:00
|
|
|
m_menu->addAction(command, G_ANALYZER_CONTROL);
|
2011-07-05 17:21:43 +02:00
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
m_menu->addSeparator(globalcontext, G_ANALYZER_TOOLS);
|
|
|
|
|
m_menu->addSeparator(globalcontext, G_ANALYZER_REMOTE_TOOLS);
|
|
|
|
|
m_menu->addSeparator(globalcontext, G_ANALYZER_OPTIONS);
|
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
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
|
|
|
|
this, &AnalyzerManagerPrivate::modeChanged);
|
2012-10-31 12:14:24 +01:00
|
|
|
|
2011-06-30 19:13:55 +02:00
|
|
|
// Right-side window with editor, output etc.
|
2014-10-16 18:45:14 +02:00
|
|
|
auto 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.
|
2014-10-16 18:45:14 +02:00
|
|
|
auto splitter = new MiniSplitter;
|
2011-03-04 12:15:18 +01:00
|
|
|
splitter->addWidget(new NavigationWidgetPlaceHolder(m_mode));
|
|
|
|
|
splitter->addWidget(mainWindowSplitter);
|
|
|
|
|
splitter->setStretchFactor(0, 0);
|
|
|
|
|
splitter->setStretchFactor(1, 1);
|
2014-10-16 18:45:14 +02:00
|
|
|
|
|
|
|
|
auto modeContextObject = new IContext(this);
|
|
|
|
|
modeContextObject->setContext(Context(C_EDITORMANAGER));
|
2014-07-01 13:20:53 +02:00
|
|
|
modeContextObject->setWidget(splitter);
|
2014-10-16 18:45:14 +02:00
|
|
|
ICore::addContextObject(modeContextObject);
|
2011-06-30 19:13:55 +02:00
|
|
|
m_mode->setWidget(splitter);
|
|
|
|
|
|
|
|
|
|
AnalyzerPlugin::instance()->addAutoReleasedObject(m_mode);
|
2011-07-12 09:17:55 +02:00
|
|
|
|
|
|
|
|
// Populate Windows->Views menu with standard actions.
|
2012-01-19 23:44:35 +01:00
|
|
|
Context analyzerContext(C_ANALYZEMODE);
|
2014-10-16 18:45:14 +02:00
|
|
|
ActionContainer *viewsMenu = ActionManager::actionContainer(M_WINDOW_VIEWS);
|
|
|
|
|
Command *cmd = ActionManager::registerAction(m_mainWindow->menuSeparator1(),
|
2013-09-03 11:42:35 +02:00
|
|
|
"Analyzer.Views.Separator1", analyzerContext);
|
2011-07-12 09:17:55 +02:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2012-01-19 23:44:35 +01:00
|
|
|
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
|
2014-10-16 18:45:14 +02:00
|
|
|
cmd = ActionManager::registerAction(m_mainWindow->autoHideTitleBarsAction(),
|
2014-09-29 17:03:25 +02:00
|
|
|
"Analyzer.Views.AutoHideTitleBars", analyzerContext);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
|
2014-10-16 18:45:14 +02:00
|
|
|
cmd = ActionManager::registerAction(m_mainWindow->menuSeparator2(),
|
2014-09-29 17:03:25 +02:00
|
|
|
"Analyzer.Views.Separator2", analyzerContext);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
|
2014-10-16 18:45:14 +02:00
|
|
|
cmd = ActionManager::registerAction(m_mainWindow->resetLayoutAction(),
|
2013-09-03 11:42:35 +02:00
|
|
|
"Analyzer.Views.ResetSimple", analyzerContext);
|
2011-07-12 09:17:55 +02:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2012-01-19 23:44:35 +01:00
|
|
|
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QToolButton *toolButton(QAction *action)
|
|
|
|
|
{
|
2014-10-16 18:45:14 +02:00
|
|
|
auto button = new QToolButton;
|
2011-03-04 12:15:18 +01:00
|
|
|
button->setDefaultAction(action);
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-30 19:13:55 +02:00
|
|
|
void AnalyzerManagerPrivate::createModeMainWindow()
|
2011-03-10 16:11:20 +01:00
|
|
|
{
|
2013-08-30 15:31:03 +02:00
|
|
|
m_mainWindow = new 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);
|
2014-10-16 18:45:14 +02:00
|
|
|
connect(m_mainWindow, &FancyMainWindow::resetLayout, this, &AnalyzerManagerPrivate::resetLayout);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
auto editorHolderLayout = new QVBoxLayout;
|
2011-03-04 12:15:18 +01:00
|
|
|
editorHolderLayout->setMargin(0);
|
|
|
|
|
editorHolderLayout->setSpacing(0);
|
|
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
auto editorAndFindWidget = new QWidget;
|
2011-03-04 12:15:18 +01:00
|
|
|
editorAndFindWidget->setLayout(editorHolderLayout);
|
|
|
|
|
editorHolderLayout->addWidget(new EditorManagerPlaceHolder(m_mode));
|
|
|
|
|
editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget));
|
|
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
auto documentAndRightPane = new MiniSplitter;
|
2011-03-04 12:15:18 +01:00
|
|
|
documentAndRightPane->addWidget(editorAndFindWidget);
|
|
|
|
|
documentAndRightPane->addWidget(new RightPanePlaceHolder(m_mode));
|
|
|
|
|
documentAndRightPane->setStretchFactor(0, 1);
|
|
|
|
|
documentAndRightPane->setStretchFactor(1, 0);
|
|
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
auto analyzeToolBar = new StyledBar;
|
2011-04-04 14:39:28 +02:00
|
|
|
analyzeToolBar->setProperty("topBorder", true);
|
2014-10-16 18:45:14 +02:00
|
|
|
|
|
|
|
|
auto analyzeToolBarLayout = new QHBoxLayout(analyzeToolBar);
|
2011-04-04 14:39:28 +02:00
|
|
|
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));
|
2013-08-30 15:31:03 +02:00
|
|
|
analyzeToolBarLayout->addWidget(new StyledSeparator);
|
2011-04-04 14:39:28 +02:00
|
|
|
analyzeToolBarLayout->addWidget(m_toolBox);
|
2011-07-06 16:28:02 +02:00
|
|
|
analyzeToolBarLayout->addWidget(m_controlsStackWidget);
|
2011-04-04 14:39:28 +02:00
|
|
|
analyzeToolBarLayout->addWidget(m_statusLabel);
|
|
|
|
|
analyzeToolBarLayout->addStretch();
|
|
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
auto dock = new QDockWidget(tr("Analyzer Toolbar"));
|
2011-04-04 14:39:28 +02:00
|
|
|
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
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
auto centralWidget = new QWidget;
|
2011-03-04 12:15:18 +01:00
|
|
|
m_mainWindow->setCentralWidget(centralWidget);
|
|
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
auto centralLayout = new QVBoxLayout(centralWidget);
|
2011-03-04 12:15:18 +01:00
|
|
|
centralWidget->setLayout(centralLayout);
|
|
|
|
|
centralLayout->setMargin(0);
|
|
|
|
|
centralLayout->setSpacing(0);
|
|
|
|
|
centralLayout->addWidget(documentAndRightPane);
|
|
|
|
|
centralLayout->setStretch(0, 1);
|
|
|
|
|
centralLayout->setStretch(1, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-06 16:28:02 +02:00
|
|
|
void AnalyzerManagerPrivate::activateDock(Qt::DockWidgetArea area, QDockWidget *dockWidget)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
dockWidget->setParent(m_mainWindow);
|
|
|
|
|
m_mainWindow->addDockWidget(area, dockWidget);
|
|
|
|
|
|
2012-01-19 23:44:35 +01:00
|
|
|
Context globalContext(C_GLOBAL);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
QAction *toggleViewAction = dockWidget->toggleViewAction();
|
|
|
|
|
toggleViewAction->setText(dockWidget->windowTitle());
|
2013-03-19 12:29:17 +01:00
|
|
|
Command *cmd = ActionManager::registerAction(toggleViewAction,
|
|
|
|
|
Id("Analyzer.").withSuffix(dockWidget->objectName()), globalContext);
|
2011-03-04 12:15:18 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2011-06-30 19:13:55 +02:00
|
|
|
|
2014-10-16 18:45:14 +02:00
|
|
|
ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS));
|
2011-06-30 19:13:55 +02:00
|
|
|
viewsMenu->addAction(cmd);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-06 16:28:02 +02:00
|
|
|
void AnalyzerManagerPrivate::deactivateDock(QDockWidget *dockWidget)
|
|
|
|
|
{
|
|
|
|
|
QAction *toggleViewAction = dockWidget->toggleViewAction();
|
2013-03-19 12:29:17 +01:00
|
|
|
ActionManager::unregisterAction(toggleViewAction,
|
|
|
|
|
Id("Analyzer.").withSuffix(dockWidget->objectName()));
|
2011-07-06 16:28:02 +02:00
|
|
|
m_mainWindow->removeDockWidget(dockWidget);
|
|
|
|
|
dockWidget->hide();
|
|
|
|
|
// Prevent saveState storing the data of the wrong children.
|
|
|
|
|
dockWidget->setParent(0);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2013-08-30 15:31:03 +02:00
|
|
|
CheckableMessageBox messageBox(ICore::mainWindow());
|
2011-04-04 14:39:28 +02:00
|
|
|
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);
|
2013-09-03 18:48:02 +02:00
|
|
|
messageBox.exec();
|
2011-04-04 14:39:28 +02:00
|
|
|
return messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const
|
2011-11-29 13:03:29 +01:00
|
|
|
{
|
|
|
|
|
if (!action || m_isRunning)
|
|
|
|
|
return false;
|
2013-08-07 19:47:30 +02:00
|
|
|
if (action->startMode() == StartRemote)
|
2011-11-29 13:03:29 +01:00
|
|
|
return true;
|
|
|
|
|
|
2015-02-18 11:05:22 +01:00
|
|
|
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->runMode(), 0);
|
2011-11-29 13:03:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 18:55:48 +02:00
|
|
|
void AnalyzerManagerPrivate::startTool()
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2013-08-07 19:47:30 +02:00
|
|
|
QTC_ASSERT(m_currentAction, return);
|
2015-02-18 14:35:20 +01:00
|
|
|
m_currentAction->toolStarter()(m_currentAction->startMode());
|
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
|
|
|
void AnalyzerManagerPrivate::selectSavedTool()
|
|
|
|
|
{
|
2012-01-19 23:44:35 +01:00
|
|
|
const QSettings *settings = ICore::settings();
|
2012-12-14 12:34:15 +01:00
|
|
|
|
|
|
|
|
if (settings->contains(QLatin1String(LAST_ACTIVE_TOOL))) {
|
2013-08-07 19:47:30 +02:00
|
|
|
const Id lastAction = Id::fromSetting(settings->value(QLatin1String(LAST_ACTIVE_TOOL)));
|
|
|
|
|
foreach (AnalyzerAction *action, m_actions) {
|
2015-02-18 14:35:20 +01:00
|
|
|
if (action->toolId() == lastAction) {
|
2013-08-07 19:47:30 +02:00
|
|
|
selectAction(action);
|
2012-12-14 12:34:15 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2011-07-01 14:19:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
2011-07-13 09:27:25 +02:00
|
|
|
// fallback to first available tool
|
2013-08-05 17:08:55 +02:00
|
|
|
if (!m_actions.isEmpty())
|
2013-08-07 19:47:30 +02:00
|
|
|
selectAction(m_actions.first());
|
2011-07-01 14:19:12 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-05 17:21:43 +02:00
|
|
|
void AnalyzerManagerPrivate::selectMenuAction()
|
2011-07-01 14:19:12 +02:00
|
|
|
{
|
2013-08-05 17:08:55 +02:00
|
|
|
AnalyzerManager::showMode();
|
2013-08-07 19:47:30 +02:00
|
|
|
AnalyzerAction *action = qobject_cast<AnalyzerAction *>(sender());
|
2011-07-05 17:21:43 +02:00
|
|
|
QTC_ASSERT(action, return);
|
2013-08-07 19:47:30 +02:00
|
|
|
selectAction(action);
|
2013-08-05 17:08:55 +02:00
|
|
|
startTool();
|
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
|
|
|
{
|
2013-08-07 19:47:30 +02:00
|
|
|
selectAction(m_actions[index]);
|
2011-07-01 14:19:12 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2013-08-05 17:08:55 +02:00
|
|
|
if (m_currentAction == action)
|
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
|
|
|
const int actionIndex = m_actions.indexOf(action);
|
|
|
|
|
QTC_ASSERT(actionIndex >= 0, return);
|
|
|
|
|
|
|
|
|
|
// Clean up old tool.
|
2013-08-07 19:47:30 +02:00
|
|
|
if (m_currentAction) {
|
2013-08-05 17:08:55 +02:00
|
|
|
saveToolSettings(m_currentAction);
|
2015-02-18 14:35:20 +01:00
|
|
|
foreach (QDockWidget *widget, m_toolWidgets.value(m_currentAction->toolId()))
|
2011-07-06 16:28:02 +02:00
|
|
|
deactivateDock(widget);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-01 14:19:12 +02:00
|
|
|
// Now change the tool.
|
2011-11-29 13:03:29 +01:00
|
|
|
m_currentAction = action;
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2015-02-18 14:35:20 +01:00
|
|
|
Id toolId = action->toolId();
|
|
|
|
|
if (!m_defaultSettings.contains(toolId)) {
|
|
|
|
|
QWidget *widget = action->createWidget();
|
2011-07-29 12:00:11 +02:00
|
|
|
QTC_CHECK(widget);
|
2015-02-18 14:35:20 +01:00
|
|
|
m_defaultSettings.insert(toolId, m_mainWindow->saveSettings());
|
|
|
|
|
QTC_CHECK(!m_controlsWidgetFromTool.contains(toolId));
|
|
|
|
|
m_controlsWidgetFromTool[toolId] = widget;
|
2011-07-06 16:28:02 +02:00
|
|
|
m_controlsStackWidget->addWidget(widget);
|
2011-05-06 17:26:01 +02:00
|
|
|
}
|
2015-02-18 14:35:20 +01:00
|
|
|
foreach (QDockWidget *widget, m_toolWidgets.value(toolId))
|
2011-07-06 16:28:02 +02:00
|
|
|
activateDock(Qt::DockWidgetArea(widget->property(INITIAL_DOCK_AREA).toInt()), widget);
|
2011-05-06 14:02:03 +02:00
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
loadToolSettings(action);
|
2011-06-30 18:55:48 +02:00
|
|
|
|
2015-02-18 14:35:20 +01:00
|
|
|
QTC_CHECK(m_controlsWidgetFromTool.contains(toolId));
|
|
|
|
|
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId));
|
2011-07-01 14:19:12 +02:00
|
|
|
m_toolBox->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
|
|
|
}
|
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
void AnalyzerManagerPrivate::addAction(AnalyzerAction *action)
|
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.
|
2013-08-05 18:18:34 +02:00
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
Id menuGroup = action->menuGroup();
|
|
|
|
|
if (menuGroup.isValid()) {
|
2015-02-18 14:35:20 +01:00
|
|
|
Command *command = ActionManager::registerAction(action, action->actionId(), Context(C_GLOBAL));
|
2013-08-07 19:47:30 +02:00
|
|
|
m_menu->addAction(command, menuGroup);
|
2011-06-30 18:55:48 +02:00
|
|
|
}
|
2013-08-07 19:47:30 +02:00
|
|
|
|
2013-08-05 18:18:34 +02:00
|
|
|
m_actions.append(action);
|
2013-08-07 19:47:30 +02:00
|
|
|
m_toolBox->addItem(action->text());
|
2013-08-05 18:18:34 +02:00
|
|
|
m_toolBox->blockSignals(blocked);
|
2014-10-16 18:45:14 +02:00
|
|
|
connect(action, &QAction::triggered, this, &AnalyzerManagerPrivate::selectMenuAction);
|
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.
|
2012-05-08 13:32:13 +02:00
|
|
|
updateRunActions();
|
2011-07-04 10:50:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerManagerPrivate::handleToolFinished()
|
|
|
|
|
{
|
|
|
|
|
m_isRunning = false;
|
2012-05-08 13:32:13 +02:00
|
|
|
updateRunActions();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
void AnalyzerManagerPrivate::loadToolSettings(AnalyzerAction *action)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-06-29 16:04:03 +02:00
|
|
|
QTC_ASSERT(m_mainWindow, return);
|
2012-01-19 23:44:35 +01:00
|
|
|
QSettings *settings = ICore::settings();
|
2015-02-18 14:35:20 +01:00
|
|
|
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->toolId().toString());
|
2012-01-25 17:39:50 +01:00
|
|
|
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
|
2011-06-29 16:04:03 +02:00
|
|
|
m_mainWindow->restoreSettings(settings);
|
2011-07-13 09:27:25 +02:00
|
|
|
else
|
2015-02-18 14:35:20 +01:00
|
|
|
m_mainWindow->restoreSettings(m_defaultSettings.value(action->toolId()));
|
2011-06-29 16:04:03 +02:00
|
|
|
settings->endGroup();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
void AnalyzerManagerPrivate::saveToolSettings(AnalyzerAction *action)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2013-08-07 19:47:30 +02:00
|
|
|
QTC_ASSERT(action, return);
|
2011-06-29 16:04:03 +02:00
|
|
|
QTC_ASSERT(m_mainWindow, return);
|
|
|
|
|
|
2012-01-19 23:44:35 +01:00
|
|
|
QSettings *settings = ICore::settings();
|
2015-02-18 14:35:20 +01:00
|
|
|
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->toolId().toString());
|
2011-06-29 16:04:03 +02:00
|
|
|
m_mainWindow->saveSettings(settings);
|
2012-01-25 17:39:50 +01:00
|
|
|
settings->setValue(QLatin1String("ToolSettingsSaved"), true);
|
2011-06-29 16:04:03 +02:00
|
|
|
settings->endGroup();
|
2015-02-18 14:35:20 +01:00
|
|
|
settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), action->toolId().toString());
|
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-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.");
|
2013-08-07 19:47:30 +02:00
|
|
|
else if (!m_currentAction)
|
2011-06-29 16:04:03 +02:00
|
|
|
disabledReason = tr("No analyzer tool selected.");
|
|
|
|
|
else
|
2014-09-04 13:48:44 +02:00
|
|
|
ProjectExplorerPlugin::canRun(SessionManager::startupProject(),
|
2015-02-18 11:05:22 +01:00
|
|
|
m_currentAction->runMode(), &disabledReason);
|
2011-06-29 16:04:03 +02:00
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
m_startAction->setEnabled(isActionRunnable(m_currentAction));
|
2011-06-29 16:04:03 +02:00
|
|
|
m_startAction->setToolTip(disabledReason);
|
2011-07-04 10:50:44 +02:00
|
|
|
m_toolBox->setEnabled(!m_isRunning);
|
|
|
|
|
m_stopAction->setEnabled(m_isRunning);
|
2013-08-07 19:47:30 +02:00
|
|
|
foreach (AnalyzerAction *action, m_actions)
|
2011-11-29 13:03:29 +01:00
|
|
|
action->setEnabled(isActionRunnable(action));
|
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
|
|
|
|
2013-08-07 17:43:45 +02:00
|
|
|
static AnalyzerManagerPrivate *d = 0;
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-06-29 16:04:03 +02:00
|
|
|
AnalyzerManager::AnalyzerManager(QObject *parent)
|
2013-08-07 17:43:45 +02:00
|
|
|
: QObject(parent)
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
QTC_CHECK(d == 0);
|
|
|
|
|
d = new AnalyzerManagerPrivate(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
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
QTC_CHECK(d);
|
2011-06-29 16:04:03 +02:00
|
|
|
delete d;
|
2013-08-07 17:43:45 +02:00
|
|
|
d = 0;
|
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
|
|
|
{
|
2013-08-08 17:37:37 +02:00
|
|
|
if (d->m_currentAction)
|
|
|
|
|
d->saveToolSettings(d->m_currentAction);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-07 19:47:30 +02:00
|
|
|
void AnalyzerManager::addAction(AnalyzerAction *action)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2013-08-07 19:47:30 +02:00
|
|
|
d->addAction(action);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-18 14:35:20 +01:00
|
|
|
QDockWidget *AnalyzerManager::createDockWidget(Core::Id toolId,
|
2011-06-29 16:04:03 +02:00
|
|
|
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);
|
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));
|
2015-02-18 14:35:20 +01:00
|
|
|
d->m_toolWidgets[toolId].push_back(dockWidget);
|
2011-06-29 16:04:03 +02:00
|
|
|
return dockWidget;
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-18 14:35:20 +01:00
|
|
|
void AnalyzerManager::selectTool(Id toolId, StartMode mode)
|
2011-06-29 18:48:08 +02:00
|
|
|
{
|
2013-08-07 19:47:30 +02:00
|
|
|
foreach (AnalyzerAction *action, d->m_actions)
|
2015-02-18 14:35:20 +01:00
|
|
|
if (action->toolId() == toolId && action->startMode() == mode)
|
2013-08-07 19:47:30 +02:00
|
|
|
d->selectAction(action);
|
2011-06-29 18:48:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-05 17:08:55 +02:00
|
|
|
void AnalyzerManager::startTool()
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
d->startTool();
|
2011-06-29 16:04:03 +02:00
|
|
|
}
|
2011-05-26 19:57:07 +02:00
|
|
|
|
2013-08-30 15:31:03 +02:00
|
|
|
FancyMainWindow *AnalyzerManager::mainWindow()
|
2011-06-29 16:04:03 +02:00
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
return 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
|
|
|
{
|
2013-08-07 19:47:30 +02:00
|
|
|
QTC_ASSERT(m_currentAction, return);
|
2015-02-18 14:35:20 +01:00
|
|
|
m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentAction->toolId()));
|
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)
|
|
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
d->m_statusLabel->showStatusMessage(message, timeoutMS);
|
2011-03-16 13:49:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerManager::showPermanentStatusMessage(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
showStatusMessage(message, -1);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 15:00:18 +02:00
|
|
|
void AnalyzerManager::showMode()
|
|
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
if (d->m_mode)
|
|
|
|
|
ModeManager::activateMode(d->m_mode->id());
|
2011-06-30 13:44:22 +02:00
|
|
|
}
|
|
|
|
|
|
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 10:50:44 +02:00
|
|
|
QAction *AnalyzerManager::stopAction()
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
return d->m_stopAction;
|
2011-06-30 13:44:22 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-05 12:56:49 +02:00
|
|
|
void AnalyzerManager::handleToolStarted()
|
|
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
d->handleToolStarted();
|
2011-07-05 12:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
void AnalyzerManager::handleToolFinished()
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2013-08-07 17:43:45 +02:00
|
|
|
d->handleToolFinished();
|
2011-05-20 09:12:34 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-01 15:02:42 +02:00
|
|
|
AnalyzerRunControl *AnalyzerManager::createRunControl(
|
2013-08-02 15:39:33 +02:00
|
|
|
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
|
2013-08-02 14:39:33 +02:00
|
|
|
{
|
2013-08-07 19:47:30 +02:00
|
|
|
foreach (AnalyzerAction *action, d->m_actions) {
|
2015-02-18 11:05:22 +01:00
|
|
|
if (action->runMode() == sp.runMode && action->startMode() == sp.startMode)
|
2015-02-18 14:35:20 +01:00
|
|
|
return action->createRunControl(sp, runConfiguration);
|
2013-08-07 19:47:30 +02:00
|
|
|
}
|
2013-08-02 14:39:33 +02:00
|
|
|
QTC_CHECK(false);
|
2011-06-30 13:44:22 +02:00
|
|
|
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"
|