1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2017 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 "autohidewidget.h"
|
---|
30 | #include "desktopinfo.h"
|
---|
31 | #include "editabletoolbar.h"
|
---|
32 |
|
---|
33 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
34 | #include "favorites.h"
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #if DOCK_PLAYLIST
|
---|
38 | #include "playlistdock.h"
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | #ifdef BUFFERING_ANIMATION
|
---|
42 | #include "statewidget.h"
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #include <QMenu>
|
---|
46 | #include <QSettings>
|
---|
47 | #include <QLabel>
|
---|
48 | #include <QStatusBar>
|
---|
49 | #include <QPushButton>
|
---|
50 | #include <QToolButton>
|
---|
51 | #include <QMenuBar>
|
---|
52 | #include <QMovie>
|
---|
53 | #include <QtCore/qmath.h>
|
---|
54 |
|
---|
55 | #define TOOLBAR_VERSION "2"
|
---|
56 | #define CONTROLWIDGET_VERSION "1"
|
---|
57 | #define CONTROLWIDGETMINI_VERSION "1"
|
---|
58 | #define FLOATING_CONTROL_VERSION "1"
|
---|
59 |
|
---|
60 | using namespace Global;
|
---|
61 |
|
---|
62 | DefaultGui::DefaultGui( QWidget * parent, Qt::WindowFlags flags )
|
---|
63 | : BaseGuiPlus( parent, flags )
|
---|
64 | {
|
---|
65 | createStatusBar();
|
---|
66 |
|
---|
67 | connect( core, SIGNAL(showTime(double)), this, SLOT(displayTime(double)));
|
---|
68 | connect( this, SIGNAL(frameChanged(int)),
|
---|
69 | this, SLOT(displayFrame(int)) );
|
---|
70 | connect( this, SIGNAL(ABMarkersChanged(int,int)),
|
---|
71 | this, SLOT(displayABSection(int,int)) );
|
---|
72 | connect( this, SIGNAL(videoInfoChanged(int,int,double)),
|
---|
73 | this, SLOT(displayVideoInfo(int,int,double)) );
|
---|
74 | connect( core, SIGNAL(bitrateChanged(int,int)), this, SLOT(displayBitrateInfo(int,int)) );
|
---|
75 |
|
---|
76 | createActions();
|
---|
77 | createMainToolBars();
|
---|
78 | createControlWidget();
|
---|
79 | createControlWidgetMini();
|
---|
80 | createFloatingControl();
|
---|
81 | createMenus();
|
---|
82 |
|
---|
83 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
84 | connect( editToolbar1Act, SIGNAL(triggered()),
|
---|
85 | toolbar1, SLOT(edit()) );
|
---|
86 | connect( editControl1Act, SIGNAL(triggered()),
|
---|
87 | controlwidget, SLOT(edit()) );
|
---|
88 | connect( editControl2Act, SIGNAL(triggered()),
|
---|
89 | controlwidget_mini, SLOT(edit()) );
|
---|
90 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
91 | iw->takeAvailableActionsFrom(this);
|
---|
92 | connect( editFloatingControlAct, SIGNAL(triggered()),
|
---|
93 | iw, SLOT(edit()) );
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | connect(this, SIGNAL(preferencesChanged()), this, SLOT(checkCompactMode()));
|
---|
97 |
|
---|
98 | menuBar()->setObjectName("menubar");
|
---|
99 |
|
---|
100 | retranslateStrings();
|
---|
101 |
|
---|
102 | loadConfig();
|
---|
103 |
|
---|
104 | //if (playlist_visible) showPlaylist(true);
|
---|
105 |
|
---|
106 | if (pref->compact_mode) {
|
---|
107 | controlwidget->hide();
|
---|
108 | toolbar1->hide();
|
---|
109 | #ifdef LANGUAGE_TOOLBAR
|
---|
110 | toolbar2->hide();
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | if (pref->floating_display_in_compact_mode) {
|
---|
114 | reconfigureFloatingControl();
|
---|
115 | floating_control->activate();
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | applyStyles();
|
---|
120 |
|
---|
121 | #ifdef ADD_QUICK_ACCESS
|
---|
122 | connect(this, SIGNAL(tabletModeChanged(bool)), this, SLOT(adaptForTabletMode()));
|
---|
123 | adaptForTabletMode();
|
---|
124 | #endif
|
---|
125 | }
|
---|
126 |
|
---|
127 | DefaultGui::~DefaultGui() {
|
---|
128 | qDebug("DefaultGui::~DefaultGui");
|
---|
129 | saveConfig();
|
---|
130 | }
|
---|
131 |
|
---|
132 | /*
|
---|
133 | void DefaultGui::closeEvent( QCloseEvent * ) {
|
---|
134 | qDebug("DefaultGui::closeEvent");
|
---|
135 |
|
---|
136 | //BaseGuiPlus::closeEvent(e);
|
---|
137 | qDebug("w: %d h: %d", width(), height() );
|
---|
138 | }
|
---|
139 | */
|
---|
140 |
|
---|
141 | void DefaultGui::createActions() {
|
---|
142 | qDebug("DefaultGui::createActions");
|
---|
143 |
|
---|
144 | timeslider_action = createTimeSliderAction(this);
|
---|
145 | volumeslider_action = createVolumeSliderAction(this);
|
---|
146 |
|
---|
147 | #if AUTODISABLE_ACTIONS
|
---|
148 | timeslider_action->disable();
|
---|
149 | volumeslider_action->disable();
|
---|
150 | #endif
|
---|
151 |
|
---|
152 | // Create the time label
|
---|
153 | time_label_action = createTimeLabelAction(TimeLabelAction::CurrentAndTotalTime, this);
|
---|
154 | time_label_action->setObjectName("timelabel_action");
|
---|
155 |
|
---|
156 | current_time_label_action = createTimeLabelAction(TimeLabelAction::CurrentTime, this);
|
---|
157 | current_time_label_action->setObjectName("current_timelabel_action");
|
---|
158 |
|
---|
159 | total_time_label_action = createTimeLabelAction(TimeLabelAction::TotalTime, this);
|
---|
160 | total_time_label_action->setObjectName("total_timelabel_action");
|
---|
161 |
|
---|
162 | remaining_time_label_action = createTimeLabelAction(TimeLabelAction::RemainingTime, this);
|
---|
163 | remaining_time_label_action->setObjectName("remaining_timelabel_action");
|
---|
164 |
|
---|
165 | #if MINI_ARROW_BUTTONS
|
---|
166 | QList<QAction*> rewind_actions;
|
---|
167 | rewind_actions << rewind1Act << rewind2Act << rewind3Act;
|
---|
168 | rewindbutton_action = new SeekingButton(rewind_actions, this);
|
---|
169 | rewindbutton_action->setObjectName("rewindbutton_action");
|
---|
170 |
|
---|
171 | QList<QAction*> forward_actions;
|
---|
172 | forward_actions << forward1Act << forward2Act << forward3Act;
|
---|
173 | forwardbutton_action = new SeekingButton(forward_actions, this);
|
---|
174 | forwardbutton_action->setObjectName("forwardbutton_action");
|
---|
175 | #endif
|
---|
176 |
|
---|
177 | // Statusbar
|
---|
178 | viewVideoInfoAct = new MyAction(this, "toggle_video_info" );
|
---|
179 | viewVideoInfoAct->setCheckable(true);
|
---|
180 | connect( viewVideoInfoAct, SIGNAL(toggled(bool)),
|
---|
181 | video_info_display, SLOT(setVisible(bool)) );
|
---|
182 |
|
---|
183 | viewFrameCounterAct = new MyAction( this, "toggle_frame_counter" );
|
---|
184 | viewFrameCounterAct->setCheckable( true );
|
---|
185 | connect( viewFrameCounterAct, SIGNAL(toggled(bool)),
|
---|
186 | frame_display, SLOT(setVisible(bool)) );
|
---|
187 |
|
---|
188 | viewFormatInfoAct = new MyAction( this, "toggle_format_info" );
|
---|
189 | viewFormatInfoAct->setCheckable( true );
|
---|
190 | connect( viewFormatInfoAct, SIGNAL(toggled(bool)),
|
---|
191 | format_info_display, SLOT(setVisible(bool)) );
|
---|
192 |
|
---|
193 | viewBitrateInfoAct = new MyAction( this, "toggle_bitrate_info" );
|
---|
194 | viewBitrateInfoAct->setCheckable( true );
|
---|
195 | connect( viewBitrateInfoAct, SIGNAL(toggled(bool)),
|
---|
196 | bitrate_info_display, SLOT(setVisible(bool)) );
|
---|
197 |
|
---|
198 | useMillisecondsAct = new MyAction( this, "use_milliseconds" );
|
---|
199 | useMillisecondsAct->setCheckable( true );
|
---|
200 |
|
---|
201 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
202 | editToolbar1Act = new MyAction( this, "edit_main_toolbar" );
|
---|
203 | editControl1Act = new MyAction( this, "edit_control1" );
|
---|
204 | editControl2Act = new MyAction( this, "edit_control2" );
|
---|
205 | editFloatingControlAct = new MyAction( this, "edit_floating_control" );
|
---|
206 | #endif
|
---|
207 | }
|
---|
208 |
|
---|
209 | #if AUTODISABLE_ACTIONS
|
---|
210 | void DefaultGui::enableActionsOnPlaying() {
|
---|
211 | qDebug("DefaultGui::enableActionsOnPlaying");
|
---|
212 | BaseGuiPlus::enableActionsOnPlaying();
|
---|
213 |
|
---|
214 | timeslider_action->enable();
|
---|
215 | volumeslider_action->enable();
|
---|
216 | }
|
---|
217 |
|
---|
218 | void DefaultGui::disableActionsOnStop() {
|
---|
219 | qDebug("DefaultGui::disableActionsOnStop");
|
---|
220 | BaseGuiPlus::disableActionsOnStop();
|
---|
221 |
|
---|
222 | timeslider_action->disable();
|
---|
223 | volumeslider_action->disable();
|
---|
224 | }
|
---|
225 | #endif // AUTODISABLE_ACTIONS
|
---|
226 |
|
---|
227 | void DefaultGui::togglePlayAction(Core::State state) {
|
---|
228 | qDebug("DefaultGui::togglePlayAction");
|
---|
229 | BaseGui::togglePlayAction(state);
|
---|
230 |
|
---|
231 | if (state == Core::Playing) {
|
---|
232 | playOrPauseAct->setIcon(Images::icon("pause"));
|
---|
233 | } else {
|
---|
234 | playOrPauseAct->setIcon(Images::icon("play"));
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | void DefaultGui::createMenus() {
|
---|
239 | toolbar_menu = new QMenu(this);
|
---|
240 | toolbar_menu->addAction(toolbar1->toggleViewAction());
|
---|
241 | #ifdef LANGUAGE_TOOLBAR
|
---|
242 | toolbar_menu->addAction(toolbar2->toggleViewAction());
|
---|
243 | #endif
|
---|
244 |
|
---|
245 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
246 | toolbar_menu->addSeparator();
|
---|
247 | toolbar_menu->addAction(editToolbar1Act);
|
---|
248 | toolbar_menu->addAction(editControl1Act);
|
---|
249 | toolbar_menu->addAction(editControl2Act);
|
---|
250 | toolbar_menu->addAction(editFloatingControlAct);
|
---|
251 | #endif
|
---|
252 |
|
---|
253 | statusbar_menu = new QMenu(this);
|
---|
254 | statusbar_menu->addAction(viewVideoInfoAct);
|
---|
255 | statusbar_menu->addAction(viewFormatInfoAct);
|
---|
256 | statusbar_menu->addAction(viewBitrateInfoAct);
|
---|
257 | statusbar_menu->addAction(viewFrameCounterAct);
|
---|
258 | statusbar_menu->addAction(useMillisecondsAct);
|
---|
259 |
|
---|
260 | populateMainMenu();
|
---|
261 | }
|
---|
262 |
|
---|
263 | void DefaultGui::populateMainMenu() {
|
---|
264 | qDebug("DefaultGui::populateMainMenu");
|
---|
265 |
|
---|
266 | BaseGuiPlus::populateMainMenu();
|
---|
267 |
|
---|
268 | optionsMenu->addSeparator();
|
---|
269 | optionsMenu->addMenu(toolbar_menu);
|
---|
270 | optionsMenu->addMenu(statusbar_menu);
|
---|
271 | }
|
---|
272 |
|
---|
273 | QMenu * DefaultGui::createPopupMenu() {
|
---|
274 | QMenu * m = new QMenu(this);
|
---|
275 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
276 | m->addAction(editToolbar1Act);
|
---|
277 | m->addAction(editControl1Act);
|
---|
278 | m->addAction(editControl2Act);
|
---|
279 | m->addAction(editFloatingControlAct);
|
---|
280 | #else
|
---|
281 | m->addAction(toolbar1->toggleViewAction());
|
---|
282 | #ifdef LANGUAGE_TOOLBAR
|
---|
283 | m->addAction(toolbar2->toggleViewAction());
|
---|
284 | #endif
|
---|
285 | #endif
|
---|
286 | return m;
|
---|
287 | }
|
---|
288 |
|
---|
289 | void DefaultGui::createMainToolBars() {
|
---|
290 | toolbar1 = new EditableToolbar( this );
|
---|
291 | toolbar1->setObjectName("toolbar1");
|
---|
292 | //toolbar1->setMovable(false);
|
---|
293 | addToolBar(Qt::TopToolBarArea, toolbar1);
|
---|
294 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
295 | QStringList toolbar1_actions;
|
---|
296 | toolbar1_actions << "open_file" << "open_url" << "favorites_menu" << "separator"
|
---|
297 | << "screenshot" << "separator" << "show_file_properties" << "show_playlist"
|
---|
298 | #ifndef IDOPT_BUILD
|
---|
299 | << "show_tube_browser"
|
---|
300 | #endif
|
---|
301 | << "separator" << "show_preferences"
|
---|
302 | #ifndef IDOPT_BUILD
|
---|
303 | << "separator" << "play_prev" << "play_next"
|
---|
304 | #endif
|
---|
305 | << "separator" << "audiotrack_menu" << "subtitlestrack_menu"
|
---|
306 | #ifdef IDOPT_BUILD
|
---|
307 | << "separator" << "send_to_screen_menu" << "tablet_mode"
|
---|
308 | #endif
|
---|
309 | ;
|
---|
310 |
|
---|
311 | toolbar1->setDefaultActions(toolbar1_actions);
|
---|
312 | #else
|
---|
313 | toolbar1->addAction(openFileAct);
|
---|
314 | /* toolbar1->addAction(openDVDAct); */
|
---|
315 | toolbar1->addAction(openURLAct);
|
---|
316 | toolbar1->addAction(favorites->menuAction());
|
---|
317 | toolbar1->addSeparator();
|
---|
318 | /*
|
---|
319 | toolbar1->addAction(compactAct);
|
---|
320 | toolbar1->addAction(fullscreenAct);
|
---|
321 | toolbar1->addSeparator();
|
---|
322 | */
|
---|
323 | toolbar1->addAction(screenshotAct);
|
---|
324 | toolbar1->addSeparator();
|
---|
325 | toolbar1->addAction(showPropertiesAct);
|
---|
326 | toolbar1->addAction(showPlaylistAct);
|
---|
327 | toolbar1->addAction(showPreferencesAct);
|
---|
328 | toolbar1->addSeparator();
|
---|
329 | toolbar1->addAction(playPrevAct);
|
---|
330 | toolbar1->addAction(playNextAct);
|
---|
331 | toolbar1->addSeparator();
|
---|
332 | toolbar1->addAction(audiotrack_menu->menuAction());
|
---|
333 | toolbar1->addAction(subtitles_track_menu->menuAction());
|
---|
334 |
|
---|
335 | // Test:
|
---|
336 | //toolbar1->addSeparator();
|
---|
337 | //toolbar1->addAction(timeslider_action);
|
---|
338 | //toolbar1->addAction(volumeslider_action);
|
---|
339 |
|
---|
340 | QToolButton * button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(favorites->menuAction()));
|
---|
341 | button->setPopupMode(QToolButton::InstantPopup);
|
---|
342 |
|
---|
343 | button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(audiotrack_menu->menuAction()));
|
---|
344 | button->setPopupMode(QToolButton::InstantPopup);
|
---|
345 |
|
---|
346 | button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(subtitles_track_menu->menuAction()));
|
---|
347 | button->setPopupMode(QToolButton::InstantPopup);
|
---|
348 |
|
---|
349 | #ifdef IDOPT_BUILD
|
---|
350 | toolbar1->addSeparator();
|
---|
351 | toolbar1->addAction(sendToScreen_menu->menuAction());
|
---|
352 | toolbar1->addAction(tabletModeAct);
|
---|
353 |
|
---|
354 | button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(sendToScreen_menu->menuAction()));
|
---|
355 | button->setPopupMode(QToolButton::InstantPopup);
|
---|
356 | #endif
|
---|
357 | #endif
|
---|
358 |
|
---|
359 | #ifdef LANGUAGE_TOOLBAR
|
---|
360 | toolbar2 = new QToolBar( this );
|
---|
361 | toolbar2->setObjectName("toolbar2");
|
---|
362 | //toolbar2->setMovable(false);
|
---|
363 | addToolBar(Qt::TopToolBarArea, toolbar2);
|
---|
364 |
|
---|
365 | select_audio = new QPushButton( this );
|
---|
366 | select_audio->setMenu( audiotrack_menu );
|
---|
367 | toolbar2->addWidget(select_audio);
|
---|
368 |
|
---|
369 | select_subtitle = new QPushButton( this );
|
---|
370 | select_subtitle->setMenu( subtitles_track_menu );
|
---|
371 | toolbar2->addWidget(select_subtitle);
|
---|
372 | #endif
|
---|
373 |
|
---|
374 | /*
|
---|
375 | toolbar1->show();
|
---|
376 | toolbar2->show();
|
---|
377 | */
|
---|
378 |
|
---|
379 | // Modify toolbars' actions
|
---|
380 | QAction *tba;
|
---|
381 | tba = toolbar1->toggleViewAction();
|
---|
382 | tba->setObjectName("show_main_toolbar");
|
---|
383 | tba->setShortcut(Qt::Key_F5);
|
---|
384 |
|
---|
385 | #ifdef LANGUAGE_TOOLBAR
|
---|
386 | tba = toolbar2->toggleViewAction();
|
---|
387 | tba->setObjectName("show_language_toolbar");
|
---|
388 | tba->setShortcut(Qt::Key_F6);
|
---|
389 | #endif
|
---|
390 |
|
---|
391 | toolbar1->setIconSize(QSize(32,32));
|
---|
392 | }
|
---|
393 |
|
---|
394 |
|
---|
395 | void DefaultGui::createControlWidgetMini() {
|
---|
396 | qDebug("DefaultGui::createControlWidgetMini");
|
---|
397 |
|
---|
398 | controlwidget_mini = new EditableToolbar( this );
|
---|
399 | controlwidget_mini->setObjectName("controlwidget_mini");
|
---|
400 | controlwidget_mini->setLayoutDirection(Qt::LeftToRight);
|
---|
401 | //controlwidget_mini->setResizeEnabled(false);
|
---|
402 | controlwidget_mini->setMovable(false);
|
---|
403 | //addDockWindow(controlwidget_mini, Qt::DockBottom );
|
---|
404 | addToolBar(Qt::BottomToolBarArea, controlwidget_mini);
|
---|
405 |
|
---|
406 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
407 | QStringList controlwidget_mini_actions;
|
---|
408 | controlwidget_mini_actions << "play_or_pause" << "stop" << "separator" << "rewind1" << "timeslider_action"
|
---|
409 | << "forward1" << "separator" << "mute" << "volumeslider_action";
|
---|
410 | controlwidget_mini->setDefaultActions(controlwidget_mini_actions);
|
---|
411 | #else
|
---|
412 | controlwidget_mini->addAction(playOrPauseAct);
|
---|
413 | controlwidget_mini->addAction(stopAct);
|
---|
414 | controlwidget_mini->addSeparator();
|
---|
415 |
|
---|
416 | controlwidget_mini->addAction(rewind1Act);
|
---|
417 |
|
---|
418 | controlwidget_mini->addAction(timeslider_action);
|
---|
419 |
|
---|
420 | controlwidget_mini->addAction(forward1Act);
|
---|
421 |
|
---|
422 | controlwidget_mini->addSeparator();
|
---|
423 |
|
---|
424 | controlwidget_mini->addAction(muteAct );
|
---|
425 |
|
---|
426 | controlwidget_mini->addAction(volumeslider_action);
|
---|
427 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
428 |
|
---|
429 | controlwidget_mini->hide();
|
---|
430 | }
|
---|
431 |
|
---|
432 | void DefaultGui::createControlWidget() {
|
---|
433 | qDebug("DefaultGui::createControlWidget");
|
---|
434 |
|
---|
435 | controlwidget = new EditableToolbar( this );
|
---|
436 | controlwidget->setObjectName("controlwidget");
|
---|
437 | controlwidget->setLayoutDirection(Qt::LeftToRight);
|
---|
438 | //controlwidget->setResizeEnabled(false);
|
---|
439 | controlwidget->setMovable(false);
|
---|
440 | //addDockWindow(controlwidget, Qt::DockBottom );
|
---|
441 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
---|
442 |
|
---|
443 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
444 | QStringList controlwidget_actions;
|
---|
445 | controlwidget_actions << "play_or_pause" << "stop" << "separator";
|
---|
446 | #if MINI_ARROW_BUTTONS
|
---|
447 | controlwidget_actions << "rewindbutton_action";
|
---|
448 | #else
|
---|
449 | controlwidget_actions << "rewind3" << "rewind2" << "rewind1";
|
---|
450 | #endif
|
---|
451 | controlwidget_actions << "timeslider_action";
|
---|
452 | #if MINI_ARROW_BUTTONS
|
---|
453 | controlwidget_actions << "forwardbutton_action";
|
---|
454 | #else
|
---|
455 | controlwidget_actions << "forward1" << "forward2" << "forward3";
|
---|
456 | #endif
|
---|
457 | controlwidget_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action";
|
---|
458 |
|
---|
459 | #ifdef ADD_QUICK_ACCESS
|
---|
460 | controlwidget_actions << "quick_access_menu";
|
---|
461 | #endif
|
---|
462 |
|
---|
463 | controlwidget->setDefaultActions(controlwidget_actions);
|
---|
464 | #else
|
---|
465 | /*
|
---|
466 | controlwidget->addAction(playAct);
|
---|
467 | controlwidget->addAction(pauseAndStepAct);
|
---|
468 | */
|
---|
469 | controlwidget->addAction(playOrPauseAct);
|
---|
470 | controlwidget->addAction(stopAct);
|
---|
471 |
|
---|
472 | controlwidget->addSeparator();
|
---|
473 |
|
---|
474 | #if MINI_ARROW_BUTTONS
|
---|
475 | controlwidget->addAction( rewindbutton_action );
|
---|
476 | #else
|
---|
477 | controlwidget->addAction(rewind3Act);
|
---|
478 | controlwidget->addAction(rewind2Act);
|
---|
479 | controlwidget->addAction(rewind1Act);
|
---|
480 | #endif
|
---|
481 |
|
---|
482 | controlwidget->addAction(timeslider_action);
|
---|
483 |
|
---|
484 | #if MINI_ARROW_BUTTONS
|
---|
485 | controlwidget->addAction( forwardbutton_action );
|
---|
486 | #else
|
---|
487 | controlwidget->addAction(forward1Act);
|
---|
488 | controlwidget->addAction(forward2Act);
|
---|
489 | controlwidget->addAction(forward3Act);
|
---|
490 | #endif
|
---|
491 |
|
---|
492 | controlwidget->addSeparator();
|
---|
493 |
|
---|
494 | controlwidget->addAction(fullscreenAct);
|
---|
495 | controlwidget->addAction(muteAct);
|
---|
496 |
|
---|
497 | controlwidget->addAction(volumeslider_action);
|
---|
498 |
|
---|
499 | #ifdef ADD_QUICK_ACCESS
|
---|
500 | controlwidget->addAction(access_menu->menuAction());
|
---|
501 | QToolButton * button = qobject_cast<QToolButton *>(controlwidget->widgetForAction(access_menu->menuAction()));
|
---|
502 | button->setPopupMode(QToolButton::InstantPopup);
|
---|
503 | #endif
|
---|
504 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
505 |
|
---|
506 | /*
|
---|
507 | controlwidget->show();
|
---|
508 | */
|
---|
509 |
|
---|
510 | controlwidget->setIconSize(QSize(40,40));
|
---|
511 | }
|
---|
512 |
|
---|
513 | void DefaultGui::createFloatingControl() {
|
---|
514 | // Floating control
|
---|
515 | floating_control = new AutohideWidget(mplayerwindow);
|
---|
516 | floating_control->setAutoHide(true);
|
---|
517 |
|
---|
518 | EditableToolbar * iw = new EditableToolbar(floating_control);
|
---|
519 | iw->setObjectName("floating_control");
|
---|
520 | connect(iw, SIGNAL(iconSizeChanged(const QSize &)), this, SLOT(adjustFloatingControlSize()));
|
---|
521 |
|
---|
522 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
523 | QStringList floatingcontrol_actions;
|
---|
524 | floatingcontrol_actions << "play_or_pause" << "stop" << "separator";
|
---|
525 | /*
|
---|
526 | #if MINI_ARROW_BUTTONS
|
---|
527 | floatingcontrol_actions << "rewindbutton_action";
|
---|
528 | #else
|
---|
529 | floatingcontrol_actions << "rewind3" << "rewind2" << "rewind1";
|
---|
530 | #endif
|
---|
531 | */
|
---|
532 | floatingcontrol_actions << "rewind1";
|
---|
533 | floatingcontrol_actions << "current_timelabel_action" << "timeslider_action" << "total_timelabel_action";
|
---|
534 | /*
|
---|
535 | #if MINI_ARROW_BUTTONS
|
---|
536 | floatingcontrol_actions << "forwardbutton_action";
|
---|
537 | #else
|
---|
538 | floatingcontrol_actions << "forward1" << "forward2" << "forward3";
|
---|
539 | #endif
|
---|
540 | */
|
---|
541 | floatingcontrol_actions << "forward1";
|
---|
542 | floatingcontrol_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action";
|
---|
543 | iw->setDefaultActions(floatingcontrol_actions);
|
---|
544 | #else
|
---|
545 | /*
|
---|
546 | iw->addAction(playAct);
|
---|
547 | iw->addAction(pauseAct);
|
---|
548 | */
|
---|
549 | iw->addAction(playOrPauseAct);
|
---|
550 | iw->addAction(stopAct);
|
---|
551 | iw->addSeparator();
|
---|
552 |
|
---|
553 | #if MINI_ARROW_BUTTONS
|
---|
554 | iw->addAction( rewindbutton_action );
|
---|
555 | #else
|
---|
556 | iw->addAction(rewind3Act);
|
---|
557 | iw->addAction(rewind2Act);
|
---|
558 | iw->addAction(rewind1Act);
|
---|
559 | #endif
|
---|
560 |
|
---|
561 | iw->addAction(current_time_label_action);
|
---|
562 | iw->addAction(timeslider_action);
|
---|
563 | iw->addAction(total_time_label_action);
|
---|
564 |
|
---|
565 | #if MINI_ARROW_BUTTONS
|
---|
566 | iw->addAction( forwardbutton_action );
|
---|
567 | #else
|
---|
568 | iw->addAction(forward1Act);
|
---|
569 | iw->addAction(forward2Act);
|
---|
570 | iw->addAction(forward3Act);
|
---|
571 | #endif
|
---|
572 |
|
---|
573 | iw->addSeparator();
|
---|
574 | iw->addAction(fullscreenAct);
|
---|
575 | iw->addAction(muteAct);
|
---|
576 | iw->addAction(volumeslider_action);
|
---|
577 | /*
|
---|
578 | iw->addSeparator();
|
---|
579 | iw->addAction(time_label_action);
|
---|
580 | */
|
---|
581 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
582 |
|
---|
583 | floating_control->setInternalWidget(iw);
|
---|
584 | iw->setIconSize(QSize(48,48));
|
---|
585 |
|
---|
586 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
---|
587 | // To make work the ESC key (exit fullscreen) and Ctrl-X (close) in Windows and OS2
|
---|
588 | /*
|
---|
589 | floating_control->addAction(exitFullscreenAct);
|
---|
590 | floating_control->addAction(exitAct);
|
---|
591 | */
|
---|
592 | //floating_control->addActions(actions());
|
---|
593 | #endif
|
---|
594 |
|
---|
595 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
596 | floating_control->adjustSize();
|
---|
597 | #endif
|
---|
598 |
|
---|
599 | floating_control->hide();
|
---|
600 | }
|
---|
601 |
|
---|
602 | void DefaultGui::createStatusBar() {
|
---|
603 | qDebug("DefaultGui::createStatusBar");
|
---|
604 |
|
---|
605 | time_display = new QLabel( statusBar() );
|
---|
606 | time_display->setObjectName("time_display");
|
---|
607 | time_display->setAlignment(Qt::AlignRight);
|
---|
608 | time_display->setFrameShape(QFrame::NoFrame);
|
---|
609 | time_display->setText(" 88:88:88 / 88:88:88 ");
|
---|
610 | time_display->setMinimumSize(time_display->sizeHint());
|
---|
611 | //connect(this, SIGNAL(timeChanged(QString)), time_display, SLOT(setText(QString)));
|
---|
612 |
|
---|
613 | frame_display = new QLabel( statusBar() );
|
---|
614 | frame_display->setObjectName("frame_display");
|
---|
615 | frame_display->setAlignment(Qt::AlignRight);
|
---|
616 | frame_display->setFrameShape(QFrame::NoFrame);
|
---|
617 | frame_display->setText("88888888");
|
---|
618 | frame_display->setMinimumSize(frame_display->sizeHint());
|
---|
619 |
|
---|
620 | ab_section_display = new QLabel( statusBar() );
|
---|
621 | ab_section_display->setObjectName("ab_section_display");
|
---|
622 | ab_section_display->setAlignment(Qt::AlignRight);
|
---|
623 | ab_section_display->setFrameShape(QFrame::NoFrame);
|
---|
624 | // ab_section_display->setText("A:0:00:00 B:0:00:00");
|
---|
625 | // ab_section_display->setMinimumSize(ab_section_display->sizeHint());
|
---|
626 |
|
---|
627 | video_info_display = new QLabel( statusBar() );
|
---|
628 | video_info_display->setObjectName("video_info_display");
|
---|
629 | video_info_display->setAlignment(Qt::AlignRight);
|
---|
630 | video_info_display->setFrameShape(QFrame::NoFrame);
|
---|
631 |
|
---|
632 | format_info_display = new QLabel( statusBar() );
|
---|
633 | format_info_display->setObjectName("format_info_display");
|
---|
634 | format_info_display->setAlignment(Qt::AlignRight);
|
---|
635 | format_info_display->setFrameShape(QFrame::NoFrame);
|
---|
636 |
|
---|
637 | bitrate_info_display = new QLabel( statusBar() );
|
---|
638 | bitrate_info_display->setObjectName("bitrate_info_display");
|
---|
639 | bitrate_info_display->setAlignment(Qt::AlignRight);
|
---|
640 | bitrate_info_display->setFrameShape(QFrame::NoFrame);
|
---|
641 |
|
---|
642 | #ifdef BUFFERING_ANIMATION
|
---|
643 | state_widget = new StateWidget(statusBar());
|
---|
644 | connect(core, SIGNAL(stateChanged(Core::State)), state_widget, SLOT(watchState(Core::State)));
|
---|
645 | statusBar()->addPermanentWidget(state_widget);
|
---|
646 | #endif
|
---|
647 |
|
---|
648 | statusBar()->setAutoFillBackground(true);
|
---|
649 |
|
---|
650 | /*
|
---|
651 | ColorUtils::setBackgroundColor( statusBar(), QColor(0,0,0) );
|
---|
652 | ColorUtils::setForegroundColor( statusBar(), QColor(255,255,255) );
|
---|
653 | ColorUtils::setBackgroundColor( time_display, QColor(0,0,0) );
|
---|
654 | ColorUtils::setForegroundColor( time_display, QColor(255,255,255) );
|
---|
655 | ColorUtils::setBackgroundColor( frame_display, QColor(0,0,0) );
|
---|
656 | ColorUtils::setForegroundColor( frame_display, QColor(255,255,255) );
|
---|
657 | ColorUtils::setBackgroundColor( ab_section_display, QColor(0,0,0) );
|
---|
658 | ColorUtils::setForegroundColor( ab_section_display, QColor(255,255,255) );
|
---|
659 | ColorUtils::setBackgroundColor( video_info_display, QColor(0,0,0) );
|
---|
660 | ColorUtils::setForegroundColor( video_info_display, QColor(255,255,255) );
|
---|
661 | */
|
---|
662 | statusBar()->setSizeGripEnabled(false);
|
---|
663 |
|
---|
664 | statusBar()->addPermanentWidget( format_info_display );
|
---|
665 | statusBar()->addPermanentWidget( bitrate_info_display );
|
---|
666 | statusBar()->addPermanentWidget( ab_section_display );
|
---|
667 | statusBar()->addPermanentWidget( video_info_display );
|
---|
668 |
|
---|
669 | statusBar()->showMessage( tr("Ready") );
|
---|
670 | statusBar()->addPermanentWidget( frame_display, 0 );
|
---|
671 | frame_display->setText( "0" );
|
---|
672 |
|
---|
673 | statusBar()->addPermanentWidget( time_display, 0 );
|
---|
674 | time_display->setText(" 00:00:00 / 00:00:00 ");
|
---|
675 |
|
---|
676 | time_display->show();
|
---|
677 | frame_display->hide();
|
---|
678 | ab_section_display->show();
|
---|
679 | video_info_display->hide();
|
---|
680 | format_info_display->hide();
|
---|
681 | bitrate_info_display->hide();
|
---|
682 | }
|
---|
683 |
|
---|
684 | void DefaultGui::retranslateStrings() {
|
---|
685 | BaseGuiPlus::retranslateStrings();
|
---|
686 |
|
---|
687 | // Change the icon of the play/pause action
|
---|
688 | playOrPauseAct->setIcon(Images::icon("play"));
|
---|
689 |
|
---|
690 | toolbar_menu->menuAction()->setText( tr("&Toolbars") );
|
---|
691 | toolbar_menu->menuAction()->setIcon( Images::icon("toolbars") );
|
---|
692 |
|
---|
693 | statusbar_menu->menuAction()->setText( tr("Status&bar") );
|
---|
694 | statusbar_menu->menuAction()->setIcon( Images::icon("statusbar") );
|
---|
695 |
|
---|
696 | toolbar1->setWindowTitle( tr("&Main toolbar") );
|
---|
697 | toolbar1->toggleViewAction()->setIcon(Images::icon("main_toolbar"));
|
---|
698 |
|
---|
699 | #ifdef LANGUAGE_TOOLBAR
|
---|
700 | toolbar2->setWindowTitle( tr("&Language toolbar") );
|
---|
701 | toolbar2->toggleViewAction()->setIcon(Images::icon("lang_toolbar"));
|
---|
702 |
|
---|
703 | select_audio->setText( tr("Audio") );
|
---|
704 | select_subtitle->setText( tr("Subtitle") );
|
---|
705 | #endif
|
---|
706 |
|
---|
707 | viewVideoInfoAct->change(Images::icon("view_video_info"), tr("&Video info") );
|
---|
708 | viewFrameCounterAct->change( Images::icon("frame_counter"), tr("&Frame counter") );
|
---|
709 | viewFormatInfoAct->change( Images::icon("view_format_info"), tr("F&ormat info") );
|
---|
710 | viewBitrateInfoAct->change( Images::icon("view_bitrate_info"), tr("&Bitrate info") );
|
---|
711 | useMillisecondsAct->change( Images::icon("use_milliseconds"), tr("&Show the current time with milliseconds") );
|
---|
712 |
|
---|
713 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
714 | editToolbar1Act->change( tr("Edit main &toolbar") );
|
---|
715 | editControl1Act->change( tr("Edit &control bar") );
|
---|
716 | editControl2Act->change( tr("Edit m&ini control bar") );
|
---|
717 | editFloatingControlAct->change( tr("Edit &floating control") );
|
---|
718 | #endif
|
---|
719 |
|
---|
720 | #ifdef BUFFERING_ANIMATION
|
---|
721 | state_widget->setAnimation(Images::file("buffering.gif"));
|
---|
722 | #endif
|
---|
723 | }
|
---|
724 |
|
---|
725 |
|
---|
726 | void DefaultGui::displayTime(double sec) {
|
---|
727 | //qDebug() << "DefaultGui::displayTime:" << sec;
|
---|
728 |
|
---|
729 | static int last_second = 0;
|
---|
730 | QString time;
|
---|
731 |
|
---|
732 | if (useMillisecondsAct->isChecked()) {
|
---|
733 | time = Helper::formatTime2(sec) + " / " + Helper::formatTime( (int) core->mdat.duration );
|
---|
734 | } else {
|
---|
735 | if (qFloor(sec) == last_second) return; // Update only once per second
|
---|
736 | last_second = qFloor(sec);
|
---|
737 | time = Helper::formatTime( (int) sec ) + " / " + Helper::formatTime( (int) core->mdat.duration );
|
---|
738 | }
|
---|
739 | time_display->setText(time);
|
---|
740 | }
|
---|
741 |
|
---|
742 | void DefaultGui::displayFrame(int frame) {
|
---|
743 | if (frame_display->isVisible()) {
|
---|
744 | frame_display->setNum( frame );
|
---|
745 | }
|
---|
746 | }
|
---|
747 |
|
---|
748 | void DefaultGui::displayABSection(int secs_a, int secs_b) {
|
---|
749 | QString s;
|
---|
750 | if (secs_a > -1) s = tr("A:%1").arg(Helper::formatTime(secs_a));
|
---|
751 |
|
---|
752 | if (secs_b > -1) {
|
---|
753 | if (!s.isEmpty()) s += " ";
|
---|
754 | s += tr("B:%1").arg(Helper::formatTime(secs_b));
|
---|
755 | }
|
---|
756 |
|
---|
757 | ab_section_display->setText( s );
|
---|
758 |
|
---|
759 | ab_section_display->setVisible( !s.isEmpty() );
|
---|
760 | }
|
---|
761 |
|
---|
762 | void DefaultGui::displayVideoInfo(int width, int height, double fps) {
|
---|
763 | if ((width != 0) && (height != 0)) {
|
---|
764 | video_info_display->setText(tr("%1x%2 %3 fps", "width + height + fps").arg(width).arg(height).arg(fps));
|
---|
765 | } else {
|
---|
766 | video_info_display->setText(" ");
|
---|
767 | }
|
---|
768 |
|
---|
769 | QString format = core->mdat.video_format;
|
---|
770 | if (!format.isEmpty() && !core->mdat.audio_format.isEmpty()) format += " / ";
|
---|
771 | format += core->mdat.audio_format;
|
---|
772 | format_info_display->setText(format.toUpper());
|
---|
773 | }
|
---|
774 |
|
---|
775 | void DefaultGui::displayBitrateInfo(int vbitrate, int abitrate) {
|
---|
776 | bitrate_info_display->setText(tr("V: %1 kbps A: %2 kbps").arg(vbitrate/1000).arg(abitrate/1000));
|
---|
777 | }
|
---|
778 |
|
---|
779 | void DefaultGui::updateWidgets() {
|
---|
780 | qDebug("DefaultGui::updateWidgets");
|
---|
781 |
|
---|
782 | BaseGuiPlus::updateWidgets();
|
---|
783 |
|
---|
784 | viewFrameCounterAct->setEnabled((PlayerID::player(pref->mplayer_bin) == PlayerID::MPLAYER));
|
---|
785 | viewBitrateInfoAct->setEnabled((PlayerID::player(pref->mplayer_bin) == PlayerID::MPV));
|
---|
786 |
|
---|
787 | panel->setFocus();
|
---|
788 | }
|
---|
789 |
|
---|
790 | void DefaultGui::checkCompactMode() {
|
---|
791 | qDebug("DefaultGui::checkCompactMode");
|
---|
792 |
|
---|
793 | if ((pref->compact_mode) && (pref->floating_display_in_compact_mode)) {
|
---|
794 | reconfigureFloatingControl();
|
---|
795 | floating_control->activate();
|
---|
796 | } else {
|
---|
797 | floating_control->deactivate();
|
---|
798 | }
|
---|
799 | }
|
---|
800 |
|
---|
801 | #ifdef ADD_QUICK_ACCESS
|
---|
802 | void DefaultGui::adaptForTabletMode() {
|
---|
803 | qDebug("DefaultGui::adaptForTabletMode");
|
---|
804 |
|
---|
805 | bool b = pref->tablet_mode;
|
---|
806 |
|
---|
807 | if (!pref->compact_mode) {
|
---|
808 | menuBar()->setVisible(!b);
|
---|
809 | toolbar1->setVisible(!b);
|
---|
810 | }
|
---|
811 | access_menu->menuAction()->setVisible(b);
|
---|
812 | }
|
---|
813 | #endif
|
---|
814 |
|
---|
815 | void DefaultGui::reconfigureFloatingControl() {
|
---|
816 | floating_control->setMargin(pref->floating_control_margin);
|
---|
817 | floating_control->setPercWidth(pref->floating_control_width);
|
---|
818 | floating_control->setAnimated(pref->floating_control_animated);
|
---|
819 | floating_control->setActivationArea( (AutohideWidget::Activation) pref->floating_activation_area);
|
---|
820 | floating_control->setHideDelay(pref->floating_hide_delay);
|
---|
821 | }
|
---|
822 |
|
---|
823 | void DefaultGui::aboutToEnterFullscreen() {
|
---|
824 | qDebug("DefaultGui::aboutToEnterFullscreen");
|
---|
825 |
|
---|
826 | BaseGuiPlus::aboutToEnterFullscreen();
|
---|
827 |
|
---|
828 | // Show floating_control
|
---|
829 | reconfigureFloatingControl();
|
---|
830 | floating_control->deactivate(); // Hide the control in case it was running from compact mode
|
---|
831 | QTimer::singleShot(100, floating_control, SLOT(activate()));
|
---|
832 |
|
---|
833 |
|
---|
834 | // Save visibility of toolbars
|
---|
835 | fullscreen_toolbar1_was_visible = toolbar1->isVisible();
|
---|
836 | #ifdef LANGUAGE_TOOLBAR
|
---|
837 | fullscreen_toolbar2_was_visible = toolbar2->isVisible();
|
---|
838 | #endif
|
---|
839 |
|
---|
840 | if (!pref->compact_mode) {
|
---|
841 | //menuBar()->hide();
|
---|
842 | //statusBar()->hide();
|
---|
843 | controlwidget->hide();
|
---|
844 | controlwidget_mini->hide();
|
---|
845 | toolbar1->hide();
|
---|
846 | #ifdef LANGUAGE_TOOLBAR
|
---|
847 | toolbar2->hide();
|
---|
848 | #endif
|
---|
849 | }
|
---|
850 | }
|
---|
851 |
|
---|
852 | void DefaultGui::aboutToExitFullscreen() {
|
---|
853 | qDebug("DefaultGui::aboutToExitFullscreen");
|
---|
854 |
|
---|
855 | BaseGuiPlus::aboutToExitFullscreen();
|
---|
856 |
|
---|
857 | // Hide floating_control
|
---|
858 | if (!pref->compact_mode || !pref->floating_display_in_compact_mode) {
|
---|
859 | floating_control->deactivate();
|
---|
860 | }
|
---|
861 |
|
---|
862 | if (!pref->compact_mode) {
|
---|
863 | //menuBar()->show();
|
---|
864 | //statusBar()->show();
|
---|
865 | controlwidget->show();
|
---|
866 |
|
---|
867 | toolbar1->setVisible( fullscreen_toolbar1_was_visible );
|
---|
868 | #ifdef LANGUAGE_TOOLBAR
|
---|
869 | toolbar2->setVisible( fullscreen_toolbar2_was_visible );
|
---|
870 | #endif
|
---|
871 | }
|
---|
872 |
|
---|
873 | #ifdef ADD_QUICK_ACCESS
|
---|
874 | if (pref->tablet_mode) menuBar()->hide();
|
---|
875 | #endif
|
---|
876 | }
|
---|
877 |
|
---|
878 | void DefaultGui::aboutToEnterCompactMode() {
|
---|
879 |
|
---|
880 | BaseGuiPlus::aboutToEnterCompactMode();
|
---|
881 |
|
---|
882 | // Show floating_control
|
---|
883 | if (pref->floating_display_in_compact_mode) {
|
---|
884 | reconfigureFloatingControl();
|
---|
885 | QTimer::singleShot(100, floating_control, SLOT(activate()));
|
---|
886 | }
|
---|
887 |
|
---|
888 |
|
---|
889 | // Save visibility of toolbars
|
---|
890 | compact_toolbar1_was_visible = toolbar1->isVisible();
|
---|
891 | #ifdef LANGUAGE_TOOLBAR
|
---|
892 | compact_toolbar2_was_visible = toolbar2->isVisible();
|
---|
893 | #endif
|
---|
894 |
|
---|
895 | //menuBar()->hide();
|
---|
896 | //statusBar()->hide();
|
---|
897 | controlwidget->hide();
|
---|
898 | controlwidget_mini->hide();
|
---|
899 | toolbar1->hide();
|
---|
900 | #ifdef LANGUAGE_TOOLBAR
|
---|
901 | toolbar2->hide();
|
---|
902 | #endif
|
---|
903 | }
|
---|
904 |
|
---|
905 | void DefaultGui::aboutToExitCompactMode() {
|
---|
906 | BaseGuiPlus::aboutToExitCompactMode();
|
---|
907 |
|
---|
908 | // Hide floating_control
|
---|
909 | if (pref->floating_display_in_compact_mode) {
|
---|
910 | floating_control->deactivate();
|
---|
911 | }
|
---|
912 |
|
---|
913 | //menuBar()->show();
|
---|
914 | //statusBar()->show();
|
---|
915 | controlwidget->show();
|
---|
916 |
|
---|
917 | toolbar1->setVisible( compact_toolbar1_was_visible );
|
---|
918 | #ifdef LANGUAGE_TOOLBAR
|
---|
919 | toolbar2->setVisible( compact_toolbar2_was_visible );
|
---|
920 | #endif
|
---|
921 |
|
---|
922 | #ifdef ADD_QUICK_ACCESS
|
---|
923 | if (pref->tablet_mode) menuBar()->hide();
|
---|
924 | #endif
|
---|
925 |
|
---|
926 | // Recheck size of controlwidget
|
---|
927 | resizeEvent( new QResizeEvent( size(), size() ) );
|
---|
928 | }
|
---|
929 |
|
---|
930 | void DefaultGui::resizeEvent( QResizeEvent * ) {
|
---|
931 | /*
|
---|
932 | qDebug("defaultGui::resizeEvent");
|
---|
933 | qDebug(" controlwidget width: %d", controlwidget->width() );
|
---|
934 | qDebug(" controlwidget_mini width: %d", controlwidget_mini->width() );
|
---|
935 | */
|
---|
936 |
|
---|
937 | #if QT_VERSION < 0x040000
|
---|
938 | #define LIMIT 470
|
---|
939 | #else
|
---|
940 | #define LIMIT 570
|
---|
941 | #endif
|
---|
942 |
|
---|
943 | if ( (controlwidget->isVisible()) && (width() < LIMIT) ) {
|
---|
944 | controlwidget->hide();
|
---|
945 | controlwidget_mini->show();
|
---|
946 | }
|
---|
947 | else
|
---|
948 | if ( (controlwidget_mini->isVisible()) && (width() > LIMIT) ) {
|
---|
949 | controlwidget_mini->hide();
|
---|
950 | controlwidget->show();
|
---|
951 | }
|
---|
952 | }
|
---|
953 |
|
---|
954 | #if USE_MINIMUMSIZE
|
---|
955 | QSize DefaultGui::minimumSizeHint() const {
|
---|
956 | return QSize(controlwidget_mini->sizeHint().width(), 0);
|
---|
957 | }
|
---|
958 | #endif
|
---|
959 |
|
---|
960 | void DefaultGui::adjustFloatingControlSize() {
|
---|
961 | qDebug("DefaultGui::adjustFloatingControlSize");
|
---|
962 | //floating_control->adjustSize();
|
---|
963 | QWidget *iw = floating_control->internalWidget();
|
---|
964 | if (iw) {
|
---|
965 | QSize iws = iw->size();
|
---|
966 | QMargins m = floating_control->contentsMargins();
|
---|
967 | int new_height = iws.height() + m.top() + m.bottom();
|
---|
968 | if (new_height < 32) new_height = 32;
|
---|
969 | floating_control->resize(floating_control->width(), new_height);
|
---|
970 | }
|
---|
971 | }
|
---|
972 |
|
---|
973 | void DefaultGui::saveConfig() {
|
---|
974 | qDebug("DefaultGui::saveConfig");
|
---|
975 |
|
---|
976 | QSettings * set = settings;
|
---|
977 |
|
---|
978 | set->beginGroup( "default_gui");
|
---|
979 |
|
---|
980 | set->setValue("video_info", viewVideoInfoAct->isChecked());
|
---|
981 | set->setValue("frame_counter", viewFrameCounterAct->isChecked());
|
---|
982 | set->setValue("format_info", viewFormatInfoAct->isChecked());
|
---|
983 | set->setValue("bitrate_info", viewBitrateInfoAct->isChecked());
|
---|
984 | set->setValue("use_milliseconds", useMillisecondsAct->isChecked());
|
---|
985 |
|
---|
986 | set->setValue("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible);
|
---|
987 | set->setValue("compact_toolbar1_was_visible", compact_toolbar1_was_visible);
|
---|
988 | #ifdef LANGUAGE_TOOLBAR
|
---|
989 | set->setValue("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible);
|
---|
990 | set->setValue("compact_toolbar2_was_visible", compact_toolbar2_was_visible);
|
---|
991 | #endif
|
---|
992 |
|
---|
993 | if (pref->save_window_size_on_exit) {
|
---|
994 | qDebug("DefaultGui::saveConfig: w: %d h: %d", width(), height());
|
---|
995 | set->setValue( "pos", pos() );
|
---|
996 | set->setValue( "size", size() );
|
---|
997 | set->setValue( "state", (int) windowState() );
|
---|
998 | }
|
---|
999 |
|
---|
1000 | set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
|
---|
1001 |
|
---|
1002 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
1003 | set->beginGroup( "actions" );
|
---|
1004 | set->setValue("toolbar1/" TOOLBAR_VERSION, toolbar1->actionsToStringList() );
|
---|
1005 | set->setValue("controlwidget/" CONTROLWIDGET_VERSION, controlwidget->actionsToStringList() );
|
---|
1006 | set->setValue("controlwidget_mini/" CONTROLWIDGETMINI_VERSION, controlwidget_mini->actionsToStringList() );
|
---|
1007 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
1008 | set->setValue("floating_control/" FLOATING_CONTROL_VERSION, iw->actionsToStringList() );
|
---|
1009 | set->endGroup();
|
---|
1010 |
|
---|
1011 | set->beginGroup("toolbars_icon_size");
|
---|
1012 | set->setValue("toolbar1", toolbar1->iconSize());
|
---|
1013 | set->setValue("controlwidget", controlwidget->iconSize());
|
---|
1014 | set->setValue("controlwidget_mini", controlwidget_mini->iconSize());
|
---|
1015 | set->setValue("floating_control", iw->iconSize());
|
---|
1016 | set->endGroup();
|
---|
1017 | #endif
|
---|
1018 |
|
---|
1019 | set->endGroup();
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | void DefaultGui::loadConfig() {
|
---|
1023 | qDebug("DefaultGui::loadConfig");
|
---|
1024 |
|
---|
1025 | QSettings * set = settings;
|
---|
1026 |
|
---|
1027 | set->beginGroup( "default_gui");
|
---|
1028 |
|
---|
1029 | viewVideoInfoAct->setChecked(set->value("video_info", false).toBool());
|
---|
1030 | viewFrameCounterAct->setChecked(set->value("frame_counter", false).toBool());
|
---|
1031 | viewFormatInfoAct->setChecked(set->value("format_info", false).toBool());
|
---|
1032 | viewBitrateInfoAct->setChecked(set->value("bitrate_info", false).toBool());
|
---|
1033 | useMillisecondsAct->setChecked(set->value("use_milliseconds", false).toBool());
|
---|
1034 |
|
---|
1035 | fullscreen_toolbar1_was_visible = set->value("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible).toBool();
|
---|
1036 | compact_toolbar1_was_visible = set->value("compact_toolbar1_was_visible", compact_toolbar1_was_visible).toBool();
|
---|
1037 | #ifdef LANGUAGE_TOOLBAR
|
---|
1038 | fullscreen_toolbar2_was_visible = set->value("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible).toBool();
|
---|
1039 | compact_toolbar2_was_visible = set->value("compact_toolbar2_was_visible", compact_toolbar2_was_visible).toBool();
|
---|
1040 | #endif
|
---|
1041 |
|
---|
1042 | if (pref->save_window_size_on_exit) {
|
---|
1043 | QPoint p = set->value("pos", pos()).toPoint();
|
---|
1044 | QSize s = set->value("size", size()).toSize();
|
---|
1045 |
|
---|
1046 | if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
|
---|
1047 | s = pref->default_size;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | move(p);
|
---|
1051 | resize(s);
|
---|
1052 |
|
---|
1053 | setWindowState( (Qt::WindowStates) set->value("state", 0).toInt() );
|
---|
1054 |
|
---|
1055 | if (!DesktopInfo::isInsideScreen(this)) {
|
---|
1056 | QPoint tl = DesktopInfo::topLeftPrimaryScreen();
|
---|
1057 | move(tl);
|
---|
1058 | qWarning("DefaultGui::loadConfig: window is outside of the screen, moved to %d x %d", tl.x(), tl.y());
|
---|
1059 | }
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
1063 | set->beginGroup( "actions" );
|
---|
1064 | toolbar1->setActionsFromStringList( set->value("toolbar1/" TOOLBAR_VERSION, toolbar1->defaultActions()).toStringList() );
|
---|
1065 |
|
---|
1066 | {
|
---|
1067 | QStringList l = set->value("controlwidget/" CONTROLWIDGET_VERSION, controlwidget->defaultActions()).toStringList();
|
---|
1068 | #ifdef ADD_QUICK_ACCESS
|
---|
1069 | if (l.indexOf("quick_access_menu") == -1) l << "quick_access_menu";
|
---|
1070 | #endif
|
---|
1071 | controlwidget->setActionsFromStringList(l);
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | controlwidget_mini->setActionsFromStringList( set->value("controlwidget_mini/" CONTROLWIDGETMINI_VERSION, controlwidget_mini->defaultActions()).toStringList() );
|
---|
1075 |
|
---|
1076 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
1077 | iw->setActionsFromStringList( set->value("floating_control/" FLOATING_CONTROL_VERSION, iw->defaultActions()).toStringList() );
|
---|
1078 | set->endGroup();
|
---|
1079 |
|
---|
1080 | set->beginGroup("toolbars_icon_size");
|
---|
1081 | toolbar1->setIconSize(set->value("toolbar1", toolbar1->iconSize()).toSize());
|
---|
1082 | controlwidget->setIconSize(set->value("controlwidget", controlwidget->iconSize()).toSize());
|
---|
1083 | controlwidget_mini->setIconSize(set->value("controlwidget_mini", controlwidget_mini->iconSize()).toSize());
|
---|
1084 | iw->setIconSize(set->value("floating_control", iw->iconSize()).toSize());
|
---|
1085 | set->endGroup();
|
---|
1086 |
|
---|
1087 | floating_control->adjustSize();
|
---|
1088 | #endif
|
---|
1089 |
|
---|
1090 | restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
|
---|
1091 |
|
---|
1092 | #if DOCK_PLAYLIST
|
---|
1093 | qDebug("DefaultGui::loadConfig: playlist visible: %d", playlistdock->isVisible());
|
---|
1094 | qDebug("DefaultGui::loadConfig: playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
1095 | qDebug("DefaultGui::loadConfig: playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
1096 | #endif
|
---|
1097 |
|
---|
1098 | set->endGroup();
|
---|
1099 |
|
---|
1100 | updateWidgets();
|
---|
1101 | }
|
---|
1102 |
|
---|
1103 | #include "moc_defaultgui.cpp"
|
---|