vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Mon Jun 11 21:50:01 2012 +0200| [523ef9f807d438c5e6e8a1a028e51fb7854321c2] | committer: Francois Cartegnie
Qt: StandardPLPanel: show dropzone on views > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=523ef9f807d438c5e6e8a1a028e51fb7854321c2 --- .../gui/qt4/components/playlist/standardpanel.cpp | 32 +++++++++++++++++++- modules/gui/qt4/pixmaps/playlist/dropzone.png | Bin 0 -> 5646 bytes modules/gui/qt4/vlc.qrc | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 7dccb55..a23f965 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -46,6 +46,7 @@ #include <QStackedLayout> #include <QSignalMapper> #include <QSettings> +#include <QStylePainter> #include <assert.h> @@ -235,7 +236,7 @@ void StandardPLPanel::wheelEvent( QWheelEvent *e ) e->accept(); } -bool StandardPLPanel::eventFilter ( QObject *, QEvent * event ) +bool StandardPLPanel::eventFilter ( QObject *obj, QEvent * event ) { if (event->type() == QEvent::KeyPress) { @@ -247,6 +248,32 @@ bool StandardPLPanel::eventFilter ( QObject *, QEvent * event ) return true; } } + else if ( event->type() == QEvent::Paint ) + {/* Warn! Don't filter events from anything else than views ! */ + if ( model->rowCount() == 0 && p_selector->getCurrentItemCategory() == PL_ITEM_TYPE ) + { + QWidget *viewport = qobject_cast<QWidget *>( obj ); + QStylePainter painter( viewport ); + QPixmap dropzone(":/dropzone"); + QRect rect = viewport->geometry(); + QSize size = rect.size() / 2 - dropzone.size() / 2; + rect.adjust( 0, size.height(), 0 , 0 ); + painter.drawItemPixmap( rect, Qt::AlignHCenter, dropzone ); + /* now select the zone just below the drop zone and let Qt center + the text by itself */ + rect.adjust( 0, dropzone.size().height() + 10, 0, 0 ); + rect.setRight( viewport->geometry().width() ); + rect.setLeft( 0 ); + painter.drawItemText( rect, + Qt::AlignHCenter, + palette(), + true, + qtr("Playlist is currently Empty\n" + "Drop a file here or select a " + "media source from the left"), + QPalette::Text ); + } + } return false; } @@ -266,6 +293,7 @@ void StandardPLPanel::createIconView() CONNECT( iconView, activated( const QModelIndex & ), this, activate( const QModelIndex & ) ); iconView->installEventFilter( this ); + iconView->viewport()->installEventFilter( this ); viewStack->addWidget( iconView ); } @@ -278,6 +306,7 @@ void StandardPLPanel::createListView() CONNECT( listView, activated( const QModelIndex & ), this, activate( const QModelIndex & ) ); listView->installEventFilter( this ); + listView->viewport()->installEventFilter( this ); viewStack->addWidget( listView ); } @@ -326,6 +355,7 @@ void StandardPLPanel::createTreeView() CONNECT( treeView, customContextMenuRequested( const QPoint & ), this, popupPlView( const QPoint & ) ); treeView->installEventFilter( this ); + treeView->viewport()->installEventFilter( this ); /* SignalMapper for columns */ selectColumnsSigMapper = new QSignalMapper( this ); diff --git a/modules/gui/qt4/pixmaps/playlist/dropzone.png b/modules/gui/qt4/pixmaps/playlist/dropzone.png new file mode 100644 index 0000000..072662d Binary files /dev/null and b/modules/gui/qt4/pixmaps/playlist/dropzone.png differ diff --git a/modules/gui/qt4/vlc.qrc b/modules/gui/qt4/vlc.qrc index 98d094b..f741da2 100644 --- a/modules/gui/qt4/vlc.qrc +++ b/modules/gui/qt4/vlc.qrc @@ -98,6 +98,7 @@ <file alias="new.png">pixmaps/profile_new.png</file> <file alias="lock">pixmaps/lock.png</file> <file alias="search_clear">pixmaps/search_clear.png</file> + <file alias="dropzone">pixmaps/playlist/dropzone.png</file> </qresource> <qresource prefix="/prefsmenu"> <file alias="cone_audio_64">pixmaps/prefs/spref_cone_Audio_64.png</file> _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org http://mailman.videolan.org/listinfo/vlc-commits