2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-12-02 17:43:14 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-12-02 17:43:14 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-12-02 17:43:14 +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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-12-02 17:43:14 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-12-02 17:43:14 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-12-02 17:43:14 +01:00
|
|
|
|
|
|
|
|
#include "debugger_global.h"
|
2016-02-29 18:15:36 +01:00
|
|
|
|
|
|
|
|
#include <utils/fancymainwindow.h>
|
|
|
|
|
#include <utils/statuslabel.h>
|
|
|
|
|
|
|
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QSet>
|
|
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QComboBox;
|
2018-07-24 13:30:16 +02:00
|
|
|
class QToolButton;
|
2016-02-29 18:15:36 +01:00
|
|
|
class QStackedWidget;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2016-03-25 20:00:19 +01:00
|
|
|
namespace Core { class Id; }
|
2016-03-10 08:53:49 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
namespace Utils {
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
class DEBUGGER_EXPORT Perspective
|
2016-02-29 18:15:36 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2016-03-02 14:39:20 +01:00
|
|
|
enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise };
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
class DEBUGGER_EXPORT Operation
|
2016-03-01 07:51:06 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2016-03-02 14:39:20 +01:00
|
|
|
Operation() = default;
|
2016-03-02 13:57:37 +01:00
|
|
|
Operation(const QByteArray &dockId, QWidget *widget,
|
|
|
|
|
const QByteArray &anchorDockId,
|
|
|
|
|
OperationType operationType,
|
|
|
|
|
bool visibleByDefault = true,
|
|
|
|
|
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
|
|
|
|
|
|
|
|
|
|
QByteArray dockId;
|
2016-03-24 13:59:05 +01:00
|
|
|
QPointer<QWidget> widget;
|
2016-03-02 13:57:37 +01:00
|
|
|
QByteArray anchorDockId;
|
2016-11-29 15:39:21 +01:00
|
|
|
OperationType operationType = Raise;
|
|
|
|
|
bool visibleByDefault = true;
|
|
|
|
|
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea;
|
2016-02-29 18:15:36 +01:00
|
|
|
};
|
|
|
|
|
|
2016-03-01 07:51:06 +01:00
|
|
|
Perspective() = default;
|
2016-05-12 11:57:29 +02:00
|
|
|
// Takes ownership of \a centralWidget and all dock widgets in \a operations.
|
2018-07-24 11:50:08 +02:00
|
|
|
Perspective(const QString &name,
|
|
|
|
|
const QVector<Operation> &operations = {},
|
2018-02-01 10:59:24 +01:00
|
|
|
QWidget *centralWidget = nullptr);
|
2016-05-12 11:57:29 +02:00
|
|
|
~Perspective();
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-03-02 14:39:20 +01:00
|
|
|
void addOperation(const Operation &operation);
|
2018-07-24 11:50:08 +02:00
|
|
|
void addWindow(QWidget *widget,
|
|
|
|
|
OperationType op,
|
|
|
|
|
bool visibleByDefault = true,
|
|
|
|
|
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-03-02 14:39:20 +01:00
|
|
|
QVector<Operation> operations() const { return m_operations; }
|
2016-03-02 13:57:37 +01:00
|
|
|
QVector<QByteArray> docks() const { return m_docks; }
|
2016-05-12 11:57:29 +02:00
|
|
|
QWidget *centralWidget() const { return m_centralWidget; }
|
2016-03-02 13:57:37 +01:00
|
|
|
|
|
|
|
|
QString name() const;
|
|
|
|
|
void setName(const QString &name);
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-11-21 13:57:11 +01:00
|
|
|
using Callback = std::function<void()>;
|
|
|
|
|
void setAboutToActivateCallback(const Callback &cb);
|
2016-11-21 14:32:03 +01:00
|
|
|
void aboutToActivate() const;
|
2016-11-21 13:57:11 +01:00
|
|
|
|
2016-02-29 18:15:36 +01:00
|
|
|
private:
|
2016-05-12 11:57:29 +02:00
|
|
|
Perspective(const Perspective &) = delete;
|
|
|
|
|
void operator=(const Perspective &) = delete;
|
|
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
QString m_name;
|
|
|
|
|
QVector<QByteArray> m_docks;
|
2016-03-02 14:39:20 +01:00
|
|
|
QVector<Operation> m_operations;
|
2016-05-12 11:57:29 +02:00
|
|
|
QPointer<QWidget> m_centralWidget;
|
2016-11-21 13:57:11 +01:00
|
|
|
Callback m_aboutToActivateCallback;
|
2016-02-29 18:15:36 +01:00
|
|
|
};
|
|
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
class DEBUGGER_EXPORT ToolbarDescription
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ToolbarDescription() = default;
|
|
|
|
|
ToolbarDescription(const QList<QWidget *> &widgets) : m_widgets(widgets) {}
|
2010-12-02 17:43:14 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
QList<QWidget *> widgets() const;
|
2014-12-12 15:33:16 +01:00
|
|
|
|
2018-07-24 12:16:13 +02:00
|
|
|
QToolButton *addAction(QAction *action, const QIcon &toolbarIcon = QIcon());
|
2016-03-02 13:57:37 +01:00
|
|
|
void addWidget(QWidget *widget);
|
2016-03-01 07:51:06 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
private:
|
|
|
|
|
QList<QWidget *> m_widgets;
|
|
|
|
|
};
|
2010-12-02 17:43:14 +01:00
|
|
|
|
2016-03-10 08:53:49 +01:00
|
|
|
class DEBUGGER_EXPORT DebuggerMainWindow : public FancyMainWindow
|
2016-02-29 18:15:36 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2016-03-02 13:57:37 +01:00
|
|
|
DebuggerMainWindow();
|
|
|
|
|
~DebuggerMainWindow() override;
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-05-12 11:57:29 +02:00
|
|
|
void registerPerspective(const QByteArray &perspectiveId, const Perspective *perspective);
|
2016-03-02 13:57:37 +01:00
|
|
|
void registerToolbar(const QByteArray &perspectiveId, QWidget *widget);
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-03-01 07:51:06 +01:00
|
|
|
void resetCurrentPerspective();
|
2016-03-02 13:57:37 +01:00
|
|
|
void restorePerspective(const QByteArray &perspectiveId);
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-03-24 13:59:05 +01:00
|
|
|
void finalizeSetup();
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
void showStatusMessage(const QString &message, int timeoutMS);
|
|
|
|
|
QDockWidget *dockWidget(const QByteArray &dockId) const;
|
2017-10-26 16:32:48 +02:00
|
|
|
void raiseDock(const QByteArray &dockId);
|
2016-03-02 13:57:37 +01:00
|
|
|
QByteArray currentPerspective() const { return m_currentPerspectiveId; }
|
2016-05-12 11:57:29 +02:00
|
|
|
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
|
2016-02-29 18:15:36 +01:00
|
|
|
|
2016-08-26 13:33:30 +02:00
|
|
|
void onModeChanged(Core::Id mode);
|
|
|
|
|
|
2017-07-11 15:57:45 +02:00
|
|
|
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled);
|
|
|
|
|
|
2016-02-29 18:15:36 +01:00
|
|
|
private:
|
2018-07-24 13:26:52 +02:00
|
|
|
void closeEvent(QCloseEvent *) final { savePerspectiveHelper(m_currentPerspectiveId); }
|
2018-07-06 13:28:31 +02:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget);
|
|
|
|
|
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
|
2018-07-24 13:26:52 +02:00
|
|
|
void savePerspectiveHelper(const QByteArray &perspectiveId);
|
2016-03-01 07:51:06 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
QByteArray m_currentPerspectiveId;
|
|
|
|
|
QComboBox *m_perspectiveChooser;
|
2016-02-29 18:15:36 +01:00
|
|
|
QStackedWidget *m_controlsStackWidget;
|
2016-05-12 11:57:29 +02:00
|
|
|
QStackedWidget *m_centralWidgetStack;
|
|
|
|
|
QWidget *m_editorPlaceHolder;
|
2016-03-02 13:23:30 +01:00
|
|
|
Utils::StatusLabel *m_statusLabel;
|
2016-12-05 13:43:45 +01:00
|
|
|
QDockWidget *m_toolbarDock = nullptr;
|
2016-03-02 13:57:37 +01:00
|
|
|
|
|
|
|
|
QHash<QByteArray, QDockWidget *> m_dockForDockId;
|
|
|
|
|
QHash<QByteArray, QWidget *> m_toolbarForPerspectiveId;
|
2016-05-12 11:57:29 +02:00
|
|
|
QHash<QByteArray, const Perspective *> m_perspectiveForPerspectiveId;
|
2016-02-29 18:15:36 +01:00
|
|
|
};
|
|
|
|
|
|
2016-05-12 11:57:29 +02:00
|
|
|
DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow);
|
2016-03-24 13:59:05 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
} // Utils
|