1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 | umplayer, Copyright (C) 2010 Ori Rejwan
|
---|
4 |
|
---|
5 | This program is free software; you can redistribute it and/or modify
|
---|
6 | it under the terms of the GNU General Public License as published by
|
---|
7 | the Free Software Foundation; either version 2 of the License, or
|
---|
8 | (at your option) any later version.
|
---|
9 |
|
---|
10 | This program is distributed in the hope that it will be useful,
|
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | GNU General Public License for more details.
|
---|
14 |
|
---|
15 | You should have received a copy of the GNU General Public License
|
---|
16 | along with this program; if not, write to the Free Software
|
---|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | */
|
---|
19 |
|
---|
20 | #include "mediabarpanel.h"
|
---|
21 | #include "ui_mediabarpanel.h"
|
---|
22 | #include "playcontrol.h"
|
---|
23 | #include "mediapanel.h"
|
---|
24 | #include <QHBoxLayout>
|
---|
25 | #include <QLabel>
|
---|
26 | #include <QDebug>
|
---|
27 | #include "qpropertysetter.h"
|
---|
28 | #include "colorutils.h"
|
---|
29 | #include "qpropertysetter.h"
|
---|
30 | #include "volumecontrolpanel.h"
|
---|
31 |
|
---|
32 |
|
---|
33 |
|
---|
34 | MediaBarPanel::MediaBarPanel(QWidget *parent) :
|
---|
35 | QWidget(parent),ui(new Ui::MediaBarPanel),core(0)
|
---|
36 | {
|
---|
37 | ui->setupUi(this);
|
---|
38 | setAttribute(Qt::WA_StyledBackground, true);
|
---|
39 | setFixedHeight(53);
|
---|
40 | QHBoxLayout* layout = new QHBoxLayout;
|
---|
41 | playControlPanel = new PlayControl(this);
|
---|
42 | IconSetter::instance()->playControl = playControlPanel;
|
---|
43 | volumeControlPanel = new VolumeControlPanel(this);
|
---|
44 | volumeControlPanel->setObjectName("volume-control-panel");
|
---|
45 | mediaPanel = new MediaPanel(this);
|
---|
46 | mediaPanel->setObjectName("media-panel");
|
---|
47 | IconSetter::instance()->mediaPanel = mediaPanel;
|
---|
48 | layout->setSpacing(0);
|
---|
49 | layout->setContentsMargins(0, 0, 0, 0);
|
---|
50 | layout->addWidget(playControlPanel);
|
---|
51 | layout->addWidget(mediaPanel);
|
---|
52 | layout->addWidget(volumeControlPanel);
|
---|
53 | setLayout(layout);
|
---|
54 |
|
---|
55 | connect(volumeControlPanel, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
|
---|
56 | connect(volumeControlPanel, SIGNAL(volumeSliderMoved(int)), this, SIGNAL(volumeSliderMoved(int)));
|
---|
57 | connect(mediaPanel, SIGNAL(seekerChanged(int)), this, SIGNAL(seekerChanged(int)));
|
---|
58 | }
|
---|
59 |
|
---|
60 | MediaBarPanel::~MediaBarPanel()
|
---|
61 | {
|
---|
62 | delete ui;
|
---|
63 | }
|
---|
64 |
|
---|
65 | void MediaBarPanel::changeEvent(QEvent *e)
|
---|
66 | {
|
---|
67 | QWidget::changeEvent(e);
|
---|
68 | switch (e->type()) {
|
---|
69 | case QEvent::LanguageChange:
|
---|
70 | ui->retranslateUi(this);
|
---|
71 | break;
|
---|
72 | default:
|
---|
73 | break;
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | void MediaBarPanel::setToolbarActionCollection(QList<QAction *>actions) {
|
---|
78 | IconSetter::instance()->setToolbarActions(actions);
|
---|
79 | }
|
---|
80 |
|
---|
81 | void MediaBarPanel::setPlayControlActionCollection(QList<QAction *>actions)
|
---|
82 | {
|
---|
83 | playControlPanel->setActionCollection(actions);
|
---|
84 | }
|
---|
85 |
|
---|
86 | void MediaBarPanel::setMediaPanelActionCollection(QList<QAction *>actions)
|
---|
87 | {
|
---|
88 | mediaPanel->setActionCollection(actions);
|
---|
89 | }
|
---|
90 |
|
---|
91 | void MediaBarPanel::setMplayerState(Core::State state)
|
---|
92 | {
|
---|
93 | mediaPanel->setMplayerState((int)state);
|
---|
94 | }
|
---|
95 |
|
---|
96 | void MediaBarPanel::setCore(Core *c)
|
---|
97 | {
|
---|
98 | core = c;
|
---|
99 | connect(core, SIGNAL(mediaStartPlay()), this, SLOT(setDuration()));
|
---|
100 | connect(core, SIGNAL(newDuration(double)), this, SLOT(setDuration()));
|
---|
101 | connect(core, SIGNAL(showTime(double)), this, SLOT(gotCurrentTime(double)));
|
---|
102 | connect(core, SIGNAL(mediaInfoChanged()), this, SLOT(updateMediaInfo()));
|
---|
103 | connect(core, SIGNAL(buffering()), this, SLOT(setBuffering()));
|
---|
104 | connect(mediaPanel, SIGNAL(seekerWheelUp()), core, SLOT(wheelUp()));
|
---|
105 | connect(mediaPanel, SIGNAL(seekerWheelDown()), core, SLOT(wheelDown()));
|
---|
106 | }
|
---|
107 |
|
---|
108 | void MediaBarPanel::setDuration()
|
---|
109 | {
|
---|
110 | mediaPanel->setDuration(core->mdat.duration);
|
---|
111 | }
|
---|
112 |
|
---|
113 | void MediaBarPanel::setVolumeControlActionCollection(QList<QAction *>actions)
|
---|
114 | {
|
---|
115 | volumeControlPanel->setActionCollection(actions);
|
---|
116 | }
|
---|
117 |
|
---|
118 | void MediaBarPanel::gotCurrentTime(double time)
|
---|
119 | {
|
---|
120 | mediaPanel->setElapsedText(Helper::formatTime((int)time));
|
---|
121 | }
|
---|
122 |
|
---|
123 | void MediaBarPanel::updateMediaInfo()
|
---|
124 | {
|
---|
125 | //QString s = QString("%1 (%2x%3)").arg(core->mdat.displayName()).arg(core->mdat.video_width).arg(core->mdat.video_height);
|
---|
126 | mediaPanel->setMediaLabelText(core->mdat.displayName());
|
---|
127 |
|
---|
128 | if ((core->mdat.video_width != 0) && (core->mdat.video_height != 0)) {
|
---|
129 | QString s = QString("%1x%2").arg(core->mdat.video_width).arg(core->mdat.video_height);
|
---|
130 | mediaPanel->setResolutionLabelText(s);
|
---|
131 | } else {
|
---|
132 | mediaPanel->setResolutionLabelText(" ");
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|
136 | void MediaBarPanel::displayMessage(QString status, int time)
|
---|
137 | {
|
---|
138 | mediaPanel->setStatusText(status, time);
|
---|
139 | }
|
---|
140 |
|
---|
141 | void MediaBarPanel::displayMessage(QString status)
|
---|
142 | {
|
---|
143 | mediaPanel->setStatusText(status);
|
---|
144 | }
|
---|
145 |
|
---|
146 | void MediaBarPanel::displayPermanentMessage(QString status)
|
---|
147 | {
|
---|
148 | mediaPanel->setStatusText(status, 0);
|
---|
149 | }
|
---|
150 |
|
---|
151 | void MediaBarPanel::setRecordAvailable(bool av)
|
---|
152 | {
|
---|
153 | playControlPanel->setRecordEnabled(av);
|
---|
154 | }
|
---|
155 |
|
---|
156 | void MediaBarPanel::setBuffering()
|
---|
157 | {
|
---|
158 | mediaPanel->setBuffering(true);
|
---|
159 | }
|
---|
160 |
|
---|
161 | void MediaBarPanel::setVolume(int v) {
|
---|
162 | volumeControlPanel->setVolume(v);
|
---|
163 | }
|
---|
164 |
|
---|
165 | void MediaBarPanel::setSeeker(int v) {
|
---|
166 | mediaPanel->setSeeker(v);
|
---|
167 | }
|
---|
168 |
|
---|
169 | void MediaBarPanel::setResolutionVisible(bool b) {
|
---|
170 | qDebug("MediaBarPanel::setResolutionVisible: %d", b);
|
---|
171 | mediaPanel->setResolutionVisible(b);
|
---|
172 | }
|
---|
173 |
|
---|
174 | void MediaBarPanel::setScrollingEnabled(bool b) {
|
---|
175 | qDebug("MediaBarPanel::setScrollingEnabled: %d", b);
|
---|
176 | mediaPanel->setScrollingEnabled(b);
|
---|
177 | }
|
---|
178 |
|
---|
179 | #include "moc_mediabarpanel.cpp"
|
---|
180 |
|
---|