diff --git a/src/plugins/coreplugin/CMakeLists.txt b/src/plugins/coreplugin/CMakeLists.txt
index 5b97b2bbbb2..9a0a937b8bf 100644
--- a/src/plugins/coreplugin/CMakeLists.txt
+++ b/src/plugins/coreplugin/CMakeLists.txt
@@ -64,7 +64,6 @@ add_qtc_plugin(Core
find/basetextfind.cpp find/basetextfind.h
find/currentdocumentfind.cpp find/currentdocumentfind.h
find/find.qrc
- find/finddialog.ui
find/findplugin.cpp find/findplugin.h
find/findtoolbar.cpp find/findtoolbar.h
find/findtoolwindow.cpp find/findtoolwindow.h
diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs
index 2f35546178e..b0447ab16a0 100644
--- a/src/plugins/coreplugin/coreplugin.qbs
+++ b/src/plugins/coreplugin/coreplugin.qbs
@@ -294,7 +294,6 @@ Project {
"currentdocumentfind.cpp",
"currentdocumentfind.h",
"find.qrc",
- "finddialog.ui",
"findplugin.cpp",
"findplugin.h",
"findtoolbar.cpp",
diff --git a/src/plugins/coreplugin/find/finddialog.ui b/src/plugins/coreplugin/find/finddialog.ui
deleted file mode 100644
index 620e1041f7f..00000000000
--- a/src/plugins/coreplugin/find/finddialog.ui
+++ /dev/null
@@ -1,217 +0,0 @@
-
-
- Core::Internal::FindDialog
-
-
-
- QLayout::SetFixedSize
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- &Search
-
-
- true
-
-
-
- -
-
-
- Search && &Replace
-
-
-
-
-
- -
-
-
- Search f&or:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
- searchTerm
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
- 0
-
-
-
- QComboBox::AdjustToContents
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- &Case sensitive
-
-
-
- -
-
-
- Whole words o&nly
-
-
-
- -
-
-
- Use re&gular expressions
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 80
- 0
-
-
-
- Sco&pe:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
- filterList
-
-
-
- -
-
-
- -
-
-
-
- 0
- 10
-
-
-
-
- 680
- 0
-
-
-
-
-
-
-
-
- Utils::FancyLineEdit
- QLineEdit
-
-
-
-
- filterList
- searchTerm
- matchCase
- wholeWords
- regExp
-
-
-
-
diff --git a/src/plugins/coreplugin/find/findtoolwindow.cpp b/src/plugins/coreplugin/find/findtoolwindow.cpp
index 86824fc2a4e..1650d9bb538 100644
--- a/src/plugins/coreplugin/find/findtoolwindow.cpp
+++ b/src/plugins/coreplugin/find/findtoolwindow.cpp
@@ -2,22 +2,33 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "findtoolwindow.h"
+
#include "ifindfilter.h"
#include "findplugin.h"
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+
+#include
+#include
#include
+#include
+#include
#include
+#include
+#include
#include
#include
+#include
+#include
-using namespace Core;
-using namespace Core::Internal;
+using namespace Utils;
+
+namespace Core::Internal {
static FindToolWindow *m_instance = nullptr;
@@ -45,35 +56,96 @@ FindToolWindow::FindToolWindow(QWidget *parent)
m_configWidget(nullptr)
{
m_instance = this;
- m_ui.setupUi(this);
- m_ui.searchTerm->setFiltering(true);
- m_ui.searchTerm->setPlaceholderText(QString());
- setFocusProxy(m_ui.searchTerm);
- connect(m_ui.searchButton, &QAbstractButton::clicked, this, &FindToolWindow::search);
- connect(m_ui.replaceButton, &QAbstractButton::clicked, this, &FindToolWindow::replace);
- connect(m_ui.matchCase, &QAbstractButton::toggled, Find::instance(), &Find::setCaseSensitive);
- connect(m_ui.wholeWords, &QAbstractButton::toggled, Find::instance(), &Find::setWholeWord);
- connect(m_ui.regExp, &QAbstractButton::toggled, Find::instance(), &Find::setRegularExpression);
- connect(m_ui.filterList, &QComboBox::activated,
+ m_searchButton = new QPushButton(this);
+ m_searchButton->setText(QCoreApplication::translate("Core::Internal::FindDialog", "&Search", nullptr));
+ m_searchButton->setDefault(true);
+
+ m_replaceButton = new QPushButton(this);
+ m_replaceButton->setText(QCoreApplication::translate("Core::Internal::FindDialog", "Search && &Replace", nullptr));
+
+ m_searchTerm = new FancyLineEdit(this);
+ m_searchTerm->setFiltering(true);
+
+ m_searchLabel = new QLabel(this);
+ m_searchLabel->setText(QCoreApplication::translate("Core::Internal::FindDialog", "Search f&or:", nullptr));
+ m_searchLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
+ m_searchLabel->setBuddy(m_searchTerm);
+
+ m_filterList = new QComboBox;
+ m_filterList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ m_filterList->setSizeAdjustPolicy(QComboBox::AdjustToContents);
+
+ m_optionsWidget = new QWidget(this);
+
+ m_matchCase = new QCheckBox(m_optionsWidget);
+ m_matchCase->setText(QCoreApplication::translate("Core::Internal::FindDialog", "&Case sensitive", nullptr));
+
+ m_wholeWords = new QCheckBox(m_optionsWidget);
+ m_wholeWords->setText(QCoreApplication::translate("Core::Internal::FindDialog", "Whole words o&nly", nullptr));
+
+ m_regExp = new QCheckBox(m_optionsWidget);
+ m_regExp->setText(QCoreApplication::translate("Core::Internal::FindDialog", "Use re&gular expressions", nullptr));
+
+ auto label = new QLabel(this);
+ label->setText(QCoreApplication::translate("Core::Internal::FindDialog", "Sco&pe:", nullptr));
+ label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+ label->setMinimumSize(QSize(80, 0));
+ label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
+ label->setBuddy(m_filterList);
+
+ m_uiConfigWidget = new QWidget(this);
+ QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ sizePolicy2.setHorizontalStretch(0);
+ sizePolicy2.setVerticalStretch(10);
+ m_uiConfigWidget->setSizePolicy(sizePolicy2);
+ m_uiConfigWidget->setMinimumSize(QSize(680, 0));
+
+ setFocusProxy(m_searchTerm);
+
+ using namespace Layouting;
+
+ Row {
+ m_matchCase,
+ m_wholeWords,
+ m_regExp,
+ st,
+ }.attachTo(m_optionsWidget, WithoutMargins);
+
+ Grid {
+ label, m_filterList, br,
+ m_searchLabel, m_searchTerm, br,
+ empty, m_optionsWidget, br,
+ Span(2, m_uiConfigWidget), br,
+ Span(2, Row { st, m_searchButton, m_replaceButton }), br,
+ }.attachTo(this);
+
+ layout()->setSizeConstraint(QLayout::SetFixedSize);
+
+ connect(m_searchButton, &QAbstractButton::clicked, this, &FindToolWindow::search);
+ connect(m_replaceButton, &QAbstractButton::clicked, this, &FindToolWindow::replace);
+ connect(m_matchCase, &QAbstractButton::toggled, Find::instance(), &Find::setCaseSensitive);
+ connect(m_wholeWords, &QAbstractButton::toggled, Find::instance(), &Find::setWholeWord);
+ connect(m_regExp, &QAbstractButton::toggled, Find::instance(), &Find::setRegularExpression);
+ connect(m_filterList, &QComboBox::activated,
this, QOverload::of(&FindToolWindow::setCurrentFilter));
m_findCompleter->setModel(Find::findCompletionModel());
- m_ui.searchTerm->setSpecialCompleter(m_findCompleter);
- m_ui.searchTerm->installEventFilter(this);
+ m_searchTerm->setSpecialCompleter(m_findCompleter);
+ m_searchTerm->installEventFilter(this);
connect(m_findCompleter, QOverload::of(&QCompleter::activated),
this, &FindToolWindow::findCompleterActivated);
- m_ui.searchTerm->setValidationFunction(validateRegExp);
+ m_searchTerm->setValidationFunction(validateRegExp);
connect(Find::instance(), &Find::findFlagsChanged,
- m_ui.searchTerm, &Utils::FancyLineEdit::validate);
- connect(m_ui.searchTerm, &Utils::FancyLineEdit::validChanged,
+ m_searchTerm, &Utils::FancyLineEdit::validate);
+ connect(m_searchTerm, &Utils::FancyLineEdit::validChanged,
this, &FindToolWindow::updateButtonStates);
auto layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
- m_ui.configWidget->setLayout(layout);
+ m_uiConfigWidget->setLayout(layout);
updateButtonStates();
connect(Find::instance(), &Find::findFlagsChanged, this, &FindToolWindow::updateFindFlags);
@@ -96,7 +168,7 @@ bool FindToolWindow::event(QEvent *event)
if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter)
&& (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) {
ke->accept();
- if (m_ui.searchButton->isEnabled())
+ if (m_searchButton->isEnabled())
search();
return true;
}
@@ -106,10 +178,10 @@ bool FindToolWindow::event(QEvent *event)
bool FindToolWindow::eventFilter(QObject *obj, QEvent *event)
{
- if (obj == m_ui.searchTerm && event->type() == QEvent::KeyPress) {
+ if (obj == m_searchTerm && event->type() == QEvent::KeyPress) {
auto ke = static_cast(event);
if (ke->key() == Qt::Key_Down) {
- if (m_ui.searchTerm->text().isEmpty())
+ if (m_searchTerm->text().isEmpty())
m_findCompleter->setCompletionPrefix(QString());
m_findCompleter->complete();
}
@@ -121,34 +193,34 @@ void FindToolWindow::updateButtonStates()
{
bool filterEnabled = m_currentFilter && m_currentFilter->isEnabled();
bool enabled = filterEnabled && (!m_currentFilter->showSearchTermInput()
- || m_ui.searchTerm->isValid()) && m_currentFilter->isValid();
- m_ui.searchButton->setEnabled(enabled);
- m_ui.replaceButton->setEnabled(m_currentFilter
+ || m_searchTerm->isValid()) && m_currentFilter->isValid();
+ m_searchButton->setEnabled(enabled);
+ m_replaceButton->setEnabled(m_currentFilter
&& m_currentFilter->isReplaceSupported() && enabled);
if (m_configWidget)
m_configWidget->setEnabled(filterEnabled);
if (m_currentFilter) {
- m_ui.searchTerm->setVisible(m_currentFilter->showSearchTermInput());
- m_ui.searchLabel->setVisible(m_currentFilter->showSearchTermInput());
- m_ui.optionsWidget->setVisible(m_currentFilter->supportedFindFlags()
+ m_searchTerm->setVisible(m_currentFilter->showSearchTermInput());
+ m_searchLabel->setVisible(m_currentFilter->showSearchTermInput());
+ m_optionsWidget->setVisible(m_currentFilter->supportedFindFlags()
& (FindCaseSensitively | FindWholeWords | FindRegularExpression));
}
- m_ui.matchCase->setEnabled(filterEnabled
+ m_matchCase->setEnabled(filterEnabled
&& (m_currentFilter->supportedFindFlags() & FindCaseSensitively));
- m_ui.wholeWords->setEnabled(filterEnabled
+ m_wholeWords->setEnabled(filterEnabled
&& (m_currentFilter->supportedFindFlags() & FindWholeWords));
- m_ui.regExp->setEnabled(filterEnabled
+ m_regExp->setEnabled(filterEnabled
&& (m_currentFilter->supportedFindFlags() & FindRegularExpression));
- m_ui.searchTerm->setEnabled(filterEnabled);
+ m_searchTerm->setEnabled(filterEnabled);
}
void FindToolWindow::updateFindFlags()
{
- m_ui.matchCase->setChecked(Find::hasFindFlag(FindCaseSensitively));
- m_ui.wholeWords->setChecked(Find::hasFindFlag(FindWholeWords));
- m_ui.regExp->setChecked(Find::hasFindFlag(FindRegularExpression));
+ m_matchCase->setChecked(Find::hasFindFlag(FindCaseSensitively));
+ m_wholeWords->setChecked(Find::hasFindFlag(FindWholeWords));
+ m_regExp->setChecked(Find::hasFindFlag(FindRegularExpression));
}
@@ -159,7 +231,7 @@ void FindToolWindow::setFindFilters(const QList &filters)
for (IFindFilter *filter : qAsConst(m_filters))
filter->disconnect(this);
m_filters = filters;
- m_ui.filterList->clear();
+ m_filterList->clear();
QStringList names;
for (IFindFilter *filter : filters) {
names << filter->displayName();
@@ -167,7 +239,7 @@ void FindToolWindow::setFindFilters(const QList &filters)
connect(filter, &IFindFilter::displayNameChanged,
this, [this, filter]() { updateFindFilterName(filter); });
}
- m_ui.filterList->addItems(names);
+ m_filterList->addItems(names);
if (m_filters.size() > 0)
setCurrentFilter(0);
}
@@ -181,12 +253,12 @@ void FindToolWindow::updateFindFilterName(IFindFilter *filter)
{
int index = m_filters.indexOf(filter);
if (QTC_GUARD(index >= 0))
- m_ui.filterList->setItemText(index, filter->displayName());
+ m_filterList->setItemText(index, filter->displayName());
}
void FindToolWindow::setFindText(const QString &text)
{
- m_ui.searchTerm->setText(text);
+ m_searchTerm->setText(text);
}
void FindToolWindow::setCurrentFilter(IFindFilter *filter)
@@ -197,13 +269,13 @@ void FindToolWindow::setCurrentFilter(IFindFilter *filter)
if (index >= 0)
setCurrentFilter(index);
updateFindFlags();
- m_ui.searchTerm->setFocus();
- m_ui.searchTerm->selectAll();
+ m_searchTerm->setFocus();
+ m_searchTerm->selectAll();
}
void FindToolWindow::setCurrentFilter(int index)
{
- m_ui.filterList->setCurrentIndex(index);
+ m_filterList->setCurrentIndex(index);
for (int i = 0; i < m_configWidgets.size(); ++i) {
QWidget *configWidget = m_configWidgets.at(i);
if (i == index) {
@@ -221,13 +293,13 @@ void FindToolWindow::setCurrentFilter(int index)
this, &FindToolWindow::updateButtonStates);
updateButtonStates();
if (m_configWidget)
- m_ui.configWidget->layout()->addWidget(m_configWidget);
+ m_uiConfigWidget->layout()->addWidget(m_configWidget);
} else {
if (configWidget)
configWidget->setParent(nullptr);
}
}
- QWidget *w = m_ui.configWidget;
+ QWidget *w = m_uiConfigWidget;
while (w) {
auto sa = qobject_cast(w);
if (sa) {
@@ -236,7 +308,7 @@ void FindToolWindow::setCurrentFilter(int index)
}
w = w->parentWidget();
}
- for (w = m_configWidget ? m_configWidget : m_ui.configWidget; w; w = w->parentWidget()) {
+ for (w = m_configWidget ? m_configWidget : m_uiConfigWidget; w; w = w->parentWidget()) {
if (w->layout())
w->layout()->activate();
}
@@ -246,9 +318,9 @@ void FindToolWindow::acceptAndGetParameters(QString *term, IFindFilter **filter)
{
QTC_ASSERT(filter, return);
*filter = nullptr;
- Find::updateFindCompletion(m_ui.searchTerm->text(), Find::findFlags());
- int index = m_ui.filterList->currentIndex();
- QString searchTerm = m_ui.searchTerm->text();
+ Find::updateFindCompletion(m_searchTerm->text(), Find::findFlags());
+ int index = m_filterList->currentIndex();
+ QString searchTerm = m_searchTerm->text();
if (index >= 0)
*filter = m_filters.at(index);
if (term)
@@ -310,3 +382,5 @@ void FindToolWindow::findCompleterActivated(const QModelIndex &index)
Find::setRegularExpression(findFlags.testFlag(FindRegularExpression));
Find::setPreserveCase(findFlags.testFlag(FindPreserveCase));
}
+
+} // Core::Internal
diff --git a/src/plugins/coreplugin/find/findtoolwindow.h b/src/plugins/coreplugin/find/findtoolwindow.h
index 5340c28e61d..10b48aa76c1 100644
--- a/src/plugins/coreplugin/find/findtoolwindow.h
+++ b/src/plugins/coreplugin/find/findtoolwindow.h
@@ -3,17 +3,21 @@
#pragma once
-#include "ui_finddialog.h"
-#include "findplugin.h"
-
#include
+#include
-QT_FORWARD_DECLARE_CLASS(QCompleter)
+QT_BEGIN_NAMESPACE
+class QCheckBox;
+class QComboBox;
+class QCompleter;
+class QLabel;
+class QPushButton;
+QT_END_NAMESPACE
-namespace Core {
-class IFindFilter;
+namespace Core { class IFindFilter; }
+namespace Utils { class FancyLineEdit; }
-namespace Internal {
+namespace Core::Internal {
class FindToolWindow : public QWidget
{
@@ -47,13 +51,22 @@ private:
void acceptAndGetParameters(QString *term, IFindFilter **filter);
- Ui::FindDialog m_ui;
QList m_filters;
QCompleter *m_findCompleter;
QWidgetList m_configWidgets;
IFindFilter *m_currentFilter;
QWidget *m_configWidget;
+
+ QWidget *m_uiConfigWidget;
+ QPushButton *m_searchButton;
+ QPushButton *m_replaceButton;
+ QLabel *m_searchLabel;
+ QComboBox *m_filterList;
+ QWidget *m_optionsWidget;
+ QCheckBox *m_matchCase;
+ QCheckBox *m_wholeWords;
+ QCheckBox *m_regExp;
+ Utils::FancyLineEdit *m_searchTerm;
};
-} // namespace Internal
-} // namespace Core
+} // Core::Internal