[vlc-devel] [PATCH 1/2] Do not resize qt-interface larger than the current screen size
Mario Speiß
1034-135 at online.de
Sun Jul 15 17:16:22 CEST 2012
This solves ticket #3715 for the qt-interface.
Regards,
Mario
---
modules/gui/qt4/main_interface.cpp | 28 +++++++++++++++++++++++++++-
modules/gui/qt4/qt4.cpp | 6 ++++++
2 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 5025789..7e599ce 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -702,8 +702,34 @@ void MainInterface::setVideoSize( unsigned int w, unsigned int h )
void MainInterface::videoSizeChanged( int w, int h )
{
- if( !playlistWidget || playlistWidget->artContainer->currentWidget() != videoWidget )
+ if( b_autoresize && ( !playlistWidget || playlistWidget->artContainer->currentWidget() != videoWidget ) )
+ {
+ /* Calculate the future video widget position-
+ If it exceeds the current screen, rescale it to fit the screen */
+ if( var_InheritBool( p_intf, "qt-constrain-to-screen" ) )
+ {
+ QPoint pt( 0, 0 );
+ pt = stackCentralW->mapToGlobal( pt );
+ QRect rc_video = stackCentralW->rect().translated( pt );
+ QRect rc_frame = frameGeometry();
+ QRect rc_desktop = QApplication::desktop()->availableGeometry( QApplication::desktop()->screenNumber( videoWidget ) );
+ int pixel_to_right = rc_desktop.width() - pt.x() - ( rc_frame.right() - rc_video.right() );
+ int pixel_to_bottom = rc_desktop.height() - pt.y() - ( rc_frame.bottom() - rc_video.bottom() );
+ float sx = 1, sy = 1;
+ if( w > pixel_to_right )
+ sx = (float)pixel_to_right/(float)w;
+ if( h > pixel_to_bottom )
+ sy = (float)pixel_to_bottom/(float)h;
+ if( sy < 1 && sy < 1 )
+ {
+ if( sx < sy )
+ w *= sx, h *= sx;
+ else
+ w *= sy, h *= sy;
+ }
+ }
resizeStack( w, h );
+ }
}
void MainInterface::setVideoFullScreen( bool fs )
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 7adb1c5..61b6c31 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -91,6 +91,10 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
" - The video will fit to the interface size\n " \
"By default, interface resize to the native video size." )
+#define QT_CONSTRAIN_TO_SCREEN_TEXT N_( "Constrain video widget to the current screen." )
+#define QT_CONSTRAIN_TO_SCREEN_LONGTEXT N_( "Constrain the video widget size to not " \
+ "exceed the current desktop." )
+
#define TITLE_TEXT N_( "Show playing item name in window title" )
#define TITLE_LONGTEXT N_( "Show the name of the song or video in the " \
"controller window title." )
@@ -226,6 +230,8 @@ vlc_module_begin ()
add_bool( "qt-video-autoresize", true, KEEPSIZE_TEXT,
KEEPSIZE_LONGTEXT, false )
+ add_bool( "qt-constrain-to-screen", true, QT_CONSTRAIN_TO_SCREEN_TEXT,
+ QT_CONSTRAIN_TO_SCREEN_LONGTEXT, false )
add_bool( "qt-name-in-title", true, TITLE_TEXT,
TITLE_LONGTEXT, false )
add_bool( "qt-fs-controller", true, QT_FULLSCREEN_TEXT,
--
1.7.5.4
More information about the vlc-devel
mailing list