Commit df98cd39 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: possibility of having a small Qt dialog for preferences on small screens like EEE-PC and TVs.

parent 1f71a52e
...@@ -38,18 +38,18 @@ ...@@ -38,18 +38,18 @@
#include <QToolButton> #include <QToolButton>
#include <QButtonGroup> #include <QButtonGroup>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QScrollArea>
#include <QtAlgorithms> #include <QtAlgorithms>
#include <string> #include <string>
#define ICON_HEIGHT 64 #define ICON_HEIGHT 64
#define BUTTON_HEIGHT 74
/********************************************************************* /*********************************************************************
* The List of categories * The List of categories
*********************************************************************/ *********************************************************************/
SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) : SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
QWidget( _parent ), p_intf( _p_intf ) QWidget( _parent ), p_intf( _p_intf )
{ {
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
...@@ -59,13 +59,15 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -59,13 +59,15 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
CONNECT( buttonGroup, buttonClicked ( int ), CONNECT( buttonGroup, buttonClicked ( int ),
this, switchPanel( int ) ); this, switchPanel( int ) );
short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
#define ADD_CATEGORY( button, label, icon, numb ) \ #define ADD_CATEGORY( button, label, icon, numb ) \
QToolButton * button = new QToolButton( this ); \ QToolButton * button = new QToolButton( this ); \
button->setIcon( QIcon( ":/pixmaps/prefs/" #icon ) ); \ button->setIcon( QIcon( ":/pixmaps/prefs/" #icon ) ); \
button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) ); \
button->setText( label ); \ button->setText( label ); \
button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \ button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT); \ button->setIconSize( QSize( icon_height, icon_height ) ); \
button->resize( icon_height + 6 , icon_height + 6 ); \
button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \ button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
button->setAutoRaise( true ); \ button->setAutoRaise( true ); \
button->setCheckable( true ); \ button->setCheckable( true ); \
...@@ -100,7 +102,7 @@ void SPrefsCatList::switchPanel( int i ) ...@@ -100,7 +102,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 ) : QWidget( _parent ), p_intf( _p_intf ) int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
{ {
module_config_t *p_config; module_config_t *p_config;
ConfigControl *control; ConfigControl *control;
...@@ -556,8 +558,20 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -556,8 +558,20 @@ 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 );
panel_layout->addWidget( panel );
if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 ); 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 );
}
setLayout( panel_layout ); setLayout( panel_layout );
} }
......
...@@ -94,7 +94,7 @@ class SPrefsCatList : public QWidget ...@@ -94,7 +94,7 @@ class SPrefsCatList : public QWidget
{ {
Q_OBJECT; Q_OBJECT;
public: public:
SPrefsCatList( intf_thread_t *, QWidget *); SPrefsCatList( intf_thread_t *, QWidget *, bool );
virtual ~SPrefsCatList() {}; virtual ~SPrefsCatList() {};
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -108,7 +108,7 @@ class SPrefsPanel : public QWidget ...@@ -108,7 +108,7 @@ class SPrefsPanel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
SPrefsPanel( intf_thread_t *, QWidget *, int ); SPrefsPanel( intf_thread_t *, QWidget *, int, bool );
virtual ~SPrefsPanel(); virtual ~SPrefsPanel();
void apply(); void apply();
void clean(); void clean();
......
...@@ -98,7 +98,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -98,7 +98,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
main_layout->setColumnMinimumWidth( 1, 10 ); main_layout->setColumnMinimumWidth( 1, 10 );
main_layout->setColumnStretch( 0, 1 ); main_layout->setColumnStretch( 0, 1 );
main_layout->setColumnStretch( 1, 0 ); main_layout->setColumnStretch( 1, 0 );
main_layout->setColumnStretch( 2, 3 ); main_layout->setColumnStretch( 2, 10 );
main_layout->setRowStretch( 2, 4 ); main_layout->setRowStretch( 2, 4 );
...@@ -109,6 +109,9 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -109,6 +109,9 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
tree_panel_l->setMargin( 1 ); tree_panel_l->setMargin( 1 );
main_panel_l->setLayoutMargins( 6, 0, 0, 3, 3 ); main_panel_l->setLayoutMargins( 6, 0, 0, 3, 3 );
b_small = (p_intf->p_sys->i_screenHeight < 750);
if( b_small ) msg_Dbg( p_intf, "Small");
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( config_GetInt( p_intf, "qt-advanced-pref" ) == 1 ) if( config_GetInt( p_intf, "qt-advanced-pref" ) == 1 )
...@@ -123,7 +126,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -123,7 +126,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
BUTTONACT( small, setSmall() ); BUTTONACT( small, setSmall() );
BUTTONACT( all, setAdvanced() ); BUTTONACT( all, setAdvanced() );
resize( 750, sizeHint().height() ); resize( 780, sizeHint().height() );
} }
void PrefsDialog::setAdvanced() void PrefsDialog::setAdvanced()
...@@ -176,7 +179,7 @@ void PrefsDialog::setSmall() ...@@ -176,7 +179,7 @@ void PrefsDialog::setSmall()
/* 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, tree_panel ); simple_tree = new SPrefsCatList( p_intf, tree_panel, b_small );
CONNECT( simple_tree, CONNECT( simple_tree,
currentItemChanged( int ), currentItemChanged( int ),
this, changeSimplePanel( int ) ); this, changeSimplePanel( int ) );
...@@ -193,7 +196,7 @@ void PrefsDialog::setSmall() ...@@ -193,7 +196,7 @@ void PrefsDialog::setSmall()
if( !current_simple_panel ) if( !current_simple_panel )
{ {
current_simple_panel = current_simple_panel =
new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat ); new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat, b_small );
simple_panels[SPrefsDefaultCat] = current_simple_panel; simple_panels[SPrefsDefaultCat] = current_simple_panel;
main_panel_l->addWidget( current_simple_panel ); main_panel_l->addWidget( current_simple_panel );
} }
...@@ -211,7 +214,7 @@ void PrefsDialog::changeSimplePanel( int number ) ...@@ -211,7 +214,7 @@ void PrefsDialog::changeSimplePanel( int number )
current_simple_panel = simple_panels[number]; current_simple_panel = simple_panels[number];
if( !current_simple_panel ) if( !current_simple_panel )
{ {
current_simple_panel = new SPrefsPanel( p_intf, main_panel, number ); current_simple_panel = new SPrefsPanel( p_intf, main_panel, number, b_small );
simple_panels[number] = current_simple_panel; simple_panels[number] = current_simple_panel;
main_panel_l->addWidget( current_simple_panel ); main_panel_l->addWidget( current_simple_panel );
} }
......
...@@ -81,6 +81,8 @@ private: ...@@ -81,6 +81,8 @@ private:
static PrefsDialog *instance; static PrefsDialog *instance;
bool b_small;
private slots: private slots:
void setAdvanced(); void setAdvanced();
void setSmall(); void setSmall();
......
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