Git commit 6367f3a3785f505112b2253de26afe7c19bcfd37 by Michael Pyne. Committed on 26/12/2019 at 22:30. Pushed by mpyne into branch 'master'.
Continued search widget cleanup; remove needless KToolBar usage. Continuing on from the work in commit fc6fecd6394c where Carl Schwan noticed that the SearchLine class (used as a base search input element within the PlaylistSplitter and within the Advanced Search playlist dialog) didn't really need to be a QWidget. The resulting improvement to the search line's appearance above the list of music tracks came very close to looking like a no-overhead widget, but there was still a 1-pixel padding on the left/right between the line that wasn't present for the playlist tracks themselves. The cause was the nearby SearchWidget class (used in the PlaylistSplitter), which is a thin wrapper around SearchLine, and for some reason is a KToolBar. This may have been intended at some point in JuK's prehistory (e.g. to allow for dockable/movable search line) but at this point the search line always shows up in the same spot and isn't even parented into the toolwindow where a toolbar normally would go. As a result this doesn't need to be anything other than a QWidget either, and making this change allows the search bar to line up pixel-perfect with the list of music tracks as it should. GUI: CHANGELOG:Removes unintended padding between search line and rest of interface. M +7 -31 searchwidget.cpp M +4 -16 searchwidget.h https://invent.kde.org/kde/juk/commit/6367f3a3785f505112b2253de26afe7c19bcfd37 diff --git a/searchwidget.cpp b/searchwidget.cpp index f7186602..ae02c685 100644 --- a/searchwidget.cpp +++ b/searchwidget.cpp @@ -195,18 +195,14 @@ void SearchLine::updateColumns() //////////////////////////////////////////////////////////////////////////////// SearchWidget::SearchWidget(QWidget *parent) - : KToolBar(parent), - m_searchLine(this, true) + : SearchLine(parent, true) { new SearchAdaptor(this); QDBusConnection::sessionBus().registerObject("/Search", this); - m_searchLine.m_lineEdit->setPlaceholderText(i18n("Search...")); - addWidget(&m_searchLine); + m_lineEdit->setPlaceholderText(i18n("Search...")); - connect(&m_searchLine, SIGNAL(signalQueryChanged()), this, SIGNAL(signalQueryChanged())); - connect(&m_searchLine, SIGNAL(signalDownPressed()), this, SIGNAL(signalDownPressed())); - connect(m_searchLine.m_lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed())); + connect(m_lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed())); updateColumns(); } @@ -220,55 +216,35 @@ void SearchWidget::setSearch(const PlaylistSearch &search) return; } - m_searchLine.setSearchComponent(*components.begin()); + setSearchComponent(*components.begin()); } QString SearchWidget::searchText() const { - return m_searchLine.searchComponent().query(); + return searchComponent().query(); } void SearchWidget::setSearchText(const QString &text) { - m_searchLine.setSearchComponent(PlaylistSearch::Component(text)); + setSearchComponent(PlaylistSearch::Component(text)); } PlaylistSearch SearchWidget::search(const PlaylistList &playlists) const { PlaylistSearch::ComponentList components; - components.append(m_searchLine.searchComponent()); + components.append(searchComponent()); return PlaylistSearch(playlists, components); } - //////////////////////////////////////////////////////////////////////////////// // SearchWidget public slots //////////////////////////////////////////////////////////////////////////////// -void SearchWidget::clear() -{ - m_searchLine.clear(); -} - void SearchWidget::setEnabled(bool enable) { emit signalShown(enable); setVisible(enable); } -void SearchWidget::setFocus() -{ - m_searchLine.setFocus(); -} - -//////////////////////////////////////////////////////////////////////////////// -// SearchWidget private methods -//////////////////////////////////////////////////////////////////////////////// - -void SearchWidget::updateColumns() -{ - m_searchLine.updateColumns(); -} - // vim: set et sw=4 tw=0 sta: diff --git a/searchwidget.h b/searchwidget.h index 0fc0e876..cfd4f763 100644 --- a/searchwidget.h +++ b/searchwidget.h @@ -15,11 +15,10 @@ * this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef SEARCHWIDGET_H -#define SEARCHWIDGET_H - -#include <KToolBar> +#ifndef JUK_SEARCHWIDGET_H +#define JUK_SEARCHWIDGET_H +#include <QWidget> #include <QList> #include <QLineEdit> @@ -68,7 +67,7 @@ private: QList<int> m_columnList; }; -class SearchWidget : public KToolBar +class SearchWidget : public SearchLine { Q_OBJECT @@ -82,26 +81,15 @@ public: virtual void setSearchText(const QString &text); public slots: - void clear(); void setEnabled(bool enable); - virtual void setFocus(); signals: - void signalQueryChanged(); - void returnPressed(); - // This signal is only emitted when the Show/Hide action is triggered. // Minimizing/closing the JuK window will not trigger this signal. void signalShown(bool shown); - void signalDownPressed(); - -private: - void updateColumns(); - private: - SearchLine m_searchLine; QStringList m_columnHeaders; };
