forked from qt-creator/qt-creator
ProjectExplorer: Replace project mode main window splitter by dockwidget
The main window of the project mode is already a QMainWindow, using a dock window also for the empty space on the right makes it consistent with the separation of the project tree on the left. Change-Id: Ida42f267b87eb45cd1692ebcc16ded2ee6c1e523 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -25,12 +25,10 @@
|
|||||||
|
|
||||||
#include "panelswidget.h"
|
#include "panelswidget.h"
|
||||||
|
|
||||||
#include <coreplugin/minisplitter.h>
|
|
||||||
|
|
||||||
#include <utils/stylehelper.h>
|
|
||||||
#include <utils/theme/theme.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@@ -55,18 +53,14 @@ const int PANEL_LEFT_MARGIN = 70;
|
|||||||
// PanelsWidget
|
// PanelsWidget
|
||||||
///
|
///
|
||||||
|
|
||||||
PanelsWidget::PanelsWidget(QWidget *parent)
|
PanelsWidget::PanelsWidget(QWidget *parent) : QWidget(parent)
|
||||||
: QWidget(parent), m_splitter(new Core::MiniSplitter(this))
|
|
||||||
{
|
{
|
||||||
m_root = new QWidget(nullptr);
|
m_root = new QWidget(nullptr);
|
||||||
m_root->setFocusPolicy(Qt::NoFocus);
|
m_root->setFocusPolicy(Qt::NoFocus);
|
||||||
m_root->setContentsMargins(0, 0, 40, 0);
|
m_root->setContentsMargins(0, 0, 40, 0);
|
||||||
m_splitter->addWidget(m_root);
|
|
||||||
m_splitter->addWidget(new QWidget);
|
|
||||||
m_splitter->setStretchFactor(1, 100); // Force root widget to its minimum size initially
|
|
||||||
|
|
||||||
const auto scroller = new QScrollArea(this);
|
const auto scroller = new QScrollArea(this);
|
||||||
scroller->setWidget(m_splitter);
|
scroller->setWidget(m_root);
|
||||||
scroller->setFrameStyle(QFrame::NoFrame);
|
scroller->setFrameStyle(QFrame::NoFrame);
|
||||||
scroller->setWidgetResizable(true);
|
scroller->setWidgetResizable(true);
|
||||||
scroller->setFocusPolicy(Qt::NoFocus);
|
scroller->setFocusPolicy(Qt::NoFocus);
|
||||||
@@ -153,14 +147,4 @@ void PanelsWidget::addPropertiesPanel(const QString &displayName, const QIcon &i
|
|||||||
m_layout->addWidget(widget, widgetRow, 0, 1, 2);
|
m_layout->addWidget(widget, widgetRow, 0, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray PanelsWidget::saveSplitterState() const
|
|
||||||
{
|
|
||||||
return m_splitter->saveState().toHex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PanelsWidget::loadSplitterState(const QByteArray &state)
|
|
||||||
{
|
|
||||||
m_splitter->restoreState(QByteArray::fromHex(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // ProjectExplorer
|
} // ProjectExplorer
|
||||||
|
@@ -34,8 +34,6 @@ class QGridLayout;
|
|||||||
class QIcon;
|
class QIcon;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core { class MiniSplitter; }
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT PanelsWidget : public QWidget
|
class PROJECTEXPLORER_EXPORT PanelsWidget : public QWidget
|
||||||
@@ -51,12 +49,8 @@ public:
|
|||||||
void addPropertiesPanel(const QString &displayName, const QIcon &icon,
|
void addPropertiesPanel(const QString &displayName, const QIcon &icon,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
QByteArray saveSplitterState() const;
|
|
||||||
void loadSplitterState(const QByteArray &state);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGridLayout *m_layout;
|
QGridLayout *m_layout;
|
||||||
Core::MiniSplitter * const m_splitter;
|
|
||||||
QWidget *m_root;
|
QWidget *m_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -653,6 +653,19 @@ ProjectWindow::ProjectWindow()
|
|||||||
{
|
{
|
||||||
setBackgroundRole(QPalette::Base);
|
setBackgroundRole(QPalette::Base);
|
||||||
|
|
||||||
|
// The empty space on the right side of the project mode window.
|
||||||
|
auto rightSpace = new QWidget;
|
||||||
|
rightSpace->setAutoFillBackground(true);
|
||||||
|
rightSpace->setObjectName("ProjectModeRightSpace"); // Needed for dock widget state saving
|
||||||
|
rightSpace->setWindowTitle("dummy");
|
||||||
|
|
||||||
|
auto rightSpaceLayout = new QVBoxLayout(rightSpace);
|
||||||
|
rightSpaceLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
rightSpaceLayout->addWidget(new StyledBar(rightSpace)); // The black blob on top
|
||||||
|
rightSpaceLayout->addStretch();
|
||||||
|
|
||||||
|
addDockWidget(Qt::RightDockWidgetArea, addDockForWidget(rightSpace, true));
|
||||||
|
|
||||||
// Request custom context menu but do not provide any to avoid
|
// Request custom context menu but do not provide any to avoid
|
||||||
// the creation of the dock window selection menu.
|
// the creation of the dock window selection menu.
|
||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@@ -612,33 +612,14 @@ public:
|
|||||||
QWidget *panel() const
|
QWidget *panel() const
|
||||||
{
|
{
|
||||||
if (!m_panel) {
|
if (!m_panel) {
|
||||||
QString splitterStateKey = "PanelSplitterState:"
|
m_panel = (m_subIndex == RunPage)
|
||||||
+ m_project->projectFilePath().toString() + ':';
|
? new PanelsWidget(RunSettingsWidget::tr("Run Settings"),
|
||||||
if (m_subIndex == RunPage) {
|
|
||||||
splitterStateKey += "Run";
|
|
||||||
m_panel = new PanelsWidget(RunSettingsWidget::tr("Run Settings"),
|
|
||||||
QIcon(":/projectexplorer/images/RunSettings.png"),
|
QIcon(":/projectexplorer/images/RunSettings.png"),
|
||||||
new RunSettingsWidget(target()));
|
new RunSettingsWidget(target()))
|
||||||
} else {
|
: new PanelsWidget(QCoreApplication::translate("BuildSettingsPanel", "Build Settings"),
|
||||||
splitterStateKey += "Build";
|
|
||||||
m_panel = new PanelsWidget(QCoreApplication::translate("BuildSettingsPanel", "Build Settings"),
|
|
||||||
QIcon(":/projectexplorer/images/BuildSettings.png"),
|
QIcon(":/projectexplorer/images/BuildSettings.png"),
|
||||||
new BuildSettingsWidget(target()));
|
new BuildSettingsWidget(target()));
|
||||||
}
|
}
|
||||||
const auto panel = qobject_cast<PanelsWidget *>(m_panel.data());
|
|
||||||
const auto loadSplitterValue = [panel, splitterStateKey] {
|
|
||||||
const QByteArray splitterState = SessionManager::value(splitterStateKey).toByteArray();
|
|
||||||
if (!splitterState.isEmpty())
|
|
||||||
panel->loadSplitterState(splitterState);
|
|
||||||
};
|
|
||||||
loadSplitterValue();
|
|
||||||
QObject::connect(SessionManager::instance(), &SessionManager::aboutToSaveSession,
|
|
||||||
panel, [panel, splitterStateKey] {
|
|
||||||
SessionManager::setValue(splitterStateKey, panel->saveSplitterState());
|
|
||||||
});
|
|
||||||
QObject::connect(SessionManager::instance(), &SessionManager::sessionLoaded,
|
|
||||||
panel, loadSplitterValue);
|
|
||||||
}
|
|
||||||
return m_panel;
|
return m_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user