1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2012 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 "defaultgui.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 "toolbareditor.h"
|
---|
31 | #include "desktopinfo.h"
|
---|
32 |
|
---|
33 | #if DOCK_PLAYLIST
|
---|
34 | #include "playlistdock.h"
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #include <QMenu>
|
---|
38 | #include <QToolBar>
|
---|
39 | #include <QSettings>
|
---|
40 | #include <QLabel>
|
---|
41 | #include <QStatusBar>
|
---|
42 | #include <QPushButton>
|
---|
43 | #include <QToolButton>
|
---|
44 | #include <QMenuBar>
|
---|
45 |
|
---|
46 | #define TOOLBAR_VERSION 1
|
---|
47 |
|
---|
48 | using namespace Global;
|
---|
49 |
|
---|
50 | DefaultGui::DefaultGui( bool use_server, QWidget * parent, Qt::WindowFlags flags )
|
---|
51 | : BaseGuiPlus( use_server, parent, flags )
|
---|
52 | {
|
---|
53 | createStatusBar();
|
---|
54 |
|
---|
55 | connect( this, SIGNAL(timeChanged(QString)),
|
---|
56 | this, SLOT(displayTime(QString)) );
|
---|
57 | connect( this, SIGNAL(frameChanged(int)),
|
---|
58 | this, SLOT(displayFrame(int)) );
|
---|
59 | connect( this, SIGNAL(ABMarkersChanged(int,int)),
|
---|
60 | this, SLOT(displayABSection(int,int)) );
|
---|
61 | connect( this, SIGNAL(videoInfoChanged(int,int,double)),
|
---|
62 | this, SLOT(displayVideoInfo(int,int,double)) );
|
---|
63 |
|
---|
64 | connect( this, SIGNAL(cursorNearBottom(QPoint)),
|
---|
65 | this, SLOT(showFloatingControl(QPoint)) );
|
---|
66 | connect( this, SIGNAL(cursorNearTop(QPoint)),
|
---|
67 | this, SLOT(showFloatingMenu(QPoint)) );
|
---|
68 | connect( this, SIGNAL(cursorFarEdges()),
|
---|
69 | this, SLOT(hideFloatingControls()) );
|
---|
70 |
|
---|
71 | createActions();
|
---|
72 | createMainToolBars();
|
---|
73 | createControlWidget();
|
---|
74 | createControlWidgetMini();
|
---|
75 | createFloatingControl();
|
---|
76 | createMenus();
|
---|
77 |
|
---|
78 | retranslateStrings();
|
---|
79 |
|
---|
80 | loadConfig();
|
---|
81 |
|
---|
82 | //if (playlist_visible) showPlaylist(true);
|
---|
83 |
|
---|
84 | if (pref->compact_mode) {
|
---|
85 | controlwidget->hide();
|
---|
86 | toolbar1->hide();
|
---|
87 | toolbar2->hide();
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | DefaultGui::~DefaultGui() {
|
---|
92 | saveConfig();
|
---|
93 | }
|
---|
94 |
|
---|
95 | /*
|
---|
96 | void DefaultGui::closeEvent( QCloseEvent * ) {
|
---|
97 | qDebug("DefaultGui::closeEvent");
|
---|
98 |
|
---|
99 | //BaseGuiPlus::closeEvent(e);
|
---|
100 | qDebug("w: %d h: %d", width(), height() );
|
---|
101 | }
|
---|
102 | */
|
---|
103 |
|
---|
104 | void DefaultGui::createActions() {
|
---|
105 | qDebug("DefaultGui::createActions");
|
---|
106 |
|
---|
107 | timeslider_action = createTimeSliderAction(this);
|
---|
108 | timeslider_action->disable();
|
---|
109 |
|
---|
110 | volumeslider_action = createVolumeSliderAction(this);
|
---|
111 | volumeslider_action->disable();
|
---|
112 |
|
---|
113 | // Create the time label
|
---|
114 | time_label_action = new TimeLabelAction(this);
|
---|
115 | time_label_action->setObjectName("timelabel_action");
|
---|
116 |
|
---|
117 | #if MINI_ARROW_BUTTONS
|
---|
118 | QList<QAction*> rewind_actions;
|
---|
119 | rewind_actions << rewind1Act << rewind2Act << rewind3Act;
|
---|
120 | rewindbutton_action = new SeekingButton(rewind_actions, this);
|
---|
121 | rewindbutton_action->setObjectName("rewindbutton_action");
|
---|
122 |
|
---|
123 | QList<QAction*> forward_actions;
|
---|
124 | forward_actions << forward1Act << forward2Act << forward3Act;
|
---|
125 | forwardbutton_action = new SeekingButton(forward_actions, this);
|
---|
126 | forwardbutton_action->setObjectName("forwardbutton_action");
|
---|
127 | #endif
|
---|
128 |
|
---|
129 | // Statusbar
|
---|
130 | viewVideoInfoAct = new MyAction(this, "toggle_video_info" );
|
---|
131 | viewVideoInfoAct->setCheckable(true);
|
---|
132 | connect( viewVideoInfoAct, SIGNAL(toggled(bool)),
|
---|
133 | video_info_display, SLOT(setVisible(bool)) );
|
---|
134 |
|
---|
135 | viewFrameCounterAct = new MyAction( this, "toggle_frame_counter" );
|
---|
136 | viewFrameCounterAct->setCheckable( true );
|
---|
137 | connect( viewFrameCounterAct, SIGNAL(toggled(bool)),
|
---|
138 | frame_display, SLOT(setVisible(bool)) );
|
---|
139 | }
|
---|
140 |
|
---|
141 | #if AUTODISABLE_ACTIONS
|
---|
142 | void DefaultGui::enableActionsOnPlaying() {
|
---|
143 | qDebug("DefaultGui::enableActionsOnPlaying");
|
---|
144 | BaseGuiPlus::enableActionsOnPlaying();
|
---|
145 |
|
---|
146 | timeslider_action->enable();
|
---|
147 | volumeslider_action->enable();
|
---|
148 | }
|
---|
149 |
|
---|
150 | void DefaultGui::disableActionsOnStop() {
|
---|
151 | qDebug("DefaultGui::disableActionsOnStop");
|
---|
152 | BaseGuiPlus::disableActionsOnStop();
|
---|
153 |
|
---|
154 | timeslider_action->disable();
|
---|
155 | volumeslider_action->disable();
|
---|
156 | }
|
---|
157 | #endif // AUTODISABLE_ACTIONS
|
---|
158 |
|
---|
159 | void DefaultGui::createMenus() {
|
---|
160 | toolbar_menu = new QMenu(this);
|
---|
161 | toolbar_menu->addAction(toolbar1->toggleViewAction());
|
---|
162 | toolbar_menu->addAction(toolbar2->toggleViewAction());
|
---|
163 | optionsMenu->addSeparator();
|
---|
164 | optionsMenu->addMenu(toolbar_menu);
|
---|
165 |
|
---|
166 | statusbar_menu = new QMenu(this);
|
---|
167 | statusbar_menu->addAction(viewVideoInfoAct);
|
---|
168 | statusbar_menu->addAction(viewFrameCounterAct);
|
---|
169 |
|
---|
170 | optionsMenu->addMenu(statusbar_menu);
|
---|
171 | }
|
---|
172 |
|
---|
173 | QMenu * DefaultGui::createPopupMenu() {
|
---|
174 | QMenu * m = new QMenu(this);
|
---|
175 | m->addAction(toolbar1->toggleViewAction());
|
---|
176 | m->addAction(toolbar2->toggleViewAction());
|
---|
177 | return m;
|
---|
178 | }
|
---|
179 |
|
---|
180 | void DefaultGui::createMainToolBars() {
|
---|
181 | toolbar1 = new QToolBar( this );
|
---|
182 | toolbar1->setObjectName("toolbar1");
|
---|
183 | //toolbar1->setMovable(false);
|
---|
184 | addToolBar(Qt::TopToolBarArea, toolbar1);
|
---|
185 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
186 | toolbar1->addAction(openFileAct);
|
---|
187 | toolbar1->addAction(openDVDAct);
|
---|
188 | toolbar1->addAction(openURLAct);
|
---|
189 | toolbar1->addSeparator();
|
---|
190 | toolbar1->addAction(compactAct);
|
---|
191 | toolbar1->addAction(fullscreenAct);
|
---|
192 | toolbar1->addSeparator();
|
---|
193 | toolbar1->addAction(screenshotAct);
|
---|
194 | toolbar1->addSeparator();
|
---|
195 | toolbar1->addAction(showPropertiesAct);
|
---|
196 | toolbar1->addAction(showPlaylistAct);
|
---|
197 | toolbar1->addAction(showPreferencesAct);
|
---|
198 | toolbar1->addSeparator();
|
---|
199 | toolbar1->addAction(playPrevAct);
|
---|
200 | toolbar1->addAction(playNextAct);
|
---|
201 | // Test:
|
---|
202 | //toolbar1->addSeparator();
|
---|
203 | //toolbar1->addAction(timeslider_action);
|
---|
204 | //toolbar1->addAction(volumeslider_action);
|
---|
205 | #endif
|
---|
206 |
|
---|
207 | toolbar2 = new QToolBar( this );
|
---|
208 | toolbar2->setObjectName("toolbar2");
|
---|
209 | //toolbar2->setMovable(false);
|
---|
210 | addToolBar(Qt::TopToolBarArea, toolbar2);
|
---|
211 |
|
---|
212 | select_audio = new QPushButton( this );
|
---|
213 | select_audio->setMenu( audiotrack_menu );
|
---|
214 | toolbar2->addWidget(select_audio);
|
---|
215 |
|
---|
216 | select_subtitle = new QPushButton( this );
|
---|
217 | select_subtitle->setMenu( subtitlestrack_menu );
|
---|
218 | toolbar2->addWidget(select_subtitle);
|
---|
219 |
|
---|
220 | /*
|
---|
221 | toolbar1->show();
|
---|
222 | toolbar2->show();
|
---|
223 | */
|
---|
224 |
|
---|
225 | // Modify toolbars' actions
|
---|
226 | QAction *tba;
|
---|
227 | tba = toolbar1->toggleViewAction();
|
---|
228 | tba->setObjectName("show_main_toolbar");
|
---|
229 | tba->setShortcut(Qt::Key_F5);
|
---|
230 |
|
---|
231 | tba = toolbar2->toggleViewAction();
|
---|
232 | tba->setObjectName("show_language_toolbar");
|
---|
233 | tba->setShortcut(Qt::Key_F6);
|
---|
234 | }
|
---|
235 |
|
---|
236 |
|
---|
237 | void DefaultGui::createControlWidgetMini() {
|
---|
238 | qDebug("DefaultGui::createControlWidgetMini");
|
---|
239 |
|
---|
240 | controlwidget_mini = new QToolBar( this );
|
---|
241 | controlwidget_mini->setObjectName("controlwidget_mini");
|
---|
242 | //controlwidget_mini->setResizeEnabled(false);
|
---|
243 | controlwidget_mini->setMovable(false);
|
---|
244 | //addDockWindow(controlwidget_mini, Qt::DockBottom );
|
---|
245 | addToolBar(Qt::BottomToolBarArea, controlwidget_mini);
|
---|
246 |
|
---|
247 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
248 | controlwidget_mini->addAction(playOrPauseAct);
|
---|
249 | controlwidget_mini->addAction(stopAct);
|
---|
250 | controlwidget_mini->addSeparator();
|
---|
251 |
|
---|
252 | controlwidget_mini->addAction(rewind1Act);
|
---|
253 |
|
---|
254 | controlwidget_mini->addAction(timeslider_action);
|
---|
255 |
|
---|
256 | controlwidget_mini->addAction(forward1Act);
|
---|
257 |
|
---|
258 | controlwidget_mini->addSeparator();
|
---|
259 |
|
---|
260 | controlwidget_mini->addAction(muteAct );
|
---|
261 |
|
---|
262 | controlwidget_mini->addAction(volumeslider_action);
|
---|
263 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
264 |
|
---|
265 | controlwidget_mini->hide();
|
---|
266 | }
|
---|
267 |
|
---|
268 | void DefaultGui::createControlWidget() {
|
---|
269 | qDebug("DefaultGui::createControlWidget");
|
---|
270 |
|
---|
271 | controlwidget = new QToolBar( this );
|
---|
272 | controlwidget->setObjectName("controlwidget");
|
---|
273 | //controlwidget->setResizeEnabled(false);
|
---|
274 | controlwidget->setMovable(false);
|
---|
275 | //addDockWindow(controlwidget, Qt::DockBottom );
|
---|
276 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
---|
277 |
|
---|
278 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
279 | controlwidget->addAction(playAct);
|
---|
280 | controlwidget->addAction(pauseAndStepAct);
|
---|
281 | controlwidget->addAction(stopAct);
|
---|
282 |
|
---|
283 | controlwidget->addSeparator();
|
---|
284 |
|
---|
285 | #if MINI_ARROW_BUTTONS
|
---|
286 | controlwidget->addAction( rewindbutton_action );
|
---|
287 | #else
|
---|
288 | controlwidget->addAction(rewind3Act);
|
---|
289 | controlwidget->addAction(rewind2Act);
|
---|
290 | controlwidget->addAction(rewind1Act);
|
---|
291 | #endif
|
---|
292 |
|
---|
293 | controlwidget->addAction(timeslider_action);
|
---|
294 |
|
---|
295 | #if MINI_ARROW_BUTTONS
|
---|
296 | controlwidget->addAction( forwardbutton_action );
|
---|
297 | #else
|
---|
298 | controlwidget->addAction(forward1Act);
|
---|
299 | controlwidget->addAction(forward2Act);
|
---|
300 | controlwidget->addAction(forward3Act);
|
---|
301 | #endif
|
---|
302 |
|
---|
303 | controlwidget->addSeparator();
|
---|
304 |
|
---|
305 | controlwidget->addAction(fullscreenAct);
|
---|
306 | controlwidget->addAction(muteAct);
|
---|
307 |
|
---|
308 | controlwidget->addAction(volumeslider_action);
|
---|
309 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
310 |
|
---|
311 | /*
|
---|
312 | controlwidget->show();
|
---|
313 | */
|
---|
314 | }
|
---|
315 |
|
---|
316 | void DefaultGui::createFloatingControl() {
|
---|
317 | // Floating control
|
---|
318 | floating_control = new FloatingWidget(this);
|
---|
319 |
|
---|
320 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
321 | floating_control->toolbar()->addAction(playAct);
|
---|
322 | floating_control->toolbar()->addAction(pauseAct);
|
---|
323 | floating_control->toolbar()->addAction(stopAct);
|
---|
324 | floating_control->toolbar()->addSeparator();
|
---|
325 |
|
---|
326 | #if MINI_ARROW_BUTTONS
|
---|
327 | floating_control->toolbar()->addAction( rewindbutton_action );
|
---|
328 | #else
|
---|
329 | floating_control->toolbar()->addAction(rewind3Act);
|
---|
330 | floating_control->toolbar()->addAction(rewind2Act);
|
---|
331 | floating_control->toolbar()->addAction(rewind1Act);
|
---|
332 | #endif
|
---|
333 |
|
---|
334 | floating_control->toolbar()->addAction(timeslider_action);
|
---|
335 |
|
---|
336 | #if MINI_ARROW_BUTTONS
|
---|
337 | floating_control->toolbar()->addAction( forwardbutton_action );
|
---|
338 | #else
|
---|
339 | floating_control->toolbar()->addAction(forward1Act);
|
---|
340 | floating_control->toolbar()->addAction(forward2Act);
|
---|
341 | floating_control->toolbar()->addAction(forward3Act);
|
---|
342 | #endif
|
---|
343 |
|
---|
344 | floating_control->toolbar()->addSeparator();
|
---|
345 | floating_control->toolbar()->addAction(fullscreenAct);
|
---|
346 | floating_control->toolbar()->addAction(muteAct);
|
---|
347 | floating_control->toolbar()->addAction(volumeslider_action);
|
---|
348 | floating_control->toolbar()->addSeparator();
|
---|
349 | floating_control->toolbar()->addAction(time_label_action);
|
---|
350 |
|
---|
351 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
352 |
|
---|
353 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
---|
354 | // To make work the ESC key (exit fullscreen) and Ctrl-X (close) in Windows and OS2
|
---|
355 | floating_control->addAction(exitFullscreenAct);
|
---|
356 | floating_control->addAction(exitAct);
|
---|
357 | #endif
|
---|
358 |
|
---|
359 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
360 | floating_control->adjustSize();
|
---|
361 | #endif
|
---|
362 | }
|
---|
363 |
|
---|
364 | void DefaultGui::createStatusBar() {
|
---|
365 | qDebug("DefaultGui::createStatusBar");
|
---|
366 |
|
---|
367 | time_display = new QLabel( statusBar() );
|
---|
368 | time_display->setAlignment(Qt::AlignRight);
|
---|
369 | time_display->setFrameShape(QFrame::NoFrame);
|
---|
370 | time_display->setText(" 88:88:88 / 88:88:88 ");
|
---|
371 | time_display->setMinimumSize(time_display->sizeHint());
|
---|
372 |
|
---|
373 | frame_display = new QLabel( statusBar() );
|
---|
374 | frame_display->setAlignment(Qt::AlignRight);
|
---|
375 | frame_display->setFrameShape(QFrame::NoFrame);
|
---|
376 | frame_display->setText("88888888");
|
---|
377 | frame_display->setMinimumSize(frame_display->sizeHint());
|
---|
378 |
|
---|
379 | ab_section_display = new QLabel( statusBar() );
|
---|
380 | ab_section_display->setAlignment(Qt::AlignRight);
|
---|
381 | ab_section_display->setFrameShape(QFrame::NoFrame);
|
---|
382 | // ab_section_display->setText("A:0:00:00 B:0:00:00");
|
---|
383 | // ab_section_display->setMinimumSize(ab_section_display->sizeHint());
|
---|
384 |
|
---|
385 | video_info_display = new QLabel( statusBar() );
|
---|
386 | video_info_display->setAlignment(Qt::AlignRight);
|
---|
387 | video_info_display->setFrameShape(QFrame::NoFrame);
|
---|
388 |
|
---|
389 | statusBar()->setAutoFillBackground(TRUE);
|
---|
390 |
|
---|
391 | ColorUtils::setBackgroundColor( statusBar(), QColor(0,0,0) );
|
---|
392 | ColorUtils::setForegroundColor( statusBar(), QColor(255,255,255) );
|
---|
393 | ColorUtils::setBackgroundColor( time_display, QColor(0,0,0) );
|
---|
394 | ColorUtils::setForegroundColor( time_display, QColor(255,255,255) );
|
---|
395 | ColorUtils::setBackgroundColor( frame_display, QColor(0,0,0) );
|
---|
396 | ColorUtils::setForegroundColor( frame_display, QColor(255,255,255) );
|
---|
397 | ColorUtils::setBackgroundColor( ab_section_display, QColor(0,0,0) );
|
---|
398 | ColorUtils::setForegroundColor( ab_section_display, QColor(255,255,255) );
|
---|
399 | ColorUtils::setBackgroundColor( video_info_display, QColor(0,0,0) );
|
---|
400 | ColorUtils::setForegroundColor( video_info_display, QColor(255,255,255) );
|
---|
401 | statusBar()->setSizeGripEnabled(FALSE);
|
---|
402 |
|
---|
403 | statusBar()->addPermanentWidget( video_info_display );
|
---|
404 | statusBar()->addPermanentWidget( ab_section_display );
|
---|
405 |
|
---|
406 | statusBar()->showMessage( tr("Welcome to SMPlayer") );
|
---|
407 | statusBar()->addPermanentWidget( frame_display, 0 );
|
---|
408 | frame_display->setText( "0" );
|
---|
409 |
|
---|
410 | statusBar()->addPermanentWidget( time_display, 0 );
|
---|
411 | time_display->setText(" 00:00:00 / 00:00:00 ");
|
---|
412 |
|
---|
413 | time_display->show();
|
---|
414 | frame_display->hide();
|
---|
415 | ab_section_display->show();
|
---|
416 | video_info_display->hide();
|
---|
417 | }
|
---|
418 |
|
---|
419 | void DefaultGui::retranslateStrings() {
|
---|
420 | BaseGuiPlus::retranslateStrings();
|
---|
421 |
|
---|
422 | toolbar_menu->menuAction()->setText( tr("&Toolbars") );
|
---|
423 | toolbar_menu->menuAction()->setIcon( Images::icon("toolbars") );
|
---|
424 |
|
---|
425 | statusbar_menu->menuAction()->setText( tr("Status&bar") );
|
---|
426 | statusbar_menu->menuAction()->setIcon( Images::icon("statusbar") );
|
---|
427 |
|
---|
428 | toolbar1->setWindowTitle( tr("&Main toolbar") );
|
---|
429 | toolbar1->toggleViewAction()->setIcon(Images::icon("main_toolbar"));
|
---|
430 |
|
---|
431 | toolbar2->setWindowTitle( tr("&Language toolbar") );
|
---|
432 | toolbar2->toggleViewAction()->setIcon(Images::icon("lang_toolbar"));
|
---|
433 |
|
---|
434 | select_audio->setText( tr("Audio") );
|
---|
435 | select_subtitle->setText( tr("Subtitle") );
|
---|
436 |
|
---|
437 | viewVideoInfoAct->change(Images::icon("view_video_info"), tr("&Video info") );
|
---|
438 | viewFrameCounterAct->change( Images::icon("frame_counter"), tr("&Frame counter") );
|
---|
439 | }
|
---|
440 |
|
---|
441 |
|
---|
442 | void DefaultGui::displayTime(QString text) {
|
---|
443 | time_display->setText( text );
|
---|
444 | time_label_action->setText(text);
|
---|
445 | }
|
---|
446 |
|
---|
447 | void DefaultGui::displayFrame(int frame) {
|
---|
448 | if (frame_display->isVisible()) {
|
---|
449 | frame_display->setNum( frame );
|
---|
450 | }
|
---|
451 | }
|
---|
452 |
|
---|
453 | void DefaultGui::displayABSection(int secs_a, int secs_b) {
|
---|
454 | QString s;
|
---|
455 | if (secs_a > -1) s = tr("A:%1").arg(Helper::formatTime(secs_a));
|
---|
456 |
|
---|
457 | if (secs_b > -1) {
|
---|
458 | if (!s.isEmpty()) s += " ";
|
---|
459 | s += tr("B:%1").arg(Helper::formatTime(secs_b));
|
---|
460 | }
|
---|
461 |
|
---|
462 | ab_section_display->setText( s );
|
---|
463 |
|
---|
464 | ab_section_display->setShown( !s.isEmpty() );
|
---|
465 | }
|
---|
466 |
|
---|
467 | void DefaultGui::displayVideoInfo(int width, int height, double fps) {
|
---|
468 | video_info_display->setText(tr("%1x%2 %3 fps", "width + height + fps").arg(width).arg(height).arg(fps));
|
---|
469 | }
|
---|
470 |
|
---|
471 | void DefaultGui::updateWidgets() {
|
---|
472 | qDebug("DefaultGui::updateWidgets");
|
---|
473 |
|
---|
474 | BaseGuiPlus::updateWidgets();
|
---|
475 |
|
---|
476 | panel->setFocus();
|
---|
477 | }
|
---|
478 |
|
---|
479 | void DefaultGui::aboutToEnterFullscreen() {
|
---|
480 | qDebug("DefaultGui::aboutToEnterFullscreen");
|
---|
481 |
|
---|
482 | BaseGuiPlus::aboutToEnterFullscreen();
|
---|
483 |
|
---|
484 | // Save visibility of toolbars
|
---|
485 | fullscreen_toolbar1_was_visible = toolbar1->isVisible();
|
---|
486 | fullscreen_toolbar2_was_visible = toolbar2->isVisible();
|
---|
487 |
|
---|
488 | if (!pref->compact_mode) {
|
---|
489 | //menuBar()->hide();
|
---|
490 | //statusBar()->hide();
|
---|
491 | controlwidget->hide();
|
---|
492 | controlwidget_mini->hide();
|
---|
493 | toolbar1->hide();
|
---|
494 | toolbar2->hide();
|
---|
495 | }
|
---|
496 | }
|
---|
497 |
|
---|
498 | void DefaultGui::aboutToExitFullscreen() {
|
---|
499 | qDebug("DefaultGui::aboutToExitFullscreen");
|
---|
500 |
|
---|
501 | BaseGuiPlus::aboutToExitFullscreen();
|
---|
502 |
|
---|
503 | floating_control->hide();
|
---|
504 |
|
---|
505 | if (!pref->compact_mode) {
|
---|
506 | //menuBar()->show();
|
---|
507 | //statusBar()->show();
|
---|
508 | controlwidget->show();
|
---|
509 |
|
---|
510 | toolbar1->setVisible( fullscreen_toolbar1_was_visible );
|
---|
511 | toolbar2->setVisible( fullscreen_toolbar2_was_visible );
|
---|
512 | }
|
---|
513 | }
|
---|
514 |
|
---|
515 | void DefaultGui::aboutToEnterCompactMode() {
|
---|
516 |
|
---|
517 | BaseGuiPlus::aboutToEnterCompactMode();
|
---|
518 |
|
---|
519 | // Save visibility of toolbars
|
---|
520 | compact_toolbar1_was_visible = toolbar1->isVisible();
|
---|
521 | compact_toolbar2_was_visible = toolbar2->isVisible();
|
---|
522 |
|
---|
523 | //menuBar()->hide();
|
---|
524 | //statusBar()->hide();
|
---|
525 | controlwidget->hide();
|
---|
526 | controlwidget_mini->hide();
|
---|
527 | toolbar1->hide();
|
---|
528 | toolbar2->hide();
|
---|
529 | }
|
---|
530 |
|
---|
531 | void DefaultGui::aboutToExitCompactMode() {
|
---|
532 | BaseGuiPlus::aboutToExitCompactMode();
|
---|
533 |
|
---|
534 | //menuBar()->show();
|
---|
535 | //statusBar()->show();
|
---|
536 | controlwidget->show();
|
---|
537 |
|
---|
538 | toolbar1->setVisible( compact_toolbar1_was_visible );
|
---|
539 | toolbar2->setVisible( compact_toolbar2_was_visible );
|
---|
540 |
|
---|
541 | // Recheck size of controlwidget
|
---|
542 | resizeEvent( new QResizeEvent( size(), size() ) );
|
---|
543 | }
|
---|
544 |
|
---|
545 | void DefaultGui::showFloatingControl(QPoint /*p*/) {
|
---|
546 | qDebug("DefaultGui::showFloatingControl");
|
---|
547 |
|
---|
548 | #if CONTROLWIDGET_OVER_VIDEO
|
---|
549 | if ((pref->compact_mode) && (!pref->fullscreen)) {
|
---|
550 | floating_control->setAnimated( false );
|
---|
551 | } else {
|
---|
552 | floating_control->setAnimated( pref->floating_control_animated );
|
---|
553 | }
|
---|
554 | floating_control->setMargin(pref->floating_control_margin);
|
---|
555 | #ifndef Q_OS_WIN
|
---|
556 | floating_control->setBypassWindowManager(pref->bypass_window_manager);
|
---|
557 | #endif
|
---|
558 | floating_control->showOver(panel, pref->floating_control_width);
|
---|
559 | #else
|
---|
560 | if (!controlwidget->isVisible()) {
|
---|
561 | controlwidget->show();
|
---|
562 | }
|
---|
563 | #endif
|
---|
564 | }
|
---|
565 |
|
---|
566 | void DefaultGui::showFloatingMenu(QPoint /*p*/) {
|
---|
567 | #if !CONTROLWIDGET_OVER_VIDEO
|
---|
568 | qDebug("DefaultGui::showFloatingMenu");
|
---|
569 |
|
---|
570 | if (!menuBar()->isVisible())
|
---|
571 | menuBar()->show();
|
---|
572 | #endif
|
---|
573 | }
|
---|
574 |
|
---|
575 | void DefaultGui::hideFloatingControls() {
|
---|
576 | qDebug("DefaultGui::hideFloatingControls");
|
---|
577 |
|
---|
578 | #if CONTROLWIDGET_OVER_VIDEO
|
---|
579 | floating_control->hide();
|
---|
580 | #else
|
---|
581 | if (controlwidget->isVisible())
|
---|
582 | controlwidget->hide();
|
---|
583 |
|
---|
584 | if (menuBar()->isVisible())
|
---|
585 | menuBar()->hide();
|
---|
586 | #endif
|
---|
587 | }
|
---|
588 |
|
---|
589 | void DefaultGui::resizeEvent( QResizeEvent * ) {
|
---|
590 | /*
|
---|
591 | qDebug("defaultGui::resizeEvent");
|
---|
592 | qDebug(" controlwidget width: %d", controlwidget->width() );
|
---|
593 | qDebug(" controlwidget_mini width: %d", controlwidget_mini->width() );
|
---|
594 | */
|
---|
595 |
|
---|
596 | #if QT_VERSION < 0x040000
|
---|
597 | #define LIMIT 470
|
---|
598 | #else
|
---|
599 | #define LIMIT 570
|
---|
600 | #endif
|
---|
601 |
|
---|
602 | if ( (controlwidget->isVisible()) && (width() < LIMIT) ) {
|
---|
603 | controlwidget->hide();
|
---|
604 | controlwidget_mini->show();
|
---|
605 | }
|
---|
606 | else
|
---|
607 | if ( (controlwidget_mini->isVisible()) && (width() > LIMIT) ) {
|
---|
608 | controlwidget_mini->hide();
|
---|
609 | controlwidget->show();
|
---|
610 | }
|
---|
611 | }
|
---|
612 |
|
---|
613 | #if USE_MINIMUMSIZE
|
---|
614 | QSize DefaultGui::minimumSizeHint() const {
|
---|
615 | return QSize(controlwidget_mini->sizeHint().width(), 0);
|
---|
616 | }
|
---|
617 | #endif
|
---|
618 |
|
---|
619 |
|
---|
620 | void DefaultGui::saveConfig() {
|
---|
621 | qDebug("DefaultGui::saveConfig");
|
---|
622 |
|
---|
623 | QSettings * set = settings;
|
---|
624 |
|
---|
625 | set->beginGroup( "default_gui");
|
---|
626 |
|
---|
627 | set->setValue("video_info", viewVideoInfoAct->isChecked());
|
---|
628 | set->setValue("frame_counter", viewFrameCounterAct->isChecked());
|
---|
629 |
|
---|
630 | set->setValue("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible);
|
---|
631 | set->setValue("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible);
|
---|
632 | set->setValue("compact_toolbar1_was_visible", compact_toolbar1_was_visible);
|
---|
633 | set->setValue("compact_toolbar2_was_visible", compact_toolbar2_was_visible);
|
---|
634 |
|
---|
635 | if (pref->save_window_size_on_exit) {
|
---|
636 | qDebug("DefaultGui::saveConfig: w: %d h: %d", width(), height());
|
---|
637 | set->setValue( "pos", pos() );
|
---|
638 | set->setValue( "size", size() );
|
---|
639 | }
|
---|
640 |
|
---|
641 | set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
|
---|
642 |
|
---|
643 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
644 | set->beginGroup( "actions" );
|
---|
645 | set->setValue("toolbar1", ToolbarEditor::save(toolbar1) );
|
---|
646 | set->setValue("controlwidget", ToolbarEditor::save(controlwidget) );
|
---|
647 | set->setValue("controlwidget_mini", ToolbarEditor::save(controlwidget_mini) );
|
---|
648 | set->setValue("floating_control", ToolbarEditor::save(floating_control->toolbar()) );
|
---|
649 | set->setValue("toolbar1_version", TOOLBAR_VERSION);
|
---|
650 | set->endGroup();
|
---|
651 | #endif
|
---|
652 |
|
---|
653 | set->endGroup();
|
---|
654 | }
|
---|
655 |
|
---|
656 | void DefaultGui::loadConfig() {
|
---|
657 | qDebug("DefaultGui::loadConfig");
|
---|
658 |
|
---|
659 | QSettings * set = settings;
|
---|
660 |
|
---|
661 | set->beginGroup( "default_gui");
|
---|
662 |
|
---|
663 | viewVideoInfoAct->setChecked(set->value("video_info", false).toBool());
|
---|
664 | viewFrameCounterAct->setChecked(set->value("frame_counter", false).toBool());
|
---|
665 |
|
---|
666 | fullscreen_toolbar1_was_visible = set->value("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible).toBool();
|
---|
667 | fullscreen_toolbar2_was_visible = set->value("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible).toBool();
|
---|
668 | compact_toolbar1_was_visible = set->value("compact_toolbar1_was_visible", compact_toolbar1_was_visible).toBool();
|
---|
669 | compact_toolbar2_was_visible = set->value("compact_toolbar2_was_visible", compact_toolbar2_was_visible).toBool();
|
---|
670 |
|
---|
671 | if (pref->save_window_size_on_exit) {
|
---|
672 | QPoint p = set->value("pos", pos()).toPoint();
|
---|
673 | QSize s = set->value("size", size()).toSize();
|
---|
674 |
|
---|
675 | if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
|
---|
676 | s = pref->default_size;
|
---|
677 | }
|
---|
678 |
|
---|
679 | move(p);
|
---|
680 | resize(s);
|
---|
681 |
|
---|
682 | if (!DesktopInfo::isInsideScreen(this)) {
|
---|
683 | move(0,0);
|
---|
684 | qWarning("DefaultGui::loadConfig: window is outside of the screen, moved to 0x0");
|
---|
685 | }
|
---|
686 | }
|
---|
687 |
|
---|
688 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
689 | QList<QAction *> actions_list = findChildren<QAction *>();
|
---|
690 | QStringList toolbar1_actions;
|
---|
691 | toolbar1_actions << "open_file" << "open_dvd" << "open_url" << "favorites_menu" << "separator" << "compact" << "fullscreen"
|
---|
692 | << "separator" << "screenshot" << "separator" << "show_file_properties" << "show_playlist"
|
---|
693 | << "show_preferences" << "separator" << "play_prev" << "play_next";
|
---|
694 |
|
---|
695 | QStringList controlwidget_actions;
|
---|
696 | controlwidget_actions << "play" << "pause_and_frame_step" << "stop" << "separator";
|
---|
697 |
|
---|
698 | #if MINI_ARROW_BUTTONS
|
---|
699 | controlwidget_actions << "rewindbutton_action";
|
---|
700 | #else
|
---|
701 | controlwidget_actions << "rewind3" << "rewind2" << "rewind1";
|
---|
702 | #endif
|
---|
703 |
|
---|
704 | controlwidget_actions << "timeslider_action";
|
---|
705 |
|
---|
706 | #if MINI_ARROW_BUTTONS
|
---|
707 | controlwidget_actions << "forwardbutton_action";
|
---|
708 | #else
|
---|
709 | controlwidget_actions << "forward1" << "forward2" << "forward3";
|
---|
710 | #endif
|
---|
711 |
|
---|
712 | controlwidget_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action";
|
---|
713 |
|
---|
714 | QStringList controlwidget_mini_actions;
|
---|
715 | controlwidget_mini_actions << "play_or_pause" << "stop" << "separator" << "rewind1" << "timeslider_action"
|
---|
716 | << "forward1" << "separator" << "mute" << "volumeslider_action";
|
---|
717 |
|
---|
718 | QStringList floatingcontrol_actions;
|
---|
719 | floatingcontrol_actions << "play" << "pause" << "stop" << "separator";
|
---|
720 |
|
---|
721 | #if MINI_ARROW_BUTTONS
|
---|
722 | floatingcontrol_actions << "rewindbutton_action";
|
---|
723 | #else
|
---|
724 | floatingcontrol_actions << "rewind3" << "rewind2" << "rewind1";
|
---|
725 | #endif
|
---|
726 |
|
---|
727 | floatingcontrol_actions << "timeslider_action";
|
---|
728 |
|
---|
729 | #if MINI_ARROW_BUTTONS
|
---|
730 | floatingcontrol_actions << "forwardbutton_action";
|
---|
731 | #else
|
---|
732 | floatingcontrol_actions << "forward1" << "forward2" << "forward3";
|
---|
733 | #endif
|
---|
734 |
|
---|
735 | floatingcontrol_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action" << "separator" << "timelabel_action";
|
---|
736 |
|
---|
737 | set->beginGroup( "actions" );
|
---|
738 | int toolbar_version = set->value("toolbar1_version", 0).toInt();
|
---|
739 | if (toolbar_version >= TOOLBAR_VERSION) {
|
---|
740 | ToolbarEditor::load(toolbar1, set->value("toolbar1", toolbar1_actions).toStringList(), actions_list );
|
---|
741 | } else {
|
---|
742 | qDebug("DefaultGui::loadConfig: toolbar too old, loading default one");
|
---|
743 | ToolbarEditor::load(toolbar1, toolbar1_actions, actions_list );
|
---|
744 | }
|
---|
745 | ToolbarEditor::load(controlwidget, set->value("controlwidget", controlwidget_actions).toStringList(), actions_list );
|
---|
746 | ToolbarEditor::load(controlwidget_mini, set->value("controlwidget_mini", controlwidget_mini_actions).toStringList(), actions_list );
|
---|
747 | ToolbarEditor::load(floating_control->toolbar(), set->value("floating_control", floatingcontrol_actions).toStringList(), actions_list );
|
---|
748 | floating_control->adjustSize();
|
---|
749 | set->endGroup();
|
---|
750 | #endif
|
---|
751 |
|
---|
752 | restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
|
---|
753 |
|
---|
754 | #if DOCK_PLAYLIST
|
---|
755 | qDebug("DefaultGui::loadConfig: playlist visible: %d", playlistdock->isVisible());
|
---|
756 | qDebug("DefaultGui::loadConfig: playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
757 | qDebug("DefaultGui::loadConfig: playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
758 | #endif
|
---|
759 |
|
---|
760 | set->endGroup();
|
---|
761 |
|
---|
762 | updateWidgets();
|
---|
763 | }
|
---|
764 |
|
---|
765 | #include "moc_defaultgui.cpp"
|
---|