mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 21:38:45 -04:00
restore the title tab when searchbar loses focus
reimplement QLineEdit::focusInEvent(QFocusEvent* event) use setReadOnly method to display/hide blinking cursor
This commit is contained in:
parent
a4450d9181
commit
1f07d8b75f
@ -90,11 +90,13 @@ void SearchBar::on_currentTitleChanged(const QString& title)
|
||||
setText("");
|
||||
}
|
||||
m_button.set_searchMode(title.isEmpty());
|
||||
m_title = title;
|
||||
}
|
||||
|
||||
void SearchBar::focusInEvent( QFocusEvent* event)
|
||||
{
|
||||
if (event->reason() == Qt::MouseFocusReason) {
|
||||
setReadOnly(false);
|
||||
if (event->reason() == Qt::MouseFocusReason && text() == m_title) {
|
||||
clear();
|
||||
}
|
||||
if (event->reason() == Qt::ActiveWindowFocusReason ||
|
||||
@ -106,6 +108,16 @@ void SearchBar::focusInEvent( QFocusEvent* event)
|
||||
m_button.set_searchMode(true);
|
||||
}
|
||||
|
||||
void SearchBar::focusOutEvent(QFocusEvent* event)
|
||||
{
|
||||
setReadOnly(true);
|
||||
if (event->reason() == Qt::MouseFocusReason && text().isEmpty()) {
|
||||
m_button.set_searchMode(false);
|
||||
setText(m_title);
|
||||
}
|
||||
return QLineEdit::focusInEvent(event);
|
||||
}
|
||||
|
||||
void SearchBar::updateCompletion(const QString &text)
|
||||
{
|
||||
QStringList wordList;
|
||||
|
@ -30,12 +30,14 @@ public slots:
|
||||
void on_currentTitleChanged(const QString &title);
|
||||
protected:
|
||||
virtual void focusInEvent(QFocusEvent *);
|
||||
virtual void focusOutEvent(QFocusEvent *);
|
||||
private:
|
||||
QStringListModel m_completionModel;
|
||||
QCompleter m_completer;
|
||||
std::vector<std::string> m_urlList;
|
||||
QString m_currentZimId;
|
||||
SearchButton m_button;
|
||||
QString m_title;
|
||||
|
||||
private slots:
|
||||
void updateCompletion(const QString& text);
|
||||
|
Loading…
x
Reference in New Issue
Block a user