Commit 6367f3a3 authored by Michael Pyne's avatar Michael Pyne
Browse files

Continued search widget cleanup; remove needless KToolBar usage.

Continuing on from the work in commit fc6fecd6 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.
parent 735592f7
Pipeline #12493 passed with stage
in 5 minutes and 51 seconds
......@@ -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:
......@@ -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;
};
......
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