| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include "statewidget.h"
|
|---|
| 20 | #include <QMovie>
|
|---|
| 21 | #include <QDebug>
|
|---|
| 22 |
|
|---|
| 23 | StateWidget::StateWidget(QWidget * parent, Qt::WindowFlags f)
|
|---|
| 24 | : QLabel(parent, f)
|
|---|
| 25 | {
|
|---|
| 26 | qDebug() << "StateWidget::StateWidget: supported formats for QMovie:" << QMovie::supportedFormats();
|
|---|
| 27 |
|
|---|
| 28 | movie = new QMovie();
|
|---|
| 29 | //movie->setScaledSize(QSize(16, 16));
|
|---|
| 30 |
|
|---|
| 31 | // Buffering icon from: http://preloaders.net/
|
|---|
| 32 | setAnimation(":/default-theme/buffering.gif");
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | StateWidget::~StateWidget() {
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | void StateWidget::setAnimation(const QString & filename) {
|
|---|
| 39 | movie->setFileName(filename);
|
|---|
| 40 |
|
|---|
| 41 | if (movie->isValid()) {
|
|---|
| 42 | setMovie(movie);
|
|---|
| 43 | } else {
|
|---|
| 44 | qWarning() << "StateWidget::setAnimation: movie is not valid";
|
|---|
| 45 | }
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | void StateWidget::watchState(Core::State state) {
|
|---|
| 49 | qDebug() << "StateWidget::watchState:" << state;
|
|---|
| 50 |
|
|---|
| 51 | if (movie->isValid()) {
|
|---|
| 52 | if (state == Core::Buffering) {
|
|---|
| 53 | show();
|
|---|
| 54 | movie->start();
|
|---|
| 55 | } else {
|
|---|
| 56 | movie->stop();
|
|---|
| 57 | hide();
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | #if 0
|
|---|
| 61 | else {
|
|---|
| 62 | switch (state) {
|
|---|
| 63 | case Core::Playing: setText("Play"); break;
|
|---|
| 64 | case Core::Paused: setText("Pause"); break;
|
|---|
| 65 | case Core::Stopped: setText("Stop"); break;
|
|---|
| 66 | case Core::Buffering: setText("Buffering"); break;
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 | #endif
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | #include "moc_statewidget.cpp"
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|