Пример #1
0
SlideShow::SlideShow(QWidget *parent)
    : QMainWindow(parent)
    , imageViewer(0)
    , playlist(0)
    , statusLabel(0)
    , countdownLabel(0)
    , playAction(0)
    , stopAction(0)
{
    imageViewer = new QMediaImageViewer(this);

    connect(imageViewer, SIGNAL(stateChanged(QMediaImageViewer::State)),
            this, SLOT(stateChanged(QMediaImageViewer::State)));
    connect(imageViewer, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)),
            this, SLOT(statusChanged(QMediaImageViewer::MediaStatus)));
    connect(imageViewer, SIGNAL(elapsedTimeChanged(int)), this, SLOT(elapsedTimeChanged(int)));

    playlist = new QMediaPlaylist;
    imageViewer->bind(playlist);

    connect(playlist, SIGNAL(loaded()), this, SLOT(playlistLoaded()));
    connect(playlist, SIGNAL(loadFailed()), this, SLOT(playlistLoadFailed()));

    QVideoWidget *videoWidget = new QVideoWidget;
    imageViewer->setVideoOutput(videoWidget);

    menuBar()->addAction(tr("Open Directory..."), this, SLOT(openDirectory()));
    menuBar()->addAction(tr("Open Playlist..."), this, SLOT(openPlaylist()));

    toolBar = new QToolBar;
    toolBar->setMovable(false);
    toolBar->setFloatable(false);
    toolBar->setEnabled(false);

    toolBar->addAction(
            style()->standardIcon(QStyle::SP_MediaSkipBackward),
            tr("Previous"),
            playlist,
            SLOT(previous()));
    stopAction = toolBar->addAction(
            style()->standardIcon(QStyle::SP_MediaStop), tr("Stop"), imageViewer, SLOT(stop()));
    playAction = toolBar->addAction(
            style()->standardIcon(QStyle::SP_MediaPlay), tr("Play"), this, SLOT(play()));
    toolBar->addAction(
            style()->standardIcon(QStyle::SP_MediaSkipForward), tr("Next"), playlist, SLOT(next()));

    addToolBar(Qt::BottomToolBarArea, toolBar);

    statusLabel = new QLabel(tr("%1 Images").arg(0));
    statusLabel->setAlignment(Qt::AlignCenter);

    countdownLabel = new QLabel;
    countdownLabel->setAlignment(Qt::AlignRight);

    statusBar()->addPermanentWidget(statusLabel, 1);
    statusBar()->addPermanentWidget(countdownLabel);

    setCentralWidget(videoWidget);
}
Пример #2
0
SlideShow::SlideShow(QWidget *parent)
    : QWidget(parent)
    , imageViewer(0)
    , playlist(0)
    , statusLabel(0)
    , countdownLabel(0)
    , playButton(0)
    , stopButton(0)
    , viewerLayout(0)
{
    imageViewer = new QMediaImageViewer(this);

    connect(imageViewer, SIGNAL(stateChanged(QMediaImageViewer::State)),
            this, SLOT(stateChanged(QMediaImageViewer::State)));
    connect(imageViewer, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)),
            this, SLOT(statusChanged(QMediaImageViewer::MediaStatus)));
    connect(imageViewer, SIGNAL(elapsedTimeChanged(int)), this, SLOT(elapsedTimeChanged(int)));

    playlist = new QMediaPlaylist;
    imageViewer->bind(playlist);

    connect(playlist, SIGNAL(loaded()), this, SLOT(playlistLoaded()));
    connect(playlist, SIGNAL(loadFailed()), this, SLOT(playlistLoadFailed()));

    connect(playlist, SIGNAL(loaded()), this, SLOT(playlistLoaded()));
    connect(playlist, SIGNAL(loadFailed()), this, SLOT(playlistLoadFailed()));

    QVideoWidget *videoWidget = new QVideoWidget;
    imageViewer->bind(videoWidget);

    statusLabel = new QLabel(tr("%1 Images").arg(0));
    statusLabel->setAlignment(Qt::AlignCenter);

    viewerLayout = new QStackedLayout;
    viewerLayout->setStackingMode(QStackedLayout::StackAll);
    viewerLayout->addWidget(videoWidget);
    viewerLayout->addWidget(statusLabel);

    statusLabel = new QLabel(tr("%1 Images").arg(0));
    statusLabel->setAlignment(Qt::AlignCenter);

    viewerLayout = new QStackedLayout;
    viewerLayout->setStackingMode(QStackedLayout::StackAll);
    viewerLayout->addWidget(videoWidget);
    viewerLayout->addWidget(statusLabel);

    QMenu *openMenu = new QMenu(this);
    openMenu->addAction(tr("Directory..."), this, SLOT(openDirectory()));
    openMenu->addAction(tr("Playlist..."), this, SLOT(openPlaylist()));

    QToolButton *openButton = new QToolButton;
    openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
    openButton->setMenu(openMenu);
    openButton->setPopupMode(QToolButton::InstantPopup);

    playButton = new QToolButton;
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
    playButton->setEnabled(false);

    connect(playButton, SIGNAL(clicked()), this, SLOT(play()));
    connect(this, SIGNAL(enableButtons(bool)), playButton, SLOT(setEnabled(bool)));

    stopButton = new QToolButton;
    stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
    stopButton->setEnabled(false);

    connect(stopButton, SIGNAL(clicked()), imageViewer, SLOT(stop()));

    QAbstractButton *nextButton = new QToolButton;
    nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
    nextButton->setEnabled(false);

    connect(nextButton, SIGNAL(clicked()), playlist, SLOT(next()));
    connect(this, SIGNAL(enableButtons(bool)), nextButton, SLOT(setEnabled(bool)));

    QAbstractButton *previousButton = new QToolButton;
    previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
    previousButton->setEnabled(false);

    connect(previousButton, SIGNAL(clicked()), playlist, SLOT(previous()));
    connect(this, SIGNAL(enableButtons(bool)), previousButton, SLOT(setEnabled(bool)));

    countdownLabel = new QLabel;

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    controlLayout->addWidget(openButton);
    controlLayout->addStretch(1);
    controlLayout->addWidget(previousButton);
    controlLayout->addWidget(stopButton);
    controlLayout->addWidget(playButton);
    controlLayout->addWidget(nextButton);
    controlLayout->addStretch(1);
    controlLayout->addWidget(countdownLabel);

    QBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(viewerLayout);
    layout->addLayout(controlLayout);

    setLayout(layout);

}