From 3a7f613664abb03bc1cd64e8e4e36fe9c9c777b4 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Wed, 4 Apr 2007 00:05:33 +0000 Subject: [PATCH] Qt4 - New Simple Preferences look'n feel. Should work without too many segfaults... Got rid of the QListWidget thing. Some look has still to be done, especially for size/margin/padding. I don't know yet if the look of the button will be like that ( flat, rounded onMouseOver, darked onCliked) --- modules/gui/qt4/components/open.hpp | 2 +- .../gui/qt4/components/simple_preferences.cpp | 72 ++++++++++--------- .../gui/qt4/components/simple_preferences.hpp | 7 +- modules/gui/qt4/dialogs/preferences.cpp | 8 +-- modules/gui/qt4/dialogs/preferences.hpp | 2 +- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/modules/gui/qt4/components/open.hpp b/modules/gui/qt4/components/open.hpp index 83ed6e9035..7cf2bb1f70 100644 --- a/modules/gui/qt4/components/open.hpp +++ b/modules/gui/qt4/components/open.hpp @@ -51,7 +51,7 @@ protected: public slots: virtual void updateMRL() = 0; signals: - void mrlUpdated(QString); + void mrlUpdated( QString ); void methodChanged( QString method ); }; diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp index 80635be0e3..4272970bed 100644 --- a/modules/gui/qt4/components/simple_preferences.cpp +++ b/modules/gui/qt4/components/simple_preferences.cpp @@ -23,10 +23,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ -#include -#include #include #include +#include +#include #include "components/simple_preferences.hpp" #include "components/preferences_widgets.hpp" @@ -34,13 +34,6 @@ #include -#include "pixmaps/hotkeys_50x50.xpm" -#include "pixmaps/audio_50x50.xpm" -#include "pixmaps/input_and_codecs_50x50.xpm" -#include "pixmaps/interface_50x50.xpm" -#include "pixmaps/subtitles_50x50.xpm" -#include "pixmaps/video_50x50.xpm" - #include "ui/sprefs_audio.h" #include "ui/sprefs_input.h" #include "ui/sprefs_video.h" @@ -48,42 +41,52 @@ #include "ui/sprefs_hotkeys.h" #include "ui/sprefs_interface.h" -#define ITEM_HEIGHT 64 +#define ICON_HEIGHT 64 +#define BUTTON_HEIGHT 76 /********************************************************************* * The List of categories *********************************************************************/ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) : - QListWidget( _parent ), p_intf( _p_intf ) + QWidget( _parent ), p_intf( _p_intf ) { - setIconSize( QSize( ITEM_HEIGHT, ITEM_HEIGHT ) ); - setViewMode(QListView::ListMode); - setMovement(QListView::Static); - setMaximumWidth(200); - setSpacing(0); -// setWordWrap(true); - setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setAlternatingRowColors( true ); - -#define ADD_CATEGORY( id, label, icon ) \ - addItem( label ); \ - item( id )->setIcon( QIcon( ":/pixmaps/" #icon ) ) ; \ - item( id )->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter ); \ - item( id )->setData( Qt::UserRole, qVariantFromValue( (int)id ) ); \ - item( id )->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); + QVBoxLayout *layout = new QVBoxLayout(); + + QButtonGroup *buttonGroup = new QButtonGroup( this ); + buttonGroup->setExclusive ( true ); + CONNECT( buttonGroup, buttonClicked ( int ), + this, switchPanel( int ) ); + +#define ADD_CATEGORY( button, label, icon, numb ) \ + QToolButton * button = new QToolButton( this ); \ + button->setIcon( QIcon( ":/pixmaps/" #icon ) ); \ + button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) ); \ + button->setText( label ); \ + button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \ + button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT); \ + button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \ + button->setAutoRaise( true ); \ + button->setCheckable( true ); \ + buttonGroup->addButton( button, numb ); \ + layout->addWidget( button ); ADD_CATEGORY( SPrefsInterface, qtr("Interface"), - spref_cone_Interface_64.png ); - ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png ); - ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png ); + spref_cone_Interface_64.png, 0 ); + ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png, 1 ); + ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png, 2 ); ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles"), - spref_cone_Subtitles_64.png ); + spref_cone_Subtitles_64.png, 3 ); ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"), - spref_cone_Input_64.png ); - ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png ); + spref_cone_Input_64.png, 4 ); + ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png, 5 ); - setCurrentRow( SPrefsInterface ); + this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + setLayout( layout ); +} + +void SPrefsCatList::switchPanel( int i ) +{ + emit currentItemChanged( i ); } /********************************************************************* @@ -304,3 +307,4 @@ void SPrefsPanel::apply() void SPrefsPanel::clean() {} + diff --git a/modules/gui/qt4/components/simple_preferences.hpp b/modules/gui/qt4/components/simple_preferences.hpp index 99d6892652..39d5756c9b 100644 --- a/modules/gui/qt4/components/simple_preferences.hpp +++ b/modules/gui/qt4/components/simple_preferences.hpp @@ -25,6 +25,7 @@ #define _SIMPLEPREFS_H_ #include +#include #include #include @@ -41,7 +42,7 @@ enum { class ConfigControl; -class SPrefsCatList : public QListWidget +class SPrefsCatList : public QWidget { Q_OBJECT; public: @@ -49,6 +50,10 @@ public: virtual ~SPrefsCatList() {}; private: intf_thread_t *p_intf; +signals: + void currentItemChanged( int ); +public slots: + void switchPanel( int ); }; class SPrefsPanel : public QWidget diff --git a/modules/gui/qt4/dialogs/preferences.cpp b/modules/gui/qt4/dialogs/preferences.cpp index d404a687e3..83ca1f7240 100644 --- a/modules/gui/qt4/dialogs/preferences.cpp +++ b/modules/gui/qt4/dialogs/preferences.cpp @@ -143,8 +143,8 @@ void PrefsDialog::setSmall() { simple_tree = new SPrefsCatList( p_intf, tree_panel ); CONNECT( simple_tree, - currentItemChanged( QListWidgetItem *, QListWidgetItem *), - this, changeSimplePanel( QListWidgetItem * ) ); + currentItemChanged( int ), + this, changeSimplePanel( int ) ); } tree_panel_l->addWidget( simple_tree ); simple_tree->show(); @@ -160,9 +160,8 @@ void PrefsDialog::setSmall() simple_panel->show(); } -void PrefsDialog::changeSimplePanel( QListWidgetItem *item ) +void PrefsDialog::changeSimplePanel( int number ) { - int number = item->data( Qt::UserRole ).toInt(); if( simple_panel ) { main_panel_l->removeWidget( simple_panel ); @@ -176,7 +175,6 @@ void PrefsDialog::changeSimplePanel( QListWidgetItem *item ) } main_panel_l->addWidget( simple_panel ); simple_panel->show(); -// panel_label->setText(qtr("Test")); //FIXME } void PrefsDialog::changePanel( QTreeWidgetItem *item ) diff --git a/modules/gui/qt4/dialogs/preferences.hpp b/modules/gui/qt4/dialogs/preferences.hpp index 55e409b100..e43256dfcb 100644 --- a/modules/gui/qt4/dialogs/preferences.hpp +++ b/modules/gui/qt4/dialogs/preferences.hpp @@ -80,7 +80,7 @@ private: static PrefsDialog *instance; private slots: void changePanel( QTreeWidgetItem * ); - void changeSimplePanel( QListWidgetItem * ); + void changeSimplePanel( int ); void setAll(); void setSmall(); void save(); -- 2.39.5