void setupHud(QGraphicsWidget* parent)
    {
        // Play/Pause
        GraphicsHudButton* playPauseButton = new GraphicsHudButton;
        playPauseButton->setDefaultAction(mPlayPauseAction);

        // Seek
        mSeekSlider = new GraphicsHudSlider;
        mSeekSlider->setPageStep(5000);
        mSeekSlider->setSingleStep(200);
        QObject::connect(mSeekSlider, SIGNAL(actionTriggered(int)),
            q, SLOT(slotSeekSliderActionTriggered(int)));
        QObject::connect(mMediaObject, SIGNAL(tick(qint64)),
            q, SLOT(slotTicked(qint64)));
        QObject::connect(mMediaObject, SIGNAL(totalTimeChanged(qint64)),
            q, SLOT(updatePlayUi()));
        QObject::connect(mMediaObject, SIGNAL(seekableChanged(bool)),
            q, SLOT(updatePlayUi()));

        // Mute
        GraphicsHudButton* muteButton = new GraphicsHudButton;
        muteButton->setDefaultAction(mMuteAction);

        // Volume
        mVolumeSlider = new GraphicsHudSlider;
        mVolumeSlider->setMinimumWidth(100);
        mVolumeSlider->setRange(0, 100);
        mVolumeSlider->setPageStep(5);
        mVolumeSlider->setSingleStep(1);
        QObject::connect(mVolumeSlider, SIGNAL(valueChanged(int)),
            q, SLOT(slotVolumeSliderChanged(int)));
        QObject::connect(mAudioOutput, SIGNAL(volumeChanged(qreal)),
            q, SLOT(slotOutputVolumeChanged(qreal)));

        // Layout
        QGraphicsWidget* hudContent = new QGraphicsWidget;
        QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(hudContent);
        layout->addItem(playPauseButton);
        layout->addItem(mSeekSlider);
        layout->setStretchFactor(mSeekSlider, 5);
        layout->addItem(muteButton);
        layout->addItem(mVolumeSlider);
        layout->setStretchFactor(mVolumeSlider, 1);

        // Create hud
        mHud = new GraphicsHudWidget(parent);
        mHud->init(hudContent, GraphicsHudWidget::OptionNone);
        mHud->setZValue(1);

        // Init floater
        mFloater = new GraphicsWidgetFloater(parent);
        mFloater->setChildWidget(mHud);
        mFloater->setAlignment(Qt::AlignJustify | Qt::AlignBottom);
    }
