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

Qt: factorize

parent a21c7bcd
...@@ -180,6 +180,12 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout, ...@@ -180,6 +180,12 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
#define ENABLE_ON_INPUT( a ) \ #define ENABLE_ON_INPUT( a ) \
CONNECT( this, inputExists( bool ), a, setEnabled( bool ) ); \ CONNECT( this, inputExists( bool ), a, setEnabled( bool ) ); \
a->setEnabled( THEMIM->getIM()->hasInput() ); /* TODO: is this necessary? when input is started before the interface? */ a->setEnabled( THEMIM->getIM()->hasInput() ); /* TODO: is this necessary? when input is started before the interface? */
#define NORMAL_BUTTON( name ) \
QToolButton * name ## Button = new QToolButton; \
setupButton( name ## Button ); \
CONNECT_MAP_SET( name ## Button, name ## _ACTION ); \
BUTTON_SET_BAR( name ## Button ); \
widget = name ## Button;
QWidget *AbstractController::createWidget( buttonType_e button, int options ) QWidget *AbstractController::createWidget( buttonType_e button, int options )
{ {
...@@ -203,72 +209,39 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -203,72 +209,39 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
} }
break; break;
case STOP_BUTTON:{ case STOP_BUTTON:{
QToolButton *stopButton = new QToolButton; NORMAL_BUTTON( STOP );
setupButton( stopButton );
CONNECT_MAP_SET( stopButton, STOP_ACTION );
BUTTON_SET_BAR( stopButton );
widget = stopButton;
} }
break; break;
case OPEN_BUTTON:{ case OPEN_BUTTON:{
QToolButton *openButton = new QToolButton; NORMAL_BUTTON( OPEN );
setupButton( openButton );
CONNECT_MAP_SET( openButton, OPEN_ACTION );
BUTTON_SET_BAR( openButton );
widget = openButton;
} }
break; break;
case PREVIOUS_BUTTON:{ case PREVIOUS_BUTTON:{
QToolButton *prevButton = new QToolButton; NORMAL_BUTTON( PREVIOUS );
setupButton( prevButton );
CONNECT_MAP_SET( prevButton, PREVIOUS_ACTION );
BUTTON_SET_BAR( prevButton );
widget = prevButton;
} }
break; break;
case NEXT_BUTTON: case NEXT_BUTTON: {
{ NORMAL_BUTTON( NEXT );
QToolButton *nextButton = new QToolButton;
setupButton( nextButton );
CONNECT_MAP_SET( nextButton, NEXT_ACTION );
BUTTON_SET_BAR( nextButton );
widget = nextButton;
} }
break; break;
case SLOWER_BUTTON:{ case SLOWER_BUTTON:{
QToolButton *slowerButton = new QToolButton; NORMAL_BUTTON( SLOWER );
setupButton( slowerButton ); ENABLE_ON_INPUT( SLOWERButton );
CONNECT_MAP_SET( slowerButton, SLOWER_ACTION );
BUTTON_SET_BAR( slowerButton );
ENABLE_ON_INPUT( slowerButton );
widget = slowerButton;
} }
break; break;
case FASTER_BUTTON:{ case FASTER_BUTTON:{
QToolButton *fasterButton = new QToolButton; NORMAL_BUTTON( FASTER );
setupButton( fasterButton ); ENABLE_ON_INPUT( FASTERButton );
CONNECT_MAP_SET( fasterButton, FASTER_ACTION );
BUTTON_SET_BAR( fasterButton );
ENABLE_ON_INPUT( fasterButton );
widget = fasterButton;
} }
break; break;
case FRAME_BUTTON: { case FRAME_BUTTON: {
QToolButton *frameButton = new QToolButton; NORMAL_BUTTON( FRAME );
setupButton( frameButton ); ENABLE_ON_VIDEO( FRAMEButton );
CONNECT_MAP_SET( frameButton, FRAME_ACTION );
BUTTON_SET_BAR( frameButton );
ENABLE_ON_VIDEO( frameButton );
widget = frameButton;
} }
break; break;
case FULLSCREEN_BUTTON:{ case FULLSCREEN_BUTTON:{
QToolButton *fullscreenButton = new QToolButton; NORMAL_BUTTON( FULLSCREEN );
setupButton( fullscreenButton ); ENABLE_ON_VIDEO( FULLSCREENButton );
CONNECT_MAP_SET( fullscreenButton, FULLSCREEN_ACTION );
BUTTON_SET_BAR( fullscreenButton );
ENABLE_ON_VIDEO( fullscreenButton );
widget = fullscreenButton;
} }
break; break;
case DEFULLSCREEN_BUTTON:{ case DEFULLSCREEN_BUTTON:{
...@@ -281,28 +254,16 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -281,28 +254,16 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
} }
break; break;
case EXTENDED_BUTTON:{ case EXTENDED_BUTTON:{
QToolButton *extSettingsButton = new QToolButton; NORMAL_BUTTON( EXTENDED );
setupButton( extSettingsButton );
CONNECT_MAP_SET( extSettingsButton, EXTENDED_ACTION );
BUTTON_SET_BAR( extSettingsButton )
widget = extSettingsButton;
} }
break; break;
case PLAYLIST_BUTTON:{ case PLAYLIST_BUTTON:{
QToolButton *playlistButton = new QToolButton; NORMAL_BUTTON( PLAYLIST );
setupButton( playlistButton );
CONNECT_MAP_SET( playlistButton, PLAYLIST_ACTION );
BUTTON_SET_BAR( playlistButton );
widget = playlistButton;
} }
break; break;
case SNAPSHOT_BUTTON:{ case SNAPSHOT_BUTTON:{
QToolButton *snapshotButton = new QToolButton; NORMAL_BUTTON( SNAPSHOT );
setupButton( snapshotButton ); ENABLE_ON_VIDEO( SNAPSHOTButton );
CONNECT_MAP_SET( snapshotButton, SNAPSHOT_ACTION );
BUTTON_SET_BAR( snapshotButton );
ENABLE_ON_VIDEO( snapshotButton );
widget = snapshotButton;
} }
break; break;
case RECORD_BUTTON:{ case RECORD_BUTTON:{
...@@ -393,29 +354,21 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -393,29 +354,21 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
} }
break; break;
case SKIP_BACK_BUTTON: { case SKIP_BACK_BUTTON: {
QToolButton *skipBakButton = new QToolButton; NORMAL_BUTTON( SKIP_BACK );
setupButton( skipBakButton ); ENABLE_ON_INPUT( SKIP_BACKButton );
CONNECT_MAP_SET( skipBakButton, SKIP_BACK_ACTION );
BUTTON_SET_BAR( skipBakButton );
ENABLE_ON_INPUT( skipBakButton );
widget = skipBakButton;
} }
break; break;
case SKIP_FW_BUTTON: { case SKIP_FW_BUTTON: {
QToolButton *skipFwButton = new QToolButton; NORMAL_BUTTON( SKIP_FW );
setupButton( skipFwButton ); ENABLE_ON_INPUT( SKIP_FWButton );
CONNECT_MAP_SET( skipFwButton, SKIP_FW_ACTION );
BUTTON_SET_BAR( skipFwButton );
ENABLE_ON_INPUT( skipFwButton );
widget = skipFwButton;
} }
break; break;
case QUIT_BUTTON: { case QUIT_BUTTON: {
QToolButton *quitButton = new QToolButton; NORMAL_BUTTON( QUIT );
setupButton( quitButton ); }
CONNECT_MAP_SET( quitButton, QUIT_ACTION ); break;
BUTTON_SET_BAR( quitButton ); case RANDOM_BUTTON: {
widget = quitButton; NORMAL_BUTTON( RANDOM );
} }
break; break;
default: default:
...@@ -442,6 +395,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -442,6 +395,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
} }
return widget; return widget;
} }
#undef NORMAL_BUTTON
void AbstractController::applyAttributes( QToolButton *tmpButton, bool b_flat, bool b_big ) void AbstractController::applyAttributes( QToolButton *tmpButton, bool b_flat, bool b_big )
{ {
......
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