From 77d80fc60b53a724dd0fc6b089689ce1724b99d4 Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Sat, 29 Jun 2013 18:05:00 +0200 Subject: [PATCH] Add a playlistlist view with a helper text --- src/playlist/playlistlistview.cpp | 45 +++++++++++++++++++++++++++++++ src/playlist/playlistlistview.h | 30 +++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/playlist/playlistlistview.cpp create mode 100644 src/playlist/playlistlistview.h diff --git a/src/playlist/playlistlistview.cpp b/src/playlist/playlistlistview.cpp new file mode 100644 index 000000000..e0db25b20 --- /dev/null +++ b/src/playlist/playlistlistview.cpp @@ -0,0 +1,45 @@ +/* This file is part of Clementine. + Copyright 2013, David Sansome + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#include "playlistlistview.h" + +#include + +PlaylistListView::PlaylistListView(QWidget* parent) + : AutoExpandingTreeView(parent) +{ +} + + +void PlaylistListView::paintEvent(QPaintEvent* event) { + if (model()->rowCount() <= 0) { + QPainter p(viewport()); + QRect rect(viewport()->rect()); + + p.setPen(palette().color(QPalette::Disabled, QPalette::Text)); + + QFont bold_font; + bold_font.setBold(true); + p.setFont(bold_font); + + p.drawText(rect, Qt::AlignHCenter | Qt::TextWordWrap, tr("\n\n" + "You can favorite playlists by clicking the star icon next to a playlist name\n\n" + "Favorited playlists will be saved here")); + } else { + AutoExpandingTreeView::paintEvent(event); + } +} diff --git a/src/playlist/playlistlistview.h b/src/playlist/playlistlistview.h new file mode 100644 index 000000000..d4e5fba3e --- /dev/null +++ b/src/playlist/playlistlistview.h @@ -0,0 +1,30 @@ +/* This file is part of Clementine. + Copyright 2013, David Sansome + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#include "widgets/autoexpandingtreeview.h" + +class PlaylistListView : public AutoExpandingTreeView { + Q_OBJECT + + public: + PlaylistListView(QWidget* parent = NULL); + ~PlaylistListView() {} + + protected: + // QWidget + void paintEvent(QPaintEvent* event); +};