Exemple #1
0
Transport::Transport(Ui::CommAudioClass* gui, QWidget* parent)
    : QObject(parent), ui(gui), playingState(STOPPED)
{   
    connect(ui->playPushButton, SIGNAL(clicked()), 
            this, SLOT(onPlayClicked()));
    connect(ui->stopPushButton, SIGNAL(clicked()), 
            this, SLOT(onStopClicked()));
    connect(ui->previousPushButton, SIGNAL(clicked()), 
            this, SLOT(onPreviousClicked()));
    connect(ui->nextPushButton, SIGNAL(clicked()), 
            this, SLOT(onNextClicked()));
    connect(ui->shufflePushButton, SIGNAL(clicked()), 
            this, SLOT(onShuffleClicked()));
    connect(ui->loopPushButton, SIGNAL(clicked()), 
            this, SLOT(onLoopClicked()));
    connect(this, SIGNAL(songChanged()),
            parent, SLOT(changeDisplayedSong()));
    connect(this, SIGNAL(songStopped()),
            parent, SLOT(clearDisplayedSong()));
    
    QSettings settings;

    loop = !settings.value("loop", false).toBool();
    onLoopClicked();
    shuffle = !settings.value("shuffle", false).toBool();
    onShuffleClicked();
}
RadioControls::RadioControls()
{
    QHBoxLayout* h = new QHBoxLayout( this );
    h->setContentsMargins( 12, 0, 12, 0 );
    h->setSpacing( 5 );

    h->addWidget( ui.play = new ImageButton( ":/RadioControls/play/rest.png" ) );
    ui.play->setPixmap( QPixmap(":/RadioControls/play/onpress.png"), QIcon::Off, QIcon::Active );

    ui.play->setPixmap( QPixmap(":/RadioControls/stop/rest.png"), QIcon::On );
    ui.play->setPixmap( QPixmap(":/RadioControls/stop/onpress.png"), QIcon::On, QIcon::Active );
    ui.play->setCheckable( true );
    ui.play->setChecked( false );

    h->addWidget( ui.skip = new ImageButton( ":/RadioControls/skip/rest.png" ) );

    ui.skip->setPixmap( QPixmap(":/RadioControls/skip/onpress.png"), QIcon::Off, QIcon::Active );
    ui.play->setCheckable( true );
    ui.play->setChecked( false );

    connect( &The::radio(), SIGNAL(stopped()), SLOT(onRadioStopped()) );
    connect( &The::radio(), SIGNAL(tuningIn( const RadioStation&)), SLOT( onRadioTuningIn( const RadioStation&)));
    connect( ui.play, SIGNAL( clicked()), SLOT( onPlayClicked()) );
    connect( ui.skip, SIGNAL( clicked()), SIGNAL(skip()));

    setFixedWidth( sizeHint().width() );

    setAutoFillBackground( false );
    UnicornWidget::paintItBlack( this );
}
PlaybackControlsWidget::PlaybackControlsWidget( QWidget* parent )
                       :StylableWidget( parent )
{
    QHBoxLayout* h = new QHBoxLayout( this );
    h->setContentsMargins( 12, 0, 12, 0 );
    h->setSpacing( 5 );
    
    h->addWidget( ui.love = new QPushButton( tr( "love" ) ));
    ui.love->setObjectName( "love" );
    
    h->addWidget( ui.ban = new QPushButton( tr( "ban" ) ));
    ui.ban->setObjectName( "ban" );
    
    h->addWidget( ui.play = new QPushButton( tr( "play" ) ));
    ui.play->setObjectName( "play" );
    ui.play->setCheckable( true );
    ui.play->setChecked( false );
    
    h->addWidget( ui.skip = new QPushButton( tr( "skip" ) ));
    ui.skip->setObjectName( "skip" );
    
	connect( radio, SIGNAL(stopped()), SLOT(onRadioStopped()) );
    connect( radio, SIGNAL(tuningIn( const RadioStation&)), SLOT( onRadioTuningIn( const RadioStation&)));
	connect( ui.play, SIGNAL( clicked()), SLOT( onPlayClicked()) );
    connect( ui.skip, SIGNAL( clicked()), radio, SLOT(skip()));

    setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
    
}
bool
GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
         event->type() != QEvent::MouseMove &&
         event->type() != QEvent::MouseButtonPress &&
         event->type() != QEvent::Leave )
        return false;

    bool hoveringArtist = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }

    if ( event->type() == QEvent::MouseMove )
    {
        if ( hoveringArtist )
            m_view->setCursor( Qt::PointingHandCursor );
        else
            m_view->setCursor( Qt::ArrowCursor );

        foreach ( const QModelIndex& idx, m_playButton.keys() )
        {
            if ( index != idx )
                m_playButton.take( idx )->deleteLater();
        }

        if ( !m_playButton.contains( index ) && !m_spinner.contains( index ) && !m_pauseButton.contains( index ) )
        {
            foreach ( ImageButton* button, m_playButton )
                button->deleteLater();
            m_playButton.clear();

            // only add the play button to a album picture if the party mode is not active
            const bool isPartyMode = TomahawkSettings::instance()->partyModeEnabled();
            if ( !isPartyMode )
            {
                ImageButton* button = new ImageButton( m_view );
                button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButton, TomahawkUtils::Original, QSize( 48, 48 ) ) );
                button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButtonPressed, TomahawkUtils::Original, QSize( 48, 48 ) ), QIcon::Off, QIcon::Active );
                button->setFixedSize( 48, 48 );
                button->move( option.rect.center() - QPoint( 23, 23 ) );
                button->setContentsMargins( 0, 0, 0, 0 );
                button->setFocusPolicy( Qt::NoFocus );
                button->installEventFilter( this );
                button->show();

                NewClosure( button, SIGNAL( clicked( bool ) ),
                            const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

                m_playButton[ index ] = button;
            }
        }
