mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
FancyLineEdit: use QLineEdit's own clear button with Qt >= 5.2
This commit is contained in:
parent
2e79e8e884
commit
55da675efa
@ -15,6 +15,10 @@
|
||||
|
||||
#include "FancyLineEdit.h"
|
||||
|
||||
#if QT_VERSION < 0x050200
|
||||
#include "GuiApplication.h"
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
|
||||
#include <QEvent>
|
||||
@ -135,6 +139,20 @@ void FancyLineEdit::checkButtons(const QString &text)
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setClearButton(bool visible)
|
||||
{
|
||||
// QLineEdit::setClearButtonEnabled() has been implemented in Qt 5.2.
|
||||
// In earlier Qt versions, we roll our own button
|
||||
#if QT_VERSION < 0x050200
|
||||
setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
|
||||
setButtonVisible(FancyLineEdit::Right, visible);
|
||||
setAutoHideButton(FancyLineEdit::Right, true);
|
||||
#else
|
||||
setClearButtonEnabled(visible);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setButtonVisible(Side side, bool visible)
|
||||
{
|
||||
m_d->m_iconbutton[side]->setVisible(visible);
|
||||
|
@ -71,6 +71,9 @@ public:
|
||||
explicit FancyLineEdit(QWidget *parent = 0);
|
||||
~FancyLineEdit() {}
|
||||
|
||||
/// Set a button to clear contents
|
||||
void setClearButton(bool visible);
|
||||
|
||||
QPixmap buttonPixmap(Side side) const;
|
||||
void setButtonPixmap(Side side, const QPixmap &pixmap);
|
||||
|
||||
|
@ -64,10 +64,7 @@ GuiBibtex::GuiBibtex(GuiView & lv)
|
||||
|
||||
// The filter bar
|
||||
filter_ = new FancyLineEdit(this);
|
||||
filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
|
||||
filter_->setButtonVisible(FancyLineEdit::Right, true);
|
||||
filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
|
||||
filter_->setAutoHideButton(FancyLineEdit::Right, true);
|
||||
filter_->setClearButton(true);
|
||||
filter_->setPlaceholderText(qt_("All avail. databases"));
|
||||
|
||||
filterBarL->addWidget(filter_, 0);
|
||||
|
@ -98,10 +98,7 @@ GuiCitation::GuiCitation(GuiView & lv)
|
||||
|
||||
// The filter bar
|
||||
filter_ = new FancyLineEdit(this);
|
||||
filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
|
||||
filter_->setButtonVisible(FancyLineEdit::Right, true);
|
||||
filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
|
||||
filter_->setAutoHideButton(FancyLineEdit::Right, true);
|
||||
filter_->setClearButton(true);
|
||||
filter_->setPlaceholderText(qt_("All avail. citations"));
|
||||
|
||||
filterBarL->addWidget(filter_, 0);
|
||||
|
@ -1656,10 +1656,7 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
this, SLOT(modulesChanged()));
|
||||
// The filter bar
|
||||
filter_ = new FancyLineEdit(this);
|
||||
filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
|
||||
filter_->setButtonVisible(FancyLineEdit::Right, true);
|
||||
filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
|
||||
filter_->setAutoHideButton(FancyLineEdit::Right, true);
|
||||
filter_->setClearButton(true);
|
||||
filter_->setPlaceholderText(qt_("All avail. modules"));
|
||||
modulesModule->moduleFilterBarL->addWidget(filter_, 0);
|
||||
modulesModule->findModulesLA->setBuddy(filter_);
|
||||
|
@ -186,10 +186,7 @@ GuiLyXFiles::GuiLyXFiles(GuiView & lv)
|
||||
|
||||
// The filter bar
|
||||
filter_ = new FancyLineEdit(this);
|
||||
filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
|
||||
filter_->setButtonVisible(FancyLineEdit::Right, true);
|
||||
filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
|
||||
filter_->setAutoHideButton(FancyLineEdit::Right, true);
|
||||
filter_->setClearButton(true);
|
||||
filter_->setPlaceholderText(qt_("All available files"));
|
||||
filter_->setToolTip(qt_("Enter string to filter the list of available files"));
|
||||
#if (QT_VERSION < 0x050000)
|
||||
|
@ -56,10 +56,7 @@ GuiRef::GuiRef(GuiView & lv)
|
||||
|
||||
// The filter bar
|
||||
filter_ = new FancyLineEdit(this);
|
||||
filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
|
||||
filter_->setButtonVisible(FancyLineEdit::Right, true);
|
||||
filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
|
||||
filter_->setAutoHideButton(FancyLineEdit::Right, true);
|
||||
filter_->setClearButton(true);
|
||||
filter_->setPlaceholderText(qt_("All available labels"));
|
||||
filter_->setToolTip(qt_("Enter string to filter the list of available labels"));
|
||||
#if (QT_VERSION < 0x050000)
|
||||
|
@ -73,11 +73,7 @@ PanelStack::PanelStack(QWidget * parent)
|
||||
|
||||
// Configure the search box
|
||||
search_->setPlaceholderText(qt_("Search"));
|
||||
search_->setButtonPixmap(FancyLineEdit::Right,
|
||||
getPixmap("images/", "editclear", "svgz,png"));
|
||||
search_->setButtonVisible(FancyLineEdit::Right, true);
|
||||
search_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
|
||||
search_->setAutoHideButton(FancyLineEdit::Right, true);
|
||||
search_->setClearButton(true);
|
||||
connect(search_, SIGNAL(rightButtonClicked()),
|
||||
this, SLOT(resetSearch()));
|
||||
connect(search_, SIGNAL(textEdited(QString)),
|
||||
|
Loading…
Reference in New Issue
Block a user