diff --git a/modules/gui/qt/dialogs/mediainfo/info_panels.cpp b/modules/gui/qt/dialogs/mediainfo/info_panels.cpp index 196dcfa26e..162cde94cd 100644 --- a/modules/gui/qt/dialogs/mediainfo/info_panels.cpp +++ b/modules/gui/qt/dialogs/mediainfo/info_panels.cpp @@ -45,6 +45,8 @@ #include #include #include +#include +#include /************************************************************************ * Single panels diff --git a/modules/gui/qt/maininterface/mainctx.cpp b/modules/gui/qt/maininterface/mainctx.cpp index 673eb235a1..b090c646bf 100644 --- a/modules/gui/qt/maininterface/mainctx.cpp +++ b/modules/gui/qt/maininterface/mainctx.cpp @@ -39,6 +39,8 @@ #include "playlist/playlist_controller.hpp" +#include "dialogs/dialogs_provider.hpp" + #include "videosurface.hpp" #include "menus/menus.hpp" // Menu creation diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml index 2f2a2ebb2f..67a1b20042 100644 --- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml +++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml @@ -109,7 +109,7 @@ FocusScope { mlModel: albumModelId indexes: selectionModel.selectedIndexes - defaultCover: VLCStyle.noArtAlbum + defaultCover: VLCStyle.noArtAlbumCover } AlbumContextMenu { diff --git a/modules/gui/qt/medialibrary/qml/MusicArtist.qml b/modules/gui/qt/medialibrary/qml/MusicArtist.qml index e016244cac..a01110ccba 100644 --- a/modules/gui/qt/medialibrary/qml/MusicArtist.qml +++ b/modules/gui/qt/medialibrary/qml/MusicArtist.qml @@ -271,7 +271,7 @@ FocusScope { mlModel: albumModel indexes: albumSelectionModel.selectedIndexes - defaultCover: VLCStyle.noArtAlbum + defaultCover: VLCStyle.noArtAlbumCover } MLAlbumTrackModel { @@ -434,7 +434,7 @@ FocusScope { titleRole: "name" - defaultCover: VLCStyle.noArtCover + defaultCover: VLCStyle.noArtArtistCover } Widgets.TableColumns { diff --git a/modules/gui/qt/medialibrary/qml/VideoAll.qml b/modules/gui/qt/medialibrary/qml/VideoAll.qml index b6cc9c2533..533315c2a3 100644 --- a/modules/gui/qt/medialibrary/qml/VideoAll.qml +++ b/modules/gui/qt/medialibrary/qml/VideoAll.qml @@ -176,6 +176,8 @@ FocusScope { indexes: modelSelect.selectedIndexes coverRole: "thumbnail" + + defaultCover: VLCStyle.noArtVideoCover } Util.SelectableDelegateModel { diff --git a/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml b/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml index 5a619c3d28..f7b34a3d8a 100644 --- a/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml +++ b/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml @@ -103,7 +103,7 @@ FocusScope { id: expand_cover_id anchors.fill: parent - source: model.thumbnail || VLCStyle.noArtCover + source: model.thumbnail || VLCStyle.noArtVideoCover radius: VLCStyle.gridCover_radius } diff --git a/modules/gui/qt/widgets/native/interface_widgets.cpp b/modules/gui/qt/widgets/native/interface_widgets.cpp index 2af1ae8782..4d2fe2afc6 100644 --- a/modules/gui/qt/widgets/native/interface_widgets.cpp +++ b/modules/gui/qt/widgets/native/interface_widgets.cpp @@ -30,362 +30,19 @@ #include "qt.hpp" #include "interface_widgets.hpp" #include "dialogs/dialogs_provider.hpp" -#include "widgets/native/customwidgets.hpp" // qtEventToVLCKey, QVLCStackedWidget +#include "player/player_controller.hpp" /* Speed control */ +#include "maininterface/mainctx.hpp" /* Interface integration */ +#include "dialogs/mediainfo/info_panels.hpp" -#include -#include +#include #include -#include #include -#if defined (QT5_HAS_X11) -# include -# include -# if defined(QT5_HAS_XCB) -# include -# endif -#endif -#ifdef QT5_HAS_WAYLAND -# include QPNI_HEADER -# include -#endif - -#if defined(_WIN32) -#include -#include -#endif - #include #include -#include #include -/********************************************************************** - * Video Widget. A simple frame on which video is drawn - * This class handles resize issues - **********************************************************************/ - -VideoWidget::VideoWidget( qt_intf_t *_p_i, QWidget* p_parent ) - : QFrame( p_parent ) , p_intf( _p_i ) -{ - /* Set the policy to expand in both directions */ - // setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - - layout = new QHBoxLayout( this ); - layout->setContentsMargins( 0, 0, 0, 0 ); - stable = NULL; - p_window = NULL; - - cursorTimer = new QTimer( this ); - cursorTimer->setSingleShot( true ); - connect( cursorTimer, &QTimer::timeout, this, &VideoWidget::hideCursor ); - cursorTimeout = var_InheritInteger( _p_i, "mouse-hide-timeout" ); - - show(); -} - -VideoWidget::~VideoWidget() -{ - /* Ensure we are not leaking the video output. This would crash. */ - assert( !stable ); - assert( !p_window ); -} - -void VideoWidget::sync( void ) -{ - /* Make sure the X server has processed all requests. - * This protects other threads using distinct connections from getting - * the video widget window in an inconsistent states. */ -#ifdef QT5_HAS_X11 - if( QX11Info::isPlatformX11() ) - XSync( QX11Info::display(), False ); -#endif -} - -/** - * Request the video to avoid the conflicts - **/ -void VideoWidget::request( struct vout_window_t *p_wnd ) -{ - assert( stable == NULL ); - assert( !p_window ); - - /* The owner of the video window needs a stable handle (WinId). Reparenting - * in Qt4-X11 changes the WinId of the widget, so we need to create another - * dummy widget that stays within the reparentable widget. */ - stable = new QWidget(); - stable->setContextMenuPolicy( Qt::PreventContextMenu ); - QPalette plt = palette(); - plt.setColor( QPalette::Window, Qt::black ); - stable->setPalette( plt ); - stable->setAutoFillBackground(true); - /* Force the widget to be native so that it gets a winId() */ - stable->setAttribute( Qt::WA_NativeWindow, true ); - /* Indicates that the widget wants to draw directly onto the screen. - Widgets with this attribute set do not participate in composition - management */ - /* This is currently disabled on X11 as it does not seem to improve - * performance, but causes the video widget to be transparent... */ -#if defined (QT5_HAS_X11) - stable->setMouseTracking( true ); - setMouseTracking( true ); -#elif defined(_WIN32) - stable->setAttribute( Qt::WA_PaintOnScreen, true ); - stable->setMouseTracking( true ); - setMouseTracking( true ); - stable->setWindowFlags( Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus ); - stable->setAttribute( Qt::WA_ShowWithoutActivating ); -#else - stable->setAttribute( Qt::WA_PaintOnScreen, true ); -#endif - layout->addWidget( stable ); - - sync(); - p_window = p_wnd; - - p_wnd->type = p_intf->voutWindowType; - switch( p_wnd->type ) - { - case VOUT_WINDOW_TYPE_XID: - p_wnd->handle.xid = stable->winId(); - p_wnd->display.x11 = NULL; - break; - case VOUT_WINDOW_TYPE_HWND: - p_wnd->handle.hwnd = (void *)stable->winId(); - break; - case VOUT_WINDOW_TYPE_NSOBJECT: - p_wnd->handle.nsobject = (void *)stable->winId(); - break; -#ifdef QT5_HAS_WAYLAND - case VOUT_WINDOW_TYPE_WAYLAND: - { - /* Ensure only the video widget is native (needed for Wayland) */ - stable->setAttribute( Qt::WA_DontCreateNativeAncestors, true); - - QWindow *window = stable->windowHandle(); - assert(window != NULL); - window->create(); - - QPlatformNativeInterface *qni = qApp->platformNativeInterface(); - assert(qni != NULL); - - p_wnd->handle.wl = static_cast( - qni->nativeResourceForWindow(QByteArrayLiteral("surface"), - window)); - p_wnd->display.wl = static_cast( - qni->nativeResourceForIntegration(QByteArrayLiteral("wl_display"))); - break; - } -#endif - default: - vlc_assert_unreachable(); - } -} - -QSize VideoWidget::physicalSize() const -{ -#ifdef QT5_HAS_X11 - if ( QX11Info::isPlatformX11() ) - { - Display *p_x_display = QX11Info::display(); - Window x_window = stable->winId(); - XWindowAttributes x_attributes; - - XGetWindowAttributes( p_x_display, x_window, &x_attributes ); - - return QSize( x_attributes.width, x_attributes.height ); - } -#endif -#if defined(_WIN32) - HWND hwnd; - RECT rect; - - QWindow *window = windowHandle(); - hwnd = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window)); - - GetClientRect(hwnd, &rect); - - return QSize( rect.right, rect.bottom ); -#endif - - QSize current_size = size(); - - /* Android-like scaling */ - current_size *= devicePixelRatioF(); - - return current_size; -} - -void VideoWidget::reportSize() -{ - if( !p_window ) - return; - - QSize size = physicalSize(); - vout_window_ReportSize( p_window, size.width(), size.height() ); -} - -/* Set the Widget to the correct Size */ -/* Function has to be called by the parent - Parent has to care about resizing itself */ -void VideoWidget::setSize( unsigned int w, unsigned int h ) -{ - /* If the size changed, resizeEvent will be called, otherwise not, - * in which case we need to tell the vout what the size actually is - */ - if( (unsigned)size().width() == w && (unsigned)size().height() == h ) - { - reportSize(); - return; - } - - resize( w, h ); - emit sizeChanged( w, h ); - /* Work-around a bug?misconception? that would happen when vout core resize - twice to the same size and would make the vout not centered. - This cause a small flicker. - See #3621 - */ - if( (unsigned)size().width() == w && (unsigned)size().height() == h ) - updateGeometry(); - sync(); -} - -bool VideoWidget::nativeEvent( const QByteArray& eventType, void* message, long* ) -{ -#if defined(QT5_HAS_X11) -# if defined(QT5_HAS_XCB) - if ( eventType == "xcb_generic_event_t" ) - { - const xcb_generic_event_t* xev = static_cast( message ); - - if ( xev->response_type == XCB_CONFIGURE_NOTIFY ) - reportSize(); - } -# endif -#endif -#ifdef _WIN32 - if ( eventType == "windows_generic_MSG" ) - { - MSG* msg = static_cast( message ); - if ( msg->message == WM_SIZE ) - reportSize(); - } -#endif - // Let Qt handle that event in any case - return false; -} - -void VideoWidget::resizeEvent( QResizeEvent *event ) -{ - QWidget::resizeEvent( event ); - - if ( p_intf->voutWindowType == VOUT_WINDOW_TYPE_XID || - p_intf->voutWindowType == VOUT_WINDOW_TYPE_HWND ) - return; - reportSize(); -} - -void VideoWidget::hideCursor() -{ - setCursor( Qt::BlankCursor ); -} - -void VideoWidget::showCursor() -{ - setCursor( Qt::ArrowCursor ); - cursorTimer->start( cursorTimeout ); -} - -int VideoWidget::qtMouseButton2VLC( Qt::MouseButton qtButton ) -{ - if( p_window == NULL ) - return -1; - switch( qtButton ) - { - case Qt::LeftButton: - return 0; - case Qt::RightButton: - return 2; - case Qt::MiddleButton: - return 1; - default: - return -1; - } -} - -void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) -{ - int vlc_button = qtMouseButton2VLC( event->button() ); - if( vlc_button >= 0 ) - { - vout_window_ReportMouseReleased( p_window, vlc_button ); - showCursor(); - event->accept(); - } - else - event->ignore(); -} - -void VideoWidget::mousePressEvent( QMouseEvent* event ) -{ - int vlc_button = qtMouseButton2VLC( event->button() ); - if( vlc_button >= 0 ) - { - vout_window_ReportMousePressed( p_window, vlc_button ); - showCursor(); - event->accept(); - } - else - event->ignore(); -} - -void VideoWidget::mouseMoveEvent( QMouseEvent *event ) -{ - if( p_window != NULL ) - { - QPointF current_pos = event->localPos(); - - current_pos *= devicePixelRatioF(); - vout_window_ReportMouseMoved( p_window, current_pos.x(), current_pos.y() ); - showCursor(); - event->accept(); - } - else - event->ignore(); -} - -void VideoWidget::mouseDoubleClickEvent( QMouseEvent *event ) -{ - int vlc_button = qtMouseButton2VLC( event->button() ); - if( vlc_button >= 0 ) - { - vout_window_ReportMouseDoubleClick( p_window, vlc_button ); - showCursor(); - event->accept(); - } - else - event->ignore(); -} - - -void VideoWidget::release( void ) -{ - msg_Dbg( p_intf, "Video is not needed anymore" ); - - if( stable ) - { - layout->removeWidget( stable ); - stable->deleteLater(); - stable = NULL; - p_window = NULL; - } - - updateGeometry(); -} - - CoverArtLabel::CoverArtLabel( QWidget *parent, qt_intf_t *_p_i ) : QLabel( parent ), p_intf( _p_i ), p_item( NULL ) { @@ -431,6 +88,15 @@ void CoverArtLabel::setItem( input_item_t *_p_item ) if ( p_item ) input_item_Hold( p_item ); } +void CoverArtLabel::mouseDoubleClickEvent( QMouseEvent *event ) +{ + if( ! p_item && qobject_cast(this->window()) == NULL ) + { + THEDP->mediaInfoDialog(); + } + event->accept(); +} + void CoverArtLabel::showArtUpdate( const QString& url ) { QPixmap pix; diff --git a/modules/gui/qt/widgets/native/interface_widgets.hpp b/modules/gui/qt/widgets/native/interface_widgets.hpp index ebaabd29bf..dc3555d193 100644 --- a/modules/gui/qt/widgets/native/interface_widgets.hpp +++ b/modules/gui/qt/widgets/native/interface_widgets.hpp @@ -29,69 +29,14 @@ # include "config.h" #endif -#include "maininterface/mainctx.hpp" /* Interface integration */ -#include "player/player_controller.hpp" /* Speed control */ - -#include "dialogs/dialogs_provider.hpp" -#include "dialogs/mediainfo/info_panels.hpp" - -#include #include class QWidget; -class QTimer; class QMouseEvent; +class MetaPanel; -struct vout_window_t; - -/******************** Video Widget ****************/ -class VideoWidget : public QFrame -{ - Q_OBJECT -public: - VideoWidget( qt_intf_t *, QWidget* p_parent ); - virtual ~VideoWidget(); - - void request( struct vout_window_t * ); - void release( void ); - void sync( void ); - -protected: - QPaintEngine *paintEngine() const Q_DECL_OVERRIDE - { - return NULL; - } - - bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; - void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; - QSize physicalSize() const; - -private: - int qtMouseButton2VLC( Qt::MouseButton ); - qt_intf_t *p_intf; - vout_window_t *p_window; - - QWidget *stable; - QLayout *layout; - QTimer *cursorTimer; - int cursorTimeout; - - void reportSize(); - void showCursor(); - -signals: - void sizeChanged( int, int ); - -public slots: - void setSize( unsigned int, unsigned int ); - -private slots: - void hideCursor(); -}; +struct qt_intf_t; +struct input_item_t; class CoverArtLabel : public QLabel { @@ -102,14 +47,8 @@ public: virtual ~CoverArtLabel(); protected: - void mouseDoubleClickEvent( QMouseEvent *event ) Q_DECL_OVERRIDE - { - if( ! p_item && qobject_cast(this->window()) == NULL ) - { - THEDP->mediaInfoDialog(); - } - event->accept(); - } + virtual void mouseDoubleClickEvent( QMouseEvent *event ) override; + private: qt_intf_t *p_intf; input_item_t *p_item; diff --git a/modules/gui/qt/widgets/qml/DragItem.qml b/modules/gui/qt/widgets/qml/DragItem.qml index 61b1d6739e..bf7f81c831 100644 --- a/modules/gui/qt/widgets/qml/DragItem.qml +++ b/modules/gui/qt/widgets/qml/DragItem.qml @@ -46,7 +46,7 @@ Item { // data from last setData readonly property alias indexesData: dragItem._data - property string defaultCover: VLCStyle.noArtCover + property string defaultCover: VLCStyle.noArtAlbumCover property string defaultText: I18n.qtr("Unknown")