summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin/find/searchresultwidget.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2015-03-13 15:59:42 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2015-03-16 09:13:26 +0000
commit9f545843d39926199124b21212d52e402129a5d5 (patch)
treed56db711dc4055dc29a3f5b6f8eece154bc8a14f /src/plugins/coreplugin/find/searchresultwidget.cpp
parent4b6ee5881a2d7ff327288795959efa6630b11d13 (diff)
downloadqt-creator-9f545843d39926199124b21212d52e402129a5d5.tar.gz
Search & Replace: Save some horizontal space
Invoking global search & replace would greatly increase the main window's minimum size, so arrange the search and the replace parts vertically. Task-number: QTCREATORBUG-8770 Change-Id: Ia8ae8554a6c089e56b918192dc7ae33cf3e9a615 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'src/plugins/coreplugin/find/searchresultwidget.cpp')
-rw-r--r--src/plugins/coreplugin/find/searchresultwidget.cpp62
1 files changed, 36 insertions, 26 deletions
diff --git a/src/plugins/coreplugin/find/searchresultwidget.cpp b/src/plugins/coreplugin/find/searchresultwidget.cpp
index 0ee63e7f91..1917d6ce4d 100644
--- a/src/plugins/coreplugin/find/searchresultwidget.cpp
+++ b/src/plugins/coreplugin/find/searchresultwidget.cpp
@@ -104,11 +104,24 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
topWidget->setLineWidth(1);
}
topWidget->setAutoFillBackground(true);
- QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
- topLayout->setMargin(2);
+ auto topLayout = new QVBoxLayout(topWidget);
+ topLayout->setContentsMargins(2, 2, 2, 2);
+ topLayout->setSpacing(2);
topWidget->setLayout(topLayout);
layout->addWidget(topWidget);
+ auto topFindWidget = new QWidget(topWidget);
+ auto topFindLayout = new QHBoxLayout(topFindWidget);
+ topFindLayout->setMargin(0);
+ topFindWidget->setLayout(topFindLayout);
+ topLayout->addWidget(topFindWidget);
+
+ m_topReplaceWidget = new QWidget(topWidget);
+ auto topReplaceLayout = new QHBoxLayout(m_topReplaceWidget);
+ topReplaceLayout->setMargin(0);
+ m_topReplaceWidget->setLayout(topReplaceLayout);
+ topLayout->addWidget(m_topReplaceWidget);
+
m_messageWidget = new QFrame;
pal.setColor(QPalette::WindowText, creatorTheme()->color(Theme::CanceledSearchTextColor));
m_messageWidget->setPalette(pal);
@@ -138,7 +151,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
m_infoBarDisplay.setTarget(layout, 2);
m_infoBarDisplay.setInfoBar(&m_infoBar);
- m_descriptionContainer = new QWidget(topWidget);
+ m_descriptionContainer = new QWidget(topFindWidget);
QHBoxLayout *descriptionLayout = new QHBoxLayout(m_descriptionContainer);
m_descriptionContainer->setLayout(descriptionLayout);
descriptionLayout->setMargin(0);
@@ -150,28 +163,28 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
m_searchTerm->setVisible(false);
descriptionLayout->addWidget(m_label);
descriptionLayout->addWidget(m_searchTerm);
- m_cancelButton = new QToolButton(topWidget);
+ m_cancelButton = new QToolButton(topFindWidget);
m_cancelButton->setText(tr("Cancel"));
m_cancelButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
- m_searchAgainButton = new QToolButton(topWidget);
+ m_searchAgainButton = new QToolButton(topFindWidget);
m_searchAgainButton->setToolTip(tr("Repeat the search with same parameters."));
m_searchAgainButton->setText(tr("Search again"));
m_searchAgainButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
m_searchAgainButton->setVisible(false);
connect(m_searchAgainButton, SIGNAL(clicked()), this, SLOT(searchAgain()));
- m_replaceLabel = new QLabel(tr("Replace with:"), topWidget);
- m_replaceTextEdit = new WideEnoughLineEdit(topWidget);
+ m_replaceLabel = new QLabel(tr("Replace with:"), m_topReplaceWidget);
+ m_replaceTextEdit = new WideEnoughLineEdit(m_topReplaceWidget);
m_replaceTextEdit->setMinimumWidth(120);
m_replaceTextEdit->setEnabled(false);
m_replaceTextEdit->setTabOrder(m_replaceTextEdit, m_searchResultTreeView);
- m_replaceButton = new QToolButton(topWidget);
+ m_replaceButton = new QToolButton(m_topReplaceWidget);
m_replaceButton->setToolTip(tr("Replace all occurrences."));
m_replaceButton->setText(tr("Replace"));
m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
m_replaceButton->setEnabled(false);
- m_preserveCaseCheck = new QCheckBox(topWidget);
+ m_preserveCaseCheck = new QCheckBox(m_topReplaceWidget);
m_preserveCaseCheck->setText(tr("Preserve case"));
m_preserveCaseCheck->setEnabled(false);
@@ -180,22 +193,21 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
connect(m_preserveCaseCheck, SIGNAL(clicked(bool)), plugin, SLOT(setPreserveCase(bool)));
}
- m_matchesFoundLabel = new QLabel(topWidget);
+ m_matchesFoundLabel = new QLabel(topFindWidget);
updateMatchesFoundLabel();
- topLayout->addWidget(m_descriptionContainer);
- topLayout->addWidget(m_cancelButton);
- topLayout->addWidget(m_searchAgainButton);
- topLayout->addWidget(m_replaceLabel);
- topLayout->addWidget(m_replaceTextEdit);
- topLayout->addWidget(m_replaceButton);
- topLayout->addWidget(m_preserveCaseCheck);
- topLayout->addStretch(2);
- topLayout->addWidget(m_matchesFoundLabel);
- topWidget->setMinimumHeight(m_cancelButton->sizeHint().height()
- + topLayout->contentsMargins().top() + topLayout->contentsMargins().bottom()
- + topWidget->lineWidth());
+ topFindLayout->addWidget(m_descriptionContainer);
+ topFindLayout->addWidget(m_cancelButton);
+ topFindLayout->addWidget(m_searchAgainButton);
+ topFindLayout->addStretch(2);
+ topFindLayout->addWidget(m_matchesFoundLabel);
+ topReplaceLayout->addWidget(m_replaceLabel);
+ topReplaceLayout->addWidget(m_replaceTextEdit);
+ topReplaceLayout->addWidget(m_replaceButton);
+ topReplaceLayout->addWidget(m_preserveCaseCheck);
+ topReplaceLayout->addStretch(2);
setShowReplaceUI(false);
+ setSupportPreserveCase(true);
connect(m_searchResultTreeView, SIGNAL(jumpToSearchResult(SearchResultItem)),
this, SLOT(handleJumpToSearchResult(SearchResultItem)));
@@ -306,15 +318,13 @@ QString SearchResultWidget::textToReplace() const
void SearchResultWidget::setSupportPreserveCase(bool enabled)
{
m_preserveCaseSupported = enabled;
+ m_preserveCaseCheck->setVisible(m_preserveCaseSupported);
}
void SearchResultWidget::setShowReplaceUI(bool visible)
{
m_searchResultTreeView->model()->setShowReplaceUI(visible);
- m_replaceLabel->setVisible(visible);
- m_replaceTextEdit->setVisible(visible);
- m_replaceButton->setVisible(visible);
- m_preserveCaseCheck->setVisible(visible && m_preserveCaseSupported);
+ m_topReplaceWidget->setVisible(visible);
m_isShowingReplaceUI = visible;
}