diff --git a/src/libs/advanceddockingsystem/CMakeLists.txt b/src/libs/advanceddockingsystem/CMakeLists.txt index cd505973378..de136645353 100644 --- a/src/libs/advanceddockingsystem/CMakeLists.txt +++ b/src/libs/advanceddockingsystem/CMakeLists.txt @@ -22,7 +22,6 @@ add_qtc_library(AdvancedDockingSystem workspacedialog.cpp workspacedialog.h workspacemodel.cpp workspacemodel.h workspaceview.cpp workspaceview.h - workspacedialog.ui ) extend_qtc_library(AdvancedDockingSystem diff --git a/src/libs/advanceddockingsystem/advanceddockingsystem.qbs b/src/libs/advanceddockingsystem/advanceddockingsystem.qbs index 4401e9a1db3..9778f629492 100644 --- a/src/libs/advanceddockingsystem/advanceddockingsystem.qbs +++ b/src/libs/advanceddockingsystem/advanceddockingsystem.qbs @@ -34,7 +34,6 @@ QtcLibrary { "workspacedialog.cpp", "workspacedialog.h", "workspacemodel.cpp", "workspacemodel.h", "workspaceview.cpp", "workspaceview.h", - "workspacedialog.ui" ] } diff --git a/src/libs/advanceddockingsystem/workspacedialog.cpp b/src/libs/advanceddockingsystem/workspacedialog.cpp index 6594e05d7ca..c868564b7a4 100644 --- a/src/libs/advanceddockingsystem/workspacedialog.cpp +++ b/src/libs/advanceddockingsystem/workspacedialog.cpp @@ -4,10 +4,16 @@ #include "workspacedialog.h" #include "dockmanager.h" +#include "workspaceview.h" #include +#include -#include +#include +#include +#include +#include +#include #include #include @@ -59,12 +65,9 @@ WorkspaceNameInputDialog::WorkspaceNameInputDialog(DockManager *manager, QWidget : QDialog(parent) , m_manager(manager) { - auto hlayout = new QVBoxLayout(this); auto label = new QLabel(tr("Enter the name of the workspace:"), this); - hlayout->addWidget(label); m_newWorkspaceLineEdit = new QLineEdit(this); m_newWorkspaceLineEdit->setValidator(new WorkspaceValidator(this, m_manager->workspaces())); - hlayout->addWidget(m_newWorkspaceLineEdit); auto buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); @@ -74,8 +77,14 @@ WorkspaceNameInputDialog::WorkspaceNameInputDialog(DockManager *manager, QWidget connect(m_switchToButton, &QPushButton::clicked, [this]() { m_usedSwitchTo = true; }); connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); - hlayout->addWidget(buttons); - setLayout(hlayout); + + using namespace Utils::Layouting; + + Column { + label, + m_newWorkspaceLineEdit, + buttons + }.attachTo(this); } void WorkspaceNameInputDialog::setActionText(const QString &actionText, @@ -103,64 +112,90 @@ bool WorkspaceNameInputDialog::isSwitchToRequested() const WorkspaceDialog::WorkspaceDialog(DockManager *manager, QWidget *parent) : QDialog(parent) , m_manager(manager) + , m_workspaceView(new WorkspaceView(manager)) + , m_btCreateNew(new QPushButton(tr("&New"))) + , m_btRename(new QPushButton(tr("&Rename"))) + , m_btClone(new QPushButton(tr("C&lone"))) + , m_btDelete(new QPushButton(tr("&Delete"))) + , m_btReset(new QPushButton(tr("Reset"))) + , m_btSwitch(new QPushButton(tr("&Switch To"))) + , m_btImport(new QPushButton(tr("Import"))) + , m_btExport(new QPushButton(tr("Export"))) + , m_autoLoadCheckBox(new QCheckBox(tr("Restore last workspace on startup"))) { - m_ui.setupUi(this); - m_ui.workspaceView->setActivationMode(Utils::DoubleClickActivation); + setWindowTitle(tr("Workspace Manager")); - connect(m_ui.btCreateNew, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::createNewWorkspace); - connect(m_ui.btClone, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::cloneCurrentWorkspace); - connect(m_ui.btDelete, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::deleteSelectedWorkspaces); - connect(m_ui.btSwitch, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::switchToCurrentWorkspace); - connect(m_ui.btRename, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::renameCurrentWorkspace); - connect(m_ui.btReset, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::resetCurrentWorkspace); - connect(m_ui.workspaceView, - &WorkspaceView::workspaceActivated, - m_ui.workspaceView, - &WorkspaceView::switchToCurrentWorkspace); - connect(m_ui.workspaceView, - &WorkspaceView::workspacesSelected, - this, - &WorkspaceDialog::updateActions); - connect(m_ui.btImport, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::importWorkspace); - connect(m_ui.btExport, - &QAbstractButton::clicked, - m_ui.workspaceView, - &WorkspaceView::exportCurrentWorkspace); + m_workspaceView->setActivationMode(Utils::DoubleClickActivation); - m_ui.whatsAWorkspaceLabel->setOpenExternalLinks(true); + QLabel *whatsAWorkspaceLabel = new QLabel(tr("What is a Workspace?")); + whatsAWorkspaceLabel->setOpenExternalLinks(true); - updateActions(m_ui.workspaceView->selectedWorkspaces()); + QDialogButtonBox *buttonBox = new QDialogButtonBox; + buttonBox->setStandardButtons(QDialogButtonBox::Close); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + + using namespace Utils::Layouting; + + Column { + Row { + Column { + m_workspaceView, + m_autoLoadCheckBox + }, + Column { + m_btCreateNew, + m_btRename, + m_btClone, + m_btDelete, + m_btReset, + m_btSwitch, + st, + m_btImport, + m_btExport + } + }, + hr, + Row { + whatsAWorkspaceLabel, + buttonBox + } + }.attachTo(this); + + + connect(m_btCreateNew, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::createNewWorkspace); + connect(m_btClone, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::cloneCurrentWorkspace); + connect(m_btDelete, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::deleteSelectedWorkspaces); + connect(m_btSwitch, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::switchToCurrentWorkspace); + connect(m_btRename, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::renameCurrentWorkspace); + connect(m_btReset, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::resetCurrentWorkspace); + connect(m_workspaceView, &WorkspaceView::workspaceActivated, + m_workspaceView, &WorkspaceView::switchToCurrentWorkspace); + connect(m_workspaceView, &WorkspaceView::workspacesSelected, + this, &WorkspaceDialog::updateActions); + connect(m_btImport, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::importWorkspace); + connect(m_btExport, &QAbstractButton::clicked, + m_workspaceView, &WorkspaceView::exportCurrentWorkspace); + + updateActions(m_workspaceView->selectedWorkspaces()); } void WorkspaceDialog::setAutoLoadWorkspace(bool check) { - m_ui.autoLoadCheckBox->setChecked(check); + m_autoLoadCheckBox->setChecked(check); } bool WorkspaceDialog::autoLoadWorkspace() const { - return m_ui.autoLoadCheckBox->checkState() == Qt::Checked; + return m_autoLoadCheckBox->checkState() == Qt::Checked; } DockManager *WorkspaceDialog::dockManager() const @@ -171,12 +206,12 @@ DockManager *WorkspaceDialog::dockManager() const void WorkspaceDialog::updateActions(const QStringList &workspaces) { if (workspaces.isEmpty()) { - m_ui.btDelete->setEnabled(false); - m_ui.btRename->setEnabled(false); - m_ui.btClone->setEnabled(false); - m_ui.btReset->setEnabled(false); - m_ui.btSwitch->setEnabled(false); - m_ui.btExport->setEnabled(false); + m_btDelete->setEnabled(false); + m_btRename->setEnabled(false); + m_btClone->setEnabled(false); + m_btReset->setEnabled(false); + m_btSwitch->setEnabled(false); + m_btExport->setEnabled(false); return; } const bool presetIsSelected = Utils::anyOf(workspaces, [this](const QString &workspace) { @@ -185,12 +220,12 @@ void WorkspaceDialog::updateActions(const QStringList &workspaces) const bool activeIsSelected = Utils::anyOf(workspaces, [this](const QString &workspace) { return workspace == m_manager->activeWorkspace(); }); - m_ui.btDelete->setEnabled(!activeIsSelected && !presetIsSelected); - m_ui.btRename->setEnabled(workspaces.size() == 1 && !presetIsSelected); - m_ui.btClone->setEnabled(workspaces.size() == 1); - m_ui.btReset->setEnabled(presetIsSelected); - m_ui.btSwitch->setEnabled(workspaces.size() == 1); - m_ui.btExport->setEnabled(workspaces.size() == 1); + m_btDelete->setEnabled(!activeIsSelected && !presetIsSelected); + m_btRename->setEnabled(workspaces.size() == 1 && !presetIsSelected); + m_btClone->setEnabled(workspaces.size() == 1); + m_btReset->setEnabled(presetIsSelected); + m_btSwitch->setEnabled(workspaces.size() == 1); + m_btExport->setEnabled(workspaces.size() == 1); } } // namespace ADS diff --git a/src/libs/advanceddockingsystem/workspacedialog.h b/src/libs/advanceddockingsystem/workspacedialog.h index 3a6f1f27b1b..fe710bc885a 100644 --- a/src/libs/advanceddockingsystem/workspacedialog.h +++ b/src/libs/advanceddockingsystem/workspacedialog.h @@ -3,12 +3,10 @@ #pragma once -#include "ui_workspacedialog.h" - #include -#include QT_BEGIN_NAMESPACE +class QCheckBox; class QLineEdit; class QPushButton; QT_END_NAMESPACE @@ -16,6 +14,7 @@ QT_END_NAMESPACE namespace ADS { class DockManager; +class WorkspaceView; class WorkspaceDialog : public QDialog { @@ -32,9 +31,18 @@ public: private: void updateActions(const QStringList &workspaces); - Ui::WorkspaceDialog m_ui; - DockManager *m_manager = nullptr; + + WorkspaceView *m_workspaceView = nullptr; + QPushButton *m_btCreateNew = nullptr; + QPushButton *m_btRename = nullptr; + QPushButton *m_btClone = nullptr; + QPushButton *m_btDelete = nullptr; + QPushButton *m_btReset = nullptr; + QPushButton *m_btSwitch = nullptr; + QPushButton *m_btImport = nullptr; + QPushButton *m_btExport = nullptr; + QCheckBox *m_autoLoadCheckBox = nullptr; }; class WorkspaceNameInputDialog : public QDialog diff --git a/src/libs/advanceddockingsystem/workspacedialog.ui b/src/libs/advanceddockingsystem/workspacedialog.ui deleted file mode 100644 index ea494218aad..00000000000 --- a/src/libs/advanceddockingsystem/workspacedialog.ui +++ /dev/null @@ -1,193 +0,0 @@ - - - ADS::WorkspaceDialog - - - - 0 - 0 - 400 - 300 - - - - Workspace Manager - - - - - - - 1 - 1 - - - - - - - - 0 - - - 0 - - - - - &New - - - - - - - &Rename - - - - - - - C&lone - - - - - - - &Delete - - - - - - - Reset - - - - - - - &Switch To - - - true - - - - - - - Qt::Vertical - - - - 85 - 48 - - - - - - - - Import - - - - - - - Export - - - - - - - - - Restore last workspace on startup - - - - - - - Qt::Horizontal - - - - - - - <a href="qthelp://org.qt-project.qtcreator/doc/creator-project-managing-workspaces.html">What is a Workspace?</a> - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - QDialogButtonBox::Close - - - true - - - - - - - - WorkspaceView - QTreeView -
workspaceview.h
-
-
- - - - buttonBox - rejected() - ADS::WorkspaceDialog - reject() - - - 191 - 244 - - - 114 - 237 - - - - - buttonBox - accepted() - ADS::WorkspaceDialog - accept() - - - 246 - 237 - - - 78 - 216 - - - - -
diff --git a/src/libs/advanceddockingsystem/workspacemodel.cpp b/src/libs/advanceddockingsystem/workspacemodel.cpp index af3823f4148..44e12dafe1f 100644 --- a/src/libs/advanceddockingsystem/workspacemodel.cpp +++ b/src/libs/advanceddockingsystem/workspacemodel.cpp @@ -10,7 +10,6 @@ #include #include -#include #include namespace ADS { diff --git a/src/libs/advanceddockingsystem/workspaceview.cpp b/src/libs/advanceddockingsystem/workspaceview.cpp index 41d0dfb28ab..702794fba94 100644 --- a/src/libs/advanceddockingsystem/workspaceview.cpp +++ b/src/libs/advanceddockingsystem/workspaceview.cpp @@ -4,7 +4,6 @@ #include "workspaceview.h" #include "dockmanager.h" -#include "workspacedialog.h" #include @@ -39,17 +38,10 @@ void RemoveItemFocusDelegate::paint(QPainter *painter, QStyledItemDelegate::paint(painter, opt, index); } -WorkspaceDialog *WorkspaceView::castToWorkspaceDialog(QWidget *widget) -{ - auto dialog = qobject_cast(widget); - Q_ASSERT(dialog); - return dialog; -} - -WorkspaceView::WorkspaceView(QWidget *parent) +WorkspaceView::WorkspaceView(DockManager *manager, QWidget *parent) : Utils::TreeView(parent) - , m_manager(WorkspaceView::castToWorkspaceDialog(parent)->dockManager()) - , m_workspaceModel(m_manager) + , m_manager(manager) + , m_workspaceModel(manager) { setItemDelegate(new RemoveItemFocusDelegate(this)); setSelectionBehavior(QAbstractItemView::SelectRows); diff --git a/src/libs/advanceddockingsystem/workspaceview.h b/src/libs/advanceddockingsystem/workspaceview.h index 615678512fc..3c1edb8930c 100644 --- a/src/libs/advanceddockingsystem/workspaceview.h +++ b/src/libs/advanceddockingsystem/workspaceview.h @@ -19,7 +19,7 @@ class WorkspaceView : public Utils::TreeView Q_OBJECT public: - explicit WorkspaceView(QWidget *parent = nullptr); + explicit WorkspaceView(DockManager *manager, QWidget *parent = nullptr); void createNewWorkspace(); void deleteSelectedWorkspaces(); @@ -49,8 +49,6 @@ private: void deleteWorkspaces(const QStringList &workspaces); - static WorkspaceDialog *castToWorkspaceDialog(QWidget *widget); - DockManager *m_manager; WorkspaceModel m_workspaceModel; };