Commit 6b468738 authored by Ludovic Fauvet's avatar Ludovic Fauvet Committed by Jean-Baptiste Kempf

New recently played menu.

* Configuration aware to enable/disable (default enabled)
 * Filters available to ignore some patterns (using QRegExp)
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent d0ed93fe
set(qt4_SOURCES qt4.cpp menus.cpp main_interface.cpp dialogs_provider.cpp input_manager.cpp dialogs/playlist.cpp dialogs/bookmarks.cpp dialogs/preferences.cpp dialogs/mediainfo.cpp dialogs/extended.cpp dialogs/messages.cpp dialogs/errors.cpp dialogs/interaction.cpp dialogs/sout.cpp dialogs/help.cpp dialogs/gototime.cpp dialogs/open.cpp dialogs/vlm.cpp dialogs/podcast_configuration.cpp components/extended_panels.cpp components/info_panels.cpp components/preferences_widgets.cpp components/complete_preferences.cpp components/simple_preferences.cpp components/open_panels.cpp components/interface_widgets.cpp components/playlist/playlist_model.cpp components/playlist/playlist_item.cpp components/playlist/standardpanel.cpp components/playlist/playlist.cpp components/playlist/selector.cpp util/input_slider.cpp util/customwidgets.cpp util/registry.cpp )
set(qt4_SOURCES qt4.cpp menus.cpp main_interface.cpp dialogs_provider.cpp input_manager.cpp recents.cpp dialogs/playlist.cpp dialogs/bookmarks.cpp dialogs/preferences.cpp dialogs/mediainfo.cpp dialogs/extended.cpp dialogs/messages.cpp dialogs/errors.cpp dialogs/interaction.cpp dialogs/sout.cpp dialogs/help.cpp dialogs/gototime.cpp dialogs/open.cpp dialogs/vlm.cpp dialogs/podcast_configuration.cpp components/extended_panels.cpp components/info_panels.cpp components/preferences_widgets.cpp components/complete_preferences.cpp components/simple_preferences.cpp components/open_panels.cpp components/interface_widgets.cpp components/playlist/playlist_model.cpp components/playlist/playlist_item.cpp components/playlist/standardpanel.cpp components/playlist/playlist.cpp components/playlist/selector.cpp util/input_slider.cpp util/customwidgets.cpp util/registry.cpp )
set(qt4_UIS ui/equalizer.ui ui/v4l2.ui ui/video_effects.ui ui/open_file.ui ui/open_disk.ui 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 ui/sprefs_subtitles.ui ui/sprefs_video.ui ui/streampanel.ui ui/sout.ui ui/vlm.ui )
set(qt4_HEADERS
components/complete_preferences.hpp
......@@ -32,6 +32,7 @@ set(qt4_HEADERS
main_interface.hpp
menus.hpp
qt4.hpp
recents.hpp
util/customwidgets.hpp
util/input_slider.hpp
util/qvlcframe.hpp
......
......@@ -17,6 +17,7 @@ nodist_SOURCES_qt4 = \
menus.moc.cpp \
dialogs_provider.moc.cpp \
input_manager.moc.cpp \
recents.moc.cpp \
dialogs/playlist.moc.cpp \
dialogs/bookmarks.moc.cpp \
dialogs/mediainfo.moc.cpp \
......@@ -171,6 +172,7 @@ SOURCES_qt4 = qt4.cpp \
main_interface.cpp \
dialogs_provider.cpp \
input_manager.cpp \
recents.cpp \
dialogs/playlist.cpp \
dialogs/bookmarks.cpp \
dialogs/preferences.cpp \
......@@ -208,6 +210,7 @@ noinst_HEADERS = \
main_interface.hpp \
dialogs_provider.hpp \
input_manager.hpp \
recents.hpp \
dialogs/playlist.hpp \
dialogs/bookmarks.hpp \
dialogs/mediainfo.hpp \
......
......@@ -38,6 +38,7 @@
#include <QToolButton>
#include <QButtonGroup>
#include <QVBoxLayout>
#include <QSettings>
#include <QtAlgorithms>
......@@ -511,6 +512,14 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
#else
ui.OneInterfaceBox->hide();
#endif
/* RECENTLY PLAYED options */
CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
ui.recentlyPlayedFilters, setEnabled( bool ) );
ui.recentlyPlayedFilters->setEnabled( false );
CONFIG_GENERIC( "qt-recentplay", Bool, NULL, saveRecentlyPlayed );
CONFIG_GENERIC( "qt-recentplay-filter", String, NULL,
recentlyPlayedFilters );
END_SPREFS_CAT;
START_SPREFS_CAT( Subtitles, qtr("Subtitles & On Screen Display Settings") );
......
......@@ -28,6 +28,8 @@
#include "dialogs/open.hpp"
#include "recents.hpp"
#include <QTabWidget>
#include <QGridLayout>
#include <QRegExp>
......@@ -337,6 +339,9 @@ void OpenDialog::finish( bool b_enqueue = false )
PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
PLAYLIST_END, b_pl ? true : false, pl_Unlocked );
vlc_gc_decref( p_input );
/* Do not add the current MRL if playlist_AddInput fail */
RecentsMRL::getInstance( p_intf )->addRecent( tempMRL[i] );
}
}
else
......
......@@ -37,6 +37,7 @@
#include "menus.hpp"
#include <vlc_intf_strings.h>
#include "input_manager.hpp"
#include "recents.hpp"
/* The dialogs */
#include "dialogs/playlist.hpp"
......@@ -389,6 +390,8 @@ void DialogsProvider::addFromSimple( bool pl, bool go)
: ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
PLAYLIST_END,
pl ? true : false, false );
RecentsMRL::getInstance( p_intf )->addRecent(
toNativeSeparators( file ) );
i++;
}
}
......@@ -420,17 +423,17 @@ static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
if (!dir.isEmpty() )
{
QString mrl = dir.endsWith( "VIDEO_TS", Qt::CaseInsensitive )
? "dvd://" : "directory://" + toNativeSeparators( dir );
msg_Dbg( p_intf, "Directory opening: %s", qtu( dir ) );
input_item_t *p_input = input_item_NewExt( THEPL, qtu(
dir.endsWith( "VIDEO_TS", Qt::CaseInsensitive ) ? "dvd://"
:"directory://"
+ toNativeSeparators(dir) ),
input_item_t *p_input = input_item_NewExt( THEPL, qtu( mrl ),
NULL, 0, NULL, -1 );
/* FIXME: playlist_AddInput() can fail */
playlist_AddInput( THEPL, p_input,
go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
PLAYLIST_END, pl, pl_Unlocked );
RecentsMRL::getInstance( p_intf )->addRecent( mrl );
if( !go )
input_Read( THEPL, p_input, true );
vlc_gc_decref( p_input );
......@@ -529,6 +532,7 @@ void DialogsProvider::streamingDialog( QWidget *parent, QString mrl,
playlist_AddExt( THEPL, qtu( mrl ), "Streaming",
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
-1, &psz_option, 1, true, pl_Unlocked );
RecentsMRL::getInstance( p_intf )->addRecent( mrl );
}
}
......@@ -641,3 +645,17 @@ void DialogsProvider::loadSubtitlesFile()
qtu( qsFile ) );
}
}
/**
* Play the MRL contained in the Recently played menu.
**/
void DialogsProvider::playMRL( const QString &mrl )
{
input_item_t *p_input = input_item_New( p_intf,
qtu( mrl ), NULL );
playlist_AddInput( THEPL, p_input, PLAYLIST_GO,
PLAYLIST_END, true, pl_Unlocked );
vlc_gc_decref( p_input );
RecentsMRL::getInstance( p_intf )->addRecent( mrl );
}
......@@ -133,6 +133,7 @@ public slots:
void menuAction( QObject *);
void menuUpdateAction( QObject * );
void SDMenuAction( QString );
void playMRL( const QString & );
void playlistDialog();
void bookmarksDialog();
......
......@@ -39,6 +39,7 @@
#include "dialogs/extended.hpp"
#include "dialogs/playlist.hpp"
#include "menus.hpp"
#include "recents.hpp"
#include <QMenuBar>
#include <QCloseEvent>
......@@ -132,9 +133,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
* Menu Bar and Status Bar
**************************/
QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled );
/* StatusBar Creation */
createStatusBar();
/* Recents menu updates */
CONNECT( RecentsMRL::getInstance( p_intf ), updated(), this, updateRecentsMenu() );
/********************
* Input Manager *
......@@ -1046,6 +1050,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
PLAYLIST_APPEND | (first ? PLAYLIST_GO: 0),
PLAYLIST_END, true, false );
first = false;
RecentsMRL::getInstance( p_intf )->addRecent( s );
}
}
event->acceptProposedAction();
......@@ -1178,3 +1183,12 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
/* Show event */
return VLC_SUCCESS;
}
/*****************************************************************************
* updateRecentsMenu: event called by RecentsMRL
*****************************************************************************/
void MainInterface::updateRecentsMenu()
{
QVLCMenu::updateRecents( p_intf );
}
......@@ -175,6 +175,7 @@ private slots:
void updateSystrayTooltipName( QString );
void updateSystrayTooltipStatus( int );
void showSpeedMenu( QPoint );
void updateRecentsMenu();
signals:
void askReleaseVideo( void * );
void askVideoToResize( unsigned int, unsigned int );
......
......@@ -39,6 +39,7 @@
#include "menus.hpp"
#include "dialogs_provider.hpp"
#include "input_manager.hpp"
#include "recents.hpp"
#include <QMenu>
#include <QMenuBar>
......@@ -46,6 +47,7 @@
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>
#include <QList>
/*
This file defines the main menus and the pop-up menu (right-click menu)
......@@ -76,6 +78,8 @@ static QActionGroup *currentGroup;
* that doesn't update the QAction checked state when QMenu is hidden */
QAction *QVLCMenu::minimalViewAction = NULL;
QMenu *QVLCMenu::recentsMenu = NULL;
// Add static entries to menus
void addDPStaticEntry( QMenu *menu,
const QString text,
......@@ -273,7 +277,7 @@ void QVLCMenu::createMenuBar( MainInterface *mi,
gives the QProcess::destroyed timeout issue on Cleanlooks style with
setDesktopAware set to false */
QMenuBar *bar = mi->menuBar();
BAR_ADD( FileMenu(), qtr( "&Media" ) );
BAR_ADD( FileMenu( p_intf ), qtr( "&Media" ) );
BAR_DADD( AudioMenu( p_intf, NULL ), qtr( "&Audio" ), 1 );
BAR_DADD( VideoMenu( p_intf, NULL ), qtr( "&Video" ), 2 );
......@@ -292,7 +296,7 @@ void QVLCMenu::createMenuBar( MainInterface *mi,
* Media ( File ) Menu
* Opening, streaming and quit
**/
QMenu *QVLCMenu::FileMenu()
QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf )
{
QMenu *menu = new QMenu();
......@@ -313,6 +317,9 @@ QMenu *QVLCMenu::FileMenu()
addDPStaticEntry( menu, qtr( "Open &Capture Device..." ), "",
":/capture-card", SLOT( openCaptureDialog() ),
"Ctrl+C" );
recentsMenu = new QMenu( qtr( "Recently played" ), menu );
updateRecents( p_intf );
menu->addMenu( recentsMenu );
menu->addSeparator();
addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "", "",
......@@ -1290,3 +1297,37 @@ void QVLCMenu::DoAction( intf_thread_t *p_intf, QObject *data )
var_Set( p_object, itemData->psz_var, itemData->val );
}
void QVLCMenu::updateRecents( intf_thread_t *p_intf )
{
if (recentsMenu)
{
QAction* action;
RecentsMRL* rmrl = RecentsMRL::getInstance( p_intf );
QList<QString> l = rmrl->recents();
recentsMenu->clear();
if( !l.size() )
{
action = recentsMenu->addAction( " - Empty - " );
action->setEnabled( false );
}
else
{
for( int i = 0; i < l.size(); ++i )
{
action = recentsMenu->addAction( l.at( i ),
rmrl->signalMapper,
SLOT( map() ) );
rmrl->signalMapper->setMapping( action, l.at( i ) );
}
CONNECT( rmrl->signalMapper,
mapped(const QString & ),
DialogsProvider::getInstance( p_intf ),
playMRL( const QString & ) );
recentsMenu->addSeparator();
recentsMenu->addAction( "Clear", rmrl, SLOT( clear() ) );
}
}
}
......@@ -76,7 +76,7 @@ public:
static void createMenuBar( MainInterface *mi, intf_thread_t *, bool );
/* Menus */
static QMenu *FileMenu();
static QMenu *FileMenu( intf_thread_t * );
static QMenu *SDMenu( intf_thread_t * );
static QMenu *PlaylistMenu( intf_thread_t *, MainInterface * );
static QMenu *ToolsMenu( intf_thread_t *, QMenu *, MainInterface *,
......@@ -115,6 +115,9 @@ private:
static void UpdateItem( intf_thread_t *, QMenu *, const char *,
vlc_object_t *, bool );
static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
static QMenu *recentsMenu;
public slots:
static void updateRecents( intf_thread_t * );
};
class MenuFunc : public QObject
......
......@@ -39,6 +39,7 @@
#include "input_manager.hpp"
#include "main_interface.hpp"
#include "dialogs/help.hpp" /* update */
#include "recents.hpp"
#ifdef HAVE_X11_XLIB_H
#include <X11/Xlib.h>
......@@ -123,6 +124,9 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define PRIVACY_TEXT N_( "Ask for network policy at start" )
#define RECENTPLAY_TEXT N_( "Save the recently played items in the menu" )
#define RECENTPLAY_FILTER_TEXT N_( "List of words separated by | to filter" )
#define SLIDERCOL_TEXT N_( "Define the colors of the volume slider " )
#define SLIDERCOL_LONGTEXT N_( "Define the colors of the volume slider\n" \
"By specifying the 12 numbers separated by a ';'\n" \
......@@ -209,6 +213,10 @@ vlc_module_begin();
add_bool( "qt-privacy-ask", true, NULL, PRIVACY_TEXT, PRIVACY_TEXT,
false );
add_bool( "qt-recentplay", true, NULL, RECENTPLAY_TEXT,
RECENTPLAY_TEXT, false );
add_string( "qt-recentplay-filter", NULL, NULL,
RECENTPLAY_FILTER_TEXT, RECENTPLAY_FILTER_TEXT, false );
change_internal();
set_callbacks( OpenDialogs, Close );
......@@ -483,6 +491,9 @@ static void *Init( vlc_object_t *obj )
*/
DialogsProvider::killInstance();
/* Delete the recentsMRL object before the configuration */
RecentsMRL::killInstance();
/* Delete the configuration. Application has to be deleted after that. */
delete p_intf->p_sys->mainSettings;
......
/*****************************************************************************
* recents.cpp : Recents MRL (menu)
*****************************************************************************
* Copyright © 2006-2008 the VideoLAN team
* $Id$
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* 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 "recents.hpp"
#include <QList>
#include <QString>
#include <QAction>
#include <QSettings>
#include <QRegExp>
#include <QSignalMapper>
RecentsMRL* RecentsMRL::instance = NULL;
RecentsMRL::RecentsMRL( intf_thread_t *_p_intf ) : p_intf( _p_intf )
{
stack = new QList<QString>;
signalMapper = new QSignalMapper(this);
isActive = config_GetInt( p_intf, "qt-recentplay" );
filter = new QRegExp(
qfu( config_GetPsz( p_intf, "qt-recentplay-filter" ) ),
Qt::CaseInsensitive );
load();
if ( !isActive ) clear();
}
RecentsMRL::~RecentsMRL()
{
delete stack;
delete signalMapper;
}
void RecentsMRL::addRecent( const QString &mrl )
{
if ( !isActive || filter->indexIn( mrl ) >= 0 )
return;
if( stack->contains( mrl ) )
{
stack->removeOne( mrl );
stack->prepend( mrl );
}
else
{
stack->prepend( mrl );
if( stack->size() > RECENTS_LIST_SIZE )
stack->takeLast();
}
emit updated();
save();
}
void RecentsMRL::clear()
{
if ( stack->isEmpty() )
return;
stack->clear();
emit updated();
save();
}
QList<QString> RecentsMRL::recents()
{
return QList<QString>(*stack);
}
void RecentsMRL::load()
{
QStringList list;
getSettings()->beginGroup( "RecentsMRL" );
list = getSettings()->value( "list" ).toStringList();
getSettings()->endGroup();
for( int i = 0; i < list.size(); ++i )
{
if (filter->indexIn( list.at(i) ) == -1)
stack->append( list.at(i) );
}
}
void RecentsMRL::save()
{
QStringList list;
for( int i = 0; i < stack->size(); ++i )
list << stack->at(i);
getSettings()->beginGroup( "RecentsMRL" );
getSettings()->setValue( "list", list );
getSettings()->endGroup();
}
/*****************************************************************************
* recents.cpp : Recents MRL (menu)
*****************************************************************************
* Copyright © 2006-2008 the VideoLAN team
* $Id$
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* 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 _RECENTS_H_
#define _RECENTS_H_
#include "qt4.hpp"
#include <QObject>
#include <QList>
#include <QString>
#include <QRegExp>
#include <QSignalMapper>
#define RECENTS_LIST_SIZE 8
class RecentsMRL : public QObject
{
Q_OBJECT
signals:
void updated();
public:
static RecentsMRL* getInstance( intf_thread_t* p_intf )
{
if(!instance)
instance = new RecentsMRL( p_intf );
return instance;
}
static void killInstance()
{
if( instance ) delete instance;
instance = NULL;
}
virtual ~RecentsMRL();
void addRecent( const QString & );
QList<QString> recents();
QSignalMapper *signalMapper;
private:
RecentsMRL( intf_thread_t* _p_intf );
void load();
void save();
static RecentsMRL *instance;
intf_thread_t* p_intf;
QList<QString> *stack;
bool isActive;
QRegExp *filter;
public slots:
void clear();
};
#endif
......@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>629</width>
<height>576</height>
<width>654</width>
<height>578</height>
</rect>
</property>
<property name="sizePolicy" >
......@@ -276,9 +276,6 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="artFetcher" />
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="updatesBox" >
<property name="text" >
......@@ -296,6 +293,43 @@
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="saveRecentlyPlayed" >
<property name="text" >
<string>_("Save recently played items")</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="artFetcher" />
</item>
<item row="2" column="1" colspan="2" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>_("Filter")</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="recentlyPlayedFilters" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>_("Separate words by | (without space)")</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment