1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2014 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 "skingui.h"
|
---|
20 | #include "helper.h"
|
---|
21 | #include "colorutils.h"
|
---|
22 | #include "core.h"
|
---|
23 | #include "global.h"
|
---|
24 | #include "widgetactions.h"
|
---|
25 | #include "playlist.h"
|
---|
26 | #include "mplayerwindow.h"
|
---|
27 | #include "myaction.h"
|
---|
28 | #include "images.h"
|
---|
29 | #include "autohidewidget.h"
|
---|
30 | #include "desktopinfo.h"
|
---|
31 | #include "editabletoolbar.h"
|
---|
32 | #include "mediabarpanel.h"
|
---|
33 | #include "actionseditor.h"
|
---|
34 |
|
---|
35 | #if DOCK_PLAYLIST
|
---|
36 | #include "playlistdock.h"
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | #include <QMenu>
|
---|
40 | #include <QSettings>
|
---|
41 | #include <QLabel>
|
---|
42 | #include <QStatusBar>
|
---|
43 | #include <QPushButton>
|
---|
44 | #include <QToolButton>
|
---|
45 | #include <QMenuBar>
|
---|
46 | #include <QLayout>
|
---|
47 | #include <QApplication>
|
---|
48 | #include <QDir>
|
---|
49 |
|
---|
50 | #define TOOLBAR_VERSION 1
|
---|
51 |
|
---|
52 | using namespace Global;
|
---|
53 |
|
---|
54 | SkinGui::SkinGui( QWidget * parent, Qt::WindowFlags flags )
|
---|
55 | : BaseGuiPlus( parent, flags )
|
---|
56 | , was_muted(false)
|
---|
57 | {
|
---|
58 | connect( this, SIGNAL(timeChanged(QString)),
|
---|
59 | this, SLOT(displayTime(QString)) );
|
---|
60 |
|
---|
61 | createActions();
|
---|
62 | createMainToolBars();
|
---|
63 | createControlWidget();
|
---|
64 | createFloatingControl();
|
---|
65 | createMenus();
|
---|
66 |
|
---|
67 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
68 | connect( editToolbar1Act, SIGNAL(triggered()),
|
---|
69 | toolbar1, SLOT(edit()) );
|
---|
70 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
71 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
72 | iw->takeAvailableActionsFrom(this);
|
---|
73 | connect( editFloatingControlAct, SIGNAL(triggered()), iw, SLOT(edit()) );
|
---|
74 | #endif
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | retranslateStrings();
|
---|
78 |
|
---|
79 | loadConfig();
|
---|
80 |
|
---|
81 | //if (playlist_visible) showPlaylist(true);
|
---|
82 |
|
---|
83 | if (pref->compact_mode) {
|
---|
84 | controlwidget->hide();
|
---|
85 | toolbar1->hide();
|
---|
86 | }
|
---|
87 |
|
---|
88 | statusBar()->hide();
|
---|
89 |
|
---|
90 | changeStyleSheet(pref->iconset);
|
---|
91 | mediaBarPanel->setVolume(50);
|
---|
92 | }
|
---|
93 |
|
---|
94 | SkinGui::~SkinGui() {
|
---|
95 | saveConfig();
|
---|
96 | }
|
---|
97 |
|
---|
98 | void SkinGui::changeStyleSheet(QString style) {
|
---|
99 | if (style.isEmpty()) {
|
---|
100 | qApp->setStyleSheet("");
|
---|
101 | }
|
---|
102 | else {
|
---|
103 | QString qss = Images::styleSheet();
|
---|
104 | #ifdef USE_RESOURCES
|
---|
105 | Images::setTheme(pref->iconset);
|
---|
106 | QString path = ":/" + pref->iconset;
|
---|
107 | #else
|
---|
108 | QDir current = QDir::current();
|
---|
109 | QString td = Images::themesDirectory();
|
---|
110 | QString path = current.relativeFilePath(td);
|
---|
111 | #endif
|
---|
112 | qss.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
|
---|
113 | QString("url(%1\\1)").arg(path + "/"));
|
---|
114 | //qDebug("SkinGui::changeStyleSheet: qss: %s", qss.toLatin1().constData());
|
---|
115 | qApp->setStyleSheet(qss);
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | void SkinGui::createActions() {
|
---|
120 | qDebug("SkinGui::createActions");
|
---|
121 |
|
---|
122 | timeslider_action = createTimeSliderAction(this);
|
---|
123 | timeslider_action->disable();
|
---|
124 |
|
---|
125 | volumeslider_action = createVolumeSliderAction(this);
|
---|
126 | volumeslider_action->disable();
|
---|
127 |
|
---|
128 | // Create the time label
|
---|
129 | time_label_action = new TimeLabelAction(this);
|
---|
130 | time_label_action->setObjectName("timelabel_action");
|
---|
131 |
|
---|
132 | #if MINI_ARROW_BUTTONS
|
---|
133 | QList<QAction*> rewind_actions;
|
---|
134 | rewind_actions << rewind1Act << rewind2Act << rewind3Act;
|
---|
135 | rewindbutton_action = new SeekingButton(rewind_actions, this);
|
---|
136 | rewindbutton_action->setObjectName("rewindbutton_action");
|
---|
137 |
|
---|
138 | QList<QAction*> forward_actions;
|
---|
139 | forward_actions << forward1Act << forward2Act << forward3Act;
|
---|
140 | forwardbutton_action = new SeekingButton(forward_actions, this);
|
---|
141 | forwardbutton_action->setObjectName("forwardbutton_action");
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
145 | editToolbar1Act = new MyAction( this, "edit_main_toolbar" );
|
---|
146 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
147 | editFloatingControlAct = new MyAction( this, "edit_floating_control" );
|
---|
148 | #endif
|
---|
149 | #endif
|
---|
150 |
|
---|
151 | playOrPauseAct->setCheckable(true);
|
---|
152 |
|
---|
153 | viewVideoInfoAct = new MyAction(this, "toggle_video_info_skingui" );
|
---|
154 | viewVideoInfoAct->setCheckable(true);
|
---|
155 | }
|
---|
156 |
|
---|
157 | #if AUTODISABLE_ACTIONS
|
---|
158 | void SkinGui::enableActionsOnPlaying() {
|
---|
159 | qDebug("SkinGui::enableActionsOnPlaying");
|
---|
160 | BaseGuiPlus::enableActionsOnPlaying();
|
---|
161 |
|
---|
162 | timeslider_action->enable();
|
---|
163 | volumeslider_action->enable();
|
---|
164 | }
|
---|
165 |
|
---|
166 | void SkinGui::disableActionsOnStop() {
|
---|
167 | qDebug("SkinGui::disableActionsOnStop");
|
---|
168 | BaseGuiPlus::disableActionsOnStop();
|
---|
169 |
|
---|
170 | timeslider_action->disable();
|
---|
171 | volumeslider_action->disable();
|
---|
172 | }
|
---|
173 |
|
---|
174 | void SkinGui::togglePlayAction(Core::State state) {
|
---|
175 | qDebug("SkinGui::togglePlayAction");
|
---|
176 | BaseGuiPlus::togglePlayAction(state);
|
---|
177 |
|
---|
178 | if (state == Core::Playing) {
|
---|
179 | playOrPauseAct->setChecked(true);
|
---|
180 | }
|
---|
181 | else {
|
---|
182 | playOrPauseAct->setChecked(false);
|
---|
183 | }
|
---|
184 | }
|
---|
185 | #endif // AUTODISABLE_ACTIONS
|
---|
186 |
|
---|
187 | void SkinGui::createMenus() {
|
---|
188 | menuBar()->setObjectName("menubar");
|
---|
189 | QFont font = menuBar()->font();
|
---|
190 | font.setPixelSize(11);
|
---|
191 | menuBar()->setFont(font);
|
---|
192 | /*menuBar()->setFixedHeight(21);*/
|
---|
193 |
|
---|
194 | toolbar_menu = new QMenu(this);
|
---|
195 | toolbar_menu->addAction(toolbar1->toggleViewAction());
|
---|
196 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
197 | toolbar_menu->addSeparator();
|
---|
198 | toolbar_menu->addAction(editToolbar1Act);
|
---|
199 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
200 | toolbar_menu->addAction(editFloatingControlAct);
|
---|
201 | #endif
|
---|
202 | #endif
|
---|
203 | optionsMenu->addSeparator();
|
---|
204 | optionsMenu->addMenu(toolbar_menu);
|
---|
205 |
|
---|
206 | statusbar_menu = new QMenu(this);
|
---|
207 | statusbar_menu->addAction(viewVideoInfoAct);
|
---|
208 | optionsMenu->addMenu(statusbar_menu);
|
---|
209 | }
|
---|
210 |
|
---|
211 | QMenu * SkinGui::createPopupMenu() {
|
---|
212 | QMenu * m = new QMenu(this);
|
---|
213 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
214 | m->addAction(editToolbar1Act);
|
---|
215 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
216 | m->addAction(editFloatingControlAct);
|
---|
217 | #endif
|
---|
218 | #else
|
---|
219 | m->addAction(toolbar1->toggleViewAction());
|
---|
220 | #endif
|
---|
221 | return m;
|
---|
222 | }
|
---|
223 |
|
---|
224 | void SkinGui::createMainToolBars() {
|
---|
225 | toolbar1 = new EditableToolbar( this );
|
---|
226 | toolbar1->setObjectName("toolbar");
|
---|
227 | toolbar1->setMovable(false);
|
---|
228 | toolbar1->setFixedHeight(35);
|
---|
229 | addToolBar(Qt::TopToolBarArea, toolbar1);
|
---|
230 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
231 | QStringList toolbar1_actions;
|
---|
232 | toolbar1_actions << "open_file" << "open_url" << "favorites_menu" << "separator"
|
---|
233 | << "screenshot" << "separator" << "show_file_properties"
|
---|
234 | << "show_find_sub_dialog" << "show_tube_browser" << "show_preferences";
|
---|
235 | toolbar1->setDefaultActions(toolbar1_actions);
|
---|
236 | #else
|
---|
237 | toolbar1->addAction(openFileAct);
|
---|
238 | toolbar1->addAction(openURLAct);
|
---|
239 | toolbar1->addSeparator();
|
---|
240 | toolbar1->addAction(compactAct);
|
---|
241 | toolbar1->addAction(fullscreenAct);
|
---|
242 | toolbar1->addSeparator();
|
---|
243 | toolbar1->addAction(screenshotAct);
|
---|
244 | toolbar1->addSeparator();
|
---|
245 | toolbar1->addAction(showPropertiesAct);
|
---|
246 | toolbar1->addAction(showFindSubtitlesDialogAct);
|
---|
247 | toolbar1->addAction(showPreferencesAct);
|
---|
248 | // Test:
|
---|
249 | //toolbar1->addSeparator();
|
---|
250 | //toolbar1->addAction(timeslider_action);
|
---|
251 | //toolbar1->addAction(volumeslider_action);
|
---|
252 | #endif
|
---|
253 |
|
---|
254 | // Modify toolbars' actions
|
---|
255 | QAction *tba;
|
---|
256 | tba = toolbar1->toggleViewAction();
|
---|
257 | tba->setObjectName("show_main_toolbar");
|
---|
258 | tba->setShortcut(Qt::Key_F5);
|
---|
259 | }
|
---|
260 |
|
---|
261 |
|
---|
262 | void SkinGui::createControlWidget() {
|
---|
263 | qDebug("SkinGui::createControlWidget");
|
---|
264 |
|
---|
265 | controlwidget = new QToolBar( this );
|
---|
266 | controlwidget->setObjectName("controlwidget");
|
---|
267 | controlwidget->setLayoutDirection(Qt::LeftToRight);
|
---|
268 | controlwidget->setStyleSheet("QToolBar { spacing: 0px; }");
|
---|
269 | controlwidget->setMovable(false);
|
---|
270 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
---|
271 |
|
---|
272 | mediaBarPanel = new MediaBarPanel(panel);
|
---|
273 | mediaBarPanel->setObjectName("mediabar-panel");
|
---|
274 | mediaBarPanel->setCore(core);
|
---|
275 | /* panel->layout()->addWidget(mediaBarPanel); */
|
---|
276 |
|
---|
277 | QList<QAction*> actions;
|
---|
278 | //actions << halveSpeedAct << playPrevAct << playOrPauseAct << stopAct << recordAct << playNextAct << doubleSpeedAct;
|
---|
279 | actions << rewind1Act << playPrevAct << playOrPauseAct << stopAct << playNextAct << forward1Act;
|
---|
280 | mediaBarPanel->setPlayControlActionCollection(actions);
|
---|
281 |
|
---|
282 | actions.clear();
|
---|
283 | //actions << timeslider_action << shuffleAct << repeatPlaylistAct;
|
---|
284 | QAction * shuffleAct = ActionsEditor::findAction(playlist, "pl_shuffle");
|
---|
285 | QAction * repeatPlaylistAct = ActionsEditor::findAction(playlist, "pl_repeat");
|
---|
286 | if (shuffleAct) actions << shuffleAct;
|
---|
287 | if (repeatPlaylistAct) actions << repeatPlaylistAct;
|
---|
288 | mediaBarPanel->setMediaPanelActionCollection(actions);
|
---|
289 | connect(core, SIGNAL(stateChanged(Core::State)), mediaBarPanel, SLOT(setMplayerState(Core::State)));
|
---|
290 |
|
---|
291 | actions.clear();
|
---|
292 | //actions << volumeslider_action << showPlaylistAct << fullscreenAct << equalizerAct;
|
---|
293 | actions << volumeslider_action << showPlaylistAct << fullscreenAct << videoEqualizerAct;
|
---|
294 | mediaBarPanel->setVolumeControlActionCollection(actions);
|
---|
295 |
|
---|
296 | actions.clear();
|
---|
297 | actions << openFileAct << openDirectoryAct << openDVDAct << openURLAct << screenshotAct << showPropertiesAct;
|
---|
298 | #ifdef FIND_SUBTITLES
|
---|
299 | actions << showFindSubtitlesDialogAct;
|
---|
300 | #endif
|
---|
301 | actions << showPreferencesAct;
|
---|
302 | mediaBarPanel->setToolbarActionCollection(actions);
|
---|
303 |
|
---|
304 | connect(mediaBarPanel, SIGNAL(volumeChanged(int)), core, SLOT(setVolume(int)));
|
---|
305 | connect(mediaBarPanel, SIGNAL(volumeSliderMoved(int)), core, SLOT(setVolume(int)));
|
---|
306 | connect(core, SIGNAL(volumeChanged(int)), mediaBarPanel, SLOT(setVolume(int)));
|
---|
307 |
|
---|
308 | #ifdef SEEKBAR_RESOLUTION
|
---|
309 | connect(mediaBarPanel, SIGNAL(seekerChanged(int)), core, SLOT(goToPosition(int)));
|
---|
310 | connect(core, SIGNAL(positionChanged(int)), mediaBarPanel, SLOT(setSeeker(int)));
|
---|
311 | #else
|
---|
312 | connect(mediaBarPanel, SIGNAL(seekerChanged(int)), core, SLOT(goToPos(int)));
|
---|
313 | connect(core, SIGNAL(posChanged(int)),mediaBarPanel, SLOT(setSeeker(int)));
|
---|
314 | #endif
|
---|
315 |
|
---|
316 | connect( viewVideoInfoAct, SIGNAL(toggled(bool)),
|
---|
317 | mediaBarPanel, SLOT(setResolutionVisible(bool)) );
|
---|
318 |
|
---|
319 | mediaBarPanelAction = controlwidget->addWidget(mediaBarPanel);
|
---|
320 | }
|
---|
321 |
|
---|
322 | void SkinGui::createFloatingControl() {
|
---|
323 | // Floating control
|
---|
324 | floating_control = new AutohideWidget(panel);
|
---|
325 | floating_control->setAutoHide(true);
|
---|
326 |
|
---|
327 | #ifndef SKIN_EDITABLE_CONTROL
|
---|
328 |
|
---|
329 | // floating_control->setInternalWidget(new QLabel("hello"));
|
---|
330 |
|
---|
331 | #else
|
---|
332 |
|
---|
333 | EditableToolbar * iw = new EditableToolbar(floating_control);
|
---|
334 |
|
---|
335 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
336 | QStringList floatingcontrol_actions;
|
---|
337 | floatingcontrol_actions << "play" << "pause" << "stop" << "separator";
|
---|
338 | #if MINI_ARROW_BUTTONS
|
---|
339 | floatingcontrol_actions << "rewindbutton_action";
|
---|
340 | #else
|
---|
341 | floatingcontrol_actions << "rewind3" << "rewind2" << "rewind1";
|
---|
342 | #endif
|
---|
343 | floatingcontrol_actions << "timeslider_action";
|
---|
344 | #if MINI_ARROW_BUTTONS
|
---|
345 | floatingcontrol_actions << "forwardbutton_action";
|
---|
346 | #else
|
---|
347 | floatingcontrol_actions << "forward1" << "forward2" << "forward3";
|
---|
348 | #endif
|
---|
349 | floatingcontrol_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action" << "separator" << "timelabel_action";
|
---|
350 |
|
---|
351 | iw->setDefaultActions(floatingcontrol_actions);
|
---|
352 | #else
|
---|
353 | iw->addAction(playAct);
|
---|
354 | iw->addAction(pauseAct);
|
---|
355 | iw->addAction(stopAct);
|
---|
356 | iw->addSeparator();
|
---|
357 |
|
---|
358 | #if MINI_ARROW_BUTTONS
|
---|
359 | iw->addAction( rewindbutton_action );
|
---|
360 | #else
|
---|
361 | iw->addAction(rewind3Act);
|
---|
362 | iw->addAction(rewind2Act);
|
---|
363 | iw->addAction(rewind1Act);
|
---|
364 | #endif
|
---|
365 |
|
---|
366 | iw->addAction(timeslider_action);
|
---|
367 |
|
---|
368 | #if MINI_ARROW_BUTTONS
|
---|
369 | iw->addAction( forwardbutton_action );
|
---|
370 | #else
|
---|
371 | iw->addAction(forward1Act);
|
---|
372 | iw->addAction(forward2Act);
|
---|
373 | iw>addAction(forward3Act);
|
---|
374 | #endif
|
---|
375 |
|
---|
376 | iw->addSeparator();
|
---|
377 | iw->addAction(fullscreenAct);
|
---|
378 | iw->addAction(muteAct);
|
---|
379 | iw->addAction(volumeslider_action);
|
---|
380 | iw->addSeparator();
|
---|
381 | iw->addAction(time_label_action);
|
---|
382 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
383 |
|
---|
384 | floating_control->setInternalWidget(iw);
|
---|
385 | #endif // SKIN_EDITABLE_CONTROL
|
---|
386 |
|
---|
387 | /*
|
---|
388 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
---|
389 | // To make work the ESC key (exit fullscreen) and Ctrl-X (close) in Windows and OS2
|
---|
390 | floating_control->addAction(exitFullscreenAct);
|
---|
391 | floating_control->addAction(exitAct);
|
---|
392 | #endif
|
---|
393 | */
|
---|
394 |
|
---|
395 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
396 | floating_control->adjustSize();
|
---|
397 | #endif
|
---|
398 |
|
---|
399 | floating_control->hide();
|
---|
400 | }
|
---|
401 |
|
---|
402 | void SkinGui::retranslateStrings() {
|
---|
403 | BaseGuiPlus::retranslateStrings();
|
---|
404 |
|
---|
405 | toolbar_menu->menuAction()->setText( tr("&Toolbars") );
|
---|
406 | toolbar_menu->menuAction()->setIcon( Images::icon("toolbars") );
|
---|
407 |
|
---|
408 | statusbar_menu->menuAction()->setText( tr("Status&bar") );
|
---|
409 | statusbar_menu->menuAction()->setIcon( Images::icon("statusbar") );
|
---|
410 |
|
---|
411 | toolbar1->setWindowTitle( tr("&Main toolbar") );
|
---|
412 | toolbar1->toggleViewAction()->setIcon(Images::icon("main_toolbar"));
|
---|
413 |
|
---|
414 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
415 | editToolbar1Act->change( tr("Edit main &toolbar") );
|
---|
416 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
417 | editFloatingControlAct->change( tr("Edit &floating control") );
|
---|
418 | #endif
|
---|
419 | #endif
|
---|
420 |
|
---|
421 | viewVideoInfoAct->change(Images::icon("view_video_info"), tr("&Video info") );
|
---|
422 | }
|
---|
423 |
|
---|
424 | void SkinGui::displayTime(QString text) {
|
---|
425 | time_label_action->setText(text);
|
---|
426 | }
|
---|
427 |
|
---|
428 | void SkinGui::displayState(Core::State state) {
|
---|
429 | BaseGuiPlus::displayState(state);
|
---|
430 |
|
---|
431 | switch (state) {
|
---|
432 | case Core::Playing: mediaBarPanel->displayMessage( tr("Playing %1").arg(core->mdat.filename)); break;
|
---|
433 | case Core::Paused: mediaBarPanel->displayMessage( tr("Pause") ); break;
|
---|
434 | case Core::Stopped: mediaBarPanel->displayMessage( tr("Stop") ); break;
|
---|
435 | }
|
---|
436 | }
|
---|
437 |
|
---|
438 | void SkinGui::displayMessage(QString message, int time) {
|
---|
439 | BaseGuiPlus::displayMessage(message, time);
|
---|
440 | mediaBarPanel->displayMessage(message, time);
|
---|
441 | }
|
---|
442 |
|
---|
443 | void SkinGui::displayMessage(QString message) {
|
---|
444 | BaseGuiPlus::displayMessage(message);
|
---|
445 | mediaBarPanel->displayMessage(message);
|
---|
446 | }
|
---|
447 |
|
---|
448 | void SkinGui::updateWidgets() {
|
---|
449 | qDebug("SkinGui::updateWidgets");
|
---|
450 |
|
---|
451 | BaseGuiPlus::updateWidgets();
|
---|
452 |
|
---|
453 | panel->setFocus();
|
---|
454 |
|
---|
455 | bool muted = (pref->global_volume ? pref->mute : core->mset.mute);
|
---|
456 | if (was_muted != muted) {
|
---|
457 | was_muted = muted;
|
---|
458 | if (muted) {
|
---|
459 | mediaBarPanel->setVolume(0);
|
---|
460 | } else {
|
---|
461 | mediaBarPanel->setVolume(core->mset.volume);
|
---|
462 | }
|
---|
463 | }
|
---|
464 | }
|
---|
465 |
|
---|
466 | void SkinGui::aboutToEnterFullscreen() {
|
---|
467 | qDebug("SkinGui::aboutToEnterFullscreen");
|
---|
468 |
|
---|
469 | BaseGuiPlus::aboutToEnterFullscreen();
|
---|
470 |
|
---|
471 | #ifndef SKIN_EDITABLE_CONTROL
|
---|
472 | controlwidget->removeAction(mediaBarPanelAction);
|
---|
473 | floating_control->layout()->addWidget(mediaBarPanel);
|
---|
474 | mediaBarPanel->show();
|
---|
475 | floating_control->adjustSize();
|
---|
476 | #endif
|
---|
477 | floating_control->setMargin(pref->floating_control_margin);
|
---|
478 | floating_control->setPercWidth(pref->floating_control_width);
|
---|
479 | floating_control->setAnimated(pref->floating_control_animated);
|
---|
480 | floating_control->setActivationArea( (AutohideWidget::Activation) pref->floating_activation_area);
|
---|
481 | floating_control->setHideDelay(pref->floating_hide_delay);
|
---|
482 | QTimer::singleShot(500, floating_control, SLOT(activate()));
|
---|
483 |
|
---|
484 |
|
---|
485 | // Save visibility of toolbars
|
---|
486 | fullscreen_toolbar1_was_visible = toolbar1->isVisible();
|
---|
487 |
|
---|
488 | if (!pref->compact_mode) {
|
---|
489 | controlwidget->hide();
|
---|
490 | toolbar1->hide();
|
---|
491 | }
|
---|
492 | }
|
---|
493 |
|
---|
494 | void SkinGui::aboutToExitFullscreen() {
|
---|
495 | qDebug("SkinGui::aboutToExitFullscreen");
|
---|
496 |
|
---|
497 | BaseGuiPlus::aboutToExitFullscreen();
|
---|
498 |
|
---|
499 | floating_control->deactivate();
|
---|
500 | #ifndef SKIN_EDITABLE_CONTROL
|
---|
501 | floating_control->layout()->removeWidget(mediaBarPanel);
|
---|
502 | mediaBarPanelAction = controlwidget->addWidget(mediaBarPanel);
|
---|
503 | #endif
|
---|
504 |
|
---|
505 | if (!pref->compact_mode) {
|
---|
506 | statusBar()->hide();
|
---|
507 | controlwidget->show();
|
---|
508 | toolbar1->setVisible( fullscreen_toolbar1_was_visible );
|
---|
509 | }
|
---|
510 | }
|
---|
511 |
|
---|
512 | void SkinGui::aboutToEnterCompactMode() {
|
---|
513 |
|
---|
514 | BaseGuiPlus::aboutToEnterCompactMode();
|
---|
515 |
|
---|
516 | // Save visibility of toolbars
|
---|
517 | compact_toolbar1_was_visible = toolbar1->isVisible();
|
---|
518 |
|
---|
519 | controlwidget->hide();
|
---|
520 | toolbar1->hide();
|
---|
521 | }
|
---|
522 |
|
---|
523 | void SkinGui::aboutToExitCompactMode() {
|
---|
524 | BaseGuiPlus::aboutToExitCompactMode();
|
---|
525 |
|
---|
526 | statusBar()->hide();
|
---|
527 | controlwidget->show();
|
---|
528 | toolbar1->setVisible( compact_toolbar1_was_visible );
|
---|
529 |
|
---|
530 | // Recheck size of controlwidget
|
---|
531 | /* resizeEvent( new QResizeEvent( size(), size() ) ); */
|
---|
532 | }
|
---|
533 |
|
---|
534 | void SkinGui::saveConfig() {
|
---|
535 | qDebug("SkinGui::saveConfig");
|
---|
536 |
|
---|
537 | QSettings * set = settings;
|
---|
538 |
|
---|
539 | set->beginGroup( "skin_gui");
|
---|
540 |
|
---|
541 | set->setValue("video_info", viewVideoInfoAct->isChecked());
|
---|
542 |
|
---|
543 | set->setValue("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible);
|
---|
544 | set->setValue("compact_toolbar1_was_visible", compact_toolbar1_was_visible);
|
---|
545 |
|
---|
546 | if (pref->save_window_size_on_exit) {
|
---|
547 | qDebug("SkinGui::saveConfig: w: %d h: %d", width(), height());
|
---|
548 | set->setValue( "pos", pos() );
|
---|
549 | set->setValue( "size", size() );
|
---|
550 | set->setValue( "state", (int) windowState() );
|
---|
551 | }
|
---|
552 |
|
---|
553 | set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
|
---|
554 |
|
---|
555 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
556 | set->beginGroup( "actions" );
|
---|
557 | set->setValue("toolbar1", toolbar1->actionsToStringList() );
|
---|
558 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
559 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
560 | set->setValue("floating_control", iw->actionsToStringList() );
|
---|
561 | #endif
|
---|
562 | set->setValue("toolbar1_version", TOOLBAR_VERSION);
|
---|
563 | set->endGroup();
|
---|
564 | #endif
|
---|
565 |
|
---|
566 | set->endGroup();
|
---|
567 | }
|
---|
568 |
|
---|
569 | void SkinGui::loadConfig() {
|
---|
570 | qDebug("SkinGui::loadConfig");
|
---|
571 |
|
---|
572 | QSettings * set = settings;
|
---|
573 |
|
---|
574 | set->beginGroup( "skin_gui");
|
---|
575 |
|
---|
576 | viewVideoInfoAct->setChecked(set->value("video_info", false).toBool());
|
---|
577 |
|
---|
578 | fullscreen_toolbar1_was_visible = set->value("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible).toBool();
|
---|
579 | compact_toolbar1_was_visible = set->value("compact_toolbar1_was_visible", compact_toolbar1_was_visible).toBool();
|
---|
580 |
|
---|
581 | if (pref->save_window_size_on_exit) {
|
---|
582 | QPoint p = set->value("pos", pos()).toPoint();
|
---|
583 | QSize s = set->value("size", size()).toSize();
|
---|
584 |
|
---|
585 | if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
|
---|
586 | s = pref->default_size;
|
---|
587 | }
|
---|
588 |
|
---|
589 | move(p);
|
---|
590 | resize(s);
|
---|
591 |
|
---|
592 | setWindowState( (Qt::WindowStates) set->value("state", 0).toInt() );
|
---|
593 |
|
---|
594 | if (!DesktopInfo::isInsideScreen(this)) {
|
---|
595 | move(0,0);
|
---|
596 | qWarning("SkinGui::loadConfig: window is outside of the screen, moved to 0x0");
|
---|
597 | }
|
---|
598 | }
|
---|
599 |
|
---|
600 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
601 | set->beginGroup( "actions" );
|
---|
602 | int toolbar_version = set->value("toolbar1_version", 0).toInt();
|
---|
603 | if (toolbar_version >= TOOLBAR_VERSION) {
|
---|
604 | toolbar1->setActionsFromStringList( set->value("toolbar1", toolbar1->defaultActions()).toStringList() );
|
---|
605 | } else {
|
---|
606 | qDebug("SkinGui::loadConfig: toolbar too old, loading default one");
|
---|
607 | toolbar1->setActionsFromStringList( toolbar1->defaultActions() );
|
---|
608 | }
|
---|
609 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
610 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
611 | iw->setActionsFromStringList( set->value("floating_control", iw->defaultActions()).toStringList() );
|
---|
612 | floating_control->adjustSize();
|
---|
613 | #endif
|
---|
614 | set->endGroup();
|
---|
615 | #endif
|
---|
616 |
|
---|
617 | restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
|
---|
618 |
|
---|
619 | #if DOCK_PLAYLIST
|
---|
620 | qDebug("SkinGui::loadConfig: playlist visible: %d", playlistdock->isVisible());
|
---|
621 | qDebug("SkinGui::loadConfig: playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
622 | qDebug("SkinGui::loadConfig: playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
623 | #endif
|
---|
624 |
|
---|
625 | set->endGroup();
|
---|
626 |
|
---|
627 | updateWidgets();
|
---|
628 | }
|
---|
629 |
|
---|
630 | #include "moc_skingui.cpp"
|
---|