Show a message on the playlist when a search yielded no matches.

This commit is contained in:
David Sansome 2010-05-22 17:03:18 +00:00
parent ab1b80c1db
commit aff901e44d
26 changed files with 153 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include <QSettings>
#include <QTimeLine>
#include <QSortFilterProxyModel>
#include <QLabel>
const char* PlaylistContainer::kSettingsGroup = "Playlist";
@ -34,10 +35,30 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
redo_(NULL),
starting_up_(true),
tab_bar_visible_(false),
tab_bar_animation_(new QTimeLine(500, this))
tab_bar_animation_(new QTimeLine(500, this)),
no_matches_label_(new QLabel(this))
{
ui_->setupUi(this);
no_matches_label_->setText(tr("No matches found. Clear the search box to show the whole playlist again."));
no_matches_label_->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
no_matches_label_->setAttribute(Qt::WA_TransparentForMouseEvents);
no_matches_label_->setWordWrap(true);
no_matches_label_->raise();
no_matches_label_->hide();
// Set the colour of the no matches label to the disabled text colour
QPalette no_matches_palette = no_matches_label_->palette();
no_matches_palette.setColor(
QPalette::Normal, QPalette::WindowText,
no_matches_palette.color(QPalette::Disabled, QPalette::Text));
no_matches_label_->setPalette(no_matches_palette);
// Make it bold
QFont no_matches_font = no_matches_label_->font();
no_matches_font.setBold(true);
no_matches_label_->setFont(no_matches_font);
settings_.beginGroup(kSettingsGroup);
// Icons
@ -236,4 +257,31 @@ void PlaylistContainer::SetTabBarHeight(int height) {
void PlaylistContainer::UpdateFilter() {
manager_->current()->proxy()->setFilterFixedString(ui_->filter->text());
bool no_matches = manager_->current()->proxy()->rowCount() == 0 &&
manager_->current()->rowCount() > 0;
if (no_matches)
RepositionNoMatchesLabel(true);
no_matches_label_->setVisible(no_matches);
}
void PlaylistContainer::resizeEvent(QResizeEvent* e) {
QWidget::resizeEvent(e);
RepositionNoMatchesLabel();
}
void PlaylistContainer::RepositionNoMatchesLabel(bool force) {
if (!force && !no_matches_label_->isVisible())
return;
const int kBorder = 10;
QPoint pos = ui_->playlist->viewport()->mapTo(this, QPoint(kBorder, kBorder));
QSize size = ui_->playlist->viewport()->size();
size.setWidth(size.width() - kBorder * 2);
size.setHeight(size.height() - kBorder * 2);
no_matches_label_->move(pos);
no_matches_label_->resize(size);
}

View File

@ -27,6 +27,7 @@ class PlaylistManager;
class PlaylistView;
class QTimeLine;
class QLabel;
class PlaylistContainer : public QWidget {
Q_OBJECT
@ -50,6 +51,10 @@ signals:
void UndoRedoActionsChanged(QAction* undo, QAction* redo);
protected:
// QWidget
void resizeEvent(QResizeEvent *);
private slots:
void ClearFilter();
void NewPlaylist();
@ -74,6 +79,7 @@ private slots:
private:
void UpdateActiveIcon(const QIcon& icon);
void RepositionNoMatchesLabel(bool force = false);
private:
Ui_PlaylistContainer* ui_;
@ -87,6 +93,8 @@ private:
bool tab_bar_visible_;
QTimeLine* tab_bar_animation_;
QLabel* no_matches_label_;
};
#endif // PLAYLISTCONTAINER_H

View File

@ -327,6 +327,10 @@ msgstr "حُرِرَ بِتاريخ"
msgid "Date created"
msgstr "تاريخ الإنشاء"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -328,6 +328,10 @@ msgstr "Datum úprav"
msgid "Date created"
msgstr "Datum vytvoření"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -330,6 +330,10 @@ msgstr "Ændringsdato"
msgid "Date created"
msgstr "Oprettelsesdato"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Geändert"
msgid "Date created"
msgstr "Erstellt"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -330,6 +330,10 @@ msgstr "Ημερομηνία τροποποίησης"
msgid "Date created"
msgstr "Ημερομηνία δημιουργίας"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Date modified"
msgid "Date created"
msgstr "Date created"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -333,6 +333,10 @@ msgstr "Fecha de modificación"
msgid "Date created"
msgstr "Fecha de creación"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Muokattu"
msgid "Date created"
msgstr "Luotu"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -332,6 +332,10 @@ msgstr "Date de modification"
msgid "Date created"
msgstr "Date de création"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Data de alterazón"
msgid "Date created"
msgstr "Data de criazón"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -330,6 +330,10 @@ msgstr "Data di creazione"
msgid "Date created"
msgstr "Data di modifica"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr ""
msgid "Date created"
msgstr ""
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -328,6 +328,10 @@ msgstr "Endringsdato"
msgid "Date created"
msgstr "Laget dato"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Data de modificacion"
msgid "Date created"
msgstr ""
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -328,6 +328,10 @@ msgstr "Data modyfikacji"
msgid "Date created"
msgstr "Data utworzenia"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Data de alteração"
msgid "Date created"
msgstr "Data de criação"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Data de modificação"
msgid "Date created"
msgstr "Data de criação"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Data modificării"
msgid "Date created"
msgstr "Data creării"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr "Дата изменения"
msgid "Date created"
msgstr "Дата создания"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -328,6 +328,10 @@ msgstr "Dátum zmeny"
msgid "Date created"
msgstr "Dátum vytvorenia"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -329,6 +329,10 @@ msgstr "Datum ändrat"
msgid "Date created"
msgstr "Datum skapat"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr ""
msgid "Date created"
msgstr "Oluşturulduğu tarih"
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -318,6 +318,10 @@ msgstr ""
msgid "Date created"
msgstr ""
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""

View File

@ -327,6 +327,10 @@ msgstr ""
msgid "Date created"
msgstr ""
msgid ""
"No matches found. Clear the search box to show the whole playlist again."
msgstr ""
msgid "New playlist"
msgstr ""