[vlc-commits] [Git][videolan/vlc][master] 16 commits: qt: center the cover art in media info dialog

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Sep 22 12:58:26 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
d1ea3d94 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: center the cover art in media info dialog

- - - - -
d692c527 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: make comments text edit expand freely in media info dialog

Instead of wasting space, comments text edit can expand and use
the available space. This should not be a problem, since it is
the last text edit.

- - - - -
cdd328fd by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: location label should not expand in media info dialog

- - - - -
69ff6e32 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: close button should not expand in media info dialog

- - - - -
d8d2dbcb by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: adjust enable instead of visible for fingerprint button in media info dialog

Hiding it makes the cover art appear unsymmetrical.

- - - - -
7585b4ad by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: match minimum width of fingerprint button to cover art

so that in normal cases its width becomes equal to cover
art's width

- - - - -
b5ff2edb by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: center align fingerprint button in media info dialog

so that it becomes aligned with the cover art

- - - - -
f1d06e91 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: disable context menu in media info dialog's cover art when there is no item

if there is no input item, context menu is not relevant therefore should not
be shown.

- - - - -
b8ccddd6 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: do not signal input changed before the input item changes in PlayerController

- - - - -
4082d52a by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: use `inputChanged()` signal for input item update handler in media info dialog

- - - - -
f81bc67c by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: prevent updating the item if it is the same in CoverArtLabel

- - - - -
e20a77b8 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: make `showArtUpdate()` method private in CoverArtLabel

Having this public does not make sense, because there
is already the input item. Having this method public
enables synchronization issues (different art than
the art associated with the input item).

- - - - -
d537c3b2 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: remove the weirdly positioned and often empty URL label in media info dialog

Keeping this is a problem to make the artwork vertically centered.

- - - - -
aa456bb7 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: align fingerprint button with text input in media info dialog

- - - - -
d7d05c47 by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: align art cover with fingerprint button in media info dialog

- - - - -
eafb925f by Fatih Uzunoglu at 2024-09-22T12:36:47+00:00
qt: display meta URL in `Metadata` tab in media info dialog

Since the label is removed from the general tab due to lack
of space, it is now displayed in the extra meta data tab.

- - - - -


6 changed files:

- modules/gui/qt/dialogs/mediainfo/info_panels.cpp
- modules/gui/qt/dialogs/mediainfo/info_panels.hpp
- modules/gui/qt/dialogs/mediainfo/mediainfo.cpp
- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/widgets/native/interface_widgets.cpp
- modules/gui/qt/widgets/native/interface_widgets.hpp


Changes:

