forked from qt-creator/qt-creator
Fix the Creator widgets Designer plugin, add DetailsWidgets.
Polish the DetailsWidget for that purpose, add properties, make it survive without widgets, add a container extension.
This commit is contained in:
@@ -3,21 +3,23 @@
|
||||
|
||||
#include <QtGui/QGridLayout>
|
||||
#include <QtCore/QStack>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QGridLayout>
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
DetailsWidget::DetailsWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_summaryLabel(new QLabel(this)),
|
||||
m_detailsButton(new DetailsButton(this)),
|
||||
m_widget(0),
|
||||
m_toolWidget(0)
|
||||
m_toolWidget(0),
|
||||
m_grid(new QGridLayout(this))
|
||||
|
||||
{
|
||||
m_grid = new QGridLayout(this);
|
||||
//m_grid->setMargin(0);
|
||||
m_summaryLabel = new QLabel(this);
|
||||
m_summaryLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
m_summaryLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_detailsButton = new DetailsButton(this);
|
||||
|
||||
m_grid->addWidget(m_summaryLabel, 0, 0, 2, 0);
|
||||
m_grid->addWidget(m_detailsButton, 1, 2);
|
||||
@@ -45,8 +47,8 @@ void DetailsWidget::paintEvent(QPaintEvent *paintEvent)
|
||||
if (!m_detailsButton->isToggled())
|
||||
return;
|
||||
|
||||
QRect detailsGeometry = m_detailsButton->geometry();
|
||||
QRect widgetGeometry = m_widget->geometry();
|
||||
const QRect detailsGeometry = m_detailsButton->geometry();
|
||||
const QRect widgetGeometry = m_widget ? m_widget->geometry() : QRect(x(), y() + height(), width(), 0);
|
||||
|
||||
QPoint tl(detailsGeometry.topLeft());
|
||||
tl += QPoint(-3, -3);
|
||||
@@ -85,29 +87,65 @@ void DetailsWidget::setSummaryText(const QString &text)
|
||||
m_summaryLabel->setText(text);
|
||||
}
|
||||
|
||||
QString DetailsWidget::summaryText() const
|
||||
{
|
||||
return m_summaryLabel->text();
|
||||
}
|
||||
|
||||
bool DetailsWidget::expanded() const
|
||||
{
|
||||
return m_detailsButton->isToggled();
|
||||
}
|
||||
|
||||
void DetailsWidget::setExpanded(bool v)
|
||||
{
|
||||
if (expanded() != v)
|
||||
m_detailsButton->animateClick();
|
||||
}
|
||||
|
||||
QWidget *DetailsWidget::widget() const
|
||||
{
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void DetailsWidget::setWidget(QWidget *widget)
|
||||
{
|
||||
if (m_widget == widget)
|
||||
return;
|
||||
if (m_widget)
|
||||
if (m_widget) {
|
||||
m_grid->removeWidget(m_widget);
|
||||
m_grid->addWidget(widget, 2, 0, 1, 3);
|
||||
m_widget = widget;
|
||||
m_widget->setVisible(m_detailsButton->isToggled());
|
||||
m_widget = 0;
|
||||
}
|
||||
if (widget) {
|
||||
m_grid->addWidget(widget, 2, 0, 1, 3);
|
||||
m_widget = widget;
|
||||
m_widget->setVisible(m_detailsButton->isToggled());
|
||||
}
|
||||
}
|
||||
|
||||
void DetailsWidget::setToolWidget(QWidget *widget)
|
||||
{
|
||||
if (m_toolWidget == widget)
|
||||
return;
|
||||
if (m_toolWidget)
|
||||
if (m_toolWidget) {
|
||||
m_grid->removeWidget(m_toolWidget);
|
||||
m_grid->addWidget(widget, 1, 1);
|
||||
m_toolWidget = widget;
|
||||
m_toolWidget = 0;
|
||||
}
|
||||
if (widget) {
|
||||
m_grid->addWidget(widget, 1, 1);
|
||||
m_toolWidget = widget;
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *DetailsWidget::toolWidget() const
|
||||
{
|
||||
return m_toolWidget;
|
||||
}
|
||||
|
||||
void DetailsWidget::fixUpLayout()
|
||||
{
|
||||
if (!m_widget)
|
||||
return;
|
||||
QWidget *parent = m_widget;
|
||||
QStack<QWidget *> widgets;
|
||||
while((parent = parent->parentWidget()) && parent && parent->layout()) {
|
||||
|
||||
Reference in New Issue
Block a user