Commit 32b29b9e authored by Joseph Tulou's avatar Joseph Tulou Committed by Jean-Baptiste Kempf

implements --qt-keep-size (persistent main windows for qt4)

this patch features :
- persistent resizable main windows
- video confined to preexisting window size
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 9e22b863
......@@ -101,9 +101,17 @@ VideoWidget::~VideoWidget()
* Request the video to avoid the conflicts
**/
void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
unsigned int *pi_width, unsigned int *pi_height )
unsigned int *pi_width, unsigned int *pi_height,
bool b_keep_size )
{
msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y );
if( b_keep_size )
{
*pi_width = size().width();
*pi_height = size().height();
}
emit askVideoWidgetToShow( *pi_width, *pi_height );
if( p_vout )
{
......
......@@ -60,7 +60,7 @@ public:
virtual ~VideoWidget();
void *request( vout_thread_t *, int *, int *,
unsigned int *, unsigned int * );
unsigned int *, unsigned int *, bool );
void release( void );
int control( void *, int, va_list );
......
......@@ -99,6 +99,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* Set The Video In emebedded Mode or not */
videoEmbeddedFlag = config_GetInt( p_intf, "embedded-video" );
/* Do we confine videos within a persistent resizeable window */
b_keep_size = config_GetInt( p_intf, "qt-keep-size" );
/* Are we in the enhanced always-video mode or not ? */
i_visualmode = config_GetInt( p_intf, "qt-display-mode" );
......@@ -106,6 +109,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
settings = getSettings();
settings->beginGroup( "MainWindow" );
/**
* Retrieve saved sizes for main window
* mainBasedSize = based window size for normal mode
* (no video, no background)
* mainVideoSize = window size with video (all modes)
**/
mainBasedSize = settings->value( "mainBasedSize", QSize( 350, 120 ) ).toSize();
mainVideoSize = settings->value( "mainVideoSize", QSize( 400, 300 ) ).toSize();
/* Visualisation, not really used yet */
visualSelectorEnabled = settings->value( "visual-selector", false).toBool();
......@@ -209,6 +221,20 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
settings->beginGroup( "MainWindow" );
QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
/* resize to previously saved main window size if appicable */
if( b_keep_size )
{
if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
i_visualmode == QT_MINIMAL_MODE )
{
resize( mainVideoSize );
}
else
{
resize( mainBasedSize );
}
}
bool b_visible = settings->value( "playlist-visible", 0 ).toInt();
settings->endGroup();
......@@ -259,6 +285,9 @@ MainInterface::~MainInterface()
settings->setValue( "adv-controls",
getControlsVisibilityStatus() & CONTROLS_ADVANCED );
settings->setValue( "mainBasedSize", mainBasedSize );
settings->setValue( "mainVideoSize", mainVideoSize );
if( bgWidget )
settings->setValue( "backgroundSize", bgWidget->size() );
......@@ -397,7 +426,6 @@ void MainInterface::handleMainUi( QSettings *settings )
mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
controls, 0, Qt::AlignBottom );
/* Finish the sizing */
main->updateGeometry();
......@@ -518,6 +546,24 @@ int MainInterface::privacyDialog( QList<ConfigControl *> *controls )
QSize MainInterface::sizeHint() const
{
if( b_keep_size )
{
if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
i_visualmode == QT_MINIMAL_MODE )
{
return mainVideoSize;
}
else
{
if( VISIBLE( bgWidget) ||
( videoIsActive && videoWidget->isVisible() )
)
return mainVideoSize;
else
return mainBasedSize;
}
}
int nwidth = controls->sizeHint().width();
int nheight = controls->isVisible() ?
controls->size().height()
......@@ -596,7 +642,8 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
unsigned int *pi_height )
{
/* Request the videoWidget */
void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
void *ret = videoWidget->request( p_nvout,pi_x, pi_y,
pi_width, pi_height, b_keep_size );
if( ret ) /* The videoWidget is available */
{
/* Did we have a bg ? Hide it! */
......@@ -1071,6 +1118,27 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
e->ignore();
}
void MainInterface::resizeEvent( QResizeEvent * event )
{
if( b_keep_size )
{
if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
i_visualmode == QT_MINIMAL_MODE )
{
mainVideoSize = size();
}
else
{
if( VISIBLE( bgWidget) ||
( videoIsActive && videoWidget->isVisible() )
)
mainVideoSize = size();
else
mainBasedSize = size();
}
}
}
void MainInterface::wheelEvent( QWheelEvent *e )
{
int i_vlckey = qtWheelEventToVLCKey( e );
......
......@@ -132,6 +132,9 @@ private:
bool visualSelectorEnabled;
bool notificationEnabled; /// Systray Notifications
bool bgWasVisible;
bool b_keep_size; ///< persistent resizeable window
QSize mainBasedSize; ///< based Wnd (normal mode only)
QSize mainVideoSize; ///< Wnd with video (all modes)
int i_visualmode; ///< Visual Mode
pl_dock_e i_pl_dock;
bool isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
......@@ -142,6 +145,7 @@ private:
virtual void customEvent( QEvent *);
virtual void keyPressEvent( QKeyEvent *);
virtual void wheelEvent( QWheelEvent * );
virtual void resizeEvent( QResizeEvent * event );
public slots:
void undockPlaylist();
......
......@@ -84,6 +84,12 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define MINIMIZED_LONGTEXT N_( "VLC will start with just an icon in " \
"your taskbar" )
#define KEEPSIZE_TEXT N_( "Confine video to a persistent resizable window" )
#define KEEPSIZE_LONGTEXT N_( "You can choose to confine a video to a " \
"persistent resizeable window or let it freely " \
"expand to match the original size. " \
"By default, videos are expanded to original size." )
#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 " \
"controler window title." )
......@@ -176,6 +182,8 @@ vlc_module_begin ()
SYSTRAY_LONGTEXT, false);
add_bool( "qt-start-minimized", false, NULL, MINIMIZED_TEXT,
MINIMIZED_LONGTEXT, true);
add_bool( "qt-keep-size", false, NULL, KEEPSIZE_TEXT,
KEEPSIZE_LONGTEXT, false )
add_bool( "qt-name-in-title", true, NULL, TITLE_TEXT,
TITLE_LONGTEXT, false );
add_bool( "qt-fs-controller", true, NULL, QT_FULLSCREEN_TEXT,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment