forked from qt-creator/qt-creator
ProjectExplorer: Don't force a smallish maximum panels widget width
This widget can often benefit from more space, as we currently often see cut-off text etc. We now use a splitter, with the main widget originally taking up its current minimum size, and the user being able to enlarge it according to their preference. Change-Id: Ibc5f0a54e0659613b3094181db258717d1886cb9 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -25,15 +25,18 @@
|
|||||||
|
|
||||||
#include "panelswidget.h"
|
#include "panelswidget.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <coreplugin/minisplitter.h>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -46,53 +49,27 @@ const int ABOVE_CONTENTS_MARGIN = 4;
|
|||||||
const int BELOW_CONTENTS_MARGIN = 16;
|
const int BELOW_CONTENTS_MARGIN = 16;
|
||||||
const int PANEL_LEFT_MARGIN = 70;
|
const int PANEL_LEFT_MARGIN = 70;
|
||||||
|
|
||||||
class RootWidget : public QWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RootWidget(QWidget *parent) : QWidget(parent) {
|
|
||||||
setFocusPolicy(Qt::NoFocus);
|
|
||||||
}
|
|
||||||
void paintEvent(QPaintEvent *) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
void RootWidget::paintEvent(QPaintEvent *e)
|
|
||||||
{
|
|
||||||
QWidget::paintEvent(e);
|
|
||||||
|
|
||||||
if (!creatorTheme()->flag(Theme::FlatToolBars)) {
|
|
||||||
// draw separator line to the right of the settings panel
|
|
||||||
QPainter painter(this);
|
|
||||||
QColor light = StyleHelper::mergedColors(
|
|
||||||
palette().button().color(), Qt::white, 30);
|
|
||||||
QColor dark = StyleHelper::mergedColors(
|
|
||||||
palette().button().color(), Qt::black, 85);
|
|
||||||
|
|
||||||
painter.setPen(light);
|
|
||||||
painter.drawLine(rect().topRight(), rect().bottomRight());
|
|
||||||
painter.setPen(dark);
|
|
||||||
painter.drawLine(rect().topRight() - QPoint(1,0), rect().bottomRight() - QPoint(1,0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// PanelsWidget
|
// PanelsWidget
|
||||||
///
|
///
|
||||||
|
|
||||||
PanelsWidget::PanelsWidget(QWidget *parent) :
|
PanelsWidget::PanelsWidget(QWidget *parent) : QWidget(parent)
|
||||||
QWidget(parent),
|
|
||||||
m_root(new RootWidget(this))
|
|
||||||
{
|
{
|
||||||
// We want a 900px wide widget with and the scrollbar at the
|
const auto splitter = new Core::MiniSplitter(this);
|
||||||
// side of the screen.
|
m_root = new QWidget(nullptr);
|
||||||
m_root->setMaximumWidth(900);
|
m_root->setFocusPolicy(Qt::NoFocus);
|
||||||
m_root->setContentsMargins(0, 0, 40, 0);
|
m_root->setContentsMargins(0, 0, 40, 0);
|
||||||
|
splitter->addWidget(m_root);
|
||||||
|
splitter->addWidget(new QWidget);
|
||||||
|
splitter->setStretchFactor(1, 100); // Force root widget to its minimum size initially
|
||||||
|
|
||||||
m_scroller = new QScrollArea(this);
|
const auto scroller = new QScrollArea(this);
|
||||||
m_scroller->setWidget(m_root);
|
scroller->setWidget(splitter);
|
||||||
m_scroller->setFrameStyle(QFrame::NoFrame);
|
scroller->setFrameStyle(QFrame::NoFrame);
|
||||||
m_scroller->setWidgetResizable(true);
|
scroller->setWidgetResizable(true);
|
||||||
m_scroller->setFocusPolicy(Qt::NoFocus);
|
scroller->setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
// The layout holding the individual panels:
|
// The layout holding the individual panels:
|
||||||
auto topLayout = new QVBoxLayout(m_root);
|
auto topLayout = new QVBoxLayout(m_root);
|
||||||
@@ -110,7 +87,7 @@ PanelsWidget::PanelsWidget(QWidget *parent) :
|
|||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->addWidget(new Utils::StyledBar(this));
|
layout->addWidget(new Utils::StyledBar(this));
|
||||||
layout->addWidget(m_scroller);
|
layout->addWidget(scroller);
|
||||||
|
|
||||||
//layout->addWidget(new FindToolBarPlaceHolder(this));
|
//layout->addWidget(new FindToolBarPlaceHolder(this));
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
|
|
||||||
#include <QScrollArea>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
@@ -51,7 +51,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QGridLayout *m_layout;
|
QGridLayout *m_layout;
|
||||||
QScrollArea *m_scroller;
|
|
||||||
QWidget *m_root;
|
QWidget *m_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user