forked from qt-creator/qt-creator
Add addToLayout()-method to KitConfigWidget.
Provide default implementation to do a single-line layout and let the DebuggerKitConfigWidget span 3 rows, aligning label and button accordingly. Change-Id: I0fb3a3116a593822da9c4499c142b8a8255c02d0 Reviewed-by: Eike Ziller <eike.ziller@nokia.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -100,6 +100,13 @@ DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *k,
|
||||
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshLabel()));
|
||||
}
|
||||
|
||||
void DebuggerKitConfigWidget::addToLayout(QGridLayout *layout, int row)
|
||||
{
|
||||
addLabel(layout, row);
|
||||
layout->addWidget(this, row, WidgetColumn, 3 , 1);
|
||||
addButtonWidget(layout, row + 2);
|
||||
}
|
||||
|
||||
QString DebuggerKitConfigWidget::displayName() const
|
||||
{
|
||||
return tr("Debugger:");
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
void discard();
|
||||
bool isDirty() const;
|
||||
QWidget *buttonWidget() const;
|
||||
void addToLayout(QGridLayout *layout, int row);
|
||||
|
||||
DebuggerEngineType engineType() const;
|
||||
void setEngineType(DebuggerEngineType et);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -46,6 +48,12 @@ class PROJECTEXPLORER_EXPORT KitConfigWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum LayoutColumns {
|
||||
LabelColumn,
|
||||
WidgetColumn,
|
||||
ButtonColumn
|
||||
};
|
||||
|
||||
KitConfigWidget(QWidget *parent = 0) : QWidget(parent)
|
||||
{ }
|
||||
|
||||
@@ -57,8 +65,15 @@ public:
|
||||
virtual bool isDirty() const = 0;
|
||||
|
||||
virtual QWidget *buttonWidget() const { return 0; }
|
||||
|
||||
virtual void addToLayout(QGridLayout *layout, int row);
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
|
||||
protected:
|
||||
void addLabel(QGridLayout *layout, int row);
|
||||
void addButtonWidget(QGridLayout *layout, int row);
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -44,6 +44,32 @@
|
||||
#include <QStyle>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
void KitConfigWidget::addToLayout(QGridLayout *layout, int row)
|
||||
{
|
||||
addLabel(layout, row);
|
||||
layout->addWidget(this, row, WidgetColumn);
|
||||
addButtonWidget(layout, row);
|
||||
}
|
||||
|
||||
void KitConfigWidget::addLabel(QGridLayout *layout, int row)
|
||||
{
|
||||
static const Qt::Alignment alignment
|
||||
= static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
|
||||
QLabel *label = new QLabel(displayName());
|
||||
label->setToolTip(toolTip());
|
||||
layout->addWidget(label, row, LabelColumn, alignment);
|
||||
}
|
||||
|
||||
void KitConfigWidget::addButtonWidget(QGridLayout *layout, int row)
|
||||
{
|
||||
if (QWidget *button = buttonWidget()) {
|
||||
if (button->toolTip().isEmpty())
|
||||
button->setToolTip(toolTip());
|
||||
layout->addWidget(button, row, ButtonColumn);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, QWidget *parent) :
|
||||
@@ -122,19 +148,7 @@ void KitManagerConfigWidget::addConfigWidget(ProjectExplorer::KitConfigWidget *w
|
||||
Q_ASSERT(!m_widgets.contains(widget));
|
||||
|
||||
connect(widget, SIGNAL(dirty()), this, SIGNAL(dirty()));
|
||||
int row = m_layout->rowCount();
|
||||
QLabel *label = new QLabel(widget->displayName());
|
||||
label->setToolTip(widget->toolTip());
|
||||
m_layout->addWidget(label, row, 0,
|
||||
Qt::Alignment(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment)));
|
||||
m_layout->addWidget(widget, row, 1);
|
||||
QWidget *buttonWidget = widget->buttonWidget();
|
||||
if (buttonWidget) {
|
||||
if (buttonWidget->toolTip().isEmpty())
|
||||
buttonWidget->setToolTip(widget->toolTip());
|
||||
m_layout->addWidget(widget->buttonWidget(), row, 2);
|
||||
}
|
||||
|
||||
widget->addToLayout(m_layout, m_layout->rowCount());
|
||||
m_widgets.append(widget);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user