Commit 9e84b967 authored by Scott Wheeler's avatar Scott Wheeler

More GUI cleaning to keep the crowds happy. Remove some of the clutter on

the search bar and replace it with an "Advanced Search" button (again, note
that this string was already present).

Also don't put the search bar in a splitter since, well, you can't resize it.

Made the search bar a KToolBar -- this looks more visually concistant...

svn path=/trunk/kdemultimedia/juk/; revision=266261
parent 6f1c3e06
......@@ -450,6 +450,8 @@ void PlaylistSplitter::slotRenameFile()
// private members
////////////////////////////////////////////////////////////////////////////////
#include <qlayout.h>
void PlaylistSplitter::setupLayout()
{
setOpaqueResize(false);
......@@ -468,7 +470,10 @@ void PlaylistSplitter::setupLayout()
// Create the playlist and the editor.
m_playlistStack = new QWidgetStack(editorSplitter, "playlistStack");
QWidget *top = new QWidget(editorSplitter);
QVBoxLayout *topLayout = new QVBoxLayout(top);
m_playlistStack = new QWidgetStack(top, "playlistStack");
m_editor = new TagEditor(editorSplitter, "tagEditor");
// Make the editor as small as possible (or at least as small as recommended)
......@@ -494,12 +499,17 @@ void PlaylistSplitter::setupLayout()
connect(m_collection, SIGNAL(signalCollectionChanged()), m_editor, SLOT(slotUpdateCollection()));
// Create the search widget -- this must be done after the CollectionList is created.
m_searchWidget = new SearchWidget(editorSplitter, "searchWidget");
editorSplitter->moveToFirst(m_searchWidget);
m_searchWidget = new SearchWidget(top, "searchWidget");
connect(m_searchWidget, SIGNAL(signalQueryChanged()), this, SLOT(slotShowSearchResults()));
connect(m_searchWidget, SIGNAL(signalAdvancedSearchClicked()), this, SLOT(slotAdvancedSearch()));
connect(CollectionList::instance(), SIGNAL(signalVisibleColumnsChanged()),
this, SLOT(slotVisibleColumnsChanged()));
topLayout->addWidget(m_searchWidget);
topLayout->addWidget(m_playlistStack);
// Show the collection on startup.
m_playlistBox->setSelected(0, true);
}
......
......@@ -17,6 +17,7 @@
#include <klocale.h>
#include <klineedit.h>
#include <kiconloader.h>
#include <kcombobox.h>
#include <kdebug.h>
......@@ -24,6 +25,7 @@
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qtoolbutton.h>
#include "searchwidget.h"
#include "collectionlist.h"
......@@ -32,24 +34,32 @@
// SearchLine public methods
////////////////////////////////////////////////////////////////////////////////
SearchLine::SearchLine(QWidget *parent, const char *name) : QHBox(parent, name)
SearchLine::SearchLine(QWidget *parent, bool simple, const char *name) :
QHBox(parent, name),
m_simple(simple)
{
setSpacing(5);
m_searchFieldsBox = new KComboBox(this, "searchFields");
connect(m_searchFieldsBox, SIGNAL(activated(int)),
this, SIGNAL(signalQueryChanged()));
if(!m_simple) {
m_searchFieldsBox = new KComboBox(this, "searchFields");
connect(m_searchFieldsBox, SIGNAL(activated(int)),
this, SIGNAL(signalQueryChanged()));
}
m_lineEdit = new KLineEdit(this, "searchLineEdit");
connect(m_lineEdit, SIGNAL(textChanged(const QString &)),
this, SIGNAL(signalQueryChanged()));
m_caseSensitive = new KComboBox(this);
m_caseSensitive->insertItem(i18n("Normal Matching"), 0);
m_caseSensitive->insertItem(i18n("Case Sensitive"), 1);
m_caseSensitive->insertItem(i18n("Pattern Matching"), 2);
connect(m_caseSensitive, SIGNAL(activated(int)),
this, SIGNAL(signalQueryChanged()));
if(!m_simple) {
m_caseSensitive = new KComboBox(this);
m_caseSensitive->insertItem(i18n("Normal Matching"), 0);
m_caseSensitive->insertItem(i18n("Case Sensitive"), 1);
m_caseSensitive->insertItem(i18n("Pattern Matching"), 2);
connect(m_caseSensitive, SIGNAL(activated(int)),
this, SIGNAL(signalQueryChanged()));
}
else
m_caseSensitive = 0;
updateColumns();
}
......@@ -57,13 +67,13 @@ SearchLine::SearchLine(QWidget *parent, const char *name) : QHBox(parent, name)
PlaylistSearch::Component SearchLine::searchComponent() const
{
QString query = m_lineEdit->text();
bool caseSensitive = m_caseSensitive->currentItem() == CaseSensitive;
bool caseSensitive = m_caseSensitive && m_caseSensitive->currentItem() == CaseSensitive;
Playlist *playlist = CollectionList::instance();
QValueList<int> searchedColumns;
if(m_searchFieldsBox->currentItem() == 0) {
if(!m_searchFieldsBox || m_searchFieldsBox->currentItem() == 0) {
QValueListConstIterator<int> it = m_columnList.begin();
for(; it != m_columnList.end(); ++it) {
if(playlist->isColumnVisible(*it))
......@@ -81,13 +91,15 @@ void SearchLine::setSearchComponent(const PlaylistSearch::Component &component)
if(component == searchComponent())
return;
if(!component.isPatternSearch()) {
if(m_simple || !component.isPatternSearch()) {
m_lineEdit->setText(component.query());
m_caseSensitive->setCurrentItem(component.isCaseSensitive() ? CaseSensitive : Default);
if(m_caseSensitive)
m_caseSensitive->setCurrentItem(component.isCaseSensitive() ? CaseSensitive : Default);
}
else {
m_lineEdit->setText(component.pattern().pattern());
m_caseSensitive->setCurrentItem(Pattern);
if(m_caseSensitive)
m_caseSensitive->setCurrentItem(Pattern);
}
}
......@@ -100,8 +112,12 @@ void SearchLine::clear()
void SearchLine::updateColumns()
{
QString currentText = m_searchFieldsBox->currentText();
m_searchFieldsBox->clear();
QString currentText;
if(m_searchFieldsBox) {
currentText = m_searchFieldsBox->currentText();
m_searchFieldsBox->clear();
}
QStringList columnHeaders;
......@@ -120,15 +136,17 @@ void SearchLine::updateColumns()
selection = m_columnList.size() - 1;
}
m_searchFieldsBox->insertStringList(columnHeaders);
m_searchFieldsBox->setCurrentItem(selection + 1);
if(m_searchFieldsBox) {
m_searchFieldsBox->insertStringList(columnHeaders);
m_searchFieldsBox->setCurrentItem(selection + 1);
}
}
////////////////////////////////////////////////////////////////////////////////
// SearchWidget public methods
////////////////////////////////////////////////////////////////////////////////
SearchWidget::SearchWidget(QWidget *parent, const char *name) : QWidget(parent, name)
SearchWidget::SearchWidget(QWidget *parent, const char *name) : KToolBar(parent, name)
{
setupLayout();
updateColumns();
......@@ -178,18 +196,20 @@ void SearchWidget::updateColumns()
void SearchWidget::setupLayout()
{
QHBoxLayout *layout = new QHBoxLayout(this, 5);
layout->setAutoAdd(true);
boxLayout()->setSpacing(5);
new QLabel(i18n("Search:"), this);
new QLabel(i18n("Search:"), this, "kde toolbar widget");
m_searchLine = new SearchLine(this);
m_searchLine = new SearchLine(this, true, "kde toolbar widget");
connect(m_searchLine, SIGNAL(signalQueryChanged()), this, SIGNAL(signalQueryChanged()));
QPushButton *button = new QPushButton(i18n("Clear"), this);
connect(button, SIGNAL(clicked()), this, SLOT(clear()));
setStretchableWidget(m_searchLine);
QToolButton *b = new QToolButton(this);
b->setTextLabel(i18n("Advanced Search"), true);
b->setIconSet(SmallIconSet("wizard"));
setFixedHeight(minimumSizeHint().height());
connect(b, SIGNAL(clicked()), this, SIGNAL(signalAdvancedSearchClicked()));
}
#include "searchwidget.moc"
......@@ -18,7 +18,8 @@
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#include <qwidget.h>
#include <ktoolbar.h>
#include <qhbox.h>
#include "playlistsearch.h"
......@@ -36,7 +37,7 @@ class SearchLine : public QHBox
public:
enum Mode { Default = 0, CaseSensitive = 1, Pattern = 2 };
SearchLine(QWidget *parent, const char *name = 0);
SearchLine(QWidget *parent, bool simple = false, const char *name = 0);
virtual ~SearchLine() {}
PlaylistSearch::Component searchComponent() const;
......@@ -49,13 +50,14 @@ signals:
void signalQueryChanged();
private:
bool m_simple;
KLineEdit *m_lineEdit;
KComboBox *m_searchFieldsBox;
KComboBox *m_caseSensitive;
QValueList<int> m_columnList;
};
class SearchWidget : public QWidget
class SearchWidget : public KToolBar
{
Q_OBJECT
......@@ -75,6 +77,7 @@ public slots:
signals:
void signalQueryChanged();
void signalAdvancedSearchClicked();
private:
void updateColumns();
......
......@@ -152,7 +152,7 @@ QWidget *SliderAction::createWidget(QWidget *parent) // virtual -- used by base
QToolTip::add(m_volumeSlider, i18n("Volume"));
m_layout->addWidget(m_volumeSlider);
m_volumeSlider->setName("kde toolbar widget");
m_volumeSlider->setName("kde toolbar widget");
m_trackPositionSlider->setName("kde toolbar widget");
m_layout->setStretchFactor(m_trackPositionSlider, 4);
......
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