36 #include "ui_findnotification.h"
43 : Util::PageNotification { parent }
44 , Ui_ {
new Ui::FindNotification }
45 , EscShortcut_ {
new QShortcut { Qt::Key_Escape,
this, SLOT (reject ()) } }
49 setFocusProxy (Ui_->Pattern_);
51 EscShortcut_->setContext (Qt::WidgetWithChildrenShortcut);
53 const auto addon =
new Util::ClearLineEditAddon { proxy, Ui_->Pattern_ };
54 addon->SetEscClearsEdit (
false);
56 const auto coreInstance = proxy->GetPluginsManager ()->
57 GetPluginByID (
"org.LeechCraft.CoreInstance");
58 const auto scProxy = proxy->GetShortcutProxy ();
68 this, SLOT (findNext ()), parent);
70 this, SLOT (findPrevious ()), parent);
73 FindNotification::~FindNotification ()
78 void FindNotification::SetEscCloses (
bool close)
80 EscShortcut_->setEnabled (close);
83 void FindNotification::SetText (
const QString& text)
85 Ui_->Pattern_->setText (text);
88 QString FindNotification::GetText ()
const
90 return Ui_->Pattern_->text ();
93 void FindNotification::SetSuccessful (
bool success)
95 auto ss = QString {
"QLineEdit {"
96 "background-color:rgb(" };
98 ss.append (
"255,0,0");
101 auto color = QApplication::palette ().color (QPalette::Base);
102 color.setRedF (color.redF () / 2);
103 color.setBlueF (color.blueF () / 2);
105 int r = 0, g = 0, b = 0;
106 color.getRgb (&r, &g, &b);
108 ss.append (QString (
"%1,%2,%3")
114 Ui_->Pattern_->setStyleSheet (ss);
117 auto FindNotification::GetFlags () const -> FindFlags
120 if (Ui_->MatchCase_->checkState () == Qt::Checked)
121 flags |= FindCaseSensitively;
122 if (Ui_->WrapAround_->checkState () == Qt::Checked)
123 flags |= FindWrapsAround;
127 void FindNotification::findNext ()
129 const auto& text = GetText ();
133 handleNext (text, GetFlags ());
136 void FindNotification::findPrevious ()
138 const auto& text = GetText ();
142 handleNext (text, GetFlags () | FindBackwards);
145 void FindNotification::clear ()
150 void FindNotification::reject ()
152 Ui_->Pattern_->clear ();
156 void FindNotification::on_Pattern__textChanged (
const QString& newText)
158 Ui_->FindButton_->setEnabled (!newText.isEmpty ());
161 void FindNotification::on_FindButton__released ()
163 auto flags = GetFlags ();
164 if (Ui_->SearchBackwards_->checkState () == Qt::Checked)
165 flags |= FindBackwards;
167 handleNext (Ui_->Pattern_->text (), flags);