mirror of https://github.com/PCSX2/pcsx2.git
119 lines
3.3 KiB
C++
119 lines
3.3 KiB
C++
// SPDX-FileCopyrightText: 2002-2025 PCSX2 Dev Team
|
|
// SPDX-License-Identifier: GPL-3.0+
|
|
|
|
#pragma once
|
|
|
|
#include "Debugger/Docking/DockLayout.h"
|
|
|
|
#include <kddockwidgets/MainWindow.h>
|
|
#include <kddockwidgets/DockWidget.h>
|
|
#include <kddockwidgets/core/DockRegistry.h>
|
|
#include <kddockwidgets/core/DockWidget.h>
|
|
#include <kddockwidgets/core/Draggable_p.h>
|
|
|
|
#include <QtCore/QPointer>
|
|
#include <QtWidgets/QPushButton>
|
|
#include <QtWidgets/QTabBar>
|
|
|
|
class DockManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
DockManager(QObject* parent = nullptr);
|
|
|
|
DockManager(const DockManager& rhs) = delete;
|
|
DockManager& operator=(const DockManager& rhs) = delete;
|
|
|
|
DockManager(DockManager&& rhs) = delete;
|
|
DockManager& operator=(DockManager&&) = delete;
|
|
|
|
// This needs to be called before any KDDockWidgets objects are created
|
|
// including the debugger window itself.
|
|
static void configureDockingSystem();
|
|
|
|
template <typename... Args>
|
|
DockLayout::Index createLayout(Args&&... args)
|
|
{
|
|
DockLayout::Index layout_index = m_layouts.size();
|
|
|
|
if (m_layouts.empty())
|
|
{
|
|
// Delete the placeholder created in DockManager::deleteLayout.
|
|
for (KDDockWidgets::Core::DockWidget* dock : KDDockWidgets::DockRegistry::self()->dockwidgets())
|
|
delete dock;
|
|
}
|
|
|
|
m_layouts.emplace_back(std::forward<Args>(args)..., layout_index);
|
|
|
|
return layout_index;
|
|
}
|
|
|
|
bool deleteLayout(DockLayout::Index layout_index);
|
|
|
|
void switchToLayout(DockLayout::Index layout_index, bool blink_tab = false);
|
|
bool switchToLayoutWithCPU(BreakPointCpu cpu, bool blink_tab = false);
|
|
|
|
void loadLayouts();
|
|
bool saveLayouts();
|
|
bool saveCurrentLayout();
|
|
|
|
QString currentLayoutName();
|
|
bool canResetCurrentLayout();
|
|
|
|
void resetCurrentLayout();
|
|
void resetDefaultLayouts();
|
|
void resetAllLayouts();
|
|
|
|
void createToolsMenu(QMenu* menu);
|
|
void createWindowsMenu(QMenu* menu);
|
|
|
|
QWidget* createLayoutSwitcher(QWidget* menu_bar);
|
|
void updateLayoutSwitcher();
|
|
void layoutSwitcherTabChanged(int index);
|
|
void layoutSwitcherTabMoved(int from, int to);
|
|
void layoutSwitcherContextMenu(QPoint pos);
|
|
void layoutSwitcherStartBlink();
|
|
void layoutSwitcherUpdateBlink();
|
|
void layoutSwitcherStopBlink();
|
|
|
|
bool hasNameConflict(const QString& name, DockLayout::Index layout_index);
|
|
|
|
void updateDockWidgetTitles();
|
|
|
|
const std::map<QString, QPointer<DebuggerWidget>>& debuggerWidgets();
|
|
size_t countDebuggerWidgetsOfType(const char* type);
|
|
void recreateDebuggerWidget(const QString& unique_name);
|
|
void destroyDebuggerWidget(const QString& unique_name);
|
|
void setPrimaryDebuggerWidget(DebuggerWidget* widget, bool is_primary);
|
|
void switchToDebuggerWidget(DebuggerWidget* widget);
|
|
|
|
void updateStyleSheets();
|
|
|
|
bool isLayoutLocked();
|
|
void setLayoutLocked(bool locked, QPushButton* lock_layout_toggle, bool write_back);
|
|
void updateToolBarLockState();
|
|
|
|
std::optional<BreakPointCpu> cpu();
|
|
|
|
private:
|
|
static KDDockWidgets::Core::DockWidget* dockWidgetFactory(const QString& name);
|
|
static bool dragAboutToStart(KDDockWidgets::Core::Draggable* draggable);
|
|
|
|
std::vector<DockLayout> m_layouts;
|
|
DockLayout::Index m_current_layout = DockLayout::INVALID_INDEX;
|
|
|
|
QTabBar* m_switcher = nullptr;
|
|
int m_plus_tab_index = -1;
|
|
int m_current_tab_index = -1;
|
|
bool m_ignore_current_tab_changed = false;
|
|
|
|
QMetaObject::Connection m_tab_connection;
|
|
|
|
bool m_layout_locked = true;
|
|
|
|
QTimer* m_blink_timer = nullptr;
|
|
int m_blink_tab = 0;
|
|
int m_blink_stage = 0;
|
|
};
|