/************************************************ * Widget Listing: * Creation of the list of drawed lovely buttons ************************************************/ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) : QListWidget( _parent ) { /* We need the parent to know the options checked */ parent = qobject_cast<ToolbarEditDialog *>(_parent); assert( parent ); /* Normal options */ setViewMode( QListView::ListMode ); setTextElideMode( Qt::ElideNone ); setDragEnabled( true ); int icon_size = fontMetrics().height(); setIconSize( QSize( icon_size * 2, icon_size ) ); /* All the buttons do not need a special rendering */ for( int i = 0; i < BUTTON_MAX; i++ ) { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr( nameL[i] ) ); widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); widgetItem->setIcon( QIcon( iconL[i] ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); widgetItem->setToolTip( widgetItem->text() ); addItem( widgetItem ); } /* Spacers are yet again a different thing */ QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space.svg" ), qtr( "Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER ); widgetItem->setToolTip( widgetItem->text() ); widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); addItem( widgetItem ); widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space.svg" ), qtr( "Expanding Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND ); widgetItem->setToolTip( widgetItem->text() ); widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); addItem( widgetItem ); /** * For all other widgets, we create then, do a pseudo rendering in * a pixmaps for the view, and delete the object * * A lot of code is retaken from the Abstract, but not exactly... * So, rewrite. * They are better ways to deal with this, but I doubt that this is * necessary. If you feel like you have the time, be my guest. * -- * jb **/ for( int i = SPLITTER; i < SPECIAL_MAX; i++ ) { QWidget *widget = NULL; QListWidgetItem *widgetItem = new QListWidgetItem; widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); switch( i ) { case SPLITTER: { QFrame *line = new QFrame( this ); line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } widgetItem->setText( qtr("Splitter") ); break; case INPUT_SLIDER: { SeekSlider *slider = new SeekSlider( p_intf, Qt::Horizontal, this ); widget = slider; } widgetItem->setText( qtr("Time Slider") ); break; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, parent->getOptions() & WIDGET_SHINY ); widget = snd; } widgetItem->setText( qtr("Volume") ); break; case VOLUME_SPECIAL: { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr("Small Volume") ); widgetItem->setIcon( QIcon( ":/toolbar/volume-medium.svg" ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } continue; case TIME_LABEL: { QLabel *timeLabel = new QLabel( "12:42/2:12:42", this ); widget = timeLabel; } widgetItem->setText( qtr("Time") ); break; case MENU_BUTTONS: { QWidget *discFrame = new QWidget( this ); //discFrame->setLineWidth( 1 ); QHBoxLayout *discLayout = new QHBoxLayout( discFrame ); discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); QToolButton *prevSectionButton = new QToolButton( discFrame ); prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev.svg" ) ); prevSectionButton->setToolTip( qtr("Previous Chapter/Title" ) ); discLayout->addWidget( prevSectionButton ); QToolButton *nextButton = new QToolButton( discFrame ); nextButton->setIcon( QIcon( ":/toolbar/dvd_next.svg" ) ); nextButton->setToolTip( qtr("Next Chapter/Title" ) ); discLayout->addWidget( nextButton ); QToolButton *menuButton = new QToolButton( discFrame ); menuButton->setIcon( QIcon( ":/toolbar/dvd_menu.svg" ) ); menuButton->setToolTip( qtr( "Menu" ) ); discLayout->addWidget( menuButton ); widget = discFrame; } widgetItem->setText( qtr("DVD menus") ); break; case TELETEXT_BUTTONS: { QWidget *telexFrame = new QWidget( this ); QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame ); telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); QToolButton *telexOn = new QToolButton( telexFrame ); telexOn->setIcon( QIcon( ":/toolbar/tv.svg" ) ); telexLayout->addWidget( telexOn ); QToolButton *telexTransparent = new QToolButton; telexTransparent->setIcon( QIcon( ":/toolbar/tvtelx.svg" ) ); telexTransparent->setToolTip( qtr("Teletext transparency") ); telexLayout->addWidget( telexTransparent ); QSpinBox *telexPage = new QSpinBox; telexLayout->addWidget( telexPage ); widget = telexFrame; } widgetItem->setText( qtr("Teletext") ); break; case ADVANCED_CONTROLLER: { AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } widgetItem->setText( qtr("Advanced Buttons") ); break; case PLAYBACK_BUTTONS: { widget = new QWidget; DeckButtonsLayout *layout = new DeckButtonsLayout( widget ); BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward ); BrowseButton *next = new BrowseButton( widget ); RoundButton *play = new RoundButton( widget ); layout->setBackwardButton( prev ); layout->setForwardButton( next ); layout->setRoundButton( play ); } widgetItem->setText( qtr("Playback Buttons") ); break; case ASPECT_RATIO_COMBOBOX: widget = new AspectRatioComboBox( p_intf, THEMIM->getAspectRatio() ); widgetItem->setText( qtr("Aspect ratio selector") ); break; case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); widgetItem->setText( qtr("Speed selector") ); break; case TIME_LABEL_ELAPSED: widget = new QLabel( "2:42", this ); widgetItem->setText( qtr("Elapsed time") ); break; case TIME_LABEL_REMAINING: widget = new QLabel( "-2:42", this ); widgetItem->setText( qtr("Total/Remaining time") ); break; default: msg_Warn( p_intf, "This should not happen %i", i ); break; } if( widget == NULL ) continue; widgetItem->setIcon( QIcon( widget->grab() ) ); widgetItem->setToolTip( widgetItem->text() ); widget->hide(); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); delete widget; } }
QWidget *AbstractController::createWidget( buttonType_e button, int options ) { bool b_flat = options & WIDGET_FLAT; bool b_big = options & WIDGET_BIG; bool b_shiny = options & WIDGET_SHINY; bool b_special = false; QWidget *widget = NULL; switch( button ) { case PLAY_BUTTON: { PlayButton *playButton = new PlayButton; setupButton( playButton ); BUTTON_SET_BAR( playButton ); CONNECT_MAP_SET( playButton, PLAY_ACTION ); CONNECT( this, inputPlaying( bool ), playButton, updateButtonIcons( bool )); playButton->updateButtonIcons( THEMIM->getIM()->playingStatus() == PLAYING_S ); widget = playButton; } break; case STOP_BUTTON:{ NORMAL_BUTTON( STOP ); } break; case OPEN_BUTTON:{ NORMAL_BUTTON( OPEN ); } break; case OPEN_SUB_BUTTON:{ NORMAL_BUTTON( OPEN_SUB ); } break; case PREVIOUS_BUTTON:{ NORMAL_BUTTON( PREVIOUS ); } break; case NEXT_BUTTON: { NORMAL_BUTTON( NEXT ); } break; case SLOWER_BUTTON:{ NORMAL_BUTTON( SLOWER ); ENABLE_ON_INPUT( SLOWERButton ); } break; case FASTER_BUTTON:{ NORMAL_BUTTON( FASTER ); ENABLE_ON_INPUT( FASTERButton ); } break; case PREV_SLOW_BUTTON:{ QToolButtonExt *but = new QToolButtonExt; setupButton( but ); BUTTON_SET_BAR( but ); CONNECT( but, shortClicked(), THEMIM, prev() ); CONNECT( but, longClicked(), THEAM, skipBackward() ); widget = but; } break; case NEXT_FAST_BUTTON:{ QToolButtonExt *but = new QToolButtonExt; setupButton( but ); BUTTON_SET_BAR( but ); CONNECT( but, shortClicked(), THEMIM, next() ); CONNECT( but, longClicked(), THEAM, skipForward() ); widget = but; } break; case FRAME_BUTTON: { NORMAL_BUTTON( FRAME ); ENABLE_ON_VIDEO( FRAMEButton ); } break; case FULLSCREEN_BUTTON: case DEFULLSCREEN_BUTTON: { NORMAL_BUTTON( FULLSCREEN ); ENABLE_ON_VIDEO( FULLSCREENButton ); } break; case FULLWIDTH_BUTTON: { NORMAL_BUTTON( FULLWIDTH ); } break; case EXTENDED_BUTTON:{ NORMAL_BUTTON( EXTENDED ); } break; case PLAYLIST_BUTTON:{ NORMAL_BUTTON( PLAYLIST ); } break; case SNAPSHOT_BUTTON:{ NORMAL_BUTTON( SNAPSHOT ); ENABLE_ON_VIDEO( SNAPSHOTButton ); } break; case RECORD_BUTTON:{ QToolButton *recordButton = new QToolButton; setupButton( recordButton ); CONNECT_MAP_SET( recordButton, RECORD_ACTION ); BUTTON_SET_BAR( recordButton ); ENABLE_ON_INPUT( recordButton ); recordButton->setCheckable( true ); CONNECT( THEMIM->getIM(), recordingStateChanged( bool ), recordButton, setChecked( bool ) ); widget = recordButton; } break; case ATOB_BUTTON: { AtoB_Button *ABButton = new AtoB_Button; setupButton( ABButton ); ABButton->setShortcut( qtr("Shift+L") ); BUTTON_SET_BAR( ABButton ); ENABLE_ON_INPUT( ABButton ); CONNECT_MAP_SET( ABButton, ATOB_ACTION ); CONNECT( THEMIM->getIM(), AtoBchanged( bool, bool), ABButton, updateButtonIcons( bool, bool ) ); widget = ABButton; } break; case INPUT_SLIDER: { SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL, !b_shiny ); SeekPoints *chapters = new SeekPoints( this, p_intf ); CONNECT( THEMIM->getIM(), chapterChanged( bool ), chapters, update() ); slider->setChapters( chapters ); /* Update the position when the IM has changed */ CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ), slider, setPosition( float, int64_t, int ) ); /* And update the IM, when the position has changed */ CONNECT( slider, sliderDragged( float ), THEMIM->getIM(), sliderUpdate( float ) ); CONNECT( THEMIM->getIM(), cachingChanged( float ), slider, updateBuffering( float ) ); /* Give hint to disable slider's interactivity when useless */ CONNECT( THEMIM->getIM(), inputCanSeek( bool ), slider, setSeekable( bool ) ); widget = slider; } break; case MENU_BUTTONS: widget = discFrame(); break; case TELETEXT_BUTTONS: widget = telexFrame(); widget->hide(); break; case VOLUME_SPECIAL: b_special = true; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, b_shiny, b_special ); widget = snd; } break; case TIME_LABEL: { TimeLabel *timeLabel = new TimeLabel( p_intf ); widget = timeLabel; } break; case SPLITTER: { QFrame *line = new QFrame; line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } break; case ADVANCED_CONTROLLER: if( qobject_cast<AdvControlsWidget *>(this) == NULL ) { advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } break; case REVERSE_BUTTON:{ QToolButton *reverseButton = new QToolButton; setupButton( reverseButton ); CONNECT_MAP_SET( reverseButton, REVERSE_ACTION ); BUTTON_SET_BAR( reverseButton ); reverseButton->setCheckable( true ); /* You should, of COURSE change this to the correct event, when/if we have one, that tells us if trickplay is possible . */ CONNECT( this, inputIsTrickPlayable( bool ), reverseButton, setVisible( bool ) ); reverseButton->setVisible( false ); widget = reverseButton; } break; case SKIP_BACK_BUTTON: { NORMAL_BUTTON( SKIP_BACK ); ENABLE_ON_INPUT( SKIP_BACKButton ); } break; case SKIP_FW_BUTTON: { NORMAL_BUTTON( SKIP_FW ); ENABLE_ON_INPUT( SKIP_FWButton ); } break; case QUIT_BUTTON: { NORMAL_BUTTON( QUIT ); } break; case RANDOM_BUTTON: { NORMAL_BUTTON( RANDOM ); RANDOMButton->setCheckable( true ); RANDOMButton->setChecked( var_GetBool( THEPL, "random" ) ); CONNECT( THEMIM, randomChanged( bool ), RANDOMButton, setChecked( bool ) ); } break; case LOOP_BUTTON:{ LoopButton *loopButton = new LoopButton; setupButton( loopButton ); loopButton->setToolTip( qtr( "Click to toggle between loop all, loop one and no loop") ); loopButton->setCheckable( true ); { int i_state = NORMAL; if( var_GetBool( THEPL, "loop" ) ) i_state = REPEAT_ALL; if( var_GetBool( THEPL, "repeat" ) ) i_state = REPEAT_ONE; loopButton->updateButtonIcons( i_state ); } CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateButtonIcons( int ) ); CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() ); widget = loopButton; } break; case INFO_BUTTON: { NORMAL_BUTTON( INFO ); } break; case PLAYBACK_BUTTONS:{ widget = new QWidget; DeckButtonsLayout *layout = new DeckButtonsLayout( widget ); BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward ); BrowseButton *next = new BrowseButton( widget ); RoundButton *play = new RoundButton( widget ); layout->setBackwardButton( prev ); layout->setForwardButton( next ); layout->setRoundButton( play ); CONNECT_MAP_SET( prev, PREVIOUS_ACTION ); CONNECT_MAP_SET( next, NEXT_ACTION ); CONNECT_MAP_SET( play, PLAY_ACTION ); } break; case ASPECT_RATIO_COMBOBOX: widget = new AspectRatioComboBox( p_intf ); widget->setMinimumHeight( 26 ); break; case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); break; case TIME_LABEL_ELAPSED: widget = new TimeLabel( p_intf, TimeLabel::Elapsed ); break; case TIME_LABEL_REMAINING: widget = new TimeLabel( p_intf, TimeLabel::Remaining ); break; default: msg_Warn( p_intf, "This should not happen %i", button ); break; } /* Customize Buttons */ if( b_flat || b_big ) { QFrame *frame = qobject_cast<QFrame *>(widget); if( frame ) { QList<QToolButton *> allTButtons = frame->findChildren<QToolButton *>(); for( int i = 0; i < allTButtons.count(); i++ ) applyAttributes( allTButtons[i], b_flat, b_big ); } else { QToolButton *tmpButton = qobject_cast<QToolButton *>(widget); if( tmpButton ) applyAttributes( tmpButton, b_flat, b_big ); } } return widget; }