Exemple #5
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , _ui(new Ui::MainWindow)
    , _midiOutput(new CxxMidi::Output::Default(0))
    , _midiPlayer(new CxxMidi::Player::Asynchronous(_midiOutput))
    , _midiFile(0)
    , _sliderLocked(false)
{
    _ui->setupUi(this);

    this->createMenuBar();
    this->centralWidget()->setDisabled(true);
    this->resize(this->minimumSizeHint());

    _midiPlayer->setCallbackHeartbeat(&_playerHeartbeatCallback);
    connect(&_playerHeartbeatCallback,SIGNAL(playerTimeChanged(CxxMidi::Time::Point)),
            this,SLOT(updateTimeCode(CxxMidi::Time::Point)),Qt::QueuedConnection);

    _midiPlayer->setCallbackFinished(&_playerFinishedCallback);
    connect(&_playerFinishedCallback,SIGNAL(playerFinished()),
            this,SLOT(playerFinished()),Qt::QueuedConnection);

    connect(_ui->doubleSpinBoxSpeed,SIGNAL(valueChanged(double)),
            this,SLOT(onSpeedChange(double)));

    connect(_ui->pushButtonPlay,SIGNAL(clicked()),
            this,SLOT(onPlayClicked()));

    connect(_ui->pushButtonPause,SIGNAL(clicked()),
            this,SLOT(onPauseClicked()));

    connect(_ui->sliderTimeline,SIGNAL(sliderPressed()),
            this,SLOT(onTimeSliderPressed()));

    connect(_ui->sliderTimeline,SIGNAL(sliderReleased()),
            this,SLOT(onTimeSliderReleased()));


    // first argument is file name
    if(QApplication::arguments().size() >=2 )
    {
        QString fileName = QApplication::arguments().at(1);
        this->openFile(fileName);
    }

    // second argument is output num
    if(QApplication::arguments().size() >=3)
    {
        int num = QApplication::arguments().at(2).toInt();
        this->setOutput(num);
        _outputsActionGroup->actions()[num]->setChecked(true);
    }

    // auto play
    if( QApplication::arguments().size() >= 2)
        _midiPlayer->play();
}
Exemple #6
0
PlayCtlWidget::PlayCtlWidget(QWidget *parent)
    : PlayCtlWidgetIF(parent), m_playing(false)
{
    setupUi(this);
    btn_bw->setIcon(QIcon(Helper::getIconPath("bwd.png")));
    connect(btn_bw, SIGNAL(clicked()), this, SLOT(onBackwardClicked()));
    btn_fw->setIcon(QIcon(Helper::getIconPath("fwd.png")));
    connect(btn_fw, SIGNAL(clicked()), this, SLOT(onForwardClicked()));
    btn_play->setIcon(QIcon(Helper::getIconPath("play.png")));
    connect(btn_play, SIGNAL(clicked()), this, SLOT(onPlayClicked()));
    btn_stop->setIcon(QIcon(Helper::getIconPath("stop.png")));
    connect(btn_stop, SIGNAL(clicked()), this, SLOT(onStopClicked()));
}
RestStateWidget::RestStateWidget( QWidget* parent )
        : WatermarkWidget( parent )
        , m_play_enabled( true )
{
    ui.setupUi( this );

    setFontPixelSize( ui.hello, k_helloFontSize );
    setFontPixelSize( ui.label1, k_standardFontSize );
    setFontPixelSize( ui.label2, k_standardFontSize );

    #ifdef Q_WS_MAC
        QSize s = QPixmap(":/mac/RestStateWidgetCombo.png").size();
        ui.label2->setText( tr("or listen to your music in %1.", "%1 is a media player").arg( "iTunes" ) );

    #elif defined WIN32

        updatePlayerNames();

        // the long line is too wide and makes this->sizeHint huge unless we wordwrap
        ui.label2->setWordWrap( true );

        // Dirty hack to get heights looking the same on Windows
        ui.combo->setFixedHeight( 20 );
        ui.edit->setFixedHeight( 20 );
        ui.play->setFixedHeight( 22 );

    #elif defined LINUX

        ui.label2->hide(); //no plugins on Linux

        QList<QWidget*> widgets; widgets << ui.edit << ui.combo << ui.play;
        int h = 0;
        foreach ( QWidget* w, widgets )
            h = qMax( w->height(), h );
        foreach ( QWidget* w, widgets )
            w->setFixedHeight( h );

    #endif

    connect( ui.edit, SIGNAL( returnPressed() ), ui.play, SLOT( animateClick() ) );
    connect( ui.edit, SIGNAL( textChanged( QString ) ), SLOT( onEditTextChanged( QString ) ) );
    connect( ui.play, SIGNAL( clicked() ), SLOT( onPlayClicked() ) );

    ui.hello->setText( tr("Hello %1,").arg( The::currentUser().username() ) );
    ui.combo->setCurrentIndex( CurrentUserSettings().value( "RestStateWidgetComboIndex", 0 ).toInt() );

    setFocusProxy( ui.edit );

    ui.edit->installEventFilter( this );
}
bool
AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
         event->type() != QEvent::MouseMove &&
         event->type() != QEvent::MouseButtonPress &&
         event->type() != QEvent::Leave )
        return false;

    bool hoveringArtist = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }

    if ( event->type() == QEvent::MouseMove )
    {
        foreach ( const QModelIndex& idx, m_playButton.keys() )
        {
            if ( index != idx )
                m_playButton.take( idx )->deleteLater();
        }

        if ( !m_playButton.contains( index ) && !m_spinner.contains( index ) && !m_pauseButton.contains( index ) )
        {
            foreach ( ImageButton* button, m_playButton )
                button->deleteLater();
            m_playButton.clear();

            ImageButton* button = new ImageButton( m_view );
            button->setPixmap( RESPATH "images/play-rest.png" );
            button->setPixmap( RESPATH "images/play-pressed.png", QIcon::Off, QIcon::Active );
            button->setFixedSize( 48, 48 );
            button->move( option.rect.center() - QPoint( 23, 23 ) );
            button->setContentsMargins( 0, 0, 0, 0 );
            button->setFocusPolicy( Qt::NoFocus );
            button->installEventFilter( this );
            button->show();

            NewClosure( button, SIGNAL( clicked( bool ) ),
                        const_cast<AlbumItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

            m_playButton[ index ] = button;
        }
bool
GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
            event->type() != QEvent::MouseMove &&
            event->type() != QEvent::MouseButtonPress &&
            event->type() != QEvent::Leave )
        return false;

    bool hoveringArtist = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }

    if ( event->type() == QEvent::MouseMove )
    {
        if ( hoveringArtist )
            m_view->setCursor( Qt::PointingHandCursor );
        else
            m_view->setCursor( Qt::ArrowCursor );

        foreach ( const QModelIndex& idx, m_playButton.keys() )
        {
            if ( index != idx )
                m_playButton.take( idx )->deleteLater();
        }

        if ( !m_playButton.contains( index ) && !m_spinner.contains( index ) && !m_pauseButton.contains( index ) )
        {
            foreach ( ImageButton* button, m_playButton )
                button->deleteLater();
            m_playButton.clear();

            ImageButton* button = new ImageButton( m_view );
            button->setPixmap( RESPATH "images/play-rest.png" );
            button->setPixmap( RESPATH "images/play-pressed.png", QIcon::Off, QIcon::Active );
            button->setFixedSize( 48, 48 );
            button->move( option.rect.center() - QPoint( 23, 23 ) );
            button->setContentsMargins( 0, 0, 0, 0 );
            button->setFocusPolicy( Qt::NoFocus );
            button->installEventFilter( this );
            button->show();

            NewClosure( button, SIGNAL( clicked( bool ) ),
                        const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

            m_playButton[ index ] = button;
        }

        if ( m_hoveringOver != index || ( !hoveringArtist && m_hoveringOver.isValid() ) )
        {
            emit updateIndex( m_hoveringOver );

            if ( hoveringArtist )
                m_hoveringOver = index;
            else
                m_hoveringOver = QPersistentModelIndex();

            emit updateIndex( index );
        }

        if ( m_hoverIndex != index )
        {
            if ( m_hoverIndex.isValid() )
            {
                QTimeLine* fadeOut = createTimeline( QTimeLine::Forward );
                _detail::Closure* c = NewClosure( fadeOut, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) );
                c->setAutoDelete( false );
                c = NewClosure( fadeOut, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) );
                c->setAutoDelete( false );
                m_hoverFaders[ m_hoverIndex ] = fadeOut;
                fadeOut->start();
            }

            emit updateIndex( m_hoverIndex );
            m_hoverIndex = index;

            QTimeLine* fadeIn = createTimeline( QTimeLine::Backward );
            _detail::Closure* c = NewClosure( fadeIn, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
            c->setAutoDelete( false );
            c = NewClosure( fadeIn, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
            c->setAutoDelete( false );

            m_hoverFaders[ index ] = fadeIn;
            fadeIn->start();

            emit updateIndex( index );
        }
MpdClientDialog::MpdClientDialog(QWidget *parent)
    : QDialog(parent, Qt::FramelessWindowHint)
    , vbox_(this)
    , titlebar_widget_(this)
    , titlebar_layout_(&titlebar_widget_)
    , titlebar_icon_(0)
    , titlebar_label_(0)
    , close_button_("", 0)
    , title_layout_(0)
    , title_icon_(0)
    , title_label_(0)
    , artist_layout_(0)
    , artist_icon_(0)
    , artist_label_(0)
    , hor_separator_(this)
    , button_widget_(this)
    , button_layout_(&button_widget_)
    , prev_button_("", 0)
    , play_button_("", 0)
    , stop_button_("", 0)
    , next_button_("", 0)
    , mode_button_("", 0)
{
    QIcon icon;
    QSize icon_size;

    setModal(true);

    setAutoFillBackground(true);
    setBackgroundRole(QPalette::Base);

    titlebar_icon_.setPixmap(QPixmap(":/images/music_player_small.png"));
    QFont titlebar_font(titlebar_label_.font());
    titlebar_font.setPointSize(25);
    titlebar_label_.setFont(titlebar_font);
    titlebar_label_.setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    titlebar_label_.setIndent(10);
    titlebar_label_.setText(QCoreApplication::tr("Music Player"));

    icon = loadIcon(":/images/close.png", icon_size);
    close_button_.setStyleSheet(PAGE_BUTTON_STYLE);
    close_button_.setIconSize(icon_size);
    close_button_.setIcon(icon);
    close_button_.setFocusPolicy(Qt::NoFocus);

    titlebar_layout_.setSpacing(2);
    titlebar_layout_.setContentsMargins(5, 0, 5, 0);
    titlebar_layout_.addWidget(&titlebar_icon_, 10);
    titlebar_layout_.addWidget(&titlebar_label_, 300);
    titlebar_layout_.addWidget(&close_button_);

    titlebar_widget_.setAutoFillBackground(true);
    titlebar_widget_.setBackgroundRole(QPalette::Dark);
    titlebar_widget_.setContentsMargins(0, 0, 0, 0);
    titlebar_widget_.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);

    title_icon_.setPixmap(QPixmap(":/images/title.png"));
    QFont title_font(title_label_.font());
    title_font.setPointSize(28);
    title_label_.setFont(title_font);
    title_label_.setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    title_label_.setContentsMargins(10, 0, 5, 0);
    title_label_.setMaximumWidth(400);

    title_layout_.setSpacing(2);
    title_layout_.setContentsMargins(5, 5, 5, 0);
    title_layout_.addWidget(&title_icon_, 10);
    title_layout_.addWidget(&title_label_, 200);

    artist_icon_.setPixmap(QPixmap(":/images/artist.png"));
    QFont artist_font(artist_label_.font());
    artist_font.setPointSize(20);
    artist_label_.setFont(artist_font);
    artist_label_.setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    artist_label_.setContentsMargins(10, 0, 5, 0);
    artist_label_.setMaximumWidth(400);

    artist_layout_.setSpacing(2);
    artist_layout_.setContentsMargins(5, 0, 5, 0);
    artist_layout_.addWidget(&artist_icon_, 10);
    artist_layout_.addWidget(&artist_label_, 200);

    album_icon_.setPixmap(QPixmap(":/images/album.png"));
    QFont album_font(album_label_.font());
    album_font.setPointSize(20);
    album_label_.setFont(album_font);
    album_label_.setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    album_label_.setContentsMargins(10, 0, 5, 0);
    album_label_.setMaximumWidth(400);

    album_layout_.setSpacing(2);
    album_layout_.setContentsMargins(5, 0, 5, 5);
    album_layout_.addWidget(&album_icon_, 10);
    album_layout_.addWidget(&album_label_, 200);

    progress_bar_.setMinimum(0);
    progress_bar_.setMaximum(0);
    progress_bar_.setContentsMargins(2, 1, 2, 1);

    QFont progress_font(progress_label_.font());
    progress_font.setPointSize(12);
    progress_font.setBold(true);
    progress_label_.setFont(progress_font);
    progress_label_.setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    progress_label_.setIndent(10);

    progress_layout_.setSpacing(2);
    progress_layout_.setContentsMargins(5, 0, 5, 5);
    progress_layout_.addWidget(&progress_bar_);
    progress_layout_.addWidget(&progress_label_);

    hor_separator_.setFixedHeight(1);
    hor_separator_.setFocusPolicy(Qt::NoFocus);
    hor_separator_.setFrameShape(QFrame::HLine);
    hor_separator_.setAutoFillBackground(true);
    hor_separator_.setBackgroundRole(QPalette::Light);

    icon = loadIcon(":/images/play_prev.png", icon_size);
    prev_button_.setStyleSheet(PAGE_BUTTON_STYLE);
    prev_button_.setIconSize(icon_size);
    prev_button_.setIcon(icon);
    prev_button_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    prev_button_.setFocusPolicy(Qt::TabFocus);

    play_button_.setStyleSheet(PAGE_BUTTON_STYLE);
    play_button_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    play_button_.setFocusPolicy(Qt::TabFocus);

    stop_button_.setStyleSheet(PAGE_BUTTON_STYLE);
    stop_button_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    stop_button_.setFocusPolicy(Qt::TabFocus);

    icon = loadIcon(":/images/play_next.png", icon_size);
    next_button_.setStyleSheet(PAGE_BUTTON_STYLE);
    next_button_.setIconSize(icon_size);
    next_button_.setIcon(icon);
    next_button_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    next_button_.setFocusPolicy(Qt::TabFocus);

    mode_button_.setStyleSheet(PAGE_BUTTON_STYLE);
    mode_button_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    mode_button_.setFocusPolicy(Qt::TabFocus);

    button_layout_.setSpacing(2);
    button_layout_.setContentsMargins(5, 5, 5, 5);
    button_layout_.addStretch();
    button_layout_.addWidget(&prev_button_);
    button_layout_.addWidget(&play_button_);
    button_layout_.addWidget(&stop_button_);
    button_layout_.addWidget(&next_button_);
    button_layout_.addWidget(&mode_button_);
    button_layout_.addStretch();

    button_widget_.setContentsMargins(0, 0, 0, 0);
    button_widget_.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);

    vbox_.setSpacing(0);
    vbox_.setContentsMargins(0, 0, 0, 0);
    vbox_.addWidget(&titlebar_widget_);
    vbox_.addLayout(&title_layout_);
    vbox_.addLayout(&artist_layout_);
    vbox_.addLayout(&album_layout_);
    vbox_.addLayout(&progress_layout_);
    vbox_.addWidget(&hor_separator_);
    vbox_.addWidget(&button_widget_);

    connect(&close_button_, SIGNAL(clicked()), this, SLOT(done()));
    connect(&prev_button_, SIGNAL(clicked()), this, SLOT(onPrevClicked()));
    connect(&play_button_, SIGNAL(clicked()), this, SLOT(onPlayClicked()));
    connect(&stop_button_, SIGNAL(clicked()), this, SLOT(onStopClicked()));
    connect(&next_button_, SIGNAL(clicked()), this, SLOT(onNextClicked()));
    connect(&mode_button_, SIGNAL(clicked()), this, SLOT(onModeClicked()));

    timer_ = new QTimer(this);
    timer_->setSingleShot(false);
    timer_->setInterval(2 * 1000);

    QMpdClient &mpdClient = QMpdClient::instance();
    connect(&mpdClient, SIGNAL(stateChanged(QMpdStatus::State)), this, SLOT(onStateChanged(QMpdStatus::State)));
    connect(&mpdClient, SIGNAL(modeChanged(QMpdStatus::Mode)), this, SLOT(onModeChanged(QMpdStatus::Mode)));
    connect(&mpdClient, SIGNAL(songChanged(const QMpdSong &)), this, SLOT(onSongChanged(const QMpdSong &)));
    connect(&mpdClient, SIGNAL(elapsedSecondsAtStatusChange(int)), this, SLOT(onElapsedSecondsAtStatusChange(int)));
    connect(timer_, SIGNAL(timeout()), this, SLOT(onTimeout()));

    onStateChanged(mpdClient.status().state());
    onModeChanged(mpdClient.status().mode());
    onSongChanged(mpdClient.song());
    onElapsedSecondsAtStatusChange(mpdClient.status().elapsedSeconds());

    show();
    sys::SysStatus::instance().setSystemBusy(false);
    onyx::screen::instance().flush(this, onyx::screen::ScreenProxy::GC, false);
}
Exemple #11
0
bool
GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
         event->type() != QEvent::MouseMove &&
         event->type() != QEvent::MouseButtonPress &&
         event->type() != QEvent::Leave )
        return false;

    const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
    bool hoveringArtist = false;
    bool hoveringAlbum = false;
    bool hoveringBuyButton = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }
    if ( m_albumNameRects.contains( index ) )
    {
        const QRect albumNameRect = m_albumNameRects[ index ];
        hoveringAlbum = albumNameRect.contains( ev->pos() );
    }
    if ( m_buyButtonRects.contains( index ) )
    {
        const QRect buyButtonRect = m_buyButtonRects[ index ];
        hoveringBuyButton = buyButtonRect.contains( ev->pos() );
    }

    QRect coverRect = m_view->visualRect( index );
    coverRect.setHeight( coverRect.width() );
    const bool hoveringCover = coverRect.contains( ev->pos() );

    if ( event->type() == QEvent::MouseMove )
    {
        if ( hoveringArtist || hoveringAlbum || hoveringBuyButton )
            m_view->setCursor( Qt::PointingHandCursor );
        else
            m_view->setCursor( Qt::ArrowCursor );

        foreach ( const QModelIndex& idx, m_hoverControls.keys() )
        {
            if ( index != idx )
                m_hoverControls.take( idx )->deleteLater();
        }

        if ( hoveringCover && !m_hoverControls.contains( index ) && !m_spinner.contains( index ) )
        {
            foreach ( HoverControls* control, m_hoverControls )
                control->deleteLater();
            m_hoverControls.clear();

            QRect cRect = option.rect;
            cRect.setHeight( cRect.width() );

            HoverControls* controls = new HoverControls( m_view );
            controls->setFixedSize( m_margin * 2, m_margin + m_margin / 4 );
            controls->move( cRect.center() - QPoint( controls->width() / 2 -1, controls->height() / 2 -1 ) );
            controls->setContentsMargins( 0, 0, 0, 0 );
            controls->setFocusPolicy( Qt::NoFocus );
            controls->installEventFilter( this );
            controls->show();

            NewClosure( controls, SIGNAL( play() ),
                        const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

            m_hoverControls[ index ] = controls;
        }

        if ( m_hoveringOverArtist != index || ( !hoveringArtist && m_hoveringOverArtist.isValid() ) )
        {
            emit updateIndex( m_hoveringOverArtist );

            if ( hoveringArtist )
                m_hoveringOverArtist = index;
            else
                m_hoveringOverArtist = QPersistentModelIndex();

            emit updateIndex( index );
        }
        if ( m_hoveringOverAlbum != index || ( !hoveringAlbum && m_hoveringOverAlbum.isValid() ) )
        {
            emit updateIndex( m_hoveringOverAlbum );

            if ( hoveringAlbum )
                m_hoveringOverAlbum = index;
            else
                m_hoveringOverAlbum = QPersistentModelIndex();

            emit updateIndex( index );
        }
        if ( m_hoveringOverBuyButton != index || ( !hoveringBuyButton && m_hoveringOverBuyButton.isValid() ) )
        {
            emit updateIndex( m_hoveringOverBuyButton );

            if ( hoveringBuyButton )
                m_hoveringOverBuyButton = index;
            else
                m_hoveringOverBuyButton = QPersistentModelIndex();

            emit updateIndex( index );
        }

        if ( m_hoverIndex != index || !hoveringCover )
        {
            if ( m_hoverIndex.isValid() )
            {
                int startFrame = 100;
                if ( m_hoverFaders.contains( m_hoverIndex ) )
                {
                    QTimeLine* oldFader = m_hoverFaders.take( m_hoverIndex );
                    startFrame = oldFader->currentFrame();
                    oldFader->deleteLater();
                }

                QTimeLine* fadeOut = createTimeline( QTimeLine::Backward, startFrame );
                _detail::Closure* c = NewClosure( fadeOut, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) );
                c->setAutoDelete( false );
                c = NewClosure( fadeOut, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) );
                c->setAutoDelete( false );

                m_hoverFaders[ m_hoverIndex ] = fadeOut;
                fadeOut->start();
            }
            emit updateIndex( m_hoverIndex );

            foreach ( HoverControls* controls, m_hoverControls )
                controls->deleteLater();
            m_hoverControls.clear();
            m_hoverIndex = QPersistentModelIndex();
        }

        if ( hoveringCover && m_hoverIndex != index )
        {
            m_hoverIndex = index;
            int startFrame = 0;
            if ( m_hoverFaders.contains( index ) )
            {
                QTimeLine* oldFader = m_hoverFaders.take( index );
                startFrame = oldFader->currentFrame();
                oldFader->deleteLater();
            }

            QTimeLine* fadeIn = createTimeline( QTimeLine::Forward, startFrame );
            _detail::Closure* c = NewClosure( fadeIn, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
            c->setAutoDelete( false );
            c = NewClosure( fadeIn, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
            c->setAutoDelete( false );

            m_hoverFaders[ index ] = fadeIn;
            fadeIn->start();

            emit updateIndex( index );
        }
Exemple #12
0
QmlView::QmlView(QUrl source, QWidget *parent, MafwRegistryAdapter *mafwRegistry ) :
    QMainWindow(parent),
    ui(new Ui::QmlView),
    mafwRegistry(mafwRegistry),
    mafwRenderer(mafwRegistry->renderer())
{
    ui->setupUi(this);
    ui->declarativeView->setSource(source);
    ui->declarativeView->setResizeMode(QDeclarativeView::SizeRootObjectToView);

    setAttribute(Qt::WA_DeleteOnClose);
    setAttribute(Qt::WA_Maemo5StackedWindow);
    setAttribute(Qt::WA_Maemo5NonComposited);

    QGLWidget *glWidget = new QGLWidget(this);
    ui->declarativeView->setViewport(glWidget);

    positionTimer = new QTimer(this);
    positionTimer->setInterval(1000);

    fmtx = new FMTXInterface(this);

    Rotator *rotator = Rotator::acquire();
    savedPolicy = rotator->policy();
    rotator->setPolicy(Rotator::Landscape);

    rootObject = dynamic_cast<QObject*>(ui->declarativeView->rootObject());
    rootObject->setParent(this);

    connect(rootObject, SIGNAL(quitButtonClicked()), this, SLOT(close()));
    connect(rootObject, SIGNAL(prevButtonClicked()), mafwRenderer, SLOT(previous()));
    connect(rootObject, SIGNAL(playButtonClicked()), this, SLOT(onPlayClicked()));
    connect(rootObject, SIGNAL(nextButtonClicked()), mafwRenderer, SLOT(next()));
    connect(rootObject, SIGNAL(fmtxButtonClicked()), this, SLOT(onFmtxClicked()));
    connect(rootObject, SIGNAL(sliderValueChanged(int)), this, SLOT(onSliderValueChanged(int)));
    connect(rootObject, SIGNAL(playlistItemSelected(int)), this, SLOT(onPlaylistItemChanged(int)));

    connect(this, SIGNAL(titleChanged(QVariant)), rootObject, SLOT(setSongTitle(QVariant)));
    connect(this, SIGNAL(albumChanged(QVariant)), rootObject, SLOT(setSongAlbum(QVariant)));
    connect(this, SIGNAL(artistChanged(QVariant)), rootObject, SLOT(setSongArtist(QVariant)));
    connect(this, SIGNAL(albumArtChanged(QVariant)), rootObject, SLOT(setAlbumArt(QVariant)));
    connect(this, SIGNAL(durationTextChanged(QVariant)), rootObject, SLOT(setPosition(QVariant)));
    connect(this, SIGNAL(positionChanged(QVariant)), rootObject, SLOT(setSliderValue(QVariant)));
    connect(this, SIGNAL(durationChanged(QVariant)), rootObject, SLOT(setSliderMaximum(QVariant)));
    connect(this, SIGNAL(stateIconChanged(QVariant)), rootObject, SLOT(setPlayButtonIcon(QVariant)));
    connect(this, SIGNAL(rowChanged(QVariant)), rootObject, SLOT(onRowChanged(QVariant)));
    connect(this, SIGNAL(fmtxStateChanged(QVariant)), rootObject, SLOT(onFmtxStateChanged(QVariant)));

    connect(this, SIGNAL(playlistItemAppended(QVariant,QVariant,QVariant)),
            rootObject, SLOT(appendPlaylistItem(QVariant,QVariant,QVariant)));
    connect(this, SIGNAL(playlistItemInserted(QVariant,QVariant,QVariant,QVariant)),
            rootObject, SLOT(insertPlaylistItem(QVariant,QVariant,QVariant,QVariant)));
    connect(this, SIGNAL(playlistItemSet(QVariant,QVariant,QVariant,QVariant)),
            rootObject, SLOT(setPlaylistItem(QVariant,QVariant,QVariant,QVariant)));
    connect(this, SIGNAL(playlistItemRemoved(QVariant)),
            rootObject, SLOT(removePlaylistItem(QVariant)));
    connect(this, SIGNAL(playlistCleared()),
            rootObject, SLOT(clearPlaylist()));

    connect(mafwRenderer, SIGNAL(stateChanged(MafwPlayState)), this, SLOT(onStateChanged(MafwPlayState)));
    connect(mafwRenderer, SIGNAL(positionReceived(int,QString)), this, SLOT(onPositionChanged(int)));
    connect(mafwRenderer, SIGNAL(statusReceived(MafwPlaylist*,uint,MafwPlayState,QString,QString)),
            this, SLOT(onStatusReceived(MafwPlaylist*,uint,MafwPlayState)));
    connect(positionTimer, SIGNAL(timeout()), mafwRenderer, SLOT(getPosition()));

    connect(fmtx, SIGNAL(propertyChanged()), this, SLOT(onFmtxChanged()));
    onFmtxChanged();

    positionTimer->start();

    quint32 disable = {0};
    Atom winPortraitModeSupportAtom = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_SUPPORT", false);
    XChangeProperty(QX11Info::display(), winId(), winPortraitModeSupportAtom, XA_CARDINAL, 32, PropModeReplace, (uchar*) &disable, 1);

    this->setDNDAtom(true);

    mafwRenderer->getStatus();
    mafwRenderer->getPosition();
}