Commit 9c035e4d authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: put simple preferences section at the top

Close #10763 #7909, #9624
parent 13bb59c7
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include <QDir> #include <QDir>
#include <math.h> #include <math.h>
#define ICON_HEIGHT 64 #define ICON_HEIGHT 48
#ifdef _WIN32 #ifdef _WIN32
# include <vlc_windows_interfaces.h> # include <vlc_windows_interfaces.h>
...@@ -239,10 +239,10 @@ static int getDefaultAudioVolume(vlc_object_t *obj, const char *aout) ...@@ -239,10 +239,10 @@ static int getDefaultAudioVolume(vlc_object_t *obj, const char *aout)
/********************************************************************* /*********************************************************************
* The List of categories * The List of categories
*********************************************************************/ *********************************************************************/
SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) : SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
QWidget( _parent ), p_intf( _p_intf ) QWidget( _parent ), p_intf( _p_intf )
{ {
QVBoxLayout *layout = new QVBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
/* Use autoExclusive buttons and a mapper as QButtonGroup can't /* Use autoExclusive buttons and a mapper as QButtonGroup can't
set focus (keys) when it manages the buttons's exclusivity. set focus (keys) when it manages the buttons's exclusivity.
...@@ -250,7 +250,7 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma ...@@ -250,7 +250,7 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma
QSignalMapper *mapper = new QSignalMapper( layout ); QSignalMapper *mapper = new QSignalMapper( layout );
CONNECT( mapper, mapped(int), this, switchPanel(int) ); CONNECT( mapper, mapped(int), this, switchPanel(int) );
short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT; short icon_height = ICON_HEIGHT;
#define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \ #define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \
QToolButton * button = new QToolButton( this ); \ QToolButton * button = new QToolButton( this ); \
...@@ -260,7 +260,7 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma ...@@ -260,7 +260,7 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma
button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \ button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
button->setIconSize( QSize( icon_height, icon_height ) ); \ button->setIconSize( QSize( icon_height, icon_height ) ); \
button->resize( icon_height + 6 , icon_height + 6 ); \ button->resize( icon_height + 6 , icon_height + 6 ); \
button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \ button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); \
button->setAutoRaise( true ); \ button->setAutoRaise( true ); \
button->setCheckable( true ); \ button->setCheckable( true ); \
button->setAutoExclusive( true ); \ button->setAutoExclusive( true ); \
...@@ -287,10 +287,9 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma ...@@ -287,10 +287,9 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool sma
layout->setMargin( 0 ); layout->setMargin( 0 );
layout->setSpacing( 1 ); layout->setSpacing( 1 );
setMinimumWidth( 140 ); setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred);
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); setMinimumWidth( ICON_HEIGHT * 6 + 10 );
setLayout( layout ); setLayout( layout );
} }
void SPrefsCatList::switchPanel( int i ) void SPrefsCatList::switchPanel( int i )
...@@ -302,7 +301,7 @@ void SPrefsCatList::switchPanel( int i ) ...@@ -302,7 +301,7 @@ void SPrefsCatList::switchPanel( int i )
* The Panels * The Panels
*********************************************************************/ *********************************************************************/
SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf ) int _number ) : QWidget( _parent ), p_intf( _p_intf )
{ {
module_config_t *p_config; module_config_t *p_config;
ConfigControl *control; ConfigControl *control;
...@@ -930,19 +929,11 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -930,19 +929,11 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
panel_layout->addWidget( panel_label ); panel_layout->addWidget( panel_label );
panel_layout->addWidget( title_line ); panel_layout->addWidget( title_line );
if( small ) QScrollArea *scroller= new QScrollArea;
{ scroller->setWidget( panel );
QScrollArea *scroller= new QScrollArea; scroller->setWidgetResizable( true );
scroller->setWidget( panel ); scroller->setFrameStyle( QFrame::NoFrame );
scroller->setWidgetResizable( true ); panel_layout->addWidget( scroller );
scroller->setFrameStyle( QFrame::NoFrame );
panel_layout->addWidget( scroller );
}
else
{
panel_layout->addWidget( panel );
if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
}
setLayout( panel_layout ); setLayout( panel_layout );
......
...@@ -78,7 +78,7 @@ class SPrefsCatList : public QWidget ...@@ -78,7 +78,7 @@ class SPrefsCatList : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
SPrefsCatList( intf_thread_t *, QWidget *, bool ); SPrefsCatList( intf_thread_t *, QWidget * );
virtual ~SPrefsCatList() {}; virtual ~SPrefsCatList() {};
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -92,7 +92,7 @@ class SPrefsPanel : public QWidget ...@@ -92,7 +92,7 @@ class SPrefsPanel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
SPrefsPanel( intf_thread_t *, QWidget *, int, bool ); SPrefsPanel( intf_thread_t *, QWidget *, int );
virtual ~SPrefsPanel(); virtual ~SPrefsPanel();
void apply(); void apply();
void clean(); void clean();
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "components/complete_preferences.hpp" #include "components/complete_preferences.hpp"
#include "components/simple_preferences.hpp" #include "components/simple_preferences.hpp"
#include "util/searchlineedit.hpp" #include "util/searchlineedit.hpp"
#include "util/qvlcframe.hpp"
#include "main_interface.hpp" #include "main_interface.hpp"
#include <QHBoxLayout> #include <QHBoxLayout>
...@@ -44,6 +45,7 @@ ...@@ -44,6 +45,7 @@
#include <QStackedWidget> #include <QStackedWidget>
#include <QSplitter> #include <QSplitter>
#include <QShortcut> #include <QShortcut>
#include <QScrollArea>
PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
: QVLCDialog( parent, _p_intf ) : QVLCDialog( parent, _p_intf )
...@@ -96,12 +98,10 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -96,12 +98,10 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
buttonsBox->addButton( cancel, QDialogButtonBox::RejectRole ); buttonsBox->addButton( cancel, QDialogButtonBox::RejectRole );
buttonsBox->addButton( reset, QDialogButtonBox::ResetRole ); buttonsBox->addButton( reset, QDialogButtonBox::ResetRole );
simple_split_widget = new QWidget(); simple_split_widget = new QWidget();
simple_split_widget->setLayout( new QHBoxLayout ); simple_split_widget->setLayout( new QVBoxLayout );
advanced_split_widget = new QSplitter(); advanced_split_widget = new QSplitter();
advanced_split_widget->setLayout( new QHBoxLayout );
stack = new QStackedWidget(); stack = new QStackedWidget();
stack->insertWidget( SIMPLE, simple_split_widget ); stack->insertWidget( SIMPLE, simple_split_widget );
...@@ -111,9 +111,8 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -111,9 +111,8 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
simple_split_widget->layout()->addWidget( simple_panels_stack ); simple_split_widget->layout()->addWidget( simple_panels_stack );
simple_split_widget->layout()->setMargin( 0 ); simple_split_widget->layout()->setMargin( 0 );
advanced_split_widget->layout()->addWidget( advanced_tree_panel ); advanced_split_widget->addWidget( advanced_tree_panel );
advanced_split_widget->layout()->addWidget( advanced_panels_stack ); advanced_split_widget->addWidget( advanced_panels_stack );
advanced_split_widget->layout()->setMargin( 0 );
/* Layout */ /* Layout */
main_layout->addWidget( stack, 0, 0, 3, 3 ); main_layout->addWidget( stack, 0, 0, 3, 3 );
...@@ -127,9 +126,6 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -127,9 +126,6 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
simple_tree_panel->layout()->setMargin( 1 ); simple_tree_panel->layout()->setMargin( 1 );
simple_panels_stack->layout()->setContentsMargins( 6, 0, 0, 3 ); simple_panels_stack->layout()->setContentsMargins( 6, 0, 0, 3 );
b_small = (p_intf->p_sys->i_screenHeight < 750);
if( b_small ) msg_Dbg( p_intf, "Small Resolution");
setMaximumHeight( p_intf->p_sys->i_screenHeight );
for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL; for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL;
if( var_InheritBool( p_intf, "qt-advanced-pref" ) if( var_InheritBool( p_intf, "qt-advanced-pref" )
...@@ -145,7 +141,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -145,7 +141,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
BUTTONACT( simple, setSimple() ); BUTTONACT( simple, setSimple() );
BUTTONACT( all, setAdvanced() ); BUTTONACT( all, setAdvanced() );
resize( 780, sizeHint().height() ); QVLCTools::restoreWidgetPosition( p_intf, "Preferences", this, QSize( 800 , 700 ) );
} }
void PrefsDialog::setAdvanced() void PrefsDialog::setAdvanced()
...@@ -206,7 +202,7 @@ void PrefsDialog::setSimple() ...@@ -206,7 +202,7 @@ void PrefsDialog::setSimple()
/* If no simple_tree, create one, connect it */ /* If no simple_tree, create one, connect it */
if( !simple_tree ) if( !simple_tree )
{ {
simple_tree = new SPrefsCatList( p_intf, simple_tree_panel, b_small ); simple_tree = new SPrefsCatList( p_intf, simple_tree_panel );
CONNECT( simple_tree, CONNECT( simple_tree,
currentItemChanged( int ), currentItemChanged( int ),
this, changeSimplePanel( int ) ); this, changeSimplePanel( int ) );
...@@ -227,7 +223,7 @@ void PrefsDialog::changeSimplePanel( int number ) ...@@ -227,7 +223,7 @@ void PrefsDialog::changeSimplePanel( int number )
{ {
if( ! simple_panels[number] ) if( ! simple_panels[number] )
{ {
SPrefsPanel *insert = new SPrefsPanel( p_intf, simple_panels_stack, number, b_small ) ; SPrefsPanel *insert = new SPrefsPanel( p_intf, simple_panels_stack, number ) ;
simple_panels_stack->insertWidget( number, insert ); simple_panels_stack->insertWidget( number, insert );
simple_panels[number] = insert; simple_panels[number] = insert;
} }
...@@ -310,11 +306,16 @@ void PrefsDialog::save() ...@@ -310,11 +306,16 @@ void PrefsDialog::save()
if( p_intf->p_sys->p_mi ) if( p_intf->p_sys->p_mi )
p_intf->p_sys->p_mi->reloadPrefs(); p_intf->p_sys->p_mi->reloadPrefs();
accept(); accept();
QVLCTools::saveWidgetPosition( p_intf, "Preferences", this );
} }
/* Clean the preferences, dunno if it does something really */ /* Clean the preferences, dunno if it does something really */
void PrefsDialog::cancel() void PrefsDialog::cancel()
{ {
QVLCTools::saveWidgetPosition( p_intf, "Preferences", this );
reject(); reject();
} }
......
...@@ -41,6 +41,7 @@ class QLabel; ...@@ -41,6 +41,7 @@ class QLabel;
class SearchLineEdit; class SearchLineEdit;
class QStackedWidget; class QStackedWidget;
class QSplitter; class QSplitter;
class QScrollArea;
class PrefsDialog : public QVLCDialog class PrefsDialog : public QVLCDialog
{ {
...@@ -75,8 +76,6 @@ private: ...@@ -75,8 +76,6 @@ private:
QGroupBox *types; QGroupBox *types;
QRadioButton *simple,*all; QRadioButton *simple,*all;
bool b_small;
private slots: private slots:
void setAdvanced(); void setAdvanced();
void setSimple(); void setSimple();
......
...@@ -490,10 +490,6 @@ static void *Thread( void *obj ) ...@@ -490,10 +490,6 @@ static void *Thread( void *obj )
/* Initialize timers and the Dialog Provider */ /* Initialize timers and the Dialog Provider */
DialogsProvider::getInstance( p_intf ); DialogsProvider::getInstance( p_intf );
/* Detect screensize for small screens like TV or Netbooks */
p_intf->p_sys->i_screenHeight =
app.QApplication::desktop()->availableGeometry().height();
#ifdef UPDATE_CHECK #ifdef UPDATE_CHECK
/* Checking for VLC updates */ /* Checking for VLC updates */
if( var_InheritBool( p_intf, "qt-updates-notif" ) && if( var_InheritBool( p_intf, "qt-updates-notif" ) &&
......
...@@ -75,7 +75,6 @@ struct intf_sys_t ...@@ -75,7 +75,6 @@ struct intf_sys_t
QString filepath; /* Last path used in dialogs */ QString filepath; /* Last path used in dialogs */
int i_screenHeight; /* Detection of Small screens */
unsigned voutWindowType; /* Type of vout_window_t provided */ unsigned voutWindowType; /* Type of vout_window_t provided */
bool b_isDialogProvider; /* Qt mode or Skins mode */ bool b_isDialogProvider; /* Qt mode or Skins mode */
playlist_t *p_playlist; /* playlist */ playlist_t *p_playlist; /* playlist */
......
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