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