Commit f71f837a authored by dt's avatar dt
Browse files

Replace FancyLineEdit::setHintText by QLineEdit::setPlaceHolder

Reviewed-By: con
parent 41e0e38e
......@@ -77,8 +77,6 @@ public:
FancyLineEdit::Side m_side;
bool m_useLayoutDirection;
bool m_menuTabFocusTrigger;
QString m_hintText;
bool m_showingHintText;
};
......@@ -91,8 +89,7 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
m_menuLabel(0),
m_side(FancyLineEdit::Left),
m_useLayoutDirection(false),
m_menuTabFocusTrigger(false),
m_showingHintText(false)
m_menuTabFocusTrigger(false)
{
}
......@@ -131,7 +128,6 @@ FancyLineEdit::FancyLineEdit(QWidget *parent) :
m_d->m_menuLabel = new QLabel(this);
m_d->m_menuLabel->installEventFilter(m_d);
updateMenuLabel();
showHintText();
}
FancyLineEdit::~FancyLineEdit()
......@@ -163,10 +159,6 @@ void FancyLineEdit::updateStyleSheet(Side side)
sheet += QLatin1String(": ");
sheet += QString::number(m_d->m_pixmap.width() + margin);
sheet += QLatin1Char(';');
if (m_d->m_showingHintText)
sheet += QLatin1String(" color: #BBBBBB;");
// Fix the stylesheet's clearing the size hint.
sheet += QLatin1Char('}');
setStyleSheet(sheet);
}
......@@ -257,62 +249,4 @@ void FancyLineEdit::setMenuTabFocusTrigger(bool v)
m_d->m_menuLabel->setFocusPolicy(v ? Qt::TabFocus : Qt::NoFocus);
}
QString FancyLineEdit::hintText() const
{
return m_d->m_hintText;
}
void FancyLineEdit::setHintText(const QString &ht)
{
// Updating magic to make the property work in Designer.
if (ht == m_d->m_hintText)
return;
hideHintText();
m_d->m_hintText = ht;
if (!hasFocus() && !ht.isEmpty())
showHintText();
}
void FancyLineEdit::showHintText()
{
if (!m_d->m_showingHintText && text().isEmpty() && !m_d->m_hintText.isEmpty()) {
m_d->m_showingHintText = true;
setText(m_d->m_hintText);
updateStyleSheet(side());
}
}
void FancyLineEdit::hideHintText()
{
if (m_d->m_showingHintText && !m_d->m_hintText.isEmpty()) {
m_d->m_showingHintText = false;
setText(QString());
updateStyleSheet(side());
}
}
void FancyLineEdit::focusInEvent(QFocusEvent *e)
{
hideHintText();
QLineEdit::focusInEvent(e);
}
void FancyLineEdit::focusOutEvent(QFocusEvent *e)
{
// Focus out: Switch to displaying the hint text unless
// there is user input
showHintText();
QLineEdit::focusOutEvent(e);
}
bool FancyLineEdit::isShowingHintText() const
{
return m_d->m_showingHintText;
}
QString FancyLineEdit::typedText() const
{
return m_d->m_showingHintText ? QString() : text();
}
} // namespace Utils
......@@ -54,7 +54,6 @@ class QTCREATOR_UTILS_EXPORT FancyLineEdit : public QLineEdit
Q_PROPERTY(Side side READ side WRITE setSide DESIGNABLE isSideStored STORED isSideStored)
Q_PROPERTY(bool useLayoutDirection READ useLayoutDirection WRITE setUseLayoutDirection DESIGNABLE true)
Q_PROPERTY(bool menuTabFocusTrigger READ hasMenuTabFocusTrigger WRITE setMenuTabFocusTrigger DESIGNABLE true)
Q_PROPERTY(QString hintText READ hintText WRITE setHintText DESIGNABLE true)
public:
enum Side {Left, Right};
......@@ -77,27 +76,14 @@ public:
bool hasMenuTabFocusTrigger() const;
void setMenuTabFocusTrigger(bool v);
// Hint text that is displayed when no focus is set.
QString hintText() const;
bool isShowingHintText() const;
// Convenience for accessing the text that returns "" in case of isShowingHintText().
QString typedText() const;
signals:
void buttonClicked();
public slots:
void setPixmap(const QPixmap &pixmap);
void setHintText(const QString &ht);
void showHintText();
void hideHintText();
protected:
virtual void resizeEvent(QResizeEvent *e);
virtual void focusInEvent(QFocusEvent *e);
virtual void focusOutEvent(QFocusEvent *e);
private:
friend class Utils::FancyLineEditPrivate;
......
......@@ -33,11 +33,11 @@ namespace Utils {
FilterLineEdit::FilterLineEdit(QWidget *parent) :
FancyLineEdit(parent),
m_lastFilterText(typedText())
m_lastFilterText(text())
{
setSide(Utils::FancyLineEdit::Right);
setPixmap(QPixmap(QLatin1String(":/utils/images/reset.png")));
setHintText(tr("Type to filter"));
setPlaceholderText(tr("Type to filter"));
connect(this, SIGNAL(buttonClicked()), this, SLOT(clear()));
connect(this, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged()));
......@@ -45,7 +45,7 @@ FilterLineEdit::FilterLineEdit(QWidget *parent) :
void FilterLineEdit::slotTextChanged()
{
const QString newlyTypedText = typedText();
const QString newlyTypedText = text();
if (newlyTypedText != m_lastFilterText) {
m_lastFilterText = newlyTypedText;
emit filterChanged(m_lastFilterText);
......
......@@ -282,7 +282,7 @@ LocatorWidget::LocatorWidget(LocatorPlugin *qop) :
QPixmap image(Core::Constants::ICON_MAGNIFIER);
m_fileLineEdit->setPixmap(image);
m_fileLineEdit->setUseLayoutDirection(true);
m_fileLineEdit->setHintText(tr("Type to locate"));
m_fileLineEdit->setPlaceholderText(tr("Type to locate"));
m_fileLineEdit->setFocusPolicy(Qt::ClickFocus);
m_fileLineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
......@@ -307,11 +307,6 @@ LocatorWidget::LocatorWidget(LocatorPlugin *qop) :
this, SLOT(acceptCurrentEntry()));
}
bool LocatorWidget::isShowingTypeHereMessage() const
{
return m_fileLineEdit->isShowingHintText();
}
void LocatorWidget::updateFilterList()
{
m_filterMenu->clear();
......@@ -374,7 +369,7 @@ void LocatorWidget::showCompletionList()
void LocatorWidget::showPopup()
{
updateCompletionList(m_fileLineEdit->typedText());
updateCompletionList(m_fileLineEdit->text());
showCompletionList();
}
......@@ -441,7 +436,6 @@ void LocatorWidget::acceptCurrentEntry()
void LocatorWidget::show(const QString &text, int selectionStart, int selectionLength)
{
m_fileLineEdit->hideHintText();
if (!text.isEmpty())
m_fileLineEdit->setText(text);
if (!m_fileLineEdit->hasFocus())
......
......@@ -76,7 +76,6 @@ private:
void showEvent(QShowEvent *e);
bool isShowingTypeHereMessage() const;
void showCompletionList();
void updateCompletionList(const QString &text);
QList<ILocatorFilter*> filtersFor(const QString &text, QString &searchText);
......
......@@ -166,7 +166,7 @@ ItemLibrary::ItemLibrary(QWidget *parent) :
m_d->m_lineEdit = new Utils::FilterLineEdit(this);
m_d->m_lineEdit->setObjectName(QLatin1String("itemLibrarySearchInput"));
m_d->m_lineEdit->setHintText(tr("<Filter>", "Library search input hint text"));
m_d->m_lineEdit->setPlaceholderText(tr("<Filter>", "Library search input hint text"));
m_d->m_lineEdit->setDragEnabled(false);
m_d->m_lineEdit->setMinimumWidth(75);
m_d->m_lineEdit->setTextMargins(0, 0, 0, 0);
......@@ -250,7 +250,7 @@ void ItemLibrary::setSearchFilter(const QString &searchFilter)
void ItemLibrary::updateSearch()
{
setSearchFilter(m_d->m_lineEdit->typedText());
setSearchFilter(m_d->m_lineEdit->text());
}
void ItemLibrary::clearLineEditFocus()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment