From e4bbf1c43df3c160b45b8b8d65261d4708f2e147 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sun, 2 Sep 2007 16:17:36 +0000 Subject: [PATCH] Add a podcast configuration dialog to the Qt4 interface/dialogs provider. --- modules/gui/qt4/Modules.am | 5 + .../gui/qt4/dialogs/podcast_configuration.cpp | 78 ++++++++++++ .../gui/qt4/dialogs/podcast_configuration.hpp | 47 +++++++ modules/gui/qt4/dialogs_provider.cpp | 7 ++ modules/gui/qt4/dialogs_provider.hpp | 2 + modules/gui/qt4/menus.cpp | 8 ++ modules/gui/qt4/ui/podcast_configuration.ui | 115 ++++++++++++++++++ 7 files changed, 262 insertions(+) create mode 100644 modules/gui/qt4/dialogs/podcast_configuration.cpp create mode 100644 modules/gui/qt4/dialogs/podcast_configuration.hpp create mode 100644 modules/gui/qt4/ui/podcast_configuration.ui diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am index da76351507..90a0220e21 100644 --- a/modules/gui/qt4/Modules.am +++ b/modules/gui/qt4/Modules.am @@ -30,6 +30,7 @@ nodist_SOURCES_qt4 = \ dialogs/help.moc.cpp \ dialogs/gototime.moc.cpp \ dialogs/open.moc.cpp \ + dialogs/podcast_configuration.moc.cpp \ components/extended_panels.moc.cpp \ components/infopanels.moc.cpp \ components/preferences_widgets.moc.cpp \ @@ -50,6 +51,7 @@ nodist_SOURCES_qt4 = \ ui/open_net.h \ ui/open_capture.h \ ui/open.h \ + ui/podcast_configuration.h \ ui/sprefs_audio.h \ ui/sprefs_input.h \ ui/sprefs_interface.h \ @@ -110,6 +112,7 @@ SOURCES_qt4 = qt4.cpp \ dialogs/help.cpp \ dialogs/gototime.cpp \ dialogs/open.cpp \ + dialogs/podcast_configuration.cpp \ components/extended_panels.cpp \ components/infopanels.cpp \ components/preferences_widgets.cpp \ @@ -141,6 +144,7 @@ noinst_HEADERS = \ dialogs/help.hpp \ dialogs/gototime.hpp \ dialogs/open.hpp \ + dialogs/podcast_configuration.hpp \ components/extended_panels.hpp \ components/infopanels.hpp \ components/preferences_widgets.hpp \ @@ -165,6 +169,7 @@ EXTRA_DIST += \ ui/open_net.ui \ ui/open_capture.ui \ ui/open.ui \ + ui/podcast_configuration.ui \ ui/sprefs_audio.ui \ ui/sprefs_input.ui \ ui/sprefs_interface.ui \ diff --git a/modules/gui/qt4/dialogs/podcast_configuration.cpp b/modules/gui/qt4/dialogs/podcast_configuration.cpp new file mode 100644 index 0000000000..343cd88271 --- /dev/null +++ b/modules/gui/qt4/dialogs/podcast_configuration.cpp @@ -0,0 +1,78 @@ +/***************************************************************************** + * podcast_configuration.cpp: Podcast configuration dialog + **************************************************************************** + * Copyright (C) 2007 the VideoLAN team + * $Id$ + * + * Authors: Antoine Cellerier + * + * 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 "podcast_configuration.hpp" + +PodcastConfigurationDialog::PodcastConfigurationDialog( intf_thread_t *_p_intf ) + :p_intf( _p_intf ) +{ + ui.setupUi( this ); + CONNECT( ui.podcastAdd, clicked(), this, add() ); + CONNECT( ui.podcastDelete, clicked(), this, remove() ); + + char *psz_urls = config_GetPsz( p_intf, "podcast-urls" ); + if( psz_urls ) + { + char *psz_url = psz_urls; + while( 1 ) + { + char *psz_tok = strchr( psz_url, '|' ); + if( psz_tok ) *psz_tok = '\0'; + ui.podcastList->addItem( psz_url ); + if( psz_tok ) psz_url = psz_tok+1; + else break; + } + free( psz_urls ); + } +} + +void PodcastConfigurationDialog::accept() +{ + QString urls = ""; + for( int i = 0; i < ui.podcastList->count(); i++ ) + { + urls += ui.podcastList->item(i)->text(); + if( i != ui.podcastList->count()-1 ) urls += "|"; + } + const char *psz_urls = qtu( urls ); + config_PutPsz( p_intf, "podcast-urls", psz_urls ); + if( playlist_IsServicesDiscoveryLoaded( THEPL, "podcast" ) ) + { + msg_Info( p_intf, "You will need to reload the podcast module for changes to be used (FIXME)" ); + } + QDialog::accept(); +} + +void PodcastConfigurationDialog::add() +{ + if( ui.podcastURL->text() != QString( "" ) ) + { + ui.podcastList->addItem( ui.podcastURL->text() ); + ui.podcastURL->clear(); + } +} + +void PodcastConfigurationDialog::remove() +{ + delete ui.podcastList->currentItem(); +} diff --git a/modules/gui/qt4/dialogs/podcast_configuration.hpp b/modules/gui/qt4/dialogs/podcast_configuration.hpp new file mode 100644 index 0000000000..8a90866067 --- /dev/null +++ b/modules/gui/qt4/dialogs/podcast_configuration.hpp @@ -0,0 +1,47 @@ +/***************************************************************************** + * podcast_configuration.hpp: Podcast configuration dialog + **************************************************************************** + * Copyright (C) 2007 the VideoLAN team + * $Id$ + * + * Authors: Antoine Cellerier + * + * 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 _PODCAST_CONFIGURATION_DIALOG_H_ +#define _PODCAST_CONFIGURATION_DIALOG_H_ + +#include "qt4.hpp" +#include "ui/podcast_configuration.h" + +class PodcastConfigurationDialog : public QDialog +{ + Q_OBJECT; + +public: + PodcastConfigurationDialog( intf_thread_t *p_intf ); + +private: + Ui::PodcastConfiguration ui; + intf_thread_t *p_intf; + +private slots: + void accept(); + void add(); + void remove(); +}; + +#endif diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp index 209cea7d6a..9a6cc3b49e 100644 --- a/modules/gui/qt4/dialogs_provider.cpp +++ b/modules/gui/qt4/dialogs_provider.cpp @@ -43,6 +43,7 @@ #include "dialogs/open.hpp" #include "dialogs/help.hpp" #include "dialogs/gototime.hpp" +#include "dialogs/podcast_configuration.hpp" DialogsProvider* DialogsProvider::instance = NULL; @@ -502,6 +503,12 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg ) } } +void DialogsProvider::podcastConfigureDialog() +{ + PodcastConfigurationDialog c( p_intf ); + c.exec(); +} + void DialogsProvider::switchToSkins() { var_SetString( p_intf, "intf-switch", "skins2" ); diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp index 4c439f87da..fd6269bf55 100644 --- a/modules/gui/qt4/dialogs_provider.hpp +++ b/modules/gui/qt4/dialogs_provider.hpp @@ -166,6 +166,8 @@ public slots: void openPlaylist(); void savePlaylist(); + void podcastConfigureDialog(); + void switchToSkins(); void quit(); }; diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp index 3f61acf9c9..055534b7e0 100644 --- a/modules/gui/qt4/menus.cpp +++ b/modules/gui/qt4/menus.cpp @@ -434,6 +434,14 @@ QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf ) THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] : module_GetObjName( p_parser ) ); menu->addAction( a ); + + if( !strcmp( p_parser->psz_object_name, "podcast" ) ) + { + QAction *b = new QAction( qfu( "Configure podcasts..." ), menu ); + //b->setEnabled( a->isChecked() ); + menu->addAction( b ); + CONNECT( b, triggered(), THEDP, podcastConfigureDialog() ); + } } vlc_list_release( p_list ); return menu; diff --git a/modules/gui/qt4/ui/podcast_configuration.ui b/modules/gui/qt4/ui/podcast_configuration.ui new file mode 100644 index 0000000000..e17d4b2607 --- /dev/null +++ b/modules/gui/qt4/ui/podcast_configuration.ui @@ -0,0 +1,115 @@ + + PodcastConfiguration + + + + 0 + 0 + 547 + 330 + + + + Dialog + + + + + + _("Podcast URLs list") + + + + + + + true + + + QAbstractItemView::InternalMove + + + true + + + + + + + _("URL") + + + + + + + + + + _("Add") + + + :/pixmaps/play.png + + + + + + + _("Delete") + + + :/pixmaps/vlc_quit_16px.png + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + + + + + okCancel + accepted() + PodcastConfiguration + accept() + + + 445 + 304 + + + 273 + 164 + + + + + okCancel + rejected() + PodcastConfiguration + reject() + + + 445 + 304 + + + 273 + 164 + + + + + -- 2.39.2