示例#2
0
AlbumsFilterBar::AlbumsFilterBar( QGraphicsItem *parent, Qt::WindowFlags wFlags )
    : QGraphicsWidget( parent, wFlags )
    , m_editor( new KLineEdit )
    , m_closeIcon( new Plasma::IconWidget( KIcon("dialog-close"), QString(), this ) )
{
    QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget( this );
    editProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    editProxy->setWidget( m_editor );

    m_editor->installEventFilter( this );
    m_editor->setAttribute( Qt::WA_NoSystemBackground );
    m_editor->setAutoFillBackground( true );
    m_editor->setClearButtonShown( true );
    m_editor->setClickMessage( i18n( "Filter Albums" ) );
    m_editor->setContentsMargins( 0, 0, 0, 0 );

    QSizeF iconSize = m_closeIcon->sizeFromIconSize( 16 );
    m_closeIcon->setMaximumSize( iconSize );
    m_closeIcon->setMinimumSize( iconSize );

    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Horizontal, this );
    layout->setSpacing( 1 );
    layout->addItem( editProxy );
    layout->addItem( m_closeIcon );
    layout->setStretchFactor( editProxy, 100 );
    layout->setAlignment( editProxy, Qt::AlignCenter );
    layout->setAlignment( m_closeIcon, Qt::AlignCenter );
    layout->setContentsMargins( 0, 2, 0, 0 );

    m_closeIcon->setToolTip( i18n( "Close" ) );
    connect( m_closeIcon, SIGNAL(clicked()), SIGNAL(closeRequested()) );
    connect( m_editor, SIGNAL(textChanged(QString)), SIGNAL(filterTextChanged(QString)) );
}
示例#3
0
文件: window.cpp 项目: Andreas665/qt
Window::Window(QGraphicsWidget *parent) : QGraphicsWidget(parent, Qt::Window)
{
//! [0]
    QGraphicsLinearLayout *windowLayout = new QGraphicsLinearLayout(Qt::Vertical);
    QGraphicsLinearLayout *linear = new QGraphicsLinearLayout(windowLayout);
    LayoutItem *item = new LayoutItem;
    linear->addItem(item);
    linear->setStretchFactor(item, 1);
//! [0]

//! [1]
    item = new LayoutItem;
    linear->addItem(item);
    linear->setStretchFactor(item, 3);
    windowLayout->addItem(linear);
//! [1]

//! [2]
    QGraphicsGridLayout *grid = new QGraphicsGridLayout(windowLayout);
    item = new LayoutItem;
    grid->addItem(item, 0, 0, 4, 1);
    item = new LayoutItem;
    item->setMaximumHeight(item->minimumHeight());
    grid->addItem(item, 0, 1, 2, 1, Qt::AlignVCenter);
    item = new LayoutItem;
    item->setMaximumHeight(item->minimumHeight());
    grid->addItem(item, 2, 1, 2, 1, Qt::AlignVCenter);
    item = new LayoutItem;
    grid->addItem(item, 0, 2);
    item = new LayoutItem;
    grid->addItem(item, 1, 2);
    item = new LayoutItem;
    grid->addItem(item, 2, 2);
    item = new LayoutItem;
    grid->addItem(item, 3, 2);
    windowLayout->addItem(grid);
//! [2]

//! [3]
    setLayout(windowLayout);
    setWindowTitle(tr("Basic Graphics Layouts Example"));
//! [3]

}
void FmFileView::initMainWidget()
{
	QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this );
	vLayout->setOrientation( Qt::Vertical );

	mWidget = new FmFileBrowseWidget( this );
	mWidget->setObjectName( "mainWidget" );
	setStyle( FmFileBrowseWidget::ListStyle );
	setSelectable( false );

	vLayout->addItem( mWidget );
	//set stretch factor to file browser widget, so that it could fully cover the client area.
	vLayout->setStretchFactor( mWidget, 1 );

	setLayout( vLayout );
	
    connect( mWidget, SIGNAL( startSearch( QString ) ),
             this, SLOT( startSearch( QString ) ) );
    connect( mWidget, SIGNAL( setEmptyMenu( bool ) ),
             this, SLOT( on_mainWidget_setEmptyMenu( bool ) ) );
    connect( mWidget, SIGNAL( setTitle( QString ) ),
             this, SLOT( on_mainWidget_setTitle( QString ) ) );
}
QtSyncStatusLogView::QtSyncStatusLogView(QtSyncStatusLog& log, QGraphicsItem *parent)
    : HbView(parent),
      mSyncLog(log)
{
    setTitle("QtSyncStatusSpy");
    createMenu();
    
    QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
    HbScrollArea* scrollArea = new HbScrollArea(this);
    scrollArea->setScrollDirections(Qt::Vertical);
    QGraphicsLinearLayout* layout2 = new QGraphicsLinearLayout(Qt::Vertical);
    QGraphicsWidget* content = new QGraphicsWidget(this);
    
    mTextItem = new HbTextItem();
    layout2->addItem(mTextItem);
    layout2->setContentsMargins(5, 5, 5, 5);
    content->setLayout(layout2);
    scrollArea->setContentWidget(content);

    layout->addItem(scrollArea);
    layout->setStretchFactor(scrollArea, 1);
    setLayout(layout);
}
void MpFetcherTestAppView::createLayout()
{
    qDebug() <<  "MpFetcherTestAppView::createLayout";

    QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);

    if (layout)
    {
        QGraphicsLinearLayout *topLayout = new QGraphicsLinearLayout(Qt::Vertical);

        if (topLayout)
        {
            topLayout->addStretch(5);

            mResultEdit = new HbLineEdit;
            HbLabel* label = new HbLabel("Result:");
            if (mResultEdit && label)
            {
                topLayout->addItem(label);
                mResultEdit->setMaxRows(5);
                topLayout->addItem(mResultEdit);
            }

            mErrorCodeEdit = new HbLineEdit;
            label = new HbLabel("Error code:");
            if (mErrorCodeEdit && label)
            {
                topLayout->addItem(label);
                topLayout->addItem(mErrorCodeEdit);
            }

            mErrorEdit = new HbLineEdit;
            label = new HbLabel("Error description:");
            if (mErrorEdit && label)
            {
                topLayout->addItem(label);
                mErrorEdit->setMaxRows(5);
                topLayout->addItem(mErrorEdit);
            }

            layout->addItem(topLayout);
            layout->setStretchFactor(topLayout, 5);
        }

        QGraphicsLinearLayout *bottomLayout = new QGraphicsLinearLayout(Qt::Vertical);

        if (bottomLayout)
        {
            bottomLayout->addStretch();
            HbPushButton* button = new HbPushButton("Fetch song");
            if (button)
            {
                connect(button, SIGNAL(clicked()), SLOT(fetchSong()));
                bottomLayout->addItem(button);
            }
            
            QGraphicsLinearLayout *playLayout = new QGraphicsLinearLayout(Qt::Horizontal);
            HbPushButton* playButton = new HbPushButton("Play song");
            if (playButton)
            {
                connect(playButton, SIGNAL(clicked()), SLOT(viewSong()));
                playLayout->addItem(playButton);
            }
            HbPushButton* viewButton = new HbPushButton("Play song caged");
            if (viewButton)
            {
                connect(viewButton, SIGNAL(clicked()), SLOT(viewSongCaged()));
                playLayout->addItem(viewButton);
            }
            bottomLayout->addItem(playLayout);
            
            QGraphicsLinearLayout *hsLayout = new QGraphicsLinearLayout(Qt::Horizontal);
            HbPushButton* homeScreenButton = new HbPushButton("HS Widget MainView");
            if (homeScreenButton)
            {
                connect(homeScreenButton, SIGNAL(clicked()), SLOT(launchHomeScreen()));
                hsLayout->addItem(homeScreenButton);
            }
                     
            HbPushButton* homeScreenButtonNPV = new HbPushButton("HS Widget NowPlayingView");
            if (homeScreenButtonNPV)
            {
                connect(homeScreenButtonNPV, SIGNAL(clicked()), SLOT(launchHomeScreenNowPlaying()));
                hsLayout->addItem(homeScreenButtonNPV);
            }
            
            HbPushButton* homeScreenButtonNPVS = new HbPushButton("HS Widget NPV Shuffle");
            if (homeScreenButtonNPVS)
            {
                connect(homeScreenButtonNPVS, SIGNAL(clicked()), SLOT(launchHomeScreenNPShuffle()));
                hsLayout->addItem(homeScreenButtonNPVS);
            }
            bottomLayout->addItem(hsLayout);
            
            HbPushButton* NowPlayingButton = new HbPushButton("NPV File Activity");
            if (NowPlayingButton)
            {
                connect(NowPlayingButton, SIGNAL(clicked()), SLOT(playNPVSong()));
                bottomLayout->addItem(NowPlayingButton);
            }
            QGraphicsLinearLayout *goomLayout = new QGraphicsLinearLayout(Qt::Horizontal);
            HbPushButton* endButton = new HbPushButton("End MP");
            if (endButton)
            {
                connect(endButton, SIGNAL(clicked()), SLOT(endMP()));
                goomLayout->addItem(endButton);
            }
                     
            HbPushButton* killButton = new HbPushButton("Kill MP");
            if (killButton)
            {
                connect(killButton, SIGNAL(clicked()), SLOT(killMP()));
                goomLayout->addItem(killButton);
            }
            
            bottomLayout->addItem(goomLayout);
            
            layout->addItem(bottomLayout);
        }

        setLayout(layout); // Takes ownership of layout
    }
}
示例#7
0
文件: options.cpp 项目: f0x/kcd
Options::Options(QGraphicsWidget *parent)
    : QGraphicsWidget(parent),
     // m_volume(new Plasma::IconWidget(this)),
      //m_meter(new KcdMeter(this)),
      //m_tracklist(new Plasma::IconWidget(this)),
      m_albumText(new Plasma::Label(this)),
      m_random(new Plasma::IconWidget(this)),
      m_loop(new Plasma::IconWidget(this))
{
 
   //m_volume->setIcon("audio-volume-high");
   //connect (m_volume, SIGNAL(clicked()), this, SLOT(handleVolume()));
   //m_volume->setMinimumSize(m_random->sizeFromIconSize(10));

   //m_meter->setMinimum(0);
   //m_meter->setMaximum(10);
   //m_meter->setMeterType(Plasma::Meter::BarMeterHorizontal);
   //connect (m_meter, SIGNAL(valueChanged(int)), this, SIGNAL(volumeChanged(int)));

   //m_tracklist->setIcon("format-list-unordered");
   //m_tracklist->setMinimumSize(m_random->sizeFromIconSize(10));
   //connect(m_tracklist, SIGNAL(clicked()), this, SIGNAL(showTrackList()));

   Plasma::ToolTipContent data;
   //data.setMainText(i18n("Tracklist"));
   //data.setSubText(i18n("View the tracklist"));
   //data.setImage(KIcon("format-list-unordered").pixmap(IconSize(KIconLoader::Desktop)));
   //Plasma::ToolTipManager::self()->setContent(m_tracklist, data);

   m_random->setIcon("roll");
   connect(m_random, SIGNAL(clicked()), this, SLOT(randomTrack()));
   
   data.setMainText(i18n("Random - off"));
   data.setSubText(i18n("Play random track"));
   data.setImage(KIcon("roll").pixmap(IconSize(KIconLoader::Desktop)));
   Plasma::ToolTipManager::self()->setContent(m_random, data);

   m_loop->setIcon("object-rotate-right");
   connect(m_loop, SIGNAL(clicked()), this, SLOT(loopList()));

   data.setMainText(i18n("Repeat - off"));
   data.setSubText(i18n("Play again the tracklist"));
   data.setImage(KIcon("object-rotate-right").pixmap(IconSize(KIconLoader::Desktop)));
   Plasma::ToolTipManager::self()->setContent(m_loop, data);

   QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
   layout->setOrientation(Qt::Horizontal);
   //layout->addItem(m_volume);
   //layout->addItem(m_meter);
   layout->addItem(m_albumText);
   layout->addItem(m_random);
   layout->addItem(m_loop);
   layout->setAlignment(m_albumText, Qt::AlignLeft);
   layout->setAlignment(m_random, Qt::AlignRight);
   layout->setAlignment(m_loop, Qt::AlignRight);
   layout->setStretchFactor(m_random, 0);
   layout->setStretchFactor(m_loop, 0);
   setPreferredHeight(35);
   
   //layout->setItemSpacing(0, 50);
  
  
   //layout->addItem(m_tracklist);
   //layout->setStretchFactor(m_meter, 20);
   //layout->setSpacing(0);
   //layout->setAlignment(m_random, Qt::AlignRight);
   //layout->setAlignment(m_loop, Qt::AlignRight);
   //layout->setAlignment(m_tracklist, Qt::AlignRight);
   //layout->setItemSpacing(1, 10);
   setLayout(layout);

   randomFlag = false;
   loopFlag = false;
   //volumeFlag = true;

   
}