TitleWidget::TitleWidget( TitleType titleType, Settings *settings, bool journeysSupported, QGraphicsItem *parent ) : QGraphicsWidget(parent), m_icon(0), m_filterWidget(0), m_journeysWidget(0), m_layout(new QGraphicsLinearLayout(Qt::Horizontal, this)), m_settings(settings), m_journeysSupported(journeysSupported), m_journeysAction(0), m_filtersAction(0) { m_type = titleType; m_layout->setContentsMargins( 1, 1, 0, 0 ); m_layout->setSpacing( 1 ); m_layout->setItemSpacing( 0, 4 ); // Initialize icon widget int iconExtend = 26 * settings->sizeFactor(); Plasma::IconWidget *icon = new Plasma::IconWidget; icon->setIcon( "public-transport-stop" ); icon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); icon->setMinimumSize( iconExtend, iconExtend ); icon->setMaximumSize( iconExtend, iconExtend ); setIcon( icon ); // Add a title label Plasma::Label *title = new Plasma::Label( this ); title->setAlignment( Qt::AlignVCenter | Qt::AlignLeft ); title->setWordWrap( false ); title->setMinimumWidth( 75 ); QLabel *_title = title->nativeWidget(); _title->setTextInteractionFlags( Qt::LinksAccessibleByMouse ); addWidget( title, WidgetTitle ); if ( m_journeysSupported ) { // Add a quick journey search widget createAndAddWidget( WidgetQuickJourneySearch ); } // Add a filter widget createAndAddWidget( WidgetFilter ); // Adjust to settings settingsChanged(); }
void TitleWidget::setJourneysSupported( bool supported ) { if ( m_journeysSupported == supported ) { return; } m_journeysSupported = supported; if ( supported ) { createAndAddWidget( WidgetQuickJourneySearch ); } else { removeWidget( WidgetQuickJourneySearch ); delete m_journeysWidget; m_journeysWidget = 0; } }
/* Open the generic config line for the toolbar, parse it * and create the widgets accordingly */ void AbstractController::parseAndCreate( const QString& config, QBoxLayout *newControlLayout ) { QStringList list = config.split( ";", QString::SkipEmptyParts ) ; for( int i = 0; i < list.count(); i++ ) { QStringList list2 = list.at( i ).split( "-" ); if( list2.count() < 1 ) { msg_Warn( p_intf, "Parsing error 1. Please, report this." ); continue; } bool ok; int i_option = WIDGET_NORMAL; buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok ); if( !ok ) { msg_Warn( p_intf, "Parsing error 2. Please, report this." ); continue; } if( list2.count() > 1 ) { i_option = list2.at( 1 ).toInt( &ok ); if( !ok ) { msg_Warn( p_intf, "Parsing error 3. Please, report this." ); continue; } } createAndAddWidget( newControlLayout, -1, i_type, i_option ); } if( buttonGroupLayout ) { newControlLayout->addLayout( buttonGroupLayout ); buttonGroupLayout = NULL; } }