diff options
-rw-r--r-- | src/plugins/coreplugin/find/searchresultwidget.cpp | 62 | ||||
-rw-r--r-- | src/plugins/coreplugin/find/searchresultwidget.h | 1 |
2 files changed, 37 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; } diff --git a/src/plugins/coreplugin/find/searchresultwidget.h b/src/plugins/coreplugin/find/searchresultwidget.h index 6314f5e2ff..2546f16d9e 100644 --- a/src/plugins/coreplugin/find/searchresultwidget.h +++ b/src/plugins/coreplugin/find/searchresultwidget.h @@ -132,6 +132,7 @@ private: InfoBar m_infoBar; InfoBarDisplay m_infoBarDisplay; bool m_isShowingReplaceUI; + QWidget *m_topReplaceWidget; QLabel *m_replaceLabel; QLineEdit *m_replaceTextEdit; QToolButton *m_replaceButton; |