[vlc-commits] Qt: allow to change the art
Angelo Haller
git at videolan.org
Tue Aug 28 19:33:49 CEST 2012
vlc | branch: master | Angelo Haller <angelo at szanni.org> | Tue Aug 28 19:32:42 2012 +0200| [b11bba670cd0f02296aaaa8ddd8c8bcf384bffdd] | committer: Jean-Baptiste Kempf
Qt: allow to change the art
Close #1624
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b11bba670cd0f02296aaaa8ddd8c8bcf384bffdd
---
modules/gui/qt4/components/info_panels.cpp | 1 +
modules/gui/qt4/components/interface_widgets.cpp | 21 +++++++++++++++++++++
modules/gui/qt4/components/interface_widgets.hpp | 1 +
modules/gui/qt4/input_manager.cpp | 18 ++++++++++++++++++
modules/gui/qt4/input_manager.hpp | 1 +
5 files changed, 42 insertions(+)
diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index bdce71c..f139116 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -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 */
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 85ce532..0c0127e 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -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 )
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 97b8bc6..0b7795e 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -248,6 +248,7 @@ public slots:
void showArtUpdate( const QString& );
void showArtUpdate( input_item_t * );
void askForUpdate();
+ void setArtFromFile();
};
#endif
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 83721ac..7590846 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -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 );
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index 84ac9f9..fd1e967 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -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 );
More information about the vlc-commits
mailing list