diff options
author | Takumi Asaki <asaki@sra.co.jp> | 2013-08-01 17:09:40 +0900 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-27 19:24:57 +0200 |
commit | 48f147c72c126cd82f4a4c028a8e55b8227db938 (patch) | |
tree | bf885e6b04a8e1108a2018f292727cac5dced6fb | |
parent | 262744ac1b6ba95d72bedc7679e2b49c11c74803 (diff) |
Linguist: Fix layout of message editor for length variants
Task-number: QTBUG-14348
Change-Id: I6475cd87df4bd1fe1729d437fa01f5f46d362395
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r-- | src/linguist/linguist/messageeditorwidgets.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/linguist/linguist/messageeditorwidgets.cpp b/src/linguist/linguist/messageeditorwidgets.cpp index 60dfe2140..0850d30bb 100644 --- a/src/linguist/linguist/messageeditorwidgets.cpp +++ b/src/linguist/linguist/messageeditorwidgets.cpp @@ -226,7 +226,6 @@ class ButtonWrapper : public QWidget public: ButtonWrapper(QWidget *wrapee, QWidget *relator) : m_wrapee(wrapee) { - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); QBoxLayout *box = new QVBoxLayout; box->setMargin(0); setLayout(box); @@ -240,7 +239,7 @@ protected: { if (event->type() == QEvent::Resize) { QWidget *relator = static_cast<QWidget *>(object); - setFixedHeight((relator->height() + layout()->spacing() + m_wrapee->height()) / 2); + setFixedHeight(relator->height()); } return false; } @@ -334,20 +333,33 @@ void FormMultiWidget::updateLayout() bool variants = m_multiEnabled && m_label->isEnabled(); - layout->addWidget(m_label, 0, 0, 1, variants ? 3 : 1); + layout->addWidget(m_label, 0, 0, 1, variants ? 2 : 1); + + if (variants) { + QVBoxLayout *layoutForPlusButtons = new QVBoxLayout; + layoutForPlusButtons->setMargin(0); + for (int i = 0; i < m_plusButtons.count(); ++i) + layoutForPlusButtons->addWidget(m_plusButtons.at(i), Qt::AlignTop); + layout->addLayout(layoutForPlusButtons, 1, 0); + + QGridLayout *layoutForLabels = new QGridLayout; + layoutForLabels->setMargin(0); + layoutForLabels->setRowMinimumHeight(0, m_plusButtons.at(0)->height()/2.0); + for (int j = 0; j < m_editors.count(); ++j) { + layoutForLabels->addWidget(m_editors.at(j), 1 + j, 0, Qt::AlignVCenter); + layoutForLabels->addWidget(m_minusButtons.at(j), 1 + j, 1, Qt::AlignVCenter); + } + layoutForLabels->setRowMinimumHeight(m_editors.count() + 1, m_plusButtons.at(0)->height()/2.0); + layout->addLayout(layoutForLabels, 1, 1); + } else { + for (int k = 0; k < m_editors.count(); ++k) + layout->addWidget(m_editors.at(k), 1 + k, 0, Qt::AlignVCenter); + } - for (int i = 0; i < m_plusButtons.count(); ++i) { - if (variants) - layout->addWidget(m_plusButtons.at(i), 1 + i * 2, 0, 2, 1, Qt::AlignTop); + for (int i = 0; i < m_plusButtons.count(); ++i) m_plusButtons.at(i)->setVisible(variants); - } - for (int j = 0; j < m_minusButtons.count(); ++j) { - if (variants) - layout->addWidget(m_minusButtons.at(j), 2 + j * 2, 2, 2, 1, Qt::AlignVCenter); + for (int j = 0; j < m_minusButtons.count(); ++j) m_minusButtons.at(j)->setVisible(variants); - } - for (int k = 0; k < m_editors.count(); ++k) - layout->addWidget(m_editors.at(k), 2 + k * 2, variants ? 1 : 0, 2, 1, Qt::AlignVCenter); updateGeometry(); } |