summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-05-05 08:14:51 +0200
committerUwe Klotz <uklotz@mixxx.org>2020-05-05 08:31:24 +0200
commit95863f8cb67e0f38e665177f0dd1cb06a0e6c05e (patch)
tree0b7147f1af4cd8aa9c13becdffcd751e888bb5ea /src
parent441c8e039a89a785f29d8e2dc9d87b03c3830a60 (diff)
Move logic from LibraryControl to WSearchLineEdit
Diffstat (limited to 'src')
-rw-r--r--src/library/librarycontrol.cpp9
-rw-r--r--src/library/librarycontrol.h2
-rw-r--r--src/widget/wsearchlineedit.cpp21
-rw-r--r--src/widget/wsearchlineedit.h4
4 files changed, 18 insertions, 18 deletions
diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp
index ca48351c92..9eabf573cd 100644
--- a/src/library/librarycontrol.cpp
+++ b/src/library/librarycontrol.cpp
@@ -333,9 +333,9 @@ void LibraryControl::bindSearchboxWidget(WSearchLineEdit* pSearchbox) {
}
m_pSearchbox = pSearchbox;
connect(this,
- &LibraryControl::clearSearch,
+ &LibraryControl::clearSearchIfClearButtonHasFocus,
m_pSearchbox,
- &WSearchLineEdit::clearSearch);
+ &WSearchLineEdit::clearSearchIfClearButtonHasFocus);
connect(m_pSearchbox,
&WSearchLineEdit::destroyed,
this,
@@ -621,9 +621,8 @@ void LibraryControl::slotGoToItem(double v) {
}
// Clear the search if the searchbox has focus
- if (m_pSearchbox->clearBtnHasFocus()) {
- return emit clearSearch();
- }
+ emit clearSearchIfClearButtonHasFocus();
+
// TODO(xxx) instead of remote control the widgets individual, we should
// translate this into Alt+Return and handle it at each library widget
// individual https://bugs.launchpad.net/mixxx/+bug/1758618
diff --git a/src/library/librarycontrol.h b/src/library/librarycontrol.h
index a6cb40a089..95967fbb90 100644
--- a/src/library/librarycontrol.h
+++ b/src/library/librarycontrol.h
@@ -46,7 +46,7 @@ class LibraryControl : public QObject {
void bindSearchboxWidget(WSearchLineEdit* pSearchbox);
signals:
- void clearSearch();
+ void clearSearchIfClearButtonHasFocus();
public slots:
// Deprecated navigation slots
diff --git a/src/widget/wsearchlineedit.cpp b/src/widget/wsearchlineedit.cpp
index a57396d6de..b59f9d664b 100644
--- a/src/widget/wsearchlineedit.cpp
+++ b/src/widget/wsearchlineedit.cpp
@@ -116,14 +116,12 @@ WSearchLineEdit::WSearchLineEdit(QWidget* pParent)
this,
&WSearchLineEdit::updateText);
- // When you hit enter, it will trigger the search.
+ // When you hit enter, it will trigger or clear the search.
connect(this,
&QLineEdit::returnPressed,
this,
[this] {
- if (clearBtnHasFocus()) {
- clearSearch();
- } else {
+ if (!clearSearchIfClearButtonHasFocus()) {
triggerSearch();
}
});
@@ -326,7 +324,6 @@ void WSearchLineEdit::disableSearch() {
setEnabled(false);
}
-// slot
void WSearchLineEdit::enableSearch(const QString& text) {
#if ENABLE_TRACE_LOG
kLogger.trace()
@@ -458,11 +455,6 @@ bool WSearchLineEdit::event(QEvent* pEvent) {
}
// slot
-bool WSearchLineEdit::clearBtnHasFocus() const {
- return m_clearButton->hasFocus();
-}
-
-// slot
void WSearchLineEdit::clearSearch() {
#if ENABLE_TRACE_LOG
kLogger.trace()
@@ -480,6 +472,15 @@ void WSearchLineEdit::clearSearch() {
}
// slot
+bool WSearchLineEdit::clearSearchIfClearButtonHasFocus() {
+ if (!m_clearButton->hasFocus()) {
+ return false;
+ }
+ clearSearch();
+ return true;
+}
+
+// slot
void WSearchLineEdit::updateText(const QString& text) {
#if ENABLE_TRACE_LOG
kLogger.trace()
diff --git a/src/widget/wsearchlineedit.h b/src/widget/wsearchlineedit.h
index f50b62b475..ef0f4ddb5d 100644
--- a/src/widget/wsearchlineedit.h
+++ b/src/widget/wsearchlineedit.h
@@ -39,8 +39,6 @@ class WSearchLineEdit : public QLineEdit, public WBaseWidget {
void setup(const QDomNode& node, const SkinContext& context);
- bool clearBtnHasFocus() const;
-
protected:
void resizeEvent(QResizeEvent*) override;
void focusInEvent(QFocusEvent*) override;
@@ -54,7 +52,9 @@ class WSearchLineEdit : public QLineEdit, public WBaseWidget {
void restoreSearch(const QString& text);
void disableSearch();
void slotSetFont(const QFont& font);
+
void clearSearch();
+ bool clearSearchIfClearButtonHasFocus();
private slots:
void setShortcutFocus();