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 <coreplugin/minisplitter.h>
|
||||
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/theme/theme.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/styledbar.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
@@ -55,18 +53,14 @@ const int PANEL_LEFT_MARGIN = 70;
|
||||
// PanelsWidget
|
||||
///
|
||||
|
||||
PanelsWidget::PanelsWidget(QWidget *parent)
|
||||
: QWidget(parent), m_splitter(new Core::MiniSplitter(this))
|
||||
PanelsWidget::PanelsWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_root = new QWidget(nullptr);
|
||||
m_root->setFocusPolicy(Qt::NoFocus);
|
||||
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);
|
||||
scroller->setWidget(m_splitter);
|
||||
scroller->setWidget(m_root);
|
||||
scroller->setFrameStyle(QFrame::NoFrame);
|
||||
scroller->setWidgetResizable(true);
|
||||
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);
|
||||
}
|
||||
|
||||
QByteArray PanelsWidget::saveSplitterState() const
|
||||
{
|
||||
return m_splitter->saveState().toHex();
|
||||
}
|
||||
|
||||
void PanelsWidget::loadSplitterState(const QByteArray &state)
|
||||
{
|
||||
m_splitter->restoreState(QByteArray::fromHex(state));
|
||||
}
|
||||
|
||||
} // ProjectExplorer
|
||||
|
@@ -34,8 +34,6 @@ class QGridLayout;
|
||||
class QIcon;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class MiniSplitter; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class PROJECTEXPLORER_EXPORT PanelsWidget : public QWidget
|
||||
@@ -51,12 +49,8 @@ public:
|
||||
void addPropertiesPanel(const QString &displayName, const QIcon &icon,
|
||||
QWidget *widget);
|
||||
|
||||
QByteArray saveSplitterState() const;
|
||||
void loadSplitterState(const QByteArray &state);
|
||||
|
||||
private:
|
||||
QGridLayout *m_layout;
|
||||
Core::MiniSplitter * const m_splitter;
|
||||
QWidget *m_root;
|
||||
};
|
||||
|
||||
|
@@ -653,6 +653,19 @@ ProjectWindow::ProjectWindow()
|
||||
{
|
||||
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
|
||||
// the creation of the dock window selection menu.
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
@@ -612,32 +612,13 @@ public:
|
||||
QWidget *panel() const
|
||||
{
|
||||
if (!m_panel) {
|
||||
QString splitterStateKey = "PanelSplitterState:"
|
||||
+ m_project->projectFilePath().toString() + ':';
|
||||
if (m_subIndex == RunPage) {
|
||||
splitterStateKey += "Run";
|
||||
m_panel = new PanelsWidget(RunSettingsWidget::tr("Run Settings"),
|
||||
QIcon(":/projectexplorer/images/RunSettings.png"),
|
||||
new RunSettingsWidget(target()));
|
||||
} else {
|
||||
splitterStateKey += "Build";
|
||||
m_panel = new PanelsWidget(QCoreApplication::translate("BuildSettingsPanel", "Build Settings"),
|
||||
QIcon(":/projectexplorer/images/BuildSettings.png"),
|
||||
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);
|
||||
m_panel = (m_subIndex == RunPage)
|
||||
? new PanelsWidget(RunSettingsWidget::tr("Run Settings"),
|
||||
QIcon(":/projectexplorer/images/RunSettings.png"),
|
||||
new RunSettingsWidget(target()))
|
||||
: new PanelsWidget(QCoreApplication::translate("BuildSettingsPanel", "Build Settings"),
|
||||
QIcon(":/projectexplorer/images/BuildSettings.png"),
|
||||
new BuildSettingsWidget(target()));
|
||||
}
|
||||
return m_panel;
|
||||
}
|
||||
|
Reference in New Issue
Block a user