From fcde47951ad8224954a73d423d59da046d69497e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Fri, 7 Dec 2007 02:59:19 +0000 Subject: [PATCH] Qt4 - remove PlaylistWidget from interface_widget and move it to its own file in the playlist/ --- modules/gui/qt4/Modules.am | 3 + .../gui/qt4/components/interface_widgets.cpp | 101 ------------- .../gui/qt4/components/interface_widgets.hpp | 33 ----- .../gui/qt4/components/playlist/panels.hpp | 4 +- .../gui/qt4/components/playlist/playlist.cpp | 134 ++++++++++++++++++ .../gui/qt4/components/playlist/playlist.hpp | 63 ++++++++ .../qt4/components/playlist/standardpanel.cpp | 53 ++++--- modules/gui/qt4/dialogs/playlist.cpp | 2 +- modules/gui/qt4/main_interface.cpp | 1 + 9 files changed, 241 insertions(+), 153 deletions(-) create mode 100644 modules/gui/qt4/components/playlist/playlist.cpp create mode 100644 modules/gui/qt4/components/playlist/playlist.hpp diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am index d1dac59e3c..bfa292ed0f 100644 --- a/modules/gui/qt4/Modules.am +++ b/modules/gui/qt4/Modules.am @@ -38,6 +38,7 @@ nodist_SOURCES_qt4 = \ components/simple_preferences.moc.cpp \ components/open_panels.moc.cpp \ components/interface_widgets.moc.cpp \ + components/playlist/playlist.moc.cpp \ components/playlist/panels.moc.cpp \ components/playlist/selector.moc.cpp \ util/input_slider.moc.cpp \ @@ -105,6 +106,7 @@ SOURCES_qt4 = qt4.cpp \ components/open_panels.cpp \ components/interface_widgets.cpp \ components/playlist/standardpanel.cpp \ + components/playlist/playlist.cpp \ components/playlist/selector.cpp \ util/input_slider.cpp \ util/customwidgets.cpp @@ -137,6 +139,7 @@ noinst_HEADERS = \ components/open_panels.hpp \ components/interface_widgets.hpp \ components/playlist/panels.hpp \ + components/playlist/playlist.hpp \ components/playlist/selector.hpp \ util/input_slider.hpp \ util/directslider.hpp \ diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index 22a05af583..73bac4c022 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -712,107 +712,6 @@ void ControlsWidget::toggleAdvanced() emit advancedControlsToggled( b_advancedVisible ); // doComponentsUpdate(); } -/********************************************************************** - * Playlist Widget. The embedded playlist - **********************************************************************/ -#include "components/playlist/panels.hpp" -#include "components/playlist/selector.hpp" - -#include - -PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) : - p_intf ( _p_i ) -{ - /* Left Part and design */ - QWidget *leftW = new QWidget( this ); - QVBoxLayout *left = new QVBoxLayout( leftW ); - - /* Source Selector */ - selector = new PLSelector( this, p_intf, THEPL ); - left->addWidget( selector ); - - /* Art label */ - art = new QLabel( "" ); - art->setMinimumHeight( 128 ); - art->setMinimumWidth( 128 ); - art->setMaximumHeight( 128 ); - art->setMaximumWidth( 128 ); - art->setScaledContents( true ); - art->setPixmap( QPixmap( ":/noart.png" ) ); - left->addWidget( art ); - - /* Initialisation of the playlist */ - playlist_item_t *p_root = playlist_GetPreferredNode( THEPL, - THEPL->p_local_category ); - - rightPanel = qobject_cast( new StandardPLPanel( this, - p_intf, THEPL, p_root ) ); - - /* Connects */ - CONNECT( selector, activated( int ), rightPanel, setRoot( int ) ); - - CONNECT( qobject_cast( rightPanel )->model, - artSet( QString ) , this, setArt( QString ) ); - /* Forward removal requests from the selector to the main panel */ - CONNECT( qobject_cast( selector )->model, - shouldRemove( int ), - qobject_cast( rightPanel ), removeItem( int ) ); - - connect( selector, SIGNAL( activated( int ) ), - this, SIGNAL( rootChanged( int ) ) ); - emit rootChanged( p_root->i_id ); - - /* Add the two sides of the QSplitter */ - addWidget( leftW ); - addWidget( rightPanel ); - - leftW->setMaximumWidth( 250 ); - setCollapsible( 1, false ); - - QList sizeList; - sizeList << 180 << 420 ; - setSizes( sizeList ); - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); - - /* In case we want to keep the splitter informations */ - settings->beginGroup( "playlist" ); - restoreState( settings->value("splitterSizes").toByteArray()); - resize( settings->value("size", QSize(600, 300)).toSize()); - move( settings->value("pos", QPoint( 0, 400)).toPoint()); - settings->endGroup(); -} - -void PlaylistWidget::setArt( QString url ) -{ - if( url.isNull() ) - { - art->setPixmap( QPixmap( ":/noart.png" ) ); - emit artSet( url ); - } - else if( prevArt != url ) - { - art->setPixmap( QPixmap( url ) ); - prevArt = url; - emit artSet( url ); - } -} - -QSize PlaylistWidget::sizeHint() const -{ - return QSize( 600 , 300 ); -} - -PlaylistWidget::~PlaylistWidget() -{} - -void PlaylistWidget::savingSettings( QSettings *settings ) -{ - settings->beginGroup( "playlist" ); - settings->setValue( "pos", pos() ); - settings->setValue( "size", size() ); - settings->setValue("splitterSizes", saveState() ); - settings->endGroup(); -} /********************************************************************** * Speed control widget diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp index 70a90a1d1e..893d4504d9 100644 --- a/modules/gui/qt4/components/interface_widgets.hpp +++ b/modules/gui/qt4/components/interface_widgets.hpp @@ -229,39 +229,6 @@ signals: }; -/******************** Playlist Widgets ****************/ -#include -#include -class QSignalMapper; -class PLSelector; -class PLPanel; -class QPushButton; -class QSettings; - -class PlaylistWidget : public QSplitter -{ - Q_OBJECT; -public: - PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) ; - virtual ~PlaylistWidget(); - QSize sizeHint() const; - void savingSettings( QSettings *settings ); -private: - PLSelector *selector; - PLPanel *rightPanel; - QPushButton *addButton; - QLabel *art; - QString prevArt; -protected: - intf_thread_t *p_intf; -private slots: - void setArt( QString ); -signals: - void rootChanged( int ); - void artSet( QString ); -}; - - /******************** Speed Control Widgets ****************/ class SpeedControlWidget : public QFrame { diff --git a/modules/gui/qt4/components/playlist/panels.hpp b/modules/gui/qt4/components/playlist/panels.hpp index 60de0b0483..1ac3c18474 100644 --- a/modules/gui/qt4/components/playlist/panels.hpp +++ b/modules/gui/qt4/components/playlist/panels.hpp @@ -27,12 +27,13 @@ #include #include "qt4.hpp" -#include "../interface_widgets.hpp" +#include "components/playlist/playlist.hpp" #include #include #include +class QSignalMapper; class QTreeView; class PLModel; class QPushButton; @@ -56,7 +57,6 @@ public slots: virtual void setRoot( int ) = 0; }; -class PlaylistWidget; class StandardPLPanel: public PLPanel { diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp new file mode 100644 index 0000000000..8f078449c9 --- /dev/null +++ b/modules/gui/qt4/components/playlist/playlist.cpp @@ -0,0 +1,134 @@ +/***************************************************************************** + * interface_widgets.cpp : Custom widgets for the main interface + **************************************************************************** + * Copyright ( C ) 2006 the VideoLAN team + * $Id$ + * + * Authors: Clément Stenac + * Jean-Baptiste Kempf + * Rafaël Carré + * + * This program 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 2 of the License, or + * ( at your option ) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include "components/playlist/panels.hpp" +#include "components/playlist/selector.hpp" +#include "components/playlist/playlist.hpp" + +#include +#include +#include +#include +#include +#include + +/********************************************************************** + * Playlist Widget. The embedded playlist + **********************************************************************/ + +PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) : + p_intf ( _p_i ) +{ + /* Left Part and design */ + QWidget *leftW = new QWidget( this ); + QVBoxLayout *left = new QVBoxLayout( leftW ); + + /* Source Selector */ + selector = new PLSelector( this, p_intf, THEPL ); + left->addWidget( selector ); + + /* Art label */ + art = new QLabel( "" ); + art->setMinimumHeight( 128 ); + art->setMinimumWidth( 128 ); + art->setMaximumHeight( 128 ); + art->setMaximumWidth( 128 ); + art->setScaledContents( true ); + art->setPixmap( QPixmap( ":/noart.png" ) ); + left->addWidget( art ); + + /* Initialisation of the playlist */ + playlist_item_t *p_root = playlist_GetPreferredNode( THEPL, + THEPL->p_local_category ); + + rightPanel = qobject_cast( new StandardPLPanel( this, + p_intf, THEPL, p_root ) ); + + /* Connects */ + CONNECT( selector, activated( int ), rightPanel, setRoot( int ) ); + + CONNECT( qobject_cast( rightPanel )->model, + artSet( QString ) , this, setArt( QString ) ); + /* Forward removal requests from the selector to the main panel */ + CONNECT( qobject_cast( selector )->model, + shouldRemove( int ), + qobject_cast( rightPanel ), removeItem( int ) ); + + connect( selector, SIGNAL( activated( int ) ), + this, SIGNAL( rootChanged( int ) ) ); + emit rootChanged( p_root->i_id ); + + /* Add the two sides of the QSplitter */ + addWidget( leftW ); + addWidget( rightPanel ); + + leftW->setMaximumWidth( 250 ); + setCollapsible( 1, false ); + + QList sizeList; + sizeList << 180 << 420 ; + setSizes( sizeList ); + setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); + + /* In case we want to keep the splitter informations */ + settings->beginGroup( "playlist" ); + restoreState( settings->value("splitterSizes").toByteArray()); + resize( settings->value("size", QSize(600, 300)).toSize()); + move( settings->value("pos", QPoint( 0, 400)).toPoint()); + settings->endGroup(); +} + +void PlaylistWidget::setArt( QString url ) +{ + if( url.isNull() ) + { + art->setPixmap( QPixmap( ":/noart.png" ) ); + emit artSet( url ); + } + else if( prevArt != url ) + { + art->setPixmap( QPixmap( url ) ); + prevArt = url; + emit artSet( url ); + } +} + +QSize PlaylistWidget::sizeHint() const +{ + return QSize( 600 , 300 ); +} + +PlaylistWidget::~PlaylistWidget() +{} + +void PlaylistWidget::savingSettings( QSettings *settings ) +{ + settings->beginGroup( "playlist" ); + settings->setValue( "pos", pos() ); + settings->setValue( "size", size() ); + settings->setValue("splitterSizes", saveState() ); + settings->endGroup(); +} + diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp new file mode 100644 index 0000000000..c7370db761 --- /dev/null +++ b/modules/gui/qt4/components/playlist/playlist.hpp @@ -0,0 +1,63 @@ +/***************************************************************************** + * interface_widgets.hpp : Playlist Widgets + **************************************************************************** + * Copyright (C) 2006 the VideoLAN team + * $Id$ + * + * Authors: Clément Stenac + * Jean-Baptiste Kempf + * Rafaël Carré + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef _PLAYLISTWIDGET_H_ +#define _PLAYLISTWIDGET_H_ + +#include +#include "qt4.hpp" + +#include + +class QLabel; +class PLSelector; +class PLPanel; +class QPushButton; +class QSettings; + +class PlaylistWidget : public QSplitter +{ + Q_OBJECT; +public: + PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) ; + virtual ~PlaylistWidget(); + QSize sizeHint() const; + void savingSettings( QSettings *settings ); +private: + PLSelector *selector; + PLPanel *rightPanel; + QPushButton *addButton; + QLabel *art; + QString prevArt; +protected: + intf_thread_t *p_intf; +private slots: + void setArt( QString ); +signals: + void rootChanged( int ); + void artSet( QString ); +}; + +#endif diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 35ddc7f943..e6d962cfe8 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -67,12 +68,14 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, view->setDropIndicatorShown( true ); view->setAutoScroll( true ); - view->header()->resizeSection( 0, 230 ); + /* Configure the size of the header */ + view->header()->resizeSection( 0, 200 ); view->header()->resizeSection( 1, 80 ); view->header()->setSortIndicatorShown( true ); view->header()->setClickable( true ); view->header()->setContextMenuPolicy( Qt::CustomContextMenu ); + /* Connections for the TreeView */ CONNECT( view, activated( const QModelIndex& ) , model,activateItem( const QModelIndex& ) ); CONNECT( view, rightClicked( QModelIndex , QPoint ), @@ -88,11 +91,14 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, /* Buttons configuration */ QHBoxLayout *buttons = new QHBoxLayout; - addButton = new QPushButton( QIcon( ":/pixmaps/playlist_add.png" ), "", this ); - addButton->setMaximumWidth( 25 ); + /* Add item to the playlist button */ + addButton = new QPushButton; + addButton->setIcon( QIcon( ":/pixmaps/playlist_add.png" ) ); + addButton->setMaximumWidth( 30 ); BUTTONACT( addButton, popupAdd() ); buttons->addWidget( addButton ); + /* Random 2-state button */ randomButton = new QPushButton( this ); if( model->hasRandom() ) { @@ -107,9 +113,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, BUTTONACT( randomButton, toggleRandom() ); buttons->addWidget( randomButton ); - QSpacerItem *spacer = new QSpacerItem( 10, 20 ); - buttons->addItem( spacer ); - + /* Repeat 3-state button */ repeatButton = new QPushButton( this ); if( model->hasRepeat() ) { @@ -129,24 +133,33 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, BUTTONACT( repeatButton, toggleRepeat() ); buttons->addWidget( repeatButton ); + /* A Spacer and the search possibilities */ + QSpacerItem *spacer = new QSpacerItem( 10, 20 ); + buttons->addItem( spacer ); + QLabel *filter = new QLabel( qtr(I_PL_SEARCH) + " " ); buttons->addWidget( filter ); + searchLine = new ClickLineEdit( qtr(I_PL_FILTER), 0 ); + searchLine->setMinimumWidth( 80 ); CONNECT( searchLine, textChanged(QString), this, search(QString)); buttons->addWidget( searchLine ); filter->setBuddy( searchLine ); - QPushButton *clear = new QPushButton( qfu( "CL") ); + QPushButton *clear = new QPushButton; + clear->setText( qfu( "CL") ); clear->setMaximumWidth( 30 ); clear->setToolTip( qtr( "Clear" )); BUTTONACT( clear, clearFilter() ); buttons->addWidget( clear ); + /* Finish the layout */ layout->addWidget( view ); layout->addLayout( buttons ); // layout->addWidget( bar ); setLayout( layout ); } +/* Function to toggle between the Repeat states */ void StandardPLPanel::toggleRepeat() { if( model->hasRepeat() ) @@ -169,6 +182,7 @@ void StandardPLPanel::toggleRepeat() } } +/* Function to toggle between the Random states */ void StandardPLPanel::toggleRandom() { bool prev = model->hasRandom(); @@ -206,6 +220,7 @@ void StandardPLPanel::setCurrentRootId( int _new ) addButton->setEnabled( false ); } +/* PopupAdd Menu for the Add Menu */ void StandardPLPanel::popupAdd() { QMenu popup; @@ -225,22 +240,24 @@ void StandardPLPanel::popupAdd() popup.addAction( qtr(I_PL_ADVADD), THEDP, SLOT( MLAppendDialog() ) ); popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) ); } - popup.exec( QCursor::pos() ); + popup.exec( QCursor::pos() - addButton->mapFromGlobal( QCursor::pos() ) + + QPoint( 0, addButton->height() ) ); } -void StandardPLPanel::popupSelectColumn( QPoint ) +void StandardPLPanel::popupSelectColumn( QPoint pos ) { ContextUpdateMapper = new QSignalMapper(this); QMenu selectColMenu; #define ADD_META_ACTION( meta ) { \ - QAction* option = selectColMenu.addAction( qfu(VLC_META_##meta) ); \ - option->setCheckable( true ); \ - option->setChecked( model->shownFlags() & VLC_META_ENGINE_##meta ); \ - ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta ); \ - CONNECT( option, triggered(), ContextUpdateMapper, map() ); \ - } + QAction* option = selectColMenu.addAction( qfu(VLC_META_##meta) ); \ + option->setCheckable( true ); \ + option->setChecked( model->shownFlags() & VLC_META_ENGINE_##meta ); \ + ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta ); \ + CONNECT( option, triggered(), ContextUpdateMapper, map() ); \ +} + CONNECT( ContextUpdateMapper, mapped( int ), model, viewchanged( int ) ); ADD_META_ACTION( TITLE ); @@ -255,13 +272,15 @@ void StandardPLPanel::popupSelectColumn( QPoint ) #undef ADD_META_ACTION selectColMenu.exec( QCursor::pos() ); - } +} +/* ClearFilter LineEdit */ void StandardPLPanel::clearFilter() { searchLine->setText( "" ); } +/* Search in the playlist */ void StandardPLPanel::search( QString searchText ) { model->search( searchText ); @@ -290,6 +309,8 @@ void StandardPLPanel::removeItem( int i_id ) model->removeItem( i_id ); } +/* Delete and Suppr key remove the selection + FilterKey function and code function */ void StandardPLPanel::keyPressEvent( QKeyEvent *e ) { switch( e->key() ) diff --git a/modules/gui/qt4/dialogs/playlist.cpp b/modules/gui/qt4/dialogs/playlist.cpp index 09d47c3f3c..a01c326c58 100644 --- a/modules/gui/qt4/dialogs/playlist.cpp +++ b/modules/gui/qt4/dialogs/playlist.cpp @@ -24,7 +24,7 @@ #include "dialogs/playlist.hpp" #include "main_interface.hpp" -#include "components/interface_widgets.hpp" +#include "components/playlist/playlist.hpp" #include "dialogs_provider.hpp" #include "menus.hpp" diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 8764aa1630..64eaab258b 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -29,6 +29,7 @@ #include "util/customwidgets.hpp" #include "dialogs_provider.hpp" #include "components/interface_widgets.hpp" +#include "components/playlist/playlist.hpp" #include "dialogs/extended.hpp" #include "dialogs/playlist.hpp" #include "menus.hpp" -- 2.39.5