|
|
@@ -2,6 +2,7 @@
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
|
|
#include "findtoolbar.h"
|
|
|
|
#include "findtoolbar.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "ifindfilter.h"
|
|
|
|
#include "ifindfilter.h"
|
|
|
|
#include "findplugin.h"
|
|
|
|
#include "findplugin.h"
|
|
|
|
#include "optionspopup.h"
|
|
|
|
#include "optionspopup.h"
|
|
|
@@ -16,31 +17,40 @@
|
|
|
|
#include <coreplugin/findplaceholder.h>
|
|
|
|
#include <coreplugin/findplaceholder.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
|
|
|
#include <utils/fancylineedit.h>
|
|
|
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
#include <utils/stylehelper.h>
|
|
|
|
#include <utils/stylehelper.h>
|
|
|
|
#include <utils/theme/theme.h>
|
|
|
|
#include <utils/theme/theme.h>
|
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QCompleter>
|
|
|
|
#include <QCompleter>
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
#include <QStringListModel>
|
|
|
|
#include <QStringListModel>
|
|
|
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QStringList)
|
|
|
|
Q_DECLARE_METATYPE(QStringList)
|
|
|
|
Q_DECLARE_METATYPE(Core::IFindFilter*)
|
|
|
|
Q_DECLARE_METATYPE(Core::IFindFilter*)
|
|
|
|
|
|
|
|
|
|
|
|
static const int MINIMUM_WIDTH_FOR_COMPLEX_LAYOUT = 150;
|
|
|
|
using namespace Utils;
|
|
|
|
static const int FINDBUTTON_SPACER_WIDTH = 20;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
namespace Core::Internal {
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
|
|
const int MINIMUM_WIDTH_FOR_COMPLEX_LAYOUT = 150;
|
|
|
|
|
|
|
|
const int FINDBUTTON_SPACER_WIDTH = 20;
|
|
|
|
|
|
|
|
|
|
|
|
FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
: m_currentDocumentFind(currentDocumentFind),
|
|
|
|
: m_currentDocumentFind(currentDocumentFind),
|
|
|
@@ -49,80 +59,176 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
m_findIncrementalTimer(this),
|
|
|
|
m_findIncrementalTimer(this),
|
|
|
|
m_findStepTimer(this)
|
|
|
|
m_findStepTimer(this)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//setup ui
|
|
|
|
setWindowTitle(QCoreApplication::translate("Core::Internal::FindWidget", "Find", nullptr));
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
|
|
|
// compensate for a vertically expanding spacer below the label
|
|
|
|
|
|
|
|
m_ui.replaceLabel->setMinimumHeight(m_ui.replaceEdit->sizeHint().height());
|
|
|
|
|
|
|
|
m_ui.mainLayout->setColumnStretch(1, 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setFocusProxy(m_ui.findEdit);
|
|
|
|
m_findLabel = new QLabel;
|
|
|
|
|
|
|
|
m_findLabel->setText(QCoreApplication::translate("Core::Internal::FindWidget", "Find:", nullptr));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_findEdit = new FancyLineEdit;
|
|
|
|
|
|
|
|
m_findEdit->setMinimumWidth(100);
|
|
|
|
|
|
|
|
m_findEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_findPreviousButton = new QToolButton;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_findNextButton = new QToolButton;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_selectAllButton = new QToolButton;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_horizontalSpacer = new QSpacerItem(40, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_close = new QToolButton;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto findButtonsWidget = new QWidget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_findButtonLayout = new QHBoxLayout(findButtonsWidget);
|
|
|
|
|
|
|
|
m_findButtonLayout->setSpacing(3);
|
|
|
|
|
|
|
|
m_findButtonLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
m_findButtonLayout->addWidget(m_findPreviousButton);
|
|
|
|
|
|
|
|
m_findButtonLayout->addWidget(m_findNextButton);
|
|
|
|
|
|
|
|
m_findButtonLayout->addWidget(m_selectAllButton);
|
|
|
|
|
|
|
|
m_findButtonLayout->addItem(m_horizontalSpacer);
|
|
|
|
|
|
|
|
m_findButtonLayout->addWidget(m_close);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceEdit = new FancyLineEdit(this);
|
|
|
|
|
|
|
|
m_replaceEdit->setMinimumWidth(100);
|
|
|
|
|
|
|
|
m_replaceEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
|
|
|
|
|
|
|
m_replaceEdit->setFiltering(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceLabel = new QLabel;
|
|
|
|
|
|
|
|
m_replaceLabel->setText(QCoreApplication::translate("Core::Internal::FindWidget", "Replace with:"));
|
|
|
|
|
|
|
|
// compensate for a vertically expanding spacer below the label
|
|
|
|
|
|
|
|
m_replaceLabel->setMinimumHeight(m_replaceEdit->sizeHint().height());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceButtonsWidget = new QWidget;
|
|
|
|
|
|
|
|
m_replaceButtonsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceButton = new QToolButton;
|
|
|
|
|
|
|
|
m_replaceButton->setText(QCoreApplication::translate("Core::Internal::FindWidget", "Replace"));
|
|
|
|
|
|
|
|
m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
|
|
|
|
m_replaceButton->setArrowType(Qt::LeftArrow);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceNextButton = new QToolButton;
|
|
|
|
|
|
|
|
m_replaceNextButton->setText(QCoreApplication::translate("Core::Internal::FindWidget", "Replace && Find"));
|
|
|
|
|
|
|
|
m_replaceNextButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
|
|
|
|
m_replaceNextButton->setArrowType(Qt::RightArrow);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceAllButton = new QToolButton;
|
|
|
|
|
|
|
|
m_replaceAllButton->setText(QCoreApplication::translate("Core::Internal::FindWidget", "Replace All"));
|
|
|
|
|
|
|
|
m_replaceAllButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_advancedButton = new QToolButton;
|
|
|
|
|
|
|
|
m_advancedButton->setText(QCoreApplication::translate("Core::Internal::FindWidget", "Advanced..."));
|
|
|
|
|
|
|
|
m_advancedButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_findEdit, m_replaceEdit);
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_replaceEdit, m_findPreviousButton);
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_findPreviousButton, m_findNextButton);
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_findNextButton, m_replaceButton);
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_replaceButton, m_replaceNextButton);
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_replaceNextButton, m_replaceAllButton);
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_replaceAllButton, m_advancedButton);
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_advancedButton, m_close);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto replaceButtonsLayout = new QHBoxLayout(m_replaceButtonsWidget);
|
|
|
|
|
|
|
|
replaceButtonsLayout->setSpacing(3);
|
|
|
|
|
|
|
|
replaceButtonsLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
replaceButtonsLayout->addWidget(m_replaceButton);
|
|
|
|
|
|
|
|
replaceButtonsLayout->addWidget(m_replaceNextButton);
|
|
|
|
|
|
|
|
replaceButtonsLayout->addWidget(m_replaceAllButton);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto verticalLayout_3 = new QVBoxLayout();
|
|
|
|
|
|
|
|
verticalLayout_3->setSpacing(0);
|
|
|
|
|
|
|
|
verticalLayout_3->addWidget(m_advancedButton);
|
|
|
|
|
|
|
|
verticalLayout_3->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto gridLayout = new QGridLayout();
|
|
|
|
|
|
|
|
gridLayout->setHorizontalSpacing(3);
|
|
|
|
|
|
|
|
gridLayout->setVerticalSpacing(0);
|
|
|
|
|
|
|
|
gridLayout->addWidget(m_replaceButtonsWidget, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
gridLayout->addLayout(verticalLayout_3, 0, 1, 1, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
|
|
Grid {
|
|
|
|
|
|
|
|
m_findLabel,
|
|
|
|
|
|
|
|
m_findEdit,
|
|
|
|
|
|
|
|
findButtonsWidget,
|
|
|
|
|
|
|
|
br,
|
|
|
|
|
|
|
|
Column { m_replaceLabel, st }.setSpacing(0),
|
|
|
|
|
|
|
|
Column { m_replaceEdit, st }.setSpacing(0),
|
|
|
|
|
|
|
|
gridLayout,
|
|
|
|
|
|
|
|
}.attachTo(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto mainLayout = static_cast<QGridLayout *>(layout());
|
|
|
|
|
|
|
|
mainLayout->setHorizontalSpacing(3);
|
|
|
|
|
|
|
|
mainLayout->setVerticalSpacing(1);
|
|
|
|
|
|
|
|
mainLayout->setContentsMargins(5, 2, 0, 1);
|
|
|
|
|
|
|
|
mainLayout->setColumnStretch(1, 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setFocusProxy(m_findEdit);
|
|
|
|
setProperty("topBorder", true);
|
|
|
|
setProperty("topBorder", true);
|
|
|
|
setSingleRow(false);
|
|
|
|
setSingleRow(false);
|
|
|
|
m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
|
|
|
|
|
|
|
m_ui.replaceEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
|
|
|
|
|
|
|
m_ui.replaceEdit->setFiltering(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(m_ui.findEdit, &Utils::FancyLineEdit::editingFinished,
|
|
|
|
connect(m_findEdit, &Utils::FancyLineEdit::editingFinished,
|
|
|
|
this, &FindToolBar::invokeResetIncrementalSearch);
|
|
|
|
this, &FindToolBar::invokeResetIncrementalSearch);
|
|
|
|
connect(m_ui.findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
connect(m_findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
this, &FindToolBar::updateFindReplaceEnabled);
|
|
|
|
this, &FindToolBar::updateFindReplaceEnabled);
|
|
|
|
|
|
|
|
|
|
|
|
connect(m_ui.close, &QToolButton::clicked,
|
|
|
|
connect(m_close, &QToolButton::clicked,
|
|
|
|
this, &FindToolBar::hideAndResetFocus);
|
|
|
|
this, &FindToolBar::hideAndResetFocus);
|
|
|
|
|
|
|
|
|
|
|
|
m_findCompleter->setModel(Find::findCompletionModel());
|
|
|
|
m_findCompleter->setModel(Find::findCompletionModel());
|
|
|
|
m_replaceCompleter->setModel(Find::replaceCompletionModel());
|
|
|
|
m_replaceCompleter->setModel(Find::replaceCompletionModel());
|
|
|
|
m_ui.findEdit->setSpecialCompleter(m_findCompleter);
|
|
|
|
m_findEdit->setSpecialCompleter(m_findCompleter);
|
|
|
|
m_ui.replaceEdit->setSpecialCompleter(m_replaceCompleter);
|
|
|
|
m_replaceEdit->setSpecialCompleter(m_replaceCompleter);
|
|
|
|
|
|
|
|
|
|
|
|
m_ui.findEdit->setButtonVisible(Utils::FancyLineEdit::Left, true);
|
|
|
|
m_findEdit->setButtonVisible(Utils::FancyLineEdit::Left, true);
|
|
|
|
m_ui.findEdit->setFiltering(true);
|
|
|
|
m_findEdit->setFiltering(true);
|
|
|
|
m_ui.findEdit->setPlaceholderText(QString());
|
|
|
|
m_findEdit->setPlaceholderText(QString());
|
|
|
|
m_ui.findEdit->button(Utils::FancyLineEdit::Left)->setFocusPolicy(Qt::TabFocus);
|
|
|
|
m_findEdit->button(Utils::FancyLineEdit::Left)->setFocusPolicy(Qt::TabFocus);
|
|
|
|
m_ui.findEdit->setValidationFunction([this](Utils::FancyLineEdit *, QString *) {
|
|
|
|
m_findEdit->setValidationFunction([this](Utils::FancyLineEdit *, QString *) {
|
|
|
|
return m_lastResult != IFindSupport::NotFound;
|
|
|
|
return m_lastResult != IFindSupport::NotFound;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
m_ui.replaceEdit->setPlaceholderText(QString());
|
|
|
|
m_replaceEdit->setPlaceholderText(QString());
|
|
|
|
|
|
|
|
|
|
|
|
connect(m_ui.findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
connect(m_findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
this, &FindToolBar::invokeFindIncremental);
|
|
|
|
this, &FindToolBar::invokeFindIncremental);
|
|
|
|
connect(m_ui.findEdit, &Utils::FancyLineEdit::leftButtonClicked,
|
|
|
|
connect(m_findEdit, &Utils::FancyLineEdit::leftButtonClicked,
|
|
|
|
this, &FindToolBar::findEditButtonClicked);
|
|
|
|
this, &FindToolBar::findEditButtonClicked);
|
|
|
|
|
|
|
|
|
|
|
|
// invoke{Find,Replace}Helper change the completion model. QueuedConnection is used to perform these
|
|
|
|
// invoke{Find,Replace}Helper change the completion model. QueuedConnection is used to perform these
|
|
|
|
// changes only after the completer's activated() signal is handled (QTCREATORBUG-8408)
|
|
|
|
// changes only after the completer's activated() signal is handled (QTCREATORBUG-8408)
|
|
|
|
connect(m_ui.findEdit, &Utils::FancyLineEdit::returnPressed,
|
|
|
|
connect(m_findEdit, &Utils::FancyLineEdit::returnPressed,
|
|
|
|
this, &FindToolBar::invokeFindEnter, Qt::QueuedConnection);
|
|
|
|
this, &FindToolBar::invokeFindEnter, Qt::QueuedConnection);
|
|
|
|
connect(m_ui.replaceEdit, &Utils::FancyLineEdit::returnPressed,
|
|
|
|
connect(m_replaceEdit, &Utils::FancyLineEdit::returnPressed,
|
|
|
|
this, &FindToolBar::invokeReplaceEnter, Qt::QueuedConnection);
|
|
|
|
this, &FindToolBar::invokeReplaceEnter, Qt::QueuedConnection);
|
|
|
|
connect(m_findCompleter, QOverload<const QModelIndex &>::of(&QCompleter::activated),
|
|
|
|
connect(m_findCompleter, QOverload<const QModelIndex &>::of(&QCompleter::activated),
|
|
|
|
this, &FindToolBar::findCompleterActivated);
|
|
|
|
this, &FindToolBar::findCompleterActivated);
|
|
|
|
|
|
|
|
|
|
|
|
auto shiftEnterAction = new QAction(m_ui.findEdit);
|
|
|
|
auto shiftEnterAction = new QAction(m_findEdit);
|
|
|
|
shiftEnterAction->setShortcut(QKeySequence(tr("Shift+Enter")));
|
|
|
|
shiftEnterAction->setShortcut(QKeySequence(tr("Shift+Enter")));
|
|
|
|
shiftEnterAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
shiftEnterAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
connect(shiftEnterAction, &QAction::triggered,
|
|
|
|
connect(shiftEnterAction, &QAction::triggered,
|
|
|
|
this, &FindToolBar::invokeFindPrevious);
|
|
|
|
this, &FindToolBar::invokeFindPrevious);
|
|
|
|
m_ui.findEdit->addAction(shiftEnterAction);
|
|
|
|
m_findEdit->addAction(shiftEnterAction);
|
|
|
|
auto shiftReturnAction = new QAction(m_ui.findEdit);
|
|
|
|
auto shiftReturnAction = new QAction(m_findEdit);
|
|
|
|
shiftReturnAction->setShortcut(QKeySequence(tr("Shift+Return")));
|
|
|
|
shiftReturnAction->setShortcut(QKeySequence(tr("Shift+Return")));
|
|
|
|
shiftReturnAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
shiftReturnAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
connect(shiftReturnAction, &QAction::triggered,
|
|
|
|
connect(shiftReturnAction, &QAction::triggered,
|
|
|
|
this, &FindToolBar::invokeFindPrevious);
|
|
|
|
this, &FindToolBar::invokeFindPrevious);
|
|
|
|
m_ui.findEdit->addAction(shiftReturnAction);
|
|
|
|
m_findEdit->addAction(shiftReturnAction);
|
|
|
|
|
|
|
|
|
|
|
|
auto shiftEnterReplaceAction = new QAction(m_ui.replaceEdit);
|
|
|
|
auto shiftEnterReplaceAction = new QAction(m_replaceEdit);
|
|
|
|
shiftEnterReplaceAction->setShortcut(QKeySequence(tr("Shift+Enter")));
|
|
|
|
shiftEnterReplaceAction->setShortcut(QKeySequence(tr("Shift+Enter")));
|
|
|
|
shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
connect(shiftEnterReplaceAction, &QAction::triggered,
|
|
|
|
connect(shiftEnterReplaceAction, &QAction::triggered,
|
|
|
|
this, &FindToolBar::invokeReplacePrevious);
|
|
|
|
this, &FindToolBar::invokeReplacePrevious);
|
|
|
|
m_ui.replaceEdit->addAction(shiftEnterReplaceAction);
|
|
|
|
m_replaceEdit->addAction(shiftEnterReplaceAction);
|
|
|
|
auto shiftReturnReplaceAction = new QAction(m_ui.replaceEdit);
|
|
|
|
auto shiftReturnReplaceAction = new QAction(m_replaceEdit);
|
|
|
|
shiftReturnReplaceAction->setShortcut(QKeySequence(tr("Shift+Return")));
|
|
|
|
shiftReturnReplaceAction->setShortcut(QKeySequence(tr("Shift+Return")));
|
|
|
|
shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut);
|
|
|
|
connect(shiftReturnReplaceAction, &QAction::triggered,
|
|
|
|
connect(shiftReturnReplaceAction, &QAction::triggered,
|
|
|
|
this, &FindToolBar::invokeReplacePrevious);
|
|
|
|
this, &FindToolBar::invokeReplacePrevious);
|
|
|
|
m_ui.replaceEdit->addAction(shiftReturnReplaceAction);
|
|
|
|
m_replaceEdit->addAction(shiftReturnReplaceAction);
|
|
|
|
|
|
|
|
|
|
|
|
// need to make sure QStringList is registered as metatype
|
|
|
|
// need to make sure QStringList is registered as metatype
|
|
|
|
QMetaTypeId<QStringList>::qt_metatype_id();
|
|
|
|
QMetaTypeId<QStringList>::qt_metatype_id();
|
|
|
@@ -137,9 +243,9 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
Command *advancedCmd = ActionManager::command(Constants::ADVANCED_FIND);
|
|
|
|
Command *advancedCmd = ActionManager::command(Constants::ADVANCED_FIND);
|
|
|
|
if (advancedCmd)
|
|
|
|
if (advancedCmd)
|
|
|
|
advancedCmd->augmentActionWithShortcutToolTip(advancedAction);
|
|
|
|
advancedCmd->augmentActionWithShortcutToolTip(advancedAction);
|
|
|
|
m_ui.advancedButton->setDefaultAction(advancedAction);
|
|
|
|
m_advancedButton->setDefaultAction(advancedAction);
|
|
|
|
connect(advancedAction, &QAction::triggered, this, [this] {
|
|
|
|
connect(advancedAction, &QAction::triggered, this, [this] {
|
|
|
|
Find::openFindDialog(nullptr, m_ui.findEdit->text());
|
|
|
|
Find::openFindDialog(nullptr, m_findEdit->text());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
m_goToCurrentFindAction = new QAction(this);
|
|
|
|
m_goToCurrentFindAction = new QAction(this);
|
|
|
@@ -182,7 +288,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
cmd = ActionManager::registerAction(m_localFindNextAction, Constants::FIND_NEXT, findcontext);
|
|
|
|
cmd = ActionManager::registerAction(m_localFindNextAction, Constants::FIND_NEXT, findcontext);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localFindNextAction);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localFindNextAction);
|
|
|
|
connect(m_localFindNextAction, &QAction::triggered, this, &FindToolBar::invokeFindNext);
|
|
|
|
connect(m_localFindNextAction, &QAction::triggered, this, &FindToolBar::invokeFindNext);
|
|
|
|
m_ui.findNextButton->setDefaultAction(m_localFindNextAction);
|
|
|
|
m_findNextButton->setDefaultAction(m_localFindNextAction);
|
|
|
|
|
|
|
|
|
|
|
|
m_findPreviousAction = new QAction(tr("Find Previous"), this);
|
|
|
|
m_findPreviousAction = new QAction(tr("Find Previous"), this);
|
|
|
|
cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS);
|
|
|
|
cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS);
|
|
|
@@ -193,7 +299,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
cmd = ActionManager::registerAction(m_localFindPreviousAction, Constants::FIND_PREVIOUS, findcontext);
|
|
|
|
cmd = ActionManager::registerAction(m_localFindPreviousAction, Constants::FIND_PREVIOUS, findcontext);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localFindPreviousAction);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localFindPreviousAction);
|
|
|
|
connect(m_localFindPreviousAction, &QAction::triggered, this, &FindToolBar::invokeFindPrevious);
|
|
|
|
connect(m_localFindPreviousAction, &QAction::triggered, this, &FindToolBar::invokeFindPrevious);
|
|
|
|
m_ui.findPreviousButton->setDefaultAction(m_localFindPreviousAction);
|
|
|
|
m_findPreviousButton->setDefaultAction(m_localFindPreviousAction);
|
|
|
|
|
|
|
|
|
|
|
|
m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this);
|
|
|
|
m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this);
|
|
|
|
cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED);
|
|
|
|
cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED);
|
|
|
@@ -217,7 +323,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
cmd = ActionManager::registerAction(m_localSelectAllAction, Constants::FIND_SELECT_ALL, findcontext);
|
|
|
|
cmd = ActionManager::registerAction(m_localSelectAllAction, Constants::FIND_SELECT_ALL, findcontext);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localSelectAllAction);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localSelectAllAction);
|
|
|
|
connect(m_localSelectAllAction, &QAction::triggered, this, &FindToolBar::selectAll);
|
|
|
|
connect(m_localSelectAllAction, &QAction::triggered, this, &FindToolBar::selectAll);
|
|
|
|
m_ui.selectAllButton->setDefaultAction(m_localSelectAllAction);
|
|
|
|
m_selectAllButton->setDefaultAction(m_localSelectAllAction);
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceAction = new QAction(tr("Replace"), this);
|
|
|
|
m_replaceAction = new QAction(tr("Replace"), this);
|
|
|
|
cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE);
|
|
|
|
cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE);
|
|
|
@@ -228,7 +334,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
cmd = ActionManager::registerAction(m_localReplaceAction, Constants::REPLACE, findcontext);
|
|
|
|
cmd = ActionManager::registerAction(m_localReplaceAction, Constants::REPLACE, findcontext);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localReplaceAction);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localReplaceAction);
|
|
|
|
connect(m_localReplaceAction, &QAction::triggered, this, &FindToolBar::invokeReplace);
|
|
|
|
connect(m_localReplaceAction, &QAction::triggered, this, &FindToolBar::invokeReplace);
|
|
|
|
m_ui.replaceButton->setDefaultAction(m_localReplaceAction);
|
|
|
|
m_replaceButton->setDefaultAction(m_localReplaceAction);
|
|
|
|
|
|
|
|
|
|
|
|
m_replaceNextAction = new QAction(tr("Replace && Find"), this);
|
|
|
|
m_replaceNextAction = new QAction(tr("Replace && Find"), this);
|
|
|
|
cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT);
|
|
|
|
cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT);
|
|
|
@@ -240,7 +346,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
cmd = ActionManager::registerAction(m_localReplaceNextAction, Constants::REPLACE_NEXT, findcontext);
|
|
|
|
cmd = ActionManager::registerAction(m_localReplaceNextAction, Constants::REPLACE_NEXT, findcontext);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localReplaceNextAction);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localReplaceNextAction);
|
|
|
|
connect(m_localReplaceNextAction, &QAction::triggered, this, &FindToolBar::invokeReplaceNext);
|
|
|
|
connect(m_localReplaceNextAction, &QAction::triggered, this, &FindToolBar::invokeReplaceNext);
|
|
|
|
m_ui.replaceNextButton->setDefaultAction(m_localReplaceNextAction);
|
|
|
|
m_replaceNextButton->setDefaultAction(m_localReplaceNextAction);
|
|
|
|
|
|
|
|
|
|
|
|
m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this);
|
|
|
|
m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this);
|
|
|
|
cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS);
|
|
|
|
cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS);
|
|
|
@@ -261,7 +367,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|
|
|
cmd = ActionManager::registerAction(m_localReplaceAllAction, Constants::REPLACE_ALL, findcontext);
|
|
|
|
cmd = ActionManager::registerAction(m_localReplaceAllAction, Constants::REPLACE_ALL, findcontext);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localReplaceAllAction);
|
|
|
|
cmd->augmentActionWithShortcutToolTip(m_localReplaceAllAction);
|
|
|
|
connect(m_localReplaceAllAction, &QAction::triggered, this, &FindToolBar::invokeReplaceAll);
|
|
|
|
connect(m_localReplaceAllAction, &QAction::triggered, this, &FindToolBar::invokeReplaceAll);
|
|
|
|
m_ui.replaceAllButton->setDefaultAction(m_localReplaceAllAction);
|
|
|
|
m_replaceAllButton->setDefaultAction(m_localReplaceAllAction);
|
|
|
|
|
|
|
|
|
|
|
|
m_caseSensitiveAction = new QAction(tr("Case Sensitive"), this);
|
|
|
|
m_caseSensitiveAction = new QAction(tr("Case Sensitive"), this);
|
|
|
|
m_caseSensitiveAction->setIcon(Icons::FIND_CASE_INSENSITIVELY.icon());
|
|
|
|
m_caseSensitiveAction->setIcon(Icons::FIND_CASE_INSENSITIVELY.icon());
|
|
|
@@ -328,8 +434,8 @@ void FindToolBar::installEventFilters()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!m_eventFiltersInstalled) {
|
|
|
|
if (!m_eventFiltersInstalled) {
|
|
|
|
m_findCompleter->popup()->installEventFilter(this);
|
|
|
|
m_findCompleter->popup()->installEventFilter(this);
|
|
|
|
m_ui.findEdit->installEventFilter(this);
|
|
|
|
m_findEdit->installEventFilter(this);
|
|
|
|
m_ui.replaceEdit->installEventFilter(this);
|
|
|
|
m_replaceEdit->installEventFilter(this);
|
|
|
|
this->installEventFilter(this);
|
|
|
|
this->installEventFilter(this);
|
|
|
|
m_eventFiltersInstalled = true;
|
|
|
|
m_eventFiltersInstalled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -340,19 +446,19 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
if (event->type() == QEvent::KeyPress) {
|
|
|
|
if (event->type() == QEvent::KeyPress) {
|
|
|
|
auto ke = static_cast<QKeyEvent *>(event);
|
|
|
|
auto ke = static_cast<QKeyEvent *>(event);
|
|
|
|
if (ke->key() == Qt::Key_Down) {
|
|
|
|
if (ke->key() == Qt::Key_Down) {
|
|
|
|
if (obj == m_ui.findEdit) {
|
|
|
|
if (obj == m_findEdit) {
|
|
|
|
if (m_ui.findEdit->text().isEmpty())
|
|
|
|
if (m_findEdit->text().isEmpty())
|
|
|
|
m_findCompleter->setCompletionPrefix(QString());
|
|
|
|
m_findCompleter->setCompletionPrefix(QString());
|
|
|
|
m_findCompleter->complete();
|
|
|
|
m_findCompleter->complete();
|
|
|
|
} else if (obj == m_ui.replaceEdit) {
|
|
|
|
} else if (obj == m_replaceEdit) {
|
|
|
|
if (m_ui.replaceEdit->text().isEmpty())
|
|
|
|
if (m_replaceEdit->text().isEmpty())
|
|
|
|
m_replaceCompleter->setCompletionPrefix(QString());
|
|
|
|
m_replaceCompleter->setCompletionPrefix(QString());
|
|
|
|
m_replaceCompleter->complete();
|
|
|
|
m_replaceCompleter->complete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((obj == m_ui.findEdit || obj == m_findCompleter->popup())
|
|
|
|
if ((obj == m_findEdit || obj == m_findCompleter->popup())
|
|
|
|
&& event->type() == QEvent::KeyPress) {
|
|
|
|
&& event->type() == QEvent::KeyPress) {
|
|
|
|
auto ke = static_cast<QKeyEvent *>(event);
|
|
|
|
auto ke = static_cast<QKeyEvent *>(event);
|
|
|
|
if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) {
|
|
|
|
if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) {
|
|
|
@@ -413,34 +519,34 @@ void FindToolBar::updateToolBar()
|
|
|
|
m_wholeWordAction->setEnabled(enabled);
|
|
|
|
m_wholeWordAction->setEnabled(enabled);
|
|
|
|
m_regularExpressionAction->setEnabled(enabled);
|
|
|
|
m_regularExpressionAction->setEnabled(enabled);
|
|
|
|
m_preserveCaseAction->setEnabled(replaceEnabled && !hasFindFlag(FindRegularExpression));
|
|
|
|
m_preserveCaseAction->setEnabled(replaceEnabled && !hasFindFlag(FindRegularExpression));
|
|
|
|
bool replaceFocus = m_ui.replaceEdit->hasFocus();
|
|
|
|
bool replaceFocus = m_replaceEdit->hasFocus();
|
|
|
|
|
|
|
|
|
|
|
|
m_ui.findLabel->setEnabled(enabled);
|
|
|
|
m_findLabel->setEnabled(enabled);
|
|
|
|
m_ui.findLabel->setVisible(showAllControls);
|
|
|
|
m_findLabel->setVisible(showAllControls);
|
|
|
|
m_ui.findEdit->setEnabled(enabled);
|
|
|
|
m_findEdit->setEnabled(enabled);
|
|
|
|
m_ui.findEdit->setPlaceholderText(showAllControls ? QString() : tr("Search for..."));
|
|
|
|
m_findEdit->setPlaceholderText(showAllControls ? QString() : tr("Search for..."));
|
|
|
|
m_ui.findPreviousButton->setEnabled(enabled);
|
|
|
|
m_findPreviousButton->setEnabled(enabled);
|
|
|
|
m_ui.findPreviousButton->setVisible(showAllControls);
|
|
|
|
m_findPreviousButton->setVisible(showAllControls);
|
|
|
|
m_ui.findNextButton->setEnabled(enabled);
|
|
|
|
m_findNextButton->setEnabled(enabled);
|
|
|
|
m_ui.findNextButton->setVisible(showAllControls);
|
|
|
|
m_findNextButton->setVisible(showAllControls);
|
|
|
|
m_ui.selectAllButton->setVisible(style == ControlStyle::Text
|
|
|
|
m_selectAllButton->setVisible(style == ControlStyle::Text
|
|
|
|
&& m_currentDocumentFind->supportsSelectAll());
|
|
|
|
&& m_currentDocumentFind->supportsSelectAll());
|
|
|
|
m_ui.horizontalSpacer->changeSize((showAllControls ? FINDBUTTON_SPACER_WIDTH : 0), 0,
|
|
|
|
m_horizontalSpacer->changeSize((showAllControls ? FINDBUTTON_SPACER_WIDTH : 0), 0,
|
|
|
|
QSizePolicy::Expanding, QSizePolicy::Ignored);
|
|
|
|
QSizePolicy::Expanding, QSizePolicy::Ignored);
|
|
|
|
m_ui.findButtonLayout->invalidate(); // apply spacer change
|
|
|
|
m_findButtonLayout->invalidate(); // apply spacer change
|
|
|
|
|
|
|
|
|
|
|
|
m_ui.replaceLabel->setEnabled(replaceEnabled);
|
|
|
|
m_replaceLabel->setEnabled(replaceEnabled);
|
|
|
|
m_ui.replaceLabel->setVisible(replaceEnabled && showAllControls);
|
|
|
|
m_replaceLabel->setVisible(replaceEnabled && showAllControls);
|
|
|
|
m_ui.replaceEdit->setEnabled(replaceEnabled);
|
|
|
|
m_replaceEdit->setEnabled(replaceEnabled);
|
|
|
|
m_ui.replaceEdit->setPlaceholderText(showAllControls ? QString() : tr("Replace with..."));
|
|
|
|
m_replaceEdit->setPlaceholderText(showAllControls ? QString() : tr("Replace with..."));
|
|
|
|
m_ui.replaceEdit->setVisible(replaceEnabled);
|
|
|
|
m_replaceEdit->setVisible(replaceEnabled);
|
|
|
|
m_ui.replaceButtonsWidget->setVisible(replaceEnabled && showAllControls);
|
|
|
|
m_replaceButtonsWidget->setVisible(replaceEnabled && showAllControls);
|
|
|
|
m_ui.advancedButton->setVisible(replaceEnabled && showAllControls);
|
|
|
|
m_advancedButton->setVisible(replaceEnabled && showAllControls);
|
|
|
|
|
|
|
|
|
|
|
|
layout()->invalidate();
|
|
|
|
layout()->invalidate();
|
|
|
|
|
|
|
|
|
|
|
|
if (!replaceEnabled && enabled && replaceFocus)
|
|
|
|
if (!replaceEnabled && enabled && replaceFocus)
|
|
|
|
m_ui.findEdit->setFocus();
|
|
|
|
m_findEdit->setFocus();
|
|
|
|
updateIcons();
|
|
|
|
updateIcons();
|
|
|
|
updateFlagMenus();
|
|
|
|
updateFlagMenus();
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -502,29 +608,29 @@ void FindToolBar::invokeGlobalFindPrevious()
|
|
|
|
|
|
|
|
|
|
|
|
QString FindToolBar::getFindText()
|
|
|
|
QString FindToolBar::getFindText()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return m_ui.findEdit->text();
|
|
|
|
return m_findEdit->text();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString FindToolBar::getReplaceText()
|
|
|
|
QString FindToolBar::getReplaceText()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return m_ui.replaceEdit->text();
|
|
|
|
return m_replaceEdit->text();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FindToolBar::setFindText(const QString &text)
|
|
|
|
void FindToolBar::setFindText(const QString &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
disconnect(m_ui.findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
disconnect(m_findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
this, &FindToolBar::invokeFindIncremental);
|
|
|
|
this, &FindToolBar::invokeFindIncremental);
|
|
|
|
if (hasFindFlag(FindRegularExpression))
|
|
|
|
if (hasFindFlag(FindRegularExpression))
|
|
|
|
m_ui.findEdit->setText(QRegularExpression::escape(text));
|
|
|
|
m_findEdit->setText(QRegularExpression::escape(text));
|
|
|
|
else
|
|
|
|
else
|
|
|
|
m_ui.findEdit->setText(text);
|
|
|
|
m_findEdit->setText(text);
|
|
|
|
connect(m_ui.findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
connect(m_findEdit, &Utils::FancyLineEdit::textChanged,
|
|
|
|
this, &FindToolBar::invokeFindIncremental);
|
|
|
|
this, &FindToolBar::invokeFindIncremental);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FindToolBar::selectFindText()
|
|
|
|
void FindToolBar::selectFindText()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_ui.findEdit->selectAll();
|
|
|
|
m_findEdit->selectAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FindToolBar::invokeFindStep()
|
|
|
|
void FindToolBar::invokeFindStep()
|
|
|
@@ -644,7 +750,7 @@ void FindToolBar::putSelectionToFindClipboard()
|
|
|
|
void FindToolBar::updateFromFindClipboard()
|
|
|
|
void FindToolBar::updateFromFindClipboard()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (QApplication::clipboard()->supportsFindBuffer()) {
|
|
|
|
if (QApplication::clipboard()->supportsFindBuffer()) {
|
|
|
|
QSignalBlocker blocker(m_ui.findEdit);
|
|
|
|
QSignalBlocker blocker(m_findEdit);
|
|
|
|
setFindText(QApplication::clipboard()->text(QClipboard::FindBuffer));
|
|
|
|
setFindText(QApplication::clipboard()->text(QClipboard::FindBuffer));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -660,7 +766,7 @@ void FindToolBar::findFlagsChanged()
|
|
|
|
|
|
|
|
|
|
|
|
void FindToolBar::findEditButtonClicked()
|
|
|
|
void FindToolBar::findEditButtonClicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto popup = new OptionsPopup(m_ui.findEdit, {Constants::CASE_SENSITIVE, Constants::WHOLE_WORDS,
|
|
|
|
auto popup = new OptionsPopup(m_findEdit, {Constants::CASE_SENSITIVE, Constants::WHOLE_WORDS,
|
|
|
|
Constants::REGULAR_EXPRESSIONS, Constants::PRESERVE_CASE});
|
|
|
|
Constants::REGULAR_EXPRESSIONS, Constants::PRESERVE_CASE});
|
|
|
|
popup->show();
|
|
|
|
popup->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -674,9 +780,9 @@ void FindToolBar::updateIcons()
|
|
|
|
bool preserveCase = effectiveFlags & FindPreserveCase;
|
|
|
|
bool preserveCase = effectiveFlags & FindPreserveCase;
|
|
|
|
if (!casesensitive && !wholewords && !regexp && !preserveCase) {
|
|
|
|
if (!casesensitive && !wholewords && !regexp && !preserveCase) {
|
|
|
|
const QIcon icon = Utils::Icons::MAGNIFIER.icon();
|
|
|
|
const QIcon icon = Utils::Icons::MAGNIFIER.icon();
|
|
|
|
m_ui.findEdit->setButtonIcon(Utils::FancyLineEdit::Left, icon);
|
|
|
|
m_findEdit->setButtonIcon(Utils::FancyLineEdit::Left, icon);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
m_ui.findEdit->setButtonIcon(Utils::FancyLineEdit::Left,
|
|
|
|
m_findEdit->setButtonIcon(Utils::FancyLineEdit::Left,
|
|
|
|
IFindFilter::pixmapForFindFlags(effectiveFlags));
|
|
|
|
IFindFilter::pixmapForFindFlags(effectiveFlags));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -754,27 +860,27 @@ bool FindToolBar::toolBarHasFocus() const
|
|
|
|
|
|
|
|
|
|
|
|
FindToolBar::ControlStyle FindToolBar::controlStyle(bool replaceIsVisible)
|
|
|
|
FindToolBar::ControlStyle FindToolBar::controlStyle(bool replaceIsVisible)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const Qt::ToolButtonStyle currentFindButtonStyle = m_ui.findNextButton->toolButtonStyle();
|
|
|
|
const Qt::ToolButtonStyle currentFindButtonStyle = m_findNextButton->toolButtonStyle();
|
|
|
|
const int fullWidth = width();
|
|
|
|
const int fullWidth = width();
|
|
|
|
|
|
|
|
|
|
|
|
if (replaceIsVisible) {
|
|
|
|
if (replaceIsVisible) {
|
|
|
|
// Since the replace buttons do not collapse to icons, they have precedence, here.
|
|
|
|
// Since the replace buttons do not collapse to icons, they have precedence, here.
|
|
|
|
const int replaceFixedWidth = m_ui.replaceLabel->sizeHint().width()
|
|
|
|
const int replaceFixedWidth = m_replaceLabel->sizeHint().width()
|
|
|
|
+ m_ui.replaceButton->sizeHint().width()
|
|
|
|
+ m_replaceButton->sizeHint().width()
|
|
|
|
+ m_ui.replaceNextButton->sizeHint().width()
|
|
|
|
+ m_replaceNextButton->sizeHint().width()
|
|
|
|
+ m_ui.replaceAllButton->sizeHint().width()
|
|
|
|
+ m_replaceAllButton->sizeHint().width()
|
|
|
|
+ m_ui.advancedButton->sizeHint().width();
|
|
|
|
+ m_advancedButton->sizeHint().width();
|
|
|
|
return fullWidth - replaceFixedWidth >= MINIMUM_WIDTH_FOR_COMPLEX_LAYOUT ?
|
|
|
|
return fullWidth - replaceFixedWidth >= MINIMUM_WIDTH_FOR_COMPLEX_LAYOUT ?
|
|
|
|
ControlStyle::Text : ControlStyle::Hidden;
|
|
|
|
ControlStyle::Text : ControlStyle::Hidden;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto findWidth = [this] {
|
|
|
|
const auto findWidth = [this] {
|
|
|
|
const int selectAllWidth = m_currentDocumentFind->supportsSelectAll() ?
|
|
|
|
const int selectAllWidth = m_currentDocumentFind->supportsSelectAll() ?
|
|
|
|
m_ui.selectAllButton->sizeHint().width() : 0;
|
|
|
|
m_selectAllButton->sizeHint().width() : 0;
|
|
|
|
return m_ui.findLabel->sizeHint().width() + m_ui.findNextButton->sizeHint().width()
|
|
|
|
return m_findLabel->sizeHint().width() + m_findNextButton->sizeHint().width()
|
|
|
|
+ m_ui.findPreviousButton->sizeHint().width()
|
|
|
|
+ m_findPreviousButton->sizeHint().width()
|
|
|
|
+ selectAllWidth + FINDBUTTON_SPACER_WIDTH
|
|
|
|
+ selectAllWidth + FINDBUTTON_SPACER_WIDTH
|
|
|
|
+ m_ui.close->sizeHint().width();
|
|
|
|
+ m_close->sizeHint().width();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
setFindButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
setFindButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
const int findWithTextWidth = findWidth();
|
|
|
|
const int findWithTextWidth = findWidth();
|
|
|
@@ -791,8 +897,8 @@ FindToolBar::ControlStyle FindToolBar::controlStyle(bool replaceIsVisible)
|
|
|
|
|
|
|
|
|
|
|
|
void FindToolBar::setFindButtonStyle(Qt::ToolButtonStyle style)
|
|
|
|
void FindToolBar::setFindButtonStyle(Qt::ToolButtonStyle style)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_ui.findPreviousButton->setToolButtonStyle(style);
|
|
|
|
m_findPreviousButton->setToolButtonStyle(style);
|
|
|
|
m_ui.findNextButton->setToolButtonStyle(style);
|
|
|
|
m_findNextButton->setToolButtonStyle(style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
@@ -819,7 +925,7 @@ void FindToolBar::acceptCandidateAndMoveToolBar()
|
|
|
|
void FindToolBar::indicateSearchState(IFindSupport::Result searchState)
|
|
|
|
void FindToolBar::indicateSearchState(IFindSupport::Result searchState)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_lastResult = searchState;
|
|
|
|
m_lastResult = searchState;
|
|
|
|
m_ui.findEdit->validate();
|
|
|
|
m_findEdit->validate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FindToolBar::openFind(bool focus)
|
|
|
|
void FindToolBar::openFind(bool focus)
|
|
|
@@ -888,15 +994,15 @@ void FindToolBar::selectAll()
|
|
|
|
|
|
|
|
|
|
|
|
bool FindToolBar::focusNextPrevChild(bool next)
|
|
|
|
bool FindToolBar::focusNextPrevChild(bool next)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QAbstractButton *optionsButton = m_ui.findEdit->button(Utils::FancyLineEdit::Left);
|
|
|
|
QAbstractButton *optionsButton = m_findEdit->button(Utils::FancyLineEdit::Left);
|
|
|
|
// close tab order
|
|
|
|
// close tab order
|
|
|
|
if (next && m_ui.advancedButton->hasFocus())
|
|
|
|
if (next && m_advancedButton->hasFocus())
|
|
|
|
optionsButton->setFocus(Qt::TabFocusReason);
|
|
|
|
optionsButton->setFocus(Qt::TabFocusReason);
|
|
|
|
else if (next && optionsButton->hasFocus())
|
|
|
|
else if (next && optionsButton->hasFocus())
|
|
|
|
m_ui.findEdit->setFocus(Qt::TabFocusReason);
|
|
|
|
m_findEdit->setFocus(Qt::TabFocusReason);
|
|
|
|
else if (!next && optionsButton->hasFocus())
|
|
|
|
else if (!next && optionsButton->hasFocus())
|
|
|
|
m_ui.advancedButton->setFocus(Qt::TabFocusReason);
|
|
|
|
m_advancedButton->setFocus(Qt::TabFocusReason);
|
|
|
|
else if (!next && m_ui.findEdit->hasFocus())
|
|
|
|
else if (!next && m_findEdit->hasFocus())
|
|
|
|
optionsButton->setFocus(Qt::TabFocusReason);
|
|
|
|
optionsButton->setFocus(Qt::TabFocusReason);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return Utils::StyledBar::focusNextPrevChild(next);
|
|
|
|
return Utils::StyledBar::focusNextPrevChild(next);
|
|
|
@@ -1005,7 +1111,7 @@ void FindToolBar::setLightColoredIcon(bool lightColored)
|
|
|
|
: Utils::Icons::NEXT_TOOLBAR.icon());
|
|
|
|
: Utils::Icons::NEXT_TOOLBAR.icon());
|
|
|
|
m_localFindPreviousAction->setIcon(lightColored ? Utils::Icons::PREV.icon()
|
|
|
|
m_localFindPreviousAction->setIcon(lightColored ? Utils::Icons::PREV.icon()
|
|
|
|
: Utils::Icons::PREV_TOOLBAR.icon());
|
|
|
|
: Utils::Icons::PREV_TOOLBAR.icon());
|
|
|
|
m_ui.close->setIcon(lightColored ? Utils::Icons::CLOSE_FOREGROUND.icon()
|
|
|
|
m_close->setIcon(lightColored ? Utils::Icons::CLOSE_FOREGROUND.icon()
|
|
|
|
: Utils::Icons::CLOSE_TOOLBAR.icon());
|
|
|
|
: Utils::Icons::CLOSE_TOOLBAR.icon());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1040,5 +1146,4 @@ void FindToolBar::updateReplaceEnabled()
|
|
|
|
m_replacePreviousAction->setEnabled(globalsEnabled);
|
|
|
|
m_replacePreviousAction->setEnabled(globalsEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
} // Core::Internal
|
|
|
|
} // namespace Core
|
|
|
|
|
|
|
|