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