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