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