Commit b11bba67 authored by Angelo Haller's avatar Angelo Haller Committed by Jean-Baptiste Kempf

Qt: allow to change the art

Close #1624
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent cfbe138d
......@@ -169,6 +169,7 @@ MetaPanel::MetaPanel( QWidget *parent,
CONNECT( seqtot_text, textEdited( QString ), this, enterEditMode() );
CONNECT( date_text, textEdited( QString ), this, enterEditMode() );
CONNECT( THEMIM->getIM(), artChanged( QString ), this, enterEditMode() );
/* CONNECT( rating_text, valueChanged( QString ), this, enterEditMode( QString ) );*/
/* We are not yet in Edit Mode */
......
......@@ -50,6 +50,7 @@
#include <QTimer>
#include <QSlider>
#include <QBitmap>
#include <QUrl>
#ifdef Q_WS_X11
# include <X11/Xlib.h>
......@@ -520,6 +521,10 @@ CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
CONNECT( action, triggered(), this, askForUpdate() );
addAction( action );
action = new QAction( qtr( "Cover art from file" ), this );
CONNECT( action, triggered(), this, setArtFromFile() );
addAction( action );
showArtUpdate( "" );
}
......@@ -570,6 +575,22 @@ void CoverArtLabel::askForUpdate()
THEMIM->getIM()->requestArtUpdate( p_item );
}
void CoverArtLabel::setArtFromFile()
{
if( !p_item )
return;
QString filePath = QFileDialog::getOpenFileName( this, qtr( "Choose Image" ),
p_intf->p_sys->filepath, qtr( "Image Files (*.gif *.jpg *.jpeg *.png)" ) );
if( filePath.isEmpty() )
return;
QString fileUrl = QUrl::fromLocalFile( filePath ).toString();
THEMIM->getIM()->setArt( p_item, fileUrl );
}
TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
: ClickableQLabel(), p_intf( _p_intf ), bufTimer( new QTimer(this) ),
buffering( false ), showBuffering(false), bufVal( -1 ), displayType( _displayType )
......
......@@ -248,6 +248,7 @@ public slots:
void showArtUpdate( const QString& );
void showArtUpdate( input_item_t * );
void askForUpdate();
void setArtFromFile();
};
#endif
......@@ -38,6 +38,7 @@
#include <vlc_aout_intf.h>
#include <QApplication>
#include <QFile>
#include <assert.h>
......@@ -719,6 +720,23 @@ void InputManager::UpdateArt()
emit artChanged( artUrl );
}
void InputManager::setArt( input_item_t *p_item, QString fileUrl )
{
if( hasInput() )
{
char *psz_cachedir = config_GetUserDir( VLC_CACHE_DIR );
QString old_url = THEMIM->getIM()->decodeArtURL( p_item );
if( old_url.startsWith( QString::fromUtf8( psz_cachedir ) ) )
QFile( old_url ).remove(); /* Purge cached artwork */
free( psz_cachedir );
input_item_SetArtURL( p_item , fileUrl.toUtf8().constData() );
UpdateArt();
}
}
inline void InputManager::UpdateStats()
{
assert( p_input );
......
......@@ -149,6 +149,7 @@ public:
bool hasVideo() { return hasInput() && b_video; }
bool hasVisualisation();
void requestArtUpdate( input_item_t *p_item );
void setArt( input_item_t *p_item, QString fileUrl );
QString getName() { return oldName; }
static const QString decodeArtURL( input_item_t *p_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