15 #include "ui_findnotification.h" 21 , Ui_ { std::make_unique<Ui::FindNotification> () }
26 setFocusProxy (Ui_->Pattern_);
28 EscShortcut_->setContext (Qt::WidgetWithChildrenShortcut);
30 const auto addon =
new Util::ClearLineEditAddon { proxy, Ui_->Pattern_ };
31 addon->SetEscClearsEdit (
false);
33 const auto coreInstance = proxy->GetPluginsManager ()->GetPluginByID (
"org.LeechCraft.CoreInstance");
34 const auto scProxy = proxy->GetShortcutProxy ();
48 connect (Ui_->Pattern_,
49 &QLineEdit::textChanged,
50 [
this] (
const auto& str) { Ui_->FindButton_->setEnabled (!str.isEmpty ()); });
51 connect (Ui_->FindButton_,
52 &QPushButton::released,
55 auto flags = GetFlags ();
56 if (Ui_->SearchBackwards_->checkState () == Qt::Checked)
57 flags |= FindBackwards;
58 HandleNext (Ui_->Pattern_->text (), flags);
60 connect (Ui_->CloseButton_,
61 &QPushButton::released,
70 EscShortcut_->setEnabled (close);
75 Ui_->Pattern_->setText (text);
80 return Ui_->Pattern_->text ();
85 auto ss = QStringLiteral (
"QLineEdit { background-color: ");
87 ss.append (
"#FF0000");
90 auto color = QApplication::palette ().color (QPalette::Base);
91 color.setRedF (color.redF () / 2);
92 color.setBlueF (color.blueF () / 2);
93 ss.append (color.name ());
96 Ui_->Pattern_->setStyleSheet (ss);
102 if (Ui_->MatchCase_->checkState () == Qt::Checked)
104 if (Ui_->WrapAround_->checkState () == Qt::Checked)
134 Ui_->Pattern_->clear ();
~FindNotification() override
void SetSuccessful(bool successful)
Updates the widget to show whether the search has been successful.
void FindNext()
Search for the next occurrence of the search text.
void FindPrevious()
Search for the previous occurrence of the search text.
virtual void HandleNext(const QString &text, FindFlags flags)=0
Called each time the user requests a search.
void SetText(const QString &text)
Sets the text in the find field.
void SetEscCloses(bool close)
Sets whether Esc closes the widget.
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
FindNotification(const ICoreProxy_ptr &proxy, QWidget *near)
Creates the search widget in parent layout of near.
FindFlags GetFlags() const
Returns the current find flags except the direction.
QString GetText() const
Returns the currently entered text in the find field.
void Clear()
Clears the text in the find field.
A horizontal widget embedding into the parent layout of the passed parent widget. ...
void CreateShortcuts(const QList< QKeySequence > &shortcuts, const std::function< void()> &func, QWidget *parent)
Makes func invokable with shortcuts in seq.