=====================================
modules/gui/qt/dialogs/mediainfo/info_panels.cpp
=====================================
@@ -132,25 +132,21 @@ MetaPanel::MetaPanel( QWidget *parent,
     ADD_META( VLC_META_LANGUAGE, language_text, 7, -1 ); line++;
     ADD_META( VLC_META_PUBLISHER, publisher_text, 0, 7 );
 
+    /* Fingerprint button on the same line */
     fingerprintButton = new QPushButton( qtr("&Fingerprint") );
     fingerprintButton->setToolTip( qtr( "Find meta data using audio fingerprinting" ) );
-    fingerprintButton->setVisible( false );
-    metaLayout->addWidget( fingerprintButton, line, 7 , 3, -1 );
+    fingerprintButton->setEnabled( false );
+    metaLayout->addWidget( fingerprintButton, line++, 7 , 1, -1, Qt::AlignCenter );
     connect( fingerprintButton, &QPushButton::clicked, this, &MetaPanel::fingerprint );
 
-    line++;
-
-    lblURL = new QLabel;
-    lblURL->setOpenExternalLinks( true );
-    lblURL->setTextFormat( Qt::RichText );
-    lblURL->setMaximumWidth( 128 );
-    metaLayout->addWidget( lblURL, line -1, 7, 1, -1 );
+    /* ART_URL */
+    art_cover = new CoverArtLabel( this, p_intf );
+    metaLayout->addWidget( art_cover, line, 7, 6, 3, Qt::AlignCenter );
 
     ADD_META( VLC_META_COPYRIGHT, copyright_text, 0,  7 ); line++;
 
-    /* ART_URL */
-    art_cover = new CoverArtLabel( this, p_intf );
-    metaLayout->addWidget( art_cover, line, 7, 6, 3, Qt::AlignLeft );
+    fingerprintButton->setMinimumWidth( std::max( fingerprintButton->minimumSizeHint().width(),
+                                                  art_cover->minimumSizeHint().width() ) );
 
     ADD_META( VLC_META_ENCODED_BY, encodedby_text, 0, 7 ); line++;
 
@@ -161,7 +157,6 @@ MetaPanel::MetaPanel( QWidget *parent,
     description_text->setAcceptRichText( false );
     metaLayout->addWidget( description_text, line, 0, 1, 7 );
     connect( description_text, &QTextEdit::textChanged, this, &MetaPanel::enterEditMode );
-    line++;
 
     /* VLC_META_SETTING: Useless */
     /* ADD_META( TRACKID )  Useless ? */
@@ -226,7 +221,7 @@ void MetaPanel::update( const SharedInputItem& p_item )
     psz_meta = input_item_GetURI( inputItem );
     if( !EMPTY_STR( psz_meta ) )
         emit uriSet( qfu( psz_meta ) );
-    fingerprintButton->setVisible( Chromaprint::isSupported( QString( psz_meta ) ) );
+    fingerprintButton->setEnabled( Chromaprint::isSupported( QString( psz_meta ) ) );
     free( psz_meta );
 
     /* Other classic though */
@@ -251,35 +246,9 @@ void MetaPanel::update( const SharedInputItem& p_item )
         nowplaying_text->setText( qfu( psz_meta ) );
     free( psz_meta );
 
-    /* URL */
-    psz_meta = input_item_GetURL( inputItem );
-    if( !EMPTY_STR( psz_meta ) )
-    {
-        QString newURL = qfu(psz_meta);
-        if( currentURL != newURL )
-        {
-            currentURL = newURL;
-            lblURL->setText( "<a href='" + currentURL + "'>" +
-                             currentURL.remove( QRegularExpression( QStringLiteral( ".*://" ) ) ) + "</a>" );
-        }
-    }
-    free( psz_meta );
 #undef UPDATE_META_INT
 #undef UPDATE_META
 
-    // If a artURL is available as a local file, directly display it !
-
-    QString file;
-    char *psz_art = input_item_GetArtURL( inputItem );
-    if( psz_art )
-    {
-        char *psz = vlc_uri2path( psz_art );
-        free( psz_art );
-        file = qfu( psz );
-        free( psz );
-    }
-
-    art_cover->showArtUpdate( file );
     art_cover->setItem( p_item );
 }
 
@@ -352,8 +321,7 @@ void MetaPanel::clear()
     publisher_text->clear();
     encodedby_text->clear();
     art_cover->clear();
-    fingerprintButton->setVisible( false );
-    lblURL->clear();
+    fingerprintButton->setEnabled( false );
 
     setEditMode( false );
     emit uriSet( "" );
@@ -447,6 +415,9 @@ void ExtraMetaPanel::update( input_item_t *p_item )
     if( char const* psz_disc = vlc_meta_Get( p_meta,  vlc_meta_DiscNumber ) )
         add_row( VLC_META_DISCNUMBER, psz_disc );
 
+    if( char const* psz_url = vlc_meta_Get( p_meta, vlc_meta_URL ) )
+        add_row( VLC_META_URL, psz_url );
+
     char ** ppsz_keys = vlc_meta_CopyExtraNames( p_meta );
     if( ppsz_keys )
     {


=====================================
modules/gui/qt/dialogs/mediainfo/info_panels.hpp
=====================================
@@ -76,7 +76,6 @@ private:
     QLineEdit *encodedby_text;
     CoverArtLabel *art_cover;
 
-    QLabel   *lblURL;
     QString  currentURL;
 
     QPushButton *fingerprintButton;


=====================================
modules/gui/qt/dialogs/mediainfo/mediainfo.cpp
=====================================
@@ -77,9 +77,11 @@ MediaInfoDialog::MediaInfoDialog(qt_intf_t *_p_intf,
     saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
     saveMetaButton->hide();
     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
+    closeButton->setMaximumWidth(closeButton->minimumSizeHint().width());
     closeButton->setDefault( true );
 
     QLabel *uriLabel = new QLabel( qtr( "Location:" ) );
+    uriLabel->setMaximumWidth(uriLabel->minimumSizeHint().width());
     uriLine = new QLineEdit;
     uriLine->setReadOnly( true );
 
@@ -111,9 +113,9 @@ MediaInfoDialog::MediaInfoDialog(qt_intf_t *_p_intf,
          **/
         connect( THEMIM, &PlayerController::infoChanged,
                   IP, &InfoPanel::update, Qt::DirectConnection  );
-        connect( THEMIM, &PlayerController::currentMetaChanged,
-            MP, [this](input_item_t* const inputItem) {
-                MP->update( SharedInputItem { inputItem } );
+        connect( THEMIM, &PlayerController::inputChanged,
+            MP, [this]() {
+                MP->update( SharedInputItem { THEMIM->getInput() } );
             }, Qt::DirectConnection  );
         connect( THEMIM, &PlayerController::currentMetaChanged,
                   EMP, &ExtraMetaPanel::update, Qt::DirectConnection );


=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -278,9 +278,11 @@ static  void on_player_current_media_changed(vlc_player_t *, input_item_t *new_m
     if (!new_media)
     {
         that->callAsync([that] () {
+            {
+                vlc_player_locker lock{ that->m_player };
+                that->m_currentItem.reset(nullptr);
+            }
             emit that->q_func()->inputChanged(false);
-            vlc_player_locker lock{ that->m_player };
-            that->m_currentItem.reset(nullptr);
         });
         return;
     }


=====================================
modules/gui/qt/widgets/native/interface_widgets.cpp
=====================================
@@ -46,7 +46,6 @@
 CoverArtLabel::CoverArtLabel( QWidget *parent, qt_intf_t *_p_i )
     : QLabel( parent ), p_intf( _p_i )
 {
-    setContextMenuPolicy( Qt::ActionsContextMenu );
     connect( THEMIM, QOverload<QString>::of(&PlayerController::artChanged),
              this, QOverload<const QString&>::of(&CoverArtLabel::showArtUpdate) );
 
@@ -63,13 +62,9 @@ CoverArtLabel::CoverArtLabel( QWidget *parent, qt_intf_t *_p_i )
     connect( action, &QAction::triggered, this, &CoverArtLabel::setArtFromFile );
     addAction( action );
 
-    p_item = SharedInputItem{ THEMIM->getInput() } ;
-    if( p_item )
-    {
-        showArtUpdate( p_item.get() );
-    }
-    else
-        showArtUpdate( "" );
+    setItem( SharedInputItem{ THEMIM->getInput() } );
+    if ( !p_item )
+        showArtUpdate( );
 }
 
 CoverArtLabel::~CoverArtLabel()
@@ -81,7 +76,17 @@ CoverArtLabel::~CoverArtLabel()
 
 void CoverArtLabel::setItem( const SharedInputItem& _p_item )
 {
+    if( _p_item == p_item )
+        return;
+
     p_item = _p_item;
+
+    if( p_item )
+        setContextMenuPolicy( Qt::ActionsContextMenu );
+    else
+        setContextMenuPolicy( Qt::NoContextMenu );
+
+    showArtUpdate( );
 }
 
 void CoverArtLabel::mouseDoubleClickEvent( QMouseEvent *event )
@@ -109,26 +114,23 @@ void CoverArtLabel::showArtUpdate( const QString& url )
     setPixmap( pix );
 }
 
-void CoverArtLabel::showArtUpdate( input_item_t *_p_item )
+void CoverArtLabel::showArtUpdate( )
 {
-    /* not for me */
-    if ( _p_item != p_item.get() )
-        return;
-
     QString url;
-    if ( _p_item ) url = THEMIM->decodeArtURL( _p_item );
+    if ( p_item ) url = THEMIM->decodeArtURL( p_item.get() );
     showArtUpdate( url );
 }
 
 void CoverArtLabel::askForUpdate()
 {
+    assert( p_item );
+
     THEMIM->requestArtUpdate( p_item.get(), true );
 }
 
 void CoverArtLabel::setArtFromFile()
 {
-    if( !p_item )
-        return;
+    assert( p_item );
 
     QUrl fileUrl = QFileDialog::getOpenFileUrl( this, qtr( "Choose Cover Art" ),
         p_intf->p_mi->getDialogFilePath(), qtr( "Image Files (*.gif *.jpg *.jpeg *.png)" ) );


=====================================
modules/gui/qt/widgets/native/interface_widgets.hpp
=====================================
@@ -55,9 +55,10 @@ private:
     qt_intf_t *p_intf;
     SharedInputItem p_item;
 
-public slots:
     void showArtUpdate( const QString& );
-    void showArtUpdate( input_item_t * );
+    void showArtUpdate( );
+
+public slots:
     void askForUpdate();
     void setArtFromFile();
     void clear();



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/469a286ed898a8fef278f822f41333d519c3826c...eafb925f027f71311cf26eab73cf72eab8e869b5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/469a286ed898a8fef278f822f41333d519c3826c...eafb925f027f71311cf26eab73cf72eab8e869b5
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list