32 #include <QToolButton>
33 #include <QApplication>
51 , Button_ (new QToolButton (edit))
54 const bool isRtl = QApplication::layoutDirection () == Qt::RightToLeft;
55 const auto& icon = proxy->GetIconThemeManager ()->GetIcon (isRtl ?
56 "edit-clear-locationbar-ltr" :
57 "edit-clear-locationbar-rtl");
59 Button_->setIconSize (QSize (16, 16));
60 Button_->setIcon (icon);
61 Button_->setCursor (Qt::ArrowCursor);
62 Button_->setStyleSheet (
"QToolButton { border: none; padding: 0px; }");
70 SIGNAL (textChanged (QString)),
72 SLOT (updateButton (QString)));
74 updateButton (edit->text ());
78 new QShortcut (Qt::Key_Escape, Edit_, SLOT (clear ()),
nullptr, Qt::WidgetShortcut);
81 void ClearLineEditAddon::updateButton (
const QString& text)
83 Button_->setVisible (!text.isEmpty ());
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
ClearLineEditAddon(ICoreProxy_ptr proxy, QLineEdit *edit)
Creates the addon and installs it on the given edit.
Provides a "clear text" action for line edits.