[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: update name after art in player current media changed handler

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Jan 27 07:25:01 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
ded2d32c by Fatih Uzunoglu at 2025-01-27T06:58:38+00:00
qt: update name after art in player current media changed handler

- - - - -
7f1e3dc1 by Fatih Uzunoglu at 2025-01-27T06:58:38+00:00
qt: show artwork within the notification message if applicable

- - - - -


2 changed files:

- modules/gui/qt/dialogs/systray/systray.cpp
- modules/gui/qt/player/player_controller.cpp


Changes:

=====================================
modules/gui/qt/dialogs/systray/systray.cpp
=====================================
@@ -17,9 +17,11 @@
  *****************************************************************************/
 
 #include "systray.hpp"
+
+#include <QImageReader>
+
 #include "maininterface/mainctx.hpp"
 #include "menus/menus.hpp"
-#include <QSystemTrayIcon>
 #include "playlist/playlist_controller.hpp"
 #include "player/player_controller.hpp"
 #include "dialogs/dialogs_provider.hpp"
@@ -125,8 +127,34 @@ void VLCSystray::updateTooltipName( const QString& name )
         if( ( m_notificationSetting == NOTIFICATION_ALWAYS ) ||
             ( m_notificationSetting == NOTIFICATION_MINIMIZED && (windowVisiblity == QWindow::Hidden || windowVisiblity == QWindow::Minimized)))
         {
-            showMessage( qtr( "VLC media player" ), name,
-                                 QSystemTrayIcon::NoIcon, 3000 );
+            const auto showMessageTemplate = [this, &name](const auto &icon) {
+                showMessage( qtr( "VLC media player" ), name, icon, 3000 );
+            };
+
+            assert(m_intf);
+            assert(m_intf->p_mainPlayerController);
+            const QUrl& art = m_intf->p_mainPlayerController->getArtwork();
+            if (art.isValid())
+            {
+                // If there is artwork, use it but only when it is (almost) square:
+                const QString& fileName = art.toLocalFile();
+                const QImageReader imageReader(fileName);
+                if (Q_LIKELY(imageReader.canRead()))
+                {
+                    const QSize& size = imageReader.size(); // this does not read the whole image
+                    if (Q_LIKELY(!size.isEmpty()))
+                    {
+                        const double ratio = static_cast<double>(size.width()) / size.height();
+                        if (Q_LIKELY(std::abs(ratio - 1.0) < 0.2))
+                        {
+                            showMessageTemplate(QIcon(fileName));
+                            return;
+                        }
+                    }
+                }
+            }
+
+            showMessageTemplate( QSystemTrayIcon::NoIcon );
         }
     }
     update();


=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -294,9 +294,9 @@ static  void on_player_current_media_changed(vlc_player_t *, input_item_t *new_m
     SharedInputItem newMediaPtr = SharedInputItem( new_media );
     that->callAsync([that,newMediaPtr] () {
         PlayerController* q = that->q_func();
-        that->UpdateName( newMediaPtr.get() );
         that->UpdateArt( newMediaPtr.get() );
         that->UpdateMeta( newMediaPtr.get() );
+        that->UpdateName( newMediaPtr.get() );
         that->m_url = vlc::wrap_cptr( input_item_GetURI( newMediaPtr.get() ) ).get();
 
         {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ae69d42e44f979af075467a207eba97dff89d026...7f1e3dc19e3cc4d461dbe2e005653df2e3aef4da

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ae69d42e44f979af075467a207eba97dff89d026...7f1e3dc19e3cc4d461dbe2e005653df2e3aef4da
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