1 /*  smplayer, GUI front-end for mplayer.
2     Copyright (C) 2006-2021 Ricardo Villalba <ricardo@smplayer.info>
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 "basegui.h"
20 
21 #include "filedialog.h"
22 #include <QMessageBox>
23 #include <QLabel>
24 #include <QMenu>
25 #include <QFileInfo>
26 #include <QApplication>
27 #include <QMenuBar>
28 #include <QHBoxLayout>
29 #include <QCursor>
30 #include <QTimer>
31 #include <QStyle>
32 #include <QRegExp>
33 #include <QStatusBar>
34 #include <QActionGroup>
35 #include <QUrl>
36 #include <QDragEnterEvent>
37 #include <QDropEvent>
38 #include <QDesktopServices>
39 #include <QInputDialog>
40 #include <QClipboard>
41 #include <QMimeData>
42 #include <QDesktopWidget>
43 
44 #include <QtCore/qmath.h>
45 
46 #include "mplayerwindow.h"
47 #include "desktopinfo.h"
48 #include "helper.h"
49 #include "paths.h"
50 #include "colorutils.h"
51 #include "global.h"
52 #include "translator.h"
53 #include "images.h"
54 #include "preferences.h"
55 #include "discname.h"
56 #include "timeslider.h"
57 #include "logwindow.h"
58 #include "infowindow.h"
59 #include "playlist.h"
60 #include "filepropertiesdialog.h"
61 #include "eqslider.h"
62 #include "videoequalizer.h"
63 #include "audioequalizer.h"
64 #include "inputdvddirectory.h"
65 #include "inputmplayerversion.h"
66 #include "inputurl.h"
67 #include "recents.h"
68 #include "urlhistory.h"
69 #include "about.h"
70 #include "errordialog.h"
71 #include "timedialog.h"
72 #include "stereo3ddialog.h"
73 
74 #ifdef BOOKMARKS
75 #include "inputbookmark.h"
76 #include "bookmarkdialog.h"
77 #endif
78 
79 #include "clhelp.h"
80 #include "mplayerversion.h"
81 
82 #ifdef FIND_SUBTITLES
83 #include "findsubtitleswindow.h"
84 #endif
85 
86 #ifdef VIDEOPREVIEW
87 #include "videopreview.h"
88 #endif
89 
90 #include "config.h"
91 #include "actionseditor.h"
92 
93 #ifdef TV_SUPPORT
94 #include "tvlist.h"
95 #else
96 #include "favorites.h"
97 #endif
98 
99 #include "preferencesdialog.h"
100 #include "prefgeneral.h"
101 #include "prefinterface.h"
102 #include "prefinput.h"
103 #include "prefadvanced.h"
104 #include "prefplaylist.h"
105 
106 #include "myaction.h"
107 #include "myactiongroup.h"
108 #include "playlist.h"
109 
110 #include "constants.h"
111 #include "links.h"
112 
113 #ifdef MPRIS2
114 #include "mpris2/mpris2.h"
115 #endif
116 
117 #include "extensions.h"
118 #include "version.h"
119 
120 #ifdef Q_OS_WIN
121 #include "deviceinfo.h"
122 #include <QSysInfo>
123 #endif
124 
125 #ifdef OS_UNIX_NOT_MAC
126 #include "myapplication.h"
127 #endif
128 
129 #ifdef UPDATE_CHECKER
130 #include "updatechecker.h"
131 #endif
132 
133 #ifdef YOUTUBE_SUPPORT
134   #ifdef YT_CODEDOWNLOADER
135   #include "codedownloader.h"
136   #endif
137 #endif
138 
139 #ifdef USE_SMTUBE_LIB
140 #include "../smtube/browserwindow.h"
141 #endif
142 
143 #ifdef SHARE_ACTIONS
144 #include "sharedialog.h"
145 #endif
146 
147 #ifdef SHARE_WIDGET
148 #include "sharewidget.h"
149 #endif
150 
151 #ifdef AUTO_SHUTDOWN_PC
152 #include "shutdowndialog.h"
153 #include "shutdown.h"
154 #endif
155 
156 using namespace Global;
157 
BaseGui(QWidget * parent,Qt::WindowFlags flags)158 BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
159 	: QMainWindow( parent, flags )
160 #ifdef DETECT_MINIMIZE_WORKAROUND
161 	, was_minimized(false)
162 #endif
163 	, popup(0)
164 	, clhelp_window(0)
165 	, pref_dialog(0)
166 	, file_dialog (0)
167 #ifdef FIND_SUBTITLES
168 	, find_subs_dialog(0)
169 #endif
170 #ifdef VIDEOPREVIEW
171 	, video_preview(0)
172 #endif
173 #ifdef UPDATE_CHECKER
174 	, update_checker(0)
175 #endif
176 	, arg_close_on_finish(-1)
177 	, arg_start_in_fullscreen(-1)
178 #ifdef MG_DELAYED_SEEK
179 	, delayed_seek_timer(0)
180 	, delayed_seek_value(0)
181 #endif
182 #ifdef USE_SMTUBE_LIB
183 	, browser_window(0)
184 #endif
185 	, was_maximized(false)
186 #ifdef AVOID_SCREENSAVER
187 	, just_stopped(false)
188 #endif
189 	, ignore_show_hide_events(false)
190 {
191 	setWindowTitle( "SMPlayer" );
192 
193 	// Create objects:
194 	createPanel();
195 	setCentralWidget(panel);
196 
197 	createMplayerWindow();
198 	createCore();
199 	createPlaylist();
200 	createVideoEqualizer();
201 	createAudioEqualizer();
202 
203 	// Mouse Wheel
204 	/*
205 	connect( this, SIGNAL(wheelUp()),
206              core, SLOT(wheelUp()) );
207 	connect( this, SIGNAL(wheelDown()),
208              core, SLOT(wheelDown()) );
209 	*/
210 	connect( mplayerwindow, SIGNAL(wheelUp()),
211              core, SLOT(wheelUp()) );
212 	connect( mplayerwindow, SIGNAL(wheelDown()),
213              core, SLOT(wheelDown()) );
214 
215 #if STYLE_SWITCHING
216 	qApp->setStyleSheet("");
217 	default_style = qApp->style()->objectName();
218 
219 	#ifdef OS_UNIX_NOT_MAC
220 	// Some controls aren't displayed correctly with the adwaita style
221 	// so try to prevent to use it as the default style
222 	if (default_style.toLower() == "adwaita") default_style = "gtk+";
223 	#endif
224 	qDebug() << "BaseGui::BaseGui: default_style:" << default_style;
225 	//qDebug() << "BaseGui::BaseGui: qApp->style:" << qApp->style();
226 #endif
227 
228 #ifdef LOG_MPLAYER
229 	mplayer_log_window = new LogWindow(0);
230 #endif
231 #ifdef LOG_SMPLAYER
232 	smplayer_log_window = new LogWindow(0);
233 #endif
234 
235 	createActions();
236 	createMenus();
237 #if AUTODISABLE_ACTIONS
238 	setActionsEnabled(false);
239 	if (playlist->count() > 0) {
240 		playAct->setEnabled(true);
241 		playOrPauseAct->setEnabled(true);
242 	}
243 #endif
244 
245 	retranslateStrings();
246 
247 	setAcceptDrops(true);
248 
249 	resize(pref->default_size);
250 
251 	panel->setFocus();
252 
253 	setupNetworkProxy();
254 
255 	/* Initialize GUI */
256 	if (pref->compact_mode) toggleCompactMode(true);
257 	changeStayOnTop(pref->stay_on_top);
258 	updateRecents();
259 	QTimer::singleShot(20, this, SLOT(loadActions()));
260 
261 #ifdef UPDATE_CHECKER
262 	update_checker = new UpdateChecker(this, &pref->update_checker_data);
263 #endif
264 
265 #ifdef CHECK_UPGRADED
266 	QTimer::singleShot(2000, this, SLOT(checkIfUpgraded()));
267 #endif
268 
269 #ifdef DONATE_REMINDER
270 	QTimer::singleShot(1000, this, SLOT(checkReminder()));
271 #endif
272 
273 #ifdef MPRIS2
274 	if (pref->use_mpris2) new Mpris2(this, this);
275 #endif
276 
277 	MyFileDialog::setNative(pref->use_native_open_dialog);
278 }
279 
setupNetworkProxy()280 void BaseGui::setupNetworkProxy() {
281 	qDebug("BaseGui::setupNetworkProxy");
282 
283 	QNetworkProxy proxy;
284 
285 	if ( (pref->use_proxy) && (!pref->proxy_host.isEmpty()) ) {
286 		proxy.setType((QNetworkProxy::ProxyType) pref->proxy_type);
287 		proxy.setHostName(pref->proxy_host);
288 		proxy.setPort(pref->proxy_port);
289 		if ( (!pref->proxy_username.isEmpty()) && (!pref->proxy_password.isEmpty()) ) {
290 			proxy.setUser(pref->proxy_username);
291 			proxy.setPassword(pref->proxy_password);
292 		}
293 		qDebug("BaseGui::setupNetworkProxy: using proxy: host: %s, port: %d, type: %d",
294                pref->proxy_host.toUtf8().constData(), pref->proxy_port, pref->proxy_type);
295 	} else {
296 		// No proxy
297 		proxy.setType(QNetworkProxy::NoProxy);
298 		qDebug("BaseGui::setupNetworkProxy: no proxy");
299 	}
300 
301 	QNetworkProxy::setApplicationProxy(proxy);
302 }
303 
304 #ifdef SINGLE_INSTANCE
handleMessageFromOtherInstances(const QString & message)305 void BaseGui::handleMessageFromOtherInstances(const QString& message) {
306 	qDebug() << "BaseGui::handleMessageFromOtherInstances:" << message;
307 
308 	int pos = message.indexOf(' ');
309 	if (pos > -1) {
310 		QString command = message.left(pos);
311 		QString arg = message.mid(pos+1);
312 		qDebug() << "command:" << command;
313 		qDebug() << "arg:" << arg;
314 
315 		if (command == "open_file") {
316 			emit openFileRequested();
317 			open(arg);
318 		}
319 		else
320 		if (command == "open_files") {
321 			QStringList file_list = arg.split(" <<sep>> ");
322 			emit openFileRequested();
323 			openFiles(file_list);
324 		}
325 		else
326 		if (command == "add_to_playlist") {
327 			QStringList file_list = arg.split(" <<sep>> ");
328 			/* if (core->state() == Core::Stopped) { emit openFileRequested(); } */
329 			playlist->addFiles(file_list);
330 		}
331 		else
332 		if (command == "media_title") {
333 			QStringList list = arg.split(" <<sep>> ");
334 			core->addForcedTitle(list[0], list[1]);
335 		}
336 		else
337 		if (command == "action") {
338 			processFunction(arg);
339 		}
340 		else
341 		if (command == "load_sub") {
342 			setInitialSubtitle(arg);
343 			if (core->state() != Core::Stopped) {
344 				core->loadSub(arg);
345 			}
346 		}
347 		else
348 		if (command == "start_second") {
349 			setInitialSecond(arg.toInt());
350 		}
351 	}
352 }
353 #endif
354 
~BaseGui()355 BaseGui::~BaseGui() {
356 	delete core; // delete before mplayerwindow, otherwise, segfault...
357 #ifdef LOG_MPLAYER
358 	delete mplayer_log_window;
359 #endif
360 #ifdef LOG_SMPLAYER
361 	delete smplayer_log_window;
362 #endif
363 
364 	delete favorites;
365 
366 #ifdef TV_SUPPORT
367 	delete tvlist;
368 	delete radiolist;
369 #endif
370 
371 	if (playlist) {
372 		delete playlist;
373 		playlist = 0;
374 	}
375 
376 #ifdef FIND_SUBTITLES
377 	if (find_subs_dialog) {
378 		delete find_subs_dialog;
379 		find_subs_dialog = 0; // Necessary?
380 	}
381 #endif
382 
383 #ifdef VIDEOPREVIEW
384 	if (video_preview) {
385 		delete video_preview;
386 	}
387 #endif
388 
389 #if defined(YOUTUBE_SUPPORT) && defined(USE_SMTUBE_LIB)
390 	if (browser_window) delete browser_window;
391 #endif
392 
393 	if (mplayerwindow) {
394 		delete mplayerwindow;
395 	}
396 }
397 
createActions()398 void BaseGui::createActions() {
399 	// Menu File
400 	openFileAct = new MyAction( QKeySequence("Ctrl+F"), this, "open_file" );
401 	connect( openFileAct, SIGNAL(triggered()),
402              this, SLOT(openFile()) );
403 
404 	openDirectoryAct = new MyAction( this, "open_directory" );
405 	connect( openDirectoryAct, SIGNAL(triggered()),
406              this, SLOT(openDirectory()) );
407 
408 	openPlaylistAct = new MyAction( this, "open_playlist" );
409 	connect( openPlaylistAct, SIGNAL(triggered()),
410              playlist, SLOT(load()) );
411 
412 	openVCDAct = new MyAction( this, "open_vcd" );
413 	connect( openVCDAct, SIGNAL(triggered()),
414              this, SLOT(openVCD()) );
415 
416 	openAudioCDAct = new MyAction( this, "open_audio_cd" );
417 	connect( openAudioCDAct, SIGNAL(triggered()),
418              this, SLOT(openAudioCD()) );
419 
420 	openDVDAct = new MyAction( this, "open_dvd" );
421 	connect( openDVDAct, SIGNAL(triggered()),
422              this, SLOT(openDVD()) );
423 
424 	openDVDFolderAct = new MyAction( this, "open_dvd_folder" );
425 	connect( openDVDFolderAct, SIGNAL(triggered()),
426              this, SLOT(openDVDFromFolder()) );
427 
428 	// Bluray section.
429 #ifdef BLURAY_SUPPORT
430 	openBluRayAct = new MyAction( this, "open_bluray" );
431 	connect( openBluRayAct, SIGNAL(triggered()),
432              this, SLOT(openBluRay()));
433 
434 	openBluRayFolderAct = new MyAction( this, "open_bluray_folder" );
435 	connect( openBluRayFolderAct, SIGNAL(triggered()),
436              this, SLOT(openBluRayFromFolder()));
437 #endif
438 
439 	openURLAct = new MyAction( QKeySequence("Ctrl+U"), this, "open_url" );
440 	connect( openURLAct, SIGNAL(triggered()),
441              this, SLOT(openURL()) );
442 
443 	exitAct = new MyAction( QKeySequence("Ctrl+X"), this, "close" );
444 	connect( exitAct, SIGNAL(triggered()), this, SLOT(closeWindow()) );
445 
446 	clearRecentsAct = new MyAction( this, "clear_recents" );
447 	connect( clearRecentsAct, SIGNAL(triggered()), this, SLOT(clearRecentsList()) );
448 
449 	// Favorites
450 	favorites = new Favorites(Paths::configPath() + "/favorites.m3u8", this);
451 	favorites->menuAction()->setObjectName( "favorites_menu" );
452 	addAction(favorites->editAct());
453 	addAction(favorites->jumpAct());
454 	addAction(favorites->nextAct());
455 	addAction(favorites->previousAct());
456 	connect(favorites, SIGNAL(activated(QString)), this, SLOT(openFavorite(QString)));
457 	connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
458             favorites, SLOT(getCurrentMedia(const QString &, const QString &)));
459 
460 	// TV and Radio
461 #ifdef TV_SUPPORT
462 	tvlist = new TVList(pref->check_channels_conf_on_startup,
463                         TVList::TV, Paths::configPath() + "/tv.m3u8", this);
464 	tvlist->menuAction()->setObjectName( "tv_menu" );
465 	addAction(tvlist->editAct());
466 	addAction(tvlist->jumpAct());
467 	addAction(tvlist->nextAct());
468 	addAction(tvlist->previousAct());
469 	tvlist->nextAct()->setShortcut( Qt::Key_H );
470 	tvlist->previousAct()->setShortcut( Qt::Key_L );
471 	tvlist->nextAct()->setObjectName("next_tv");
472 	tvlist->previousAct()->setObjectName("previous_tv");
473 	tvlist->editAct()->setObjectName("edit_tv_list");
474 	tvlist->jumpAct()->setObjectName("jump_tv_list");
475 	connect(tvlist, SIGNAL(activated(QString)), this, SLOT(open(QString)));
476 	connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
477             tvlist, SLOT(getCurrentMedia(const QString &, const QString &)));
478 
479 	radiolist = new TVList(pref->check_channels_conf_on_startup,
480                            TVList::Radio, Paths::configPath() + "/radio.m3u8", this);
481 	radiolist->menuAction()->setObjectName( "radio_menu" );
482 	addAction(radiolist->editAct());
483 	addAction(radiolist->jumpAct());
484 	addAction(radiolist->nextAct());
485 	addAction(radiolist->previousAct());
486 	radiolist->nextAct()->setShortcut( Qt::SHIFT | Qt::Key_H );
487 	radiolist->previousAct()->setShortcut( Qt::SHIFT | Qt::Key_L );
488 	radiolist->nextAct()->setObjectName("next_radio");
489 	radiolist->previousAct()->setObjectName("previous_radio");
490 	radiolist->editAct()->setObjectName("edit_radio_list");
491 	radiolist->jumpAct()->setObjectName("jump_radio_list");
492 	connect(radiolist, SIGNAL(activated(QString)), this, SLOT(open(QString)));
493 	connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
494             radiolist, SLOT(getCurrentMedia(const QString &, const QString &)));
495 #endif
496 
497 
498 	// Menu Play
499 	playAct = new MyAction( this, "play" );
500 	connect( playAct, SIGNAL(triggered()),
501              core, SLOT(play()) );
502 
503 	playOrPauseAct = new MyAction( Qt::Key_MediaPlay, this, "play_or_pause" );
504 	playOrPauseAct->addShortcut(QKeySequence("Toggle Media Play/Pause")); // MCE remote key
505 	connect( playOrPauseAct, SIGNAL(triggered()),
506              core, SLOT(play_or_pause()) );
507 
508 	pauseAct = new MyAction( Qt::Key_Space, this, "pause" );
509 	pauseAct->addShortcut(QKeySequence("Media Pause")); // MCE remote key
510 	connect( pauseAct, SIGNAL(triggered()),
511              core, SLOT(pause()) );
512 
513 	pauseAndStepAct = new MyAction( this, "pause_and_frame_step" );
514 	connect( pauseAndStepAct, SIGNAL(triggered()),
515              core, SLOT(pause_and_frame_step()) );
516 
517 	stopAct = new MyAction( Qt::Key_MediaStop, this, "stop" );
518 	connect( stopAct, SIGNAL(triggered()),
519              core, SLOT(stop()) );
520 
521 	frameStepAct = new MyAction( Qt::Key_Period, this, "frame_step" );
522 	connect( frameStepAct, SIGNAL(triggered()),
523              core, SLOT(frameStep()) );
524 
525 	frameBackStepAct = new MyAction( Qt::Key_Comma, this, "frame_back_step" );
526 	connect( frameBackStepAct, SIGNAL(triggered()),
527              core, SLOT(frameBackStep()) );
528 
529 	rewind1Act = new MyAction( Qt::Key_Left, this, "rewind1" );
530 	rewind1Act->addShortcut(QKeySequence("Shift+Ctrl+B")); // MCE remote key
531 	connect( rewind1Act, SIGNAL(triggered()),
532              core, SLOT(srewind()) );
533 
534 	rewind2Act = new MyAction( Qt::Key_Down, this, "rewind2" );
535 	connect( rewind2Act, SIGNAL(triggered()),
536              core, SLOT(rewind()) );
537 
538 	rewind3Act = new MyAction( Qt::Key_PageDown, this, "rewind3" );
539 	connect( rewind3Act, SIGNAL(triggered()),
540              core, SLOT(fastrewind()) );
541 
542 	forward1Act = new MyAction( Qt::Key_Right, this, "forward1" );
543 	forward1Act->addShortcut(QKeySequence("Shift+Ctrl+F")); // MCE remote key
544 	connect( forward1Act, SIGNAL(triggered()),
545              core, SLOT(sforward()) );
546 
547 	forward2Act = new MyAction( Qt::Key_Up, this, "forward2" );
548 	connect( forward2Act, SIGNAL(triggered()),
549              core, SLOT(forward()) );
550 
551 	forward3Act = new MyAction( Qt::Key_PageUp, this, "forward3" );
552 	connect( forward3Act, SIGNAL(triggered()),
553              core, SLOT(fastforward()) );
554 
555 	setAMarkerAct = new MyAction( this, "set_a_marker" );
556 	connect( setAMarkerAct, SIGNAL(triggered()),
557              core, SLOT(setAMarker()) );
558 
559 	setBMarkerAct = new MyAction( this, "set_b_marker" );
560 	connect( setBMarkerAct, SIGNAL(triggered()),
561              core, SLOT(setBMarker()) );
562 
563 	clearABMarkersAct = new MyAction( this, "clear_ab_markers" );
564 	connect( clearABMarkersAct, SIGNAL(triggered()),
565              core, SLOT(clearABMarkers()) );
566 
567 	repeatAct = new MyAction( this, "repeat" );
568 	repeatAct->setCheckable( true );
569 	connect( repeatAct, SIGNAL(toggled(bool)),
570              core, SLOT(toggleRepeat(bool)) );
571 
572 	gotoAct = new MyAction( QKeySequence("Ctrl+J"), this, "jump_to" );
573 	connect( gotoAct, SIGNAL(triggered()),
574              this, SLOT(showGotoDialog()) );
575 
576 	// Submenu Speed
577 	normalSpeedAct = new MyAction( Qt::Key_Backspace, this, "normal_speed" );
578 	connect( normalSpeedAct, SIGNAL(triggered()),
579              core, SLOT(normalSpeed()) );
580 
581 	halveSpeedAct = new MyAction( Qt::Key_BraceLeft, this, "halve_speed" );
582 	connect( halveSpeedAct, SIGNAL(triggered()),
583              core, SLOT(halveSpeed()) );
584 
585 	doubleSpeedAct = new MyAction( Qt::Key_BraceRight, this, "double_speed" );
586 	connect( doubleSpeedAct, SIGNAL(triggered()),
587              core, SLOT(doubleSpeed()) );
588 
589 	decSpeed10Act = new MyAction( Qt::Key_BracketLeft, this, "dec_speed" );
590 	connect( decSpeed10Act, SIGNAL(triggered()),
591              core, SLOT(decSpeed10()) );
592 
593 	incSpeed10Act = new MyAction( Qt::Key_BracketRight, this, "inc_speed" );
594 	connect( incSpeed10Act, SIGNAL(triggered()),
595              core, SLOT(incSpeed10()) );
596 
597 	decSpeed4Act = new MyAction( this, "dec_speed_4" );
598 	connect( decSpeed4Act, SIGNAL(triggered()),
599              core, SLOT(decSpeed4()) );
600 
601 	incSpeed4Act = new MyAction( this, "inc_speed_4" );
602 	connect( incSpeed4Act, SIGNAL(triggered()),
603              core, SLOT(incSpeed4()) );
604 
605 	decSpeed1Act = new MyAction( this, "dec_speed_1" );
606 	connect( decSpeed1Act, SIGNAL(triggered()),
607              core, SLOT(decSpeed1()) );
608 
609 	incSpeed1Act = new MyAction( this, "inc_speed_1" );
610 	connect( incSpeed1Act, SIGNAL(triggered()),
611              core, SLOT(incSpeed1()) );
612 
613 	for (double speed = 0.25; speed < 2; speed += 0.25) {
614 		if (speed == 1.0) continue;
615 		QByteArray action_name = "speed_" + QByteArray::number(speed) + "x";
616 		MyAction * a = new MyAction(this, action_name.constData());
617 		a->setText(QString::number(speed) + "x");
618 		a->setData(speed);
619 		connect(a, SIGNAL(triggered()), this, SLOT(setSpeed()));
620 		speed_acts.append(a);
621 	}
622 
623 	// Menu Video
624 	fullscreenAct = new MyAction( Qt::Key_F, this, "fullscreen" );
625 	fullscreenAct->addShortcut(QKeySequence("Ctrl+T")); // MCE remote key
626 	fullscreenAct->setCheckable( true );
627 	connect( fullscreenAct, SIGNAL(toggled(bool)),
628              this, SLOT(toggleFullscreen(bool)) );
629 
630 	compactAct = new MyAction( QKeySequence("Ctrl+C"), this, "compact" );
631 	compactAct->setCheckable( true );
632 	connect( compactAct, SIGNAL(toggled(bool)),
633              this, SLOT(toggleCompactMode(bool)) );
634 
635 	videoEqualizerAct = new MyAction( QKeySequence("Ctrl+E"), this, "video_equalizer" );
636 	videoEqualizerAct->setCheckable( true );
637 	connect( videoEqualizerAct, SIGNAL(toggled(bool)),
638              this, SLOT(showVideoEqualizer(bool)) );
639 
640 	// Single screenshot
641 	screenshotAct = new MyAction( Qt::Key_S, this, "screenshot" );
642 	connect( screenshotAct, SIGNAL(triggered()),
643              core, SLOT(screenshot()) );
644 
645 	screenshotWithSubsAct = new MyAction( QKeySequence("Ctrl+Shift+S"), this, "screenshot_with_subtitles" );
646 	connect( screenshotWithSubsAct, SIGNAL(triggered()),
647              core, SLOT(screenshotWithSubtitles()) );
648 
649 	screenshotWithNoSubsAct = new MyAction( QKeySequence("Ctrl+Alt+S"), this, "screenshot_without_subtitles" );
650 	connect( screenshotWithNoSubsAct, SIGNAL(triggered()),
651              core, SLOT(screenshotWithoutSubtitles()) );
652 
653 	// Multiple screenshots
654 	screenshotsAct = new MyAction( QKeySequence("Shift+D"), this, "multiple_screenshots" );
655 	connect( screenshotsAct, SIGNAL(triggered()),
656              core, SLOT(screenshots()) );
657 
658 #ifdef CAPTURE_STREAM
659 	capturingAct = new MyAction( /*Qt::Key_C,*/ this, "capture_stream");
660 	connect( capturingAct, SIGNAL(triggered()),
661              core, SLOT(switchCapturing()) );
662 #endif
663 
664 #ifdef VIDEOPREVIEW
665 	videoPreviewAct = new MyAction( this, "video_preview" );
666 	connect( videoPreviewAct, SIGNAL(triggered()),
667              this, SLOT(showVideoPreviewDialog()) );
668 #endif
669 
670 	flipAct = new MyAction( this, "flip" );
671 	flipAct->setCheckable( true );
672 	connect( flipAct, SIGNAL(toggled(bool)),
673              core, SLOT(toggleFlip(bool)) );
674 
675 	mirrorAct = new MyAction( this, "mirror" );
676 	mirrorAct->setCheckable( true );
677 	connect( mirrorAct, SIGNAL(toggled(bool)),
678              core, SLOT(toggleMirror(bool)) );
679 
680 	stereo3dAct = new MyAction( this, "stereo_3d_filter" );
681 	connect( stereo3dAct, SIGNAL(triggered()),
682              this, SLOT(showStereo3dDialog()) );
683 
684 	// Submenu filter
685 	postProcessingAct = new MyAction( this, "postprocessing" );
686 	postProcessingAct->setCheckable( true );
687 	connect( postProcessingAct, SIGNAL(toggled(bool)),
688              core, SLOT(togglePostprocessing(bool)) );
689 
690 	phaseAct = new MyAction( this, "autodetect_phase" );
691 	phaseAct->setCheckable( true );
692 	connect( phaseAct, SIGNAL(toggled(bool)),
693              core, SLOT(toggleAutophase(bool)) );
694 
695 	deblockAct = new MyAction( this, "deblock" );
696 	deblockAct->setCheckable( true );
697 	connect( deblockAct, SIGNAL(toggled(bool)),
698              core, SLOT(toggleDeblock(bool)) );
699 
700 	deringAct = new MyAction( this, "dering" );
701 	deringAct->setCheckable( true );
702 	connect( deringAct, SIGNAL(toggled(bool)),
703              core, SLOT(toggleDering(bool)) );
704 
705 	gradfunAct = new MyAction( this, "gradfun" );
706 	gradfunAct->setCheckable( true );
707 	connect( gradfunAct, SIGNAL(toggled(bool)),
708              core, SLOT(toggleGradfun(bool)) );
709 
710 
711 	addNoiseAct = new MyAction( this, "add_noise" );
712 	addNoiseAct->setCheckable( true );
713 	connect( addNoiseAct, SIGNAL(toggled(bool)),
714              core, SLOT(toggleNoise(bool)) );
715 
716 	addLetterboxAct = new MyAction( this, "add_letterbox" );
717 	addLetterboxAct->setCheckable( true );
718 	connect( addLetterboxAct, SIGNAL(toggled(bool)),
719              core, SLOT(changeLetterbox(bool)) );
720 
721 	upscaleAct = new MyAction( this, "upscaling" );
722 	upscaleAct->setCheckable( true );
723 	connect( upscaleAct, SIGNAL(toggled(bool)),
724              core, SLOT(changeUpscale(bool)) );
725 
726 
727 	// Menu Audio
728 	audioEqualizerAct = new MyAction( this, "audio_equalizer" );
729 	audioEqualizerAct->setCheckable( true );
730 	connect( audioEqualizerAct, SIGNAL(toggled(bool)),
731              this, SLOT(showAudioEqualizer(bool)) );
732 
733 	muteAct = new MyAction( Qt::Key_M, this, "mute" );
734 	muteAct->addShortcut(Qt::Key_VolumeMute); // MCE remote key
735 	muteAct->setCheckable( true );
736 	connect( muteAct, SIGNAL(toggled(bool)),
737              core, SLOT(mute(bool)) );
738 
739 #if USE_MULTIPLE_SHORTCUTS
740 	decVolumeAct = new MyAction( this, "decrease_volume" );
741 	decVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("9,/") );
742 	decVolumeAct->addShortcut(Qt::Key_VolumeDown); // MCE remote key
743 #else
744 	decVolumeAct = new MyAction( Qt::Key_9, this, "dec_volume" );
745 #endif
746 	connect( decVolumeAct, SIGNAL(triggered()),
747              core, SLOT(decVolume()) );
748 
749 #if USE_MULTIPLE_SHORTCUTS
750 	incVolumeAct = new MyAction( this, "increase_volume" );
751 	incVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("0,*") );
752 	incVolumeAct->addShortcut(Qt::Key_VolumeUp); // MCE remote key
753 #else
754 	incVolumeAct = new MyAction( Qt::Key_0, this, "inc_volume" );
755 #endif
756 	connect( incVolumeAct, SIGNAL(triggered()),
757              core, SLOT(incVolume()) );
758 
759 	decAudioDelayAct = new MyAction( Qt::Key_Minus, this, "dec_audio_delay" );
760 	connect( decAudioDelayAct, SIGNAL(triggered()),
761              core, SLOT(decAudioDelay()) );
762 
763 	incAudioDelayAct = new MyAction( Qt::Key_Plus, this, "inc_audio_delay" );
764 	connect( incAudioDelayAct, SIGNAL(triggered()),
765              core, SLOT(incAudioDelay()) );
766 
767 	audioDelayAct = new MyAction( this, "audio_delay" );
768 	connect( audioDelayAct, SIGNAL(triggered()),
769              this, SLOT(showAudioDelayDialog()) );
770 
771 	loadAudioAct = new MyAction( this, "load_audio_file" );
772 	connect( loadAudioAct, SIGNAL(triggered()),
773              this, SLOT(loadAudioFile()) );
774 
775 	unloadAudioAct = new MyAction( this, "unload_audio_file" );
776 	connect( unloadAudioAct, SIGNAL(triggered()),
777              core, SLOT(unloadAudioFile()) );
778 
779 
780 	// Submenu Filters
781 	extrastereoAct = new MyAction( this, "extrastereo_filter" );
782 	extrastereoAct->setCheckable( true );
783 	connect( extrastereoAct, SIGNAL(toggled(bool)),
784              core, SLOT(toggleExtrastereo(bool)) );
785 
786 	karaokeAct = new MyAction( this, "karaoke_filter" );
787 	karaokeAct->setCheckable( true );
788 	connect( karaokeAct, SIGNAL(toggled(bool)),
789              core, SLOT(toggleKaraoke(bool)) );
790 
791 	volnormAct = new MyAction( this, "volnorm_filter" );
792 	volnormAct->setCheckable( true );
793 	connect( volnormAct, SIGNAL(toggled(bool)),
794              core, SLOT(toggleVolnorm(bool)) );
795 
796 #ifdef MPV_SUPPORT
797 	earwaxAct = new MyAction( this, "earwax_filter" );
798 	earwaxAct->setCheckable( true );
799 	connect( earwaxAct, SIGNAL(toggled(bool)),
800              core, SLOT(toggleEarwax(bool)) );
801 #endif
802 
803 	// Menu Subtitles
804 	loadSubsAct = new MyAction( this, "load_subs" );
805 	connect( loadSubsAct, SIGNAL(triggered()),
806              this, SLOT(loadSub()) );
807 
808 	unloadSubsAct = new MyAction( this, "unload_subs" );
809 	connect( unloadSubsAct, SIGNAL(triggered()),
810              core, SLOT(unloadSub()) );
811 
812 	decSubDelayAct = new MyAction( Qt::Key_Z, this, "dec_sub_delay" );
813 	connect( decSubDelayAct, SIGNAL(triggered()),
814              core, SLOT(decSubDelay()) );
815 
816 	incSubDelayAct = new MyAction( Qt::Key_X, this, "inc_sub_delay" );
817 	connect( incSubDelayAct, SIGNAL(triggered()),
818              core, SLOT(incSubDelay()) );
819 
820 	subDelayAct = new MyAction( this, "sub_delay" );
821 	connect( subDelayAct, SIGNAL(triggered()),
822              this, SLOT(showSubDelayDialog()) );
823 
824 	decSubPosAct = new MyAction( Qt::Key_R, this, "dec_sub_pos" );
825 	connect( decSubPosAct, SIGNAL(triggered()),
826              core, SLOT(decSubPos()) );
827 	incSubPosAct = new MyAction( Qt::Key_T, this, "inc_sub_pos" );
828 	connect( incSubPosAct, SIGNAL(triggered()),
829              core, SLOT(incSubPos()) );
830 
831 	decSubScaleAct = new MyAction( Qt::SHIFT | Qt::Key_R, this, "dec_sub_scale" );
832 	connect( decSubScaleAct, SIGNAL(triggered()),
833              core, SLOT(decSubScale()) );
834 
835 	incSubScaleAct = new MyAction( Qt::SHIFT | Qt::Key_T, this, "inc_sub_scale" );
836 	connect( incSubScaleAct, SIGNAL(triggered()),
837              core, SLOT(incSubScale()) );
838 
839 	decSubStepAct = new MyAction( Qt::Key_G, this, "dec_sub_step" );
840 	connect( decSubStepAct, SIGNAL(triggered()),
841              core, SLOT(decSubStep()) );
842 
843 	incSubStepAct = new MyAction( Qt::Key_Y, this, "inc_sub_step" );
844 	connect( incSubStepAct, SIGNAL(triggered()),
845              core, SLOT(incSubStep()) );
846 
847 #ifdef MPV_SUPPORT
848 	seekNextSubAct = new MyAction(Qt::CTRL | Qt::Key_Right, this, "seek_next_sub");
849 	connect(seekNextSubAct, SIGNAL(triggered()),
850             core, SLOT(seekToNextSub()));
851 
852 	seekPrevSubAct = new MyAction(Qt::CTRL | Qt::Key_Left, this, "seek_prev_sub");
853 	connect(seekPrevSubAct, SIGNAL(triggered()),
854             core, SLOT(seekToPrevSub()));
855 #endif
856 
857 	useCustomSubStyleAct = new MyAction(this, "use_custom_sub_style");
858 	useCustomSubStyleAct->setCheckable(true);
859 	connect( useCustomSubStyleAct, SIGNAL(toggled(bool)), core, SLOT(changeUseCustomSubStyle(bool)) );
860 
861 	useForcedSubsOnlyAct = new MyAction(this, "use_forced_subs_only");
862 	useForcedSubsOnlyAct->setCheckable(true);
863 	connect( useForcedSubsOnlyAct, SIGNAL(toggled(bool)), core, SLOT(toggleForcedSubsOnly(bool)) );
864 
865 	subVisibilityAct = new MyAction(this, "sub_visibility");
866 	subVisibilityAct->setCheckable(true);
867 	connect( subVisibilityAct, SIGNAL(toggled(bool)), core, SLOT(changeSubVisibility(bool)) );
868 
869 #ifdef FIND_SUBTITLES
870 	showFindSubtitlesDialogAct = new MyAction( this, "show_find_sub_dialog" );
871 	connect( showFindSubtitlesDialogAct, SIGNAL(triggered()),
872              this, SLOT(showFindSubtitlesDialog()) );
873 
874 	openUploadSubtitlesPageAct = new MyAction( this, "upload_subtitles" );		//turbos
875 	connect( openUploadSubtitlesPageAct, SIGNAL(triggered()),					//turbos
876              this, SLOT(openUploadSubtitlesPage()) );							//turbos
877 #endif
878 
879 	// Menu Options
880 	showPlaylistAct = new MyAction( QKeySequence("Ctrl+L"), this, "show_playlist" );
881 	showPlaylistAct->setCheckable( true );
882 	connect( showPlaylistAct, SIGNAL(toggled(bool)),
883              this, SLOT(showPlaylist(bool)) );
884 	playlist->addAction(showPlaylistAct);
885 
886 	showPropertiesAct = new MyAction( QKeySequence("Ctrl+I"), this, "show_file_properties" );
887 	connect( showPropertiesAct, SIGNAL(triggered()),
888              this, SLOT(showFilePropertiesDialog()) );
889 
890 	showPreferencesAct = new MyAction( QKeySequence("Ctrl+P"), this, "show_preferences" );
891 	showPreferencesAct->setMenuRole(QAction::PreferencesRole);
892 	connect( showPreferencesAct, SIGNAL(triggered()),
893              this, SLOT(showPreferencesDialog()) );
894 
895 #ifdef YOUTUBE_SUPPORT
896 	showTubeBrowserAct = new MyAction( Qt::Key_F11, this, "show_tube_browser" );
897 	connect( showTubeBrowserAct, SIGNAL(triggered()),
898              this, SLOT(showTubeBrowser()) );
899 #endif
900 
901 	// Submenu Logs
902 #ifdef LOG_MPLAYER
903 	showLogMplayerAct = new MyAction( QKeySequence("Ctrl+M"), this, "show_mplayer_log" );
904 	connect( showLogMplayerAct, SIGNAL(triggered()),
905              this, SLOT(showMplayerLog()) );
906 #endif
907 
908 #ifdef LOG_SMPLAYER
909 	showLogSmplayerAct = new MyAction( QKeySequence("Ctrl+S"), this, "show_smplayer_log" );
910 	connect( showLogSmplayerAct, SIGNAL(triggered()),
911              this, SLOT(showLog()) );
912 #endif
913 
914 	tabletModeAct = new MyAction(this, "tablet_mode");
915 	tabletModeAct->setCheckable(true);
916 	connect(tabletModeAct, SIGNAL(toggled(bool)), this, SLOT(setTabletMode(bool)));
917 
918 
919 	// Menu Help
920 	showFirstStepsAct = new MyAction( this, "first_steps" );
921 	connect( showFirstStepsAct, SIGNAL(triggered()),
922              this, SLOT(helpFirstSteps()) );
923 
924 	showFAQAct = new MyAction( this, "faq" );
925 	connect( showFAQAct, SIGNAL(triggered()),
926              this, SLOT(helpFAQ()) );
927 
928 	showCLOptionsAct = new MyAction( this, "cl_options" );
929 	connect( showCLOptionsAct, SIGNAL(triggered()),
930              this, SLOT(helpCLOptions()) );
931 
932 	showCheckUpdatesAct = new MyAction( this, "check_updates" );
933 	connect( showCheckUpdatesAct, SIGNAL(triggered()),
934              this, SLOT(helpCheckUpdates()) );
935 
936 #ifdef YT_CODEDOWNLOADER
937 	updateYTAct = new MyAction( this, "update_youtube" );
938 	connect( updateYTAct, SIGNAL(triggered()),
939              this, SLOT(YTUpdate()) );
940 #endif
941 
942 	showConfigAct = new MyAction( this, "show_config" );
943 	connect( showConfigAct, SIGNAL(triggered()),
944              this, SLOT(helpShowConfig()) );
945 
946 	donateAct = new MyAction( this, "donate" );
947 	connect( donateAct, SIGNAL(triggered()),
948              this, SLOT(helpDonate()) );
949 
950 	aboutThisAct = new MyAction( this, "about_smplayer" );
951 	aboutThisAct->setMenuRole(QAction::AboutRole);
952 	connect( aboutThisAct, SIGNAL(triggered()),
953              this, SLOT(helpAbout()) );
954 
955 #ifdef SHARE_MENU
956 	facebookAct = new MyAction (this, "facebook");
957 	twitterAct = new MyAction (this, "twitter");
958 	gmailAct = new MyAction (this, "gmail");
959 	hotmailAct = new MyAction (this, "hotmail");
960 	yahooAct = new MyAction (this, "yahoo");
961 
962 	connect( facebookAct, SIGNAL(triggered()),
963              this, SLOT(shareSMPlayer()) );
964 	connect( twitterAct, SIGNAL(triggered()),
965              this, SLOT(shareSMPlayer()) );
966 	connect( gmailAct, SIGNAL(triggered()),
967              this, SLOT(shareSMPlayer()) );
968 	connect( hotmailAct, SIGNAL(triggered()),
969              this, SLOT(shareSMPlayer()) );
970 	connect( yahooAct, SIGNAL(triggered()),
971              this, SLOT(shareSMPlayer()) );
972 #endif
973 
974 	// OSD
975 	incOSDScaleAct = new MyAction(Qt::SHIFT | Qt::Key_U, this, "inc_osd_scale");
976 	connect(incOSDScaleAct, SIGNAL(triggered()), core, SLOT(incOSDScale()));
977 
978 	decOSDScaleAct = new MyAction(Qt::SHIFT | Qt::Key_Y, this, "dec_osd_scale");
979 	connect(decOSDScaleAct, SIGNAL(triggered()), core, SLOT(decOSDScale()));
980 
981 #ifdef MPV_SUPPORT
982 	OSDFractionsAct = new MyAction(this, "osd_fractions");
983 	OSDFractionsAct->setCheckable(true);
984 	connect(OSDFractionsAct, SIGNAL(toggled(bool)), core, SLOT(setOSDFractions(bool)));
985 #endif
986 
987 	// Playlist
988 	playNextAct = new MyAction(Qt::Key_Greater, this, "play_next");
989 	playNextAct->addShortcut(Qt::Key_MediaNext); // MCE remote key
990 	connect( playNextAct, SIGNAL(triggered()), playlist, SLOT(playNext()) );
991 
992 	playPrevAct = new MyAction(Qt::Key_Less, this, "play_prev");
993 	playPrevAct->addShortcut(Qt::Key_MediaPrevious); // MCE remote key
994 	connect( playPrevAct, SIGNAL(triggered()), playlist, SLOT(playPrev()) );
995 
996 
997 	// Move video window and zoom
998 	moveUpAct = new MyAction(Qt::ALT | Qt::Key_Up, this, "move_up");
999 	connect( moveUpAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveUp()) );
1000 
1001 	moveDownAct = new MyAction(Qt::ALT | Qt::Key_Down, this, "move_down");
1002 	connect( moveDownAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveDown()) );
1003 
1004 	moveLeftAct = new MyAction(Qt::ALT | Qt::Key_Left, this, "move_left");
1005 	connect( moveLeftAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveLeft()) );
1006 
1007 	moveRightAct = new MyAction(Qt::ALT | Qt::Key_Right, this, "move_right");
1008 	connect( moveRightAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveRight()) );
1009 
1010 	incZoomAct = new MyAction(Qt::Key_E, this, "inc_zoom");
1011 	connect( incZoomAct, SIGNAL(triggered()), core, SLOT(incZoom()) );
1012 
1013 	decZoomAct = new MyAction(Qt::Key_W, this, "dec_zoom");
1014 	connect( decZoomAct, SIGNAL(triggered()), core, SLOT(decZoom()) );
1015 
1016 	resetZoomAct = new MyAction(Qt::SHIFT | Qt::Key_E, this, "reset_zoom");
1017 	connect( resetZoomAct, SIGNAL(triggered()), core, SLOT(resetZoom()) );
1018 
1019 	autoZoomAct = new MyAction(Qt::SHIFT | Qt::Key_W, this, "auto_zoom");
1020 	connect( autoZoomAct, SIGNAL(triggered()), core, SLOT(autoZoom()) );
1021 
1022 	autoZoom169Act = new MyAction(Qt::SHIFT | Qt::Key_A, this, "zoom_169");
1023 	connect( autoZoom169Act, SIGNAL(triggered()), core, SLOT(autoZoomFor169()) );
1024 
1025 	autoZoom235Act = new MyAction(Qt::SHIFT | Qt::Key_S, this, "zoom_235");
1026 	connect( autoZoom235Act, SIGNAL(triggered()), core, SLOT(autoZoomFor235()) );
1027 
1028 
1029 	// Actions not in menus or buttons
1030 	// Volume 2
1031 #if !USE_MULTIPLE_SHORTCUTS
1032 	decVolume2Act = new MyAction( Qt::Key_Slash, this, "dec_volume2" );
1033 	connect( decVolume2Act, SIGNAL(triggered()), core, SLOT(decVolume()) );
1034 
1035 	incVolume2Act = new MyAction( Qt::Key_Asterisk, this, "inc_volume2" );
1036 	connect( incVolume2Act, SIGNAL(triggered()), core, SLOT(incVolume()) );
1037 #endif
1038 	// Exit fullscreen
1039 	exitFullscreenAct = new MyAction( Qt::Key_Escape, this, "exit_fullscreen" );
1040 	connect( exitFullscreenAct, SIGNAL(triggered()), this, SLOT(exitFullscreen()) );
1041 
1042 	nextOSDAct = new MyAction( Qt::Key_O, this, "next_osd");
1043 	connect( nextOSDAct, SIGNAL(triggered()), core, SLOT(nextOSD()) );
1044 
1045 	decContrastAct = new MyAction( Qt::Key_1, this, "dec_contrast");
1046 	connect( decContrastAct, SIGNAL(triggered()), core, SLOT(decContrast()) );
1047 
1048 	incContrastAct = new MyAction( Qt::Key_2, this, "inc_contrast");
1049 	connect( incContrastAct, SIGNAL(triggered()), core, SLOT(incContrast()) );
1050 
1051 	decBrightnessAct = new MyAction( Qt::Key_3, this, "dec_brightness");
1052 	connect( decBrightnessAct, SIGNAL(triggered()), core, SLOT(decBrightness()) );
1053 
1054 	incBrightnessAct = new MyAction( Qt::Key_4, this, "inc_brightness");
1055 	connect( incBrightnessAct, SIGNAL(triggered()), core, SLOT(incBrightness()) );
1056 
1057 	decHueAct = new MyAction(Qt::Key_5, this, "dec_hue");
1058 	connect( decHueAct, SIGNAL(triggered()), core, SLOT(decHue()) );
1059 
1060 	incHueAct = new MyAction( Qt::Key_6, this, "inc_hue");
1061 	connect( incHueAct, SIGNAL(triggered()), core, SLOT(incHue()) );
1062 
1063 	decSaturationAct = new MyAction( Qt::Key_7, this, "dec_saturation");
1064 	connect( decSaturationAct, SIGNAL(triggered()), core, SLOT(decSaturation()) );
1065 
1066 	incSaturationAct = new MyAction( Qt::Key_8, this, "inc_saturation");
1067 	connect( incSaturationAct, SIGNAL(triggered()), core, SLOT(incSaturation()) );
1068 
1069 	decGammaAct = new MyAction( this, "dec_gamma");
1070 	connect( decGammaAct, SIGNAL(triggered()), core, SLOT(decGamma()) );
1071 
1072 	incGammaAct = new MyAction( this, "inc_gamma");
1073 	connect( incGammaAct, SIGNAL(triggered()), core, SLOT(incGamma()) );
1074 
1075 	prevVideoAct = new MyAction( this, "previous_video");
1076 	connect( prevVideoAct, SIGNAL(triggered()), core, SLOT(prevVideo()) );
1077 
1078 	nextVideoAct = new MyAction( this, "next_video");
1079 	connect( nextVideoAct, SIGNAL(triggered()), core, SLOT(nextVideo()) );
1080 
1081 	prevAudioAct = new MyAction( Qt::SHIFT | Qt::Key_K, this, "previous_audio");
1082 	connect( prevAudioAct, SIGNAL(triggered()), core, SLOT(prevAudio()) );
1083 
1084 	nextAudioAct = new MyAction( Qt::Key_K, this, "next_audio");
1085 	connect( nextAudioAct, SIGNAL(triggered()), core, SLOT(nextAudio()) );
1086 
1087 	prevSubtitleAct = new MyAction( Qt::SHIFT | Qt::Key_J, this, "previous_subtitle");
1088 	connect( prevSubtitleAct, SIGNAL(triggered()), core, SLOT(prevSubtitle()) );
1089 
1090 	nextSubtitleAct = new MyAction( Qt::Key_J, this, "next_subtitle");
1091 	connect( nextSubtitleAct, SIGNAL(triggered()), core, SLOT(nextSubtitle()) );
1092 
1093 	nextChapterAct = new MyAction( Qt::Key_At, this, "next_chapter");
1094 	connect( nextChapterAct, SIGNAL(triggered()), core, SLOT(nextChapter()) );
1095 
1096 	prevChapterAct = new MyAction( Qt::Key_Exclam, this, "prev_chapter");
1097 	connect( prevChapterAct, SIGNAL(triggered()), core, SLOT(prevChapter()) );
1098 
1099 	doubleSizeAct = new MyAction( Qt::CTRL | Qt::Key_D, this, "toggle_double_size");
1100 	connect( doubleSizeAct, SIGNAL(triggered()), this, SLOT(toggleDoubleSize()) );
1101 
1102 	resetVideoEqualizerAct = new MyAction( this, "reset_video_equalizer");
1103 	connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer, SLOT(reset()) );
1104 
1105 	resetAudioEqualizerAct = new MyAction( this, "reset_audio_equalizer");
1106 	connect( resetAudioEqualizerAct, SIGNAL(triggered()), audio_equalizer, SLOT(reset()) );
1107 
1108 	showContextMenuAct = new MyAction( this, "show_context_menu");
1109 	connect( showContextMenuAct, SIGNAL(triggered()),
1110              this, SLOT(showPopupMenu()) );
1111 
1112 	nextAspectAct = new MyAction( Qt::Key_A, this, "next_aspect");
1113 	connect( nextAspectAct, SIGNAL(triggered()),
1114              core, SLOT(nextAspectRatio()) );
1115 
1116 	nextWheelFunctionAct = new MyAction(this, "next_wheel_function");
1117 	connect( nextWheelFunctionAct, SIGNAL(triggered()),
1118 			 core, SLOT(nextWheelFunction()) );
1119 
1120 	showFilenameAct = new MyAction(Qt::SHIFT | Qt::Key_O, this, "show_filename_osd");
1121 	connect( showFilenameAct, SIGNAL(triggered()), core, SLOT(showFilenameOnOSD()) );
1122 
1123 	showMediaInfoAct = new MyAction(Qt::SHIFT | Qt::Key_I, this, "show_info_osd");
1124 	connect( showMediaInfoAct, SIGNAL(triggered()), core, SLOT(showMediaInfoOnOSD()) );
1125 
1126 	showTimeAct = new MyAction(Qt::Key_I, this, "show_time");
1127 	connect( showTimeAct, SIGNAL(triggered()), core, SLOT(showTimeOnOSD()) );
1128 
1129 	toggleDeinterlaceAct = new MyAction(Qt::Key_D, this, "toggle_deinterlacing");
1130 	connect( toggleDeinterlaceAct, SIGNAL(triggered()), core, SLOT(toggleDeinterlace()) );
1131 
1132 
1133 	// Group actions
1134 
1135 	// OSD
1136 	osdGroup = new MyActionGroup(this);
1137 	osdNoneAct = new MyActionGroupItem(this, osdGroup, "osd_none", Preferences::None);
1138 	osdSeekAct = new MyActionGroupItem(this, osdGroup, "osd_seek", Preferences::Seek);
1139 	osdTimerAct = new MyActionGroupItem(this, osdGroup, "osd_timer", Preferences::SeekTimer);
1140 	osdTotalAct = new MyActionGroupItem(this, osdGroup, "osd_total", Preferences::SeekTimerTotal);
1141 	connect( osdGroup, SIGNAL(activated(int)), core, SLOT(changeOSD(int)) );
1142 
1143 	// Denoise
1144 	denoiseGroup = new MyActionGroup(this);
1145 	denoiseNoneAct = new MyActionGroupItem(this, denoiseGroup, "denoise_none", MediaSettings::NoDenoise);
1146 	denoiseNormalAct = new MyActionGroupItem(this, denoiseGroup, "denoise_normal", MediaSettings::DenoiseNormal);
1147 	denoiseSoftAct = new MyActionGroupItem(this, denoiseGroup, "denoise_soft", MediaSettings::DenoiseSoft);
1148 	connect( denoiseGroup, SIGNAL(activated(int)), core, SLOT(changeDenoise(int)) );
1149 
1150 	// Unsharp group
1151 	unsharpGroup = new MyActionGroup(this);
1152 	unsharpNoneAct = new MyActionGroupItem(this, unsharpGroup, "unsharp_off", 0);
1153 	blurAct = new MyActionGroupItem(this, unsharpGroup, "blur", 1);
1154 	sharpenAct = new MyActionGroupItem(this, unsharpGroup, "sharpen", 2);
1155 	connect( unsharpGroup, SIGNAL(activated(int)), core, SLOT(changeUnsharp(int)) );
1156 
1157 	// Video size
1158 	sizeGroup = new MyActionGroup(this);
1159 	size50 = new MyActionGroupItem(this, sizeGroup, "5&0%", "size_50", 50);
1160 	size75 = new MyActionGroupItem(this, sizeGroup, "7&5%", "size_75", 75);
1161 	size100 = new MyActionGroupItem(this, sizeGroup, "&100%", "size_100", 100);
1162 	size125 = new MyActionGroupItem(this, sizeGroup, "1&25%", "size_125", 125);
1163 	size150 = new MyActionGroupItem(this, sizeGroup, "15&0%", "size_150", 150);
1164 	size175 = new MyActionGroupItem(this, sizeGroup, "1&75%", "size_175", 175);
1165 	size200 = new MyActionGroupItem(this, sizeGroup, "&200%", "size_200", 200);
1166 	size300 = new MyActionGroupItem(this, sizeGroup, "&300%", "size_300", 300);
1167 	size400 = new MyActionGroupItem(this, sizeGroup, "&400%", "size_400", 400);
1168 	size100->setShortcut( Qt::CTRL | Qt::Key_1 );
1169 	size200->setShortcut( Qt::CTRL | Qt::Key_2 );
1170 	connect( sizeGroup, SIGNAL(activated(int)), this, SLOT(changeSizeFactor(int)) );
1171 	// Make all not checkable
1172 	QList <QAction *> size_list = sizeGroup->actions();
1173 	for (int n=0; n < size_list.count(); n++) {
1174 		size_list[n]->setCheckable(false);
1175 	}
1176 
1177 	// Deinterlace
1178 	deinterlaceGroup = new MyActionGroup(this);
1179 	deinterlaceNoneAct = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_none", MediaSettings::NoDeinterlace);
1180 	deinterlaceL5Act = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_l5", MediaSettings::L5);
1181 	deinterlaceYadif0Act = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_yadif0", MediaSettings::Yadif);
1182 	deinterlaceYadif1Act = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_yadif1", MediaSettings::Yadif_1);
1183 	deinterlaceLBAct = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_lb", MediaSettings::LB);
1184 	deinterlaceKernAct = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_kern", MediaSettings::Kerndeint);
1185 	connect( deinterlaceGroup, SIGNAL(activated(int)),
1186              core, SLOT(changeDeinterlace(int)) );
1187 
1188 	// Audio channels
1189 	channelsGroup = new MyActionGroup(this);
1190 	channelsDefaultAct = new MyActionGroupItem(this, channelsGroup, "channels_default", MediaSettings::ChDefault);
1191 	channelsStereoAct = new MyActionGroupItem(this, channelsGroup, "channels_stereo", MediaSettings::ChStereo);
1192 	channelsSurroundAct = new MyActionGroupItem(this, channelsGroup, "channels_surround", MediaSettings::ChSurround);
1193 	channelsFull51Act = new MyActionGroupItem(this, channelsGroup, "channels_ful51", MediaSettings::ChFull51);
1194 	channelsFull61Act = new MyActionGroupItem(this, channelsGroup, "channels_ful61", MediaSettings::ChFull61);
1195 	channelsFull71Act = new MyActionGroupItem(this, channelsGroup, "channels_ful71", MediaSettings::ChFull71);
1196 	connect( channelsGroup, SIGNAL(activated(int)),
1197              core, SLOT(setAudioChannels(int)) );
1198 
1199 	// Stereo mode
1200 	stereoGroup = new MyActionGroup(this);
1201 	stereoAct = new MyActionGroupItem(this, stereoGroup, "stereo", MediaSettings::Stereo);
1202 	leftChannelAct = new MyActionGroupItem(this, stereoGroup, "left_channel", MediaSettings::Left);
1203 	rightChannelAct = new MyActionGroupItem(this, stereoGroup, "right_channel", MediaSettings::Right);
1204 	monoAct = new MyActionGroupItem(this, stereoGroup, "mono", MediaSettings::Mono);
1205 	reverseAct = new MyActionGroupItem(this, stereoGroup, "reverse_channels", MediaSettings::Reverse);
1206 	connect( stereoGroup, SIGNAL(activated(int)),
1207              core, SLOT(setStereoMode(int)) );
1208 
1209 	// Video aspect
1210 	aspectGroup = new MyActionGroup(this);
1211 	aspectDetectAct = new MyActionGroupItem(this, aspectGroup, "aspect_detect", MediaSettings::AspectAuto);
1212 	aspect11Act = new MyActionGroupItem(this, aspectGroup, "aspect_1:1", MediaSettings::Aspect11 );
1213 	aspect54Act = new MyActionGroupItem(this, aspectGroup, "aspect_5:4", MediaSettings::Aspect54 );
1214 	aspect43Act = new MyActionGroupItem(this, aspectGroup, "aspect_4:3", MediaSettings::Aspect43);
1215 	aspect118Act = new MyActionGroupItem(this, aspectGroup, "aspect_11:8", MediaSettings::Aspect118 );
1216 	aspect1410Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:10", MediaSettings::Aspect1410 );
1217 	aspect32Act = new MyActionGroupItem(this, aspectGroup, "aspect_3:2", MediaSettings::Aspect32);
1218 	aspect149Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:9", MediaSettings::Aspect149 );
1219 	aspect1610Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:10", MediaSettings::Aspect1610 );
1220 	aspect169Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:9", MediaSettings::Aspect169 );
1221 	aspect235Act = new MyActionGroupItem(this, aspectGroup, "aspect_2.35:1", MediaSettings::Aspect235 );
1222 	{
1223 		QAction * sep = new QAction(aspectGroup);
1224 		sep->setSeparator(true);
1225 	}
1226 	aspectNoneAct = new MyActionGroupItem(this, aspectGroup, "aspect_none", MediaSettings::AspectNone);
1227 
1228 	connect( aspectGroup, SIGNAL(activated(int)),
1229              core, SLOT(changeAspectRatio(int)) );
1230 
1231 	// Rotate
1232 	rotateGroup = new MyActionGroup(this);
1233 	rotateNoneAct = new MyActionGroupItem(this, rotateGroup, "rotate_none", MediaSettings::NoRotate);
1234 	rotateClockwiseFlipAct = new MyActionGroupItem(this, rotateGroup, "rotate_clockwise_flip", MediaSettings::Clockwise_flip);
1235 	rotateClockwiseAct = new MyActionGroupItem(this, rotateGroup, "rotate_clockwise", MediaSettings::Clockwise);
1236 	rotateCounterclockwiseAct = new MyActionGroupItem(this, rotateGroup, "rotate_counterclockwise", MediaSettings::Counterclockwise);
1237 	rotateCounterclockwiseFlipAct = new MyActionGroupItem(this, rotateGroup, "rotate_counterclockwise_flip", MediaSettings::Counterclockwise_flip);
1238 	rotate180Act = new MyActionGroupItem(this, rotateGroup, "rotate_180", MediaSettings::Rotate_180);
1239 	connect( rotateGroup, SIGNAL(activated(int)),
1240              core, SLOT(changeRotate(int)) );
1241 
1242 	// On Top
1243 	onTopActionGroup = new MyActionGroup(this);
1244 	onTopAlwaysAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_always",Preferences::AlwaysOnTop);
1245 	onTopNeverAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_never",Preferences::NeverOnTop);
1246 	onTopWhilePlayingAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_playing",Preferences::WhilePlayingOnTop);
1247 	connect( onTopActionGroup , SIGNAL(activated(int)),
1248              this, SLOT(changeStayOnTop(int)) );
1249 
1250 	toggleStayOnTopAct = new MyAction( this, "toggle_stay_on_top");
1251 	connect( toggleStayOnTopAct, SIGNAL(triggered()), this, SLOT(toggleStayOnTop()) );
1252 
1253 
1254 #if USE_ADAPTER
1255 	screenGroup = new MyActionGroup(this);
1256 	screenDefaultAct = new MyActionGroupItem(this, screenGroup, "screen_default", -1);
1257 	#ifdef Q_OS_WIN
1258 	DeviceList display_devices = DeviceInfo::displayDevices();
1259 	if (!display_devices.isEmpty()) {
1260 		for (int n = 0; n < display_devices.count(); n++) {
1261 			int id = display_devices[n].ID().toInt();
1262 			QString desc = display_devices[n].desc();
1263 			MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toLatin1().constData(), id);
1264 			screen_item->change( "&"+QString::number(n) + " - " + desc);
1265 		}
1266 	}
1267 	else
1268 	#endif // Q_OS_WIN
1269 	for (int n = 1; n <= 4; n++) {
1270 		MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toLatin1().constData(), n);
1271 		screen_item->change( "&"+QString::number(n) );
1272 	}
1273 
1274 	connect( screenGroup, SIGNAL(activated(int)),
1275              core, SLOT(changeAdapter(int)) );
1276 #endif
1277 
1278 #if PROGRAM_SWITCH
1279 	// Program track
1280 	programTrackGroup = new MyActionGroup(this);
1281 	connect( programTrackGroup, SIGNAL(activated(int)),
1282 	         core, SLOT(changeProgram(int)) );
1283 #endif
1284 
1285 	// Video track
1286 	videoTrackGroup = new MyActionGroup(this);
1287 	connect( videoTrackGroup, SIGNAL(activated(int)),
1288 	         core, SLOT(changeVideo(int)) );
1289 
1290 	// Audio track
1291 	audioTrackGroup = new MyActionGroup(this);
1292 	connect( audioTrackGroup, SIGNAL(activated(int)),
1293 	         core, SLOT(changeAudio(int)) );
1294 
1295 	// Subtitle track
1296 	subtitleTrackGroup = new MyActionGroup(this);
1297 	connect( subtitleTrackGroup, SIGNAL(activated(int)),
1298 	         core, SLOT(changeSubtitle(int)) );
1299 
1300 #ifdef MPV_SUPPORT
1301 	// Secondary subtitle track
1302 	secondarySubtitleTrackGroup = new MyActionGroup(this);
1303 	connect( secondarySubtitleTrackGroup, SIGNAL(activated(int)),
1304 	         core, SLOT(changeSecondarySubtitle(int)) );
1305 #endif
1306 
1307 	ccGroup = new MyActionGroup(this);
1308 	ccNoneAct = new MyActionGroupItem(this, ccGroup, "cc_none", 0);
1309 	ccChannel1Act = new MyActionGroupItem(this, ccGroup, "cc_ch_1", 1);
1310 	ccChannel2Act = new MyActionGroupItem(this, ccGroup, "cc_ch_2", 2);
1311 	ccChannel3Act = new MyActionGroupItem(this, ccGroup, "cc_ch_3", 3);
1312 	ccChannel4Act = new MyActionGroupItem(this, ccGroup, "cc_ch_4", 4);
1313 	connect( ccGroup, SIGNAL(activated(int)),
1314              core, SLOT(changeClosedCaptionChannel(int)) );
1315 
1316 	subFPSGroup = new MyActionGroup(this);
1317 	subFPSNoneAct = new MyActionGroupItem(this, subFPSGroup, "sub_fps_none", MediaSettings::SFPS_None);
1318 	/* subFPS23Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_23", MediaSettings::SFPS_23); */
1319 	subFPS23976Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_23976", MediaSettings::SFPS_23976);
1320 	subFPS24Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_24", MediaSettings::SFPS_24);
1321 	subFPS25Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_25", MediaSettings::SFPS_25);
1322 	subFPS29970Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_29970", MediaSettings::SFPS_29970);
1323 	subFPS30Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_30", MediaSettings::SFPS_30);
1324 	connect( subFPSGroup, SIGNAL(activated(int)),
1325              core, SLOT(changeExternalSubFPS(int)) );
1326 
1327 	// Titles
1328 	titleGroup = new MyActionGroup(this);
1329 	connect( titleGroup, SIGNAL(activated(int)),
1330 			 core, SLOT(changeTitle(int)) );
1331 
1332 	// Angles
1333 	angleGroup = new MyActionGroup(this);
1334 	connect( angleGroup, SIGNAL(activated(int)),
1335 			 core, SLOT(changeAngle(int)) );
1336 
1337 	// Chapters
1338 	chapterGroup = new MyActionGroup(this);
1339 	connect( chapterGroup, SIGNAL(activated(int)),
1340 			 core, SLOT(changeChapter(int)) );
1341 
1342 #ifdef BOOKMARKS
1343 	// Bookmarks
1344 	bookmarkGroup = new MyActionGroup(this);
1345 	connect( bookmarkGroup, SIGNAL(activated(int)),
1346 			 core, SLOT(goToSec(int)) );
1347 
1348 	addBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_A, this, "add_bookmark");
1349 	connect(addBookmarkAct, SIGNAL(triggered()), this, SLOT(showAddBookmarkDialog()));
1350 
1351 	editBookmarksAct = new MyAction(this, "edit_bookmarks");
1352 	connect(editBookmarksAct, SIGNAL(triggered()), this, SLOT(showBookmarkDialog()));
1353 
1354 	prevBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_B, this, "prev_bookmark");
1355 	connect(prevBookmarkAct, SIGNAL(triggered()), core, SLOT(prevBookmark()));
1356 
1357 	nextBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_N, this, "next_bookmark");
1358 	connect(nextBookmarkAct, SIGNAL(triggered()), core, SLOT(nextBookmark()));
1359 #endif
1360 
1361 #if DVDNAV_SUPPORT
1362 	dvdnavUpAct = new MyAction(Qt::SHIFT | Qt::Key_Up, this, "dvdnav_up");
1363 	connect( dvdnavUpAct, SIGNAL(triggered()), core, SLOT(dvdnavUp()) );
1364 
1365 	dvdnavDownAct = new MyAction(Qt::SHIFT | Qt::Key_Down, this, "dvdnav_down");
1366 	connect( dvdnavDownAct, SIGNAL(triggered()), core, SLOT(dvdnavDown()) );
1367 
1368 	dvdnavLeftAct = new MyAction(Qt::SHIFT | Qt::Key_Left, this, "dvdnav_left");
1369 	connect( dvdnavLeftAct, SIGNAL(triggered()), core, SLOT(dvdnavLeft()) );
1370 
1371 	dvdnavRightAct = new MyAction(Qt::SHIFT | Qt::Key_Right, this, "dvdnav_right");
1372 	connect( dvdnavRightAct, SIGNAL(triggered()), core, SLOT(dvdnavRight()) );
1373 
1374 	dvdnavMenuAct = new MyAction(Qt::SHIFT | Qt::Key_Return, this, "dvdnav_menu");
1375 	connect( dvdnavMenuAct, SIGNAL(triggered()), core, SLOT(dvdnavMenu()) );
1376 
1377 	dvdnavSelectAct = new MyAction(Qt::Key_Return, this, "dvdnav_select");
1378 	connect( dvdnavSelectAct, SIGNAL(triggered()), core, SLOT(dvdnavSelect()) );
1379 
1380 	dvdnavPrevAct = new MyAction(Qt::SHIFT | Qt::Key_Escape, this, "dvdnav_prev");
1381 	connect( dvdnavPrevAct, SIGNAL(triggered()), core, SLOT(dvdnavPrev()) );
1382 
1383 	dvdnavMouseAct = new MyAction( this, "dvdnav_mouse");
1384 	connect( dvdnavMouseAct, SIGNAL(triggered()), core, SLOT(dvdnavMouse()) );
1385 #endif
1386 
1387 }
1388 
1389 #if AUTODISABLE_ACTIONS
setActionsEnabled(bool b)1390 void BaseGui::setActionsEnabled(bool b) {
1391 	// Menu Play
1392 	playAct->setEnabled(b);
1393 	playOrPauseAct->setEnabled(b);
1394 	pauseAct->setEnabled(b);
1395 	pauseAndStepAct->setEnabled(b);
1396 	stopAct->setEnabled(b);
1397 	frameStepAct->setEnabled(b);
1398 	frameBackStepAct->setEnabled(b);
1399 	rewind1Act->setEnabled(b);
1400 	rewind2Act->setEnabled(b);
1401 	rewind3Act->setEnabled(b);
1402 	forward1Act->setEnabled(b);
1403 	forward2Act->setEnabled(b);
1404 	forward3Act->setEnabled(b);
1405 	//repeatAct->setEnabled(b);
1406 	gotoAct->setEnabled(b);
1407 
1408 	// Menu Speed
1409 	normalSpeedAct->setEnabled(b);
1410 	halveSpeedAct->setEnabled(b);
1411 	doubleSpeedAct->setEnabled(b);
1412 	decSpeed10Act->setEnabled(b);
1413 	incSpeed10Act->setEnabled(b);
1414 	decSpeed4Act->setEnabled(b);
1415 	incSpeed4Act->setEnabled(b);
1416 	decSpeed1Act->setEnabled(b);
1417 	incSpeed1Act->setEnabled(b);
1418 	foreach(QAction *a, speed_acts) a->setEnabled(b);
1419 
1420 	// Menu Video
1421 	videoEqualizerAct->setEnabled(b);
1422 	screenshotAct->setEnabled(b);
1423 	screenshotsAct->setEnabled(b);
1424 	screenshotWithSubsAct->setEnabled(b);
1425 	screenshotWithNoSubsAct->setEnabled(b);
1426 #ifdef CAPTURE_STREAM
1427 	capturingAct->setEnabled(b);
1428 #endif
1429 	flipAct->setEnabled(b);
1430 	mirrorAct->setEnabled(b);
1431 	stereo3dAct->setEnabled(b);
1432 	postProcessingAct->setEnabled(b);
1433 	phaseAct->setEnabled(b);
1434 	deblockAct->setEnabled(b);
1435 	deringAct->setEnabled(b);
1436 	gradfunAct->setEnabled(b);
1437 	addNoiseAct->setEnabled(b);
1438 	addLetterboxAct->setEnabled(b);
1439 	upscaleAct->setEnabled(b);
1440 
1441 	// Menu Audio
1442 	audioEqualizerAct->setEnabled(b);
1443 	muteAct->setEnabled(b);
1444 	decVolumeAct->setEnabled(b);
1445 	incVolumeAct->setEnabled(b);
1446 	decAudioDelayAct->setEnabled(b);
1447 	incAudioDelayAct->setEnabled(b);
1448 	audioDelayAct->setEnabled(b);
1449 	extrastereoAct->setEnabled(b);
1450 	karaokeAct->setEnabled(b);
1451 	volnormAct->setEnabled(b);
1452 #ifdef MPV_SUPPORT
1453 	earwaxAct->setEnabled(b);
1454 #endif
1455 	loadAudioAct->setEnabled(b);
1456 	//unloadAudioAct->setEnabled(b);
1457 
1458 	// Menu Subtitles
1459 	loadSubsAct->setEnabled(b);
1460 	//unloadSubsAct->setEnabled(b);
1461 	decSubDelayAct->setEnabled(b);
1462 	incSubDelayAct->setEnabled(b);
1463 	subDelayAct->setEnabled(b);
1464 	decSubPosAct->setEnabled(b);
1465 	incSubPosAct->setEnabled(b);
1466 	incSubStepAct->setEnabled(b);
1467 	decSubStepAct->setEnabled(b);
1468 	incSubScaleAct->setEnabled(b);
1469 	decSubScaleAct->setEnabled(b);
1470 #ifdef MPV_SUPPORT
1471 	seekNextSubAct->setEnabled(b);
1472 	seekPrevSubAct->setEnabled(b);
1473 #endif
1474 
1475 	// Actions not in menus
1476 #if !USE_MULTIPLE_SHORTCUTS
1477 	decVolume2Act->setEnabled(b);
1478 	incVolume2Act->setEnabled(b);
1479 #endif
1480 	decContrastAct->setEnabled(b);
1481 	incContrastAct->setEnabled(b);
1482 	decBrightnessAct->setEnabled(b);
1483 	incBrightnessAct->setEnabled(b);
1484 	decHueAct->setEnabled(b);
1485 	incHueAct->setEnabled(b);
1486 	decSaturationAct->setEnabled(b);
1487 	incSaturationAct->setEnabled(b);
1488 	decGammaAct->setEnabled(b);
1489 	incGammaAct->setEnabled(b);
1490 	prevVideoAct->setEnabled(b);
1491 	nextVideoAct->setEnabled(b);
1492 	prevAudioAct->setEnabled(b);
1493 	nextAudioAct->setEnabled(b);
1494 	prevSubtitleAct->setEnabled(b);
1495 	nextSubtitleAct->setEnabled(b);
1496 	nextChapterAct->setEnabled(b);
1497 	prevChapterAct->setEnabled(b);
1498 	doubleSizeAct->setEnabled(b);
1499 
1500 	// Moving and zoom
1501 	moveUpAct->setEnabled(b);
1502 	moveDownAct->setEnabled(b);
1503 	moveLeftAct->setEnabled(b);
1504 	moveRightAct->setEnabled(b);
1505 	incZoomAct->setEnabled(b);
1506 	decZoomAct->setEnabled(b);
1507 	resetZoomAct->setEnabled(b);
1508 	autoZoomAct->setEnabled(b);
1509 	autoZoom169Act->setEnabled(b);
1510 	autoZoom235Act->setEnabled(b);
1511 
1512 #if DVDNAV_SUPPORT
1513 	dvdnavUpAct->setEnabled(b);
1514 	dvdnavDownAct->setEnabled(b);
1515 	dvdnavLeftAct->setEnabled(b);
1516 	dvdnavRightAct->setEnabled(b);
1517 	dvdnavMenuAct->setEnabled(b);
1518 	dvdnavSelectAct->setEnabled(b);
1519 	dvdnavPrevAct->setEnabled(b);
1520 	dvdnavMouseAct->setEnabled(b);
1521 #endif
1522 
1523 	// Groups
1524 	denoiseGroup->setActionsEnabled(b);
1525 	unsharpGroup->setActionsEnabled(b);
1526 	sizeGroup->setActionsEnabled(b);
1527 	deinterlaceGroup->setActionsEnabled(b);
1528 	aspectGroup->setActionsEnabled(b);
1529 	rotateGroup->setActionsEnabled(b);
1530 #if USE_ADAPTER
1531 	screenGroup->setActionsEnabled(b);
1532 #endif
1533 	channelsGroup->setActionsEnabled(b);
1534 	stereoGroup->setActionsEnabled(b);
1535 }
1536 
enableActionsOnPlaying()1537 void BaseGui::enableActionsOnPlaying() {
1538 	qDebug("BaseGui::enableActionsOnPlaying");
1539 
1540 	setActionsEnabled(true);
1541 
1542 	playAct->setEnabled(false);
1543 
1544 #if 1
1545 	// Screenshot option
1546 	bool screenshots_enabled = ( pref->use_screenshot &&
1547                                  !pref->screenshot_directory.isEmpty() &&
1548                                  QFileInfo(pref->screenshot_directory).isDir() );
1549 
1550 	screenshotAct->setEnabled( screenshots_enabled );
1551 	screenshotsAct->setEnabled( screenshots_enabled );
1552 #endif
1553 
1554 #ifdef CAPTURE_STREAM
1555 	capturingAct->setEnabled(!pref->capture_directory.isEmpty() && QFileInfo(pref->capture_directory).isDir());
1556 #endif
1557 
1558 	// Disable the compact action if not using video window
1559 	compactAct->setEnabled( panel->isVisible() );
1560 
1561 	// Enable or disable the audio equalizer
1562 	audioEqualizerAct->setEnabled(pref->use_audio_equalizer);
1563 
1564 	// Disable audio actions if there's not audio track
1565 	if ((core->mset.audios.numItems()==0) && (core->mset.external_audio.isEmpty())) {
1566 		audioEqualizerAct->setEnabled(false);
1567 		muteAct->setEnabled(false);
1568 		decVolumeAct->setEnabled(false);
1569 		incVolumeAct->setEnabled(false);
1570 		decAudioDelayAct->setEnabled(false);
1571 		incAudioDelayAct->setEnabled(false);
1572 		audioDelayAct->setEnabled(false);
1573 		extrastereoAct->setEnabled(false);
1574 		karaokeAct->setEnabled(false);
1575 		volnormAct->setEnabled(false);
1576 #ifdef MPV_SUPPORT
1577 		earwaxAct->setEnabled(false);
1578 #endif
1579 		channelsGroup->setActionsEnabled(false);
1580 		stereoGroup->setActionsEnabled(false);
1581 	}
1582 
1583 	// Disable video actions if it's an audio file
1584 	if (core->mdat.novideo) {
1585 		videoEqualizerAct->setEnabled(false);
1586 		screenshotAct->setEnabled(false);
1587 		screenshotsAct->setEnabled(false);
1588 		screenshotWithSubsAct->setEnabled(false);
1589 		screenshotWithNoSubsAct->setEnabled(false);
1590 #ifdef CAPTURE_STREAM
1591 		capturingAct->setEnabled(false);
1592 #endif
1593 		flipAct->setEnabled(false);
1594 		mirrorAct->setEnabled(false);
1595 		stereo3dAct->setEnabled(false);
1596 		postProcessingAct->setEnabled(false);
1597 		phaseAct->setEnabled(false);
1598 		deblockAct->setEnabled(false);
1599 		deringAct->setEnabled(false);
1600 		gradfunAct->setEnabled(false);
1601 		addNoiseAct->setEnabled(false);
1602 		addLetterboxAct->setEnabled(false);
1603 		upscaleAct->setEnabled(false);
1604 		doubleSizeAct->setEnabled(false);
1605 
1606 		// Moving and zoom
1607 		moveUpAct->setEnabled(false);
1608 		moveDownAct->setEnabled(false);
1609 		moveLeftAct->setEnabled(false);
1610 		moveRightAct->setEnabled(false);
1611 		incZoomAct->setEnabled(false);
1612 		decZoomAct->setEnabled(false);
1613 		resetZoomAct->setEnabled(false);
1614 		autoZoomAct->setEnabled(false);
1615 		autoZoom169Act->setEnabled(false);
1616 		autoZoom235Act->setEnabled(false);
1617 
1618 		denoiseGroup->setActionsEnabled(false);
1619 		unsharpGroup->setActionsEnabled(false);
1620 		sizeGroup->setActionsEnabled(false);
1621 		deinterlaceGroup->setActionsEnabled(false);
1622 		aspectGroup->setActionsEnabled(false);
1623 		rotateGroup->setActionsEnabled(false);
1624 #if USE_ADAPTER
1625 		screenGroup->setActionsEnabled(false);
1626 #endif
1627 	}
1628 
1629 #if USE_ADAPTER
1630 	screenGroup->setActionsEnabled(pref->vo.startsWith(OVERLAY_VO));
1631 #endif
1632 
1633 #ifdef OS_UNIX_NOT_MAC
1634 	// Disable video filters if using vdpau
1635 	if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) {
1636 		/*
1637 		screenshotAct->setEnabled(false);
1638 		screenshotsAct->setEnabled(false);
1639 		*/
1640 		flipAct->setEnabled(false);
1641 		mirrorAct->setEnabled(false);
1642 		stereo3dAct->setEnabled(false);
1643 		postProcessingAct->setEnabled(false);
1644 		phaseAct->setEnabled(false);
1645 		deblockAct->setEnabled(false);
1646 		deringAct->setEnabled(false);
1647 		gradfunAct->setEnabled(false);
1648 		addNoiseAct->setEnabled(false);
1649 		addLetterboxAct->setEnabled(false);
1650 		upscaleAct->setEnabled(false);
1651 
1652 		deinterlaceGroup->setActionsEnabled(false);
1653 		rotateGroup->setActionsEnabled(false);
1654 		denoiseGroup->setActionsEnabled(false);
1655 		unsharpGroup->setActionsEnabled(false);
1656 
1657 		displayMessage( tr("Video filters are disabled when using vdpau") );
1658 	}
1659 #endif
1660 
1661 #if DVDNAV_SUPPORT
1662 	if (!core->mdat.filename.startsWith("dvdnav:")) {
1663 		dvdnavUpAct->setEnabled(false);
1664 		dvdnavDownAct->setEnabled(false);
1665 		dvdnavLeftAct->setEnabled(false);
1666 		dvdnavRightAct->setEnabled(false);
1667 		dvdnavMenuAct->setEnabled(false);
1668 		dvdnavSelectAct->setEnabled(false);
1669 		dvdnavPrevAct->setEnabled(false);
1670 		dvdnavMouseAct->setEnabled(false);
1671 	}
1672 #endif
1673 
1674 
1675 #ifdef BOOKMARKS
1676 	bool bookmarks_enabled = true;
1677 	if (!pref->remember_media_settings) bookmarks_enabled = false;
1678 	else
1679 	if (core->mdat.type == TYPE_STREAM && !pref->remember_stream_settings) bookmarks_enabled = false;
1680 	else
1681 	if (core->mdat.type != TYPE_FILE && core->mdat.type != TYPE_STREAM) bookmarks_enabled = false;
1682 
1683 	addBookmarkAct->setEnabled(bookmarks_enabled);
1684 	editBookmarksAct->setEnabled(bookmarks_enabled);
1685 #endif
1686 }
1687 
disableActionsOnStop()1688 void BaseGui::disableActionsOnStop() {
1689 	qDebug("BaseGui::disableActionsOnStop");
1690 
1691 	setActionsEnabled(false);
1692 
1693 	playAct->setEnabled(true);
1694 	playOrPauseAct->setEnabled(true);
1695 	stopAct->setEnabled(true);
1696 }
1697 #endif // AUTODISABLE_ACTIONS
1698 
togglePlayAction(Core::State state)1699 void BaseGui::togglePlayAction(Core::State state) {
1700 	qDebug("BaseGui::togglePlayAction");
1701 
1702 #if AUTODISABLE_ACTIONS
1703 	if (state == Core::Playing)
1704 		playAct->setEnabled(false);
1705 	else
1706 		playAct->setEnabled(true);
1707 #endif
1708 }
1709 
retranslateStrings()1710 void BaseGui::retranslateStrings() {
1711 	setWindowIcon( Images::icon("logo", 64) );
1712 
1713 	// ACTIONS
1714 
1715 	// Menu File
1716 	openFileAct->change( Images::icon("open"), tr("&File...") );
1717 	openDirectoryAct->change( Images::icon("openfolder"), tr("D&irectory...") );
1718 	openPlaylistAct->change( Images::icon("open_playlist"), tr("&Playlist...") );
1719 	openVCDAct->change( Images::icon("vcd"), tr("V&CD") );
1720 	openAudioCDAct->change( Images::icon("cdda"), tr("&Audio CD") );
1721 	openDVDAct->change( Images::icon("dvd"), tr("&DVD from drive") );
1722 	openDVDFolderAct->change( Images::icon("dvd_hd"), tr("D&VD from folder...") );
1723 #ifdef BLURAY_SUPPORT
1724 	openBluRayAct->change( Images::icon("bluray"), tr("&Blu-ray from drive") );
1725 	openBluRayFolderAct->change( Images::icon("bluray_hd"), tr("Blu-&ray from folder...") );
1726 #endif
1727 	openURLAct->change( Images::icon("url"), tr("&URL...") );
1728 	exitAct->change( Images::icon("close"), tr("C&lose") );
1729 
1730 	// Favorites
1731 	/*
1732 	favorites->editAct()->setText( tr("&Edit...") );
1733 	favorites->addCurrentAct()->setText( tr("&Add current media") );
1734 	*/
1735 
1736 	// TV & Radio submenus
1737 	/*
1738 	tvlist->editAct()->setText( tr("&Edit...") );
1739 	radiolist->editAct()->setText( tr("&Edit...") );
1740 	tvlist->addCurrentAct()->setText( tr("&Add current media") );
1741 	radiolist->addCurrentAct()->setText( tr("&Add current media") );
1742 	tvlist->jumpAct()->setText( tr("&Jump...") );
1743 	radiolist->jumpAct()->setText( tr("&Jump...") );
1744 	tvlist->nextAct()->setText( tr("Next TV channel") );
1745 	tvlist->previousAct()->setText( tr("Previous TV channel") );
1746 	radiolist->nextAct()->setText( tr("Next radio channel") );
1747 	radiolist->previousAct()->setText( tr("Previous radio channel") );
1748 	*/
1749 
1750 	// Menu Play
1751 	playAct->change( tr("P&lay") );
1752 	playAct->setIcon( Images::icon("play") );
1753 
1754 	pauseAct->change( Images::icon("pause"), tr("&Pause"));
1755 	stopAct->change( Images::icon("stop"), tr("&Stop") );
1756 	frameStepAct->change( Images::icon("frame_step"), tr("&Frame step") );
1757 	frameBackStepAct->change( Images::icon("frame_back_step"), tr("Fra&me back step") );
1758 
1759 	playOrPauseAct->change( tr("Play / Pause") );
1760 	playOrPauseAct->setIcon( Images::icon("play_pause") );
1761 
1762 	pauseAndStepAct->change( Images::icon("pause"), tr("Pause / Frame step") );
1763 
1764 	setJumpTexts(); // Texts for rewind*Act and forward*Act
1765 
1766 	// Submenu A-B
1767 	setAMarkerAct->change( Images::icon("a_marker"), tr("Set &A marker") );
1768 	setBMarkerAct->change( Images::icon("b_marker"), tr("Set &B marker") );
1769 	clearABMarkersAct->change( Images::icon("clear_markers"), tr("&Clear A-B markers") );
1770 	repeatAct->change( Images::icon("repeat"), tr("&Repeat") );
1771 
1772 	gotoAct->change( Images::icon("jumpto"), tr("&Jump to...") );
1773 
1774 	// Submenu speed
1775 	normalSpeedAct->change( tr("&Normal speed") );
1776 	halveSpeedAct->change( tr("&Half speed") );
1777 	doubleSpeedAct->change( tr("&Double speed") );
1778 	decSpeed10Act->change( tr("Speed &-10%") );
1779 	incSpeed10Act->change( tr("Speed &+10%") );
1780 	decSpeed4Act->change( tr("Speed -&4%") );
1781 	incSpeed4Act->change( tr("&Speed +4%") );
1782 	decSpeed1Act->change( tr("Speed -&1%") );
1783 	incSpeed1Act->change( tr("S&peed +1%") );
1784 
1785 	// Menu Video
1786 	fullscreenAct->change( Images::icon("fullscreen"), tr("&Fullscreen") );
1787 	compactAct->change( Images::icon("compact"), tr("&Compact mode") );
1788 	videoEqualizerAct->change( Images::icon("equalizer"), tr("&Equalizer") );
1789 	screenshotAct->change( Images::icon("screenshot"), tr("&Screenshot") );
1790 	screenshotWithSubsAct->change( Images::icon("screenshot"), tr("Screenshot with subtitles") );
1791 	screenshotWithNoSubsAct->change( Images::icon("screenshot"), tr("Screenshot without subtitles") );
1792 	screenshotsAct->change( Images::icon("screenshots"), tr("Start/stop takin&g screenshots") );
1793 #ifdef CAPTURE_STREAM
1794 	capturingAct->change(Images::icon("record"), tr("Start/stop capturing stream"));
1795 #endif
1796 #ifdef VIDEOPREVIEW
1797 	videoPreviewAct->change( Images::icon("video_preview"), tr("Thumb&nail Generator...") );
1798 #endif
1799 	flipAct->change( Images::icon("flip"), tr("Fli&p image") );
1800 	mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") );
1801 	stereo3dAct->change( Images::icon("stereo3d"), tr("Stereo &3D filter") );
1802 
1803 	decZoomAct->change( tr("Zoom &-") );
1804 	incZoomAct->change( tr("Zoom &+") );
1805 	resetZoomAct->change( tr("&Reset") );
1806 	autoZoomAct->change( tr("&Auto zoom") );
1807 	autoZoom169Act->change( tr("Zoom for &16:9") );
1808 	autoZoom235Act->change( tr("Zoom for &2.35:1") );
1809 	moveLeftAct->change( tr("Move &left") );
1810 	moveRightAct->change( tr("Move &right") );
1811 	moveUpAct->change( tr("Move &up") );
1812 	moveDownAct->change( tr("Move &down") );
1813 
1814 	// Submenu Filters
1815 	postProcessingAct->change( tr("&Postprocessing") );
1816 	phaseAct->change( tr("&Autodetect phase") );
1817 	deblockAct->change( tr("&Deblock") );
1818 	deringAct->change( tr("De&ring") );
1819 	gradfunAct->change( tr("Debanding (&gradfun)") );
1820 	addNoiseAct->change( tr("Add n&oise") );
1821 	addLetterboxAct->change( Images::icon("letterbox"), tr("Add &black borders") );
1822 	upscaleAct->change( Images::icon("upscaling"), tr("Soft&ware scaling") );
1823 
1824 	// Menu Audio
1825 	audioEqualizerAct->change( Images::icon("audio_equalizer"), tr("E&qualizer") );
1826 	QIcon icset( Images::icon("volume") );
1827 	icset.addPixmap( Images::icon("mute"), QIcon::Normal, QIcon::On  );
1828 	muteAct->change( icset, tr("&Mute") );
1829 	decVolumeAct->change( Images::icon("audio_down"), tr("Volume &-") );
1830 	incVolumeAct->change( Images::icon("audio_up"), tr("Volume &+") );
1831 	decAudioDelayAct->change( Images::icon("delay_down"), tr("&Delay -") );
1832 	incAudioDelayAct->change( Images::icon("delay_up"), tr("D&elay +") );
1833 	audioDelayAct->change( Images::icon("audio_delay"), tr("Set dela&y...") );
1834 	loadAudioAct->change( Images::icon("open"), tr("&Load external file...") );
1835 	unloadAudioAct->change( Images::icon("unload"), tr("U&nload") );
1836 
1837 	// Submenu Filters
1838 	extrastereoAct->change( tr("&Extrastereo") );
1839 	karaokeAct->change( tr("&Karaoke") );
1840 	volnormAct->change( tr("Volume &normalization") );
1841 #ifdef MPV_SUPPORT
1842 	earwaxAct->change( tr("&Headphone optimization") + " (earwax)" );
1843 #endif
1844 
1845 	// Menu Subtitles
1846 	loadSubsAct->change( Images::icon("open"), tr("&Load...") );
1847 	unloadSubsAct->change( Images::icon("unload"), tr("U&nload") );
1848 	decSubDelayAct->change( Images::icon("delay_down"), tr("Delay &-") );
1849 	incSubDelayAct->change( Images::icon("delay_up"), tr("Delay &+") );
1850 	subDelayAct->change( Images::icon("sub_delay"), tr("Se&t delay...") );
1851 	decSubPosAct->change( Images::icon("sub_up"), tr("&Up") );
1852 	incSubPosAct->change( Images::icon("sub_down"), tr("&Down") );
1853 	decSubScaleAct->change( Images::icon("dec_sub_scale"), tr("S&ize -") );
1854 	incSubScaleAct->change( Images::icon("inc_sub_scale"), tr("Si&ze +") );
1855 	decSubStepAct->change( Images::icon("dec_sub_step"),
1856                            tr("&Previous line in subtitles") );
1857 	incSubStepAct->change( Images::icon("inc_sub_step"),
1858                            tr("N&ext line in subtitles") );
1859 #ifdef MPV_SUPPORT
1860 	seekNextSubAct->change(Images::icon("seek_next_sub"), tr("Seek to next subtitle"));
1861 	seekPrevSubAct->change(Images::icon("seek_prev_sub"), tr("Seek to previous subtitle"));
1862 #endif
1863 	useCustomSubStyleAct->change( Images::icon("use_custom_sub_style"), tr("Use custo&m style") );
1864 	useForcedSubsOnlyAct->change( Images::icon("forced_subs"), tr("&Forced subtitles only") );
1865 
1866 	subVisibilityAct->change( Images::icon("sub_visibility"), tr("Subtitle &visibility") );
1867 
1868 #ifdef FIND_SUBTITLES
1869 	showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles at &OpenSubtitles.org...") );
1870 	openUploadSubtitlesPageAct->change( Images::icon("upload_subs"), tr("Upload su&btitles to OpenSubtitles.org...") );
1871 #endif
1872 
1873 	ccNoneAct->change( tr("&Off", "closed captions menu") );
1874 	ccChannel1Act->change( "&1" );
1875 	ccChannel2Act->change( "&2" );
1876 	ccChannel3Act->change( "&3" );
1877 	ccChannel4Act->change( "&4" );
1878 
1879 	subFPSNoneAct->change( tr("&Default", "subfps menu") );
1880 	/* subFPS23Act->change( "2&3" ); */
1881 	subFPS23976Act->change( "23.9&76" );
1882 	subFPS24Act->change( "2&4" );
1883 	subFPS25Act->change( "2&5" );
1884 	subFPS29970Act->change( "29.&970" );
1885 	subFPS30Act->change( "3&0" );
1886 
1887 	// Menu Options
1888 	showPlaylistAct->change( Images::icon("playlist"), tr("&Playlist") );
1889 	showPropertiesAct->change( Images::icon("info"), tr("&Information and properties...") );
1890 	showPreferencesAct->change( Images::icon("prefs"), tr("P&references") );
1891 #ifdef YOUTUBE_SUPPORT
1892 	showTubeBrowserAct->change( Images::icon("tubebrowser"), tr("&YouTube%1 browser").arg(QChar(0x2122)) );
1893 #endif
1894 
1895 	// Submenu Logs
1896 #ifdef LOG_MPLAYER
1897 	showLogMplayerAct->change(tr("%1 log").arg(PLAYER_NAME));
1898 #endif
1899 #ifdef LOG_SMPLAYER
1900 	showLogSmplayerAct->change(tr("SMPlayer log"));
1901 #endif
1902 	tabletModeAct->change(Images::icon("tablet_mode"), tr("T&ablet mode"));
1903 
1904 	// Menu Help
1905 	showFirstStepsAct->change( Images::icon("guide"), tr("First Steps &Guide") );
1906 	showFAQAct->change( Images::icon("faq"), tr("&FAQ") );
1907 	showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") );
1908 	showCheckUpdatesAct->change( Images::icon("check_updates"), tr("Check for &updates") );
1909 
1910 #ifdef YT_CODEDOWNLOADER
1911 	#if defined(Q_OS_WIN) && !defined(PORTABLE_APP) && !defined(YT_BIN_ON_CONFIG_DIR)
1912 	updateYTAct->change( Images::icon("update_youtube"), tr("Update &YouTube support") );
1913 	#else
1914 	updateYTAct->change( Images::icon("update_youtube"), tr("Install / Update &YouTube support") );
1915 	#endif
1916 #endif
1917 
1918 	showConfigAct->change( Images::icon("show_config"), tr("&Open configuration folder") );
1919 #ifdef SHARE_ACTIONS
1920 	donateAct->change( Images::icon("donate"), tr("&Donate / Share with your friends") );
1921 #else
1922 	donateAct->change( Images::icon("donate"), tr("&Donate") );
1923 #endif
1924 	aboutThisAct->change( Images::icon("logo"), tr("About &SMPlayer") );
1925 
1926 #ifdef SHARE_MENU
1927 	facebookAct->change("&Facebook");
1928 	twitterAct->change("&Twitter");
1929 	gmailAct->change("&Gmail");
1930 	hotmailAct->change("&Hotmail");
1931 	yahooAct->change("&Yahoo!");
1932 #endif
1933 
1934 	// OSD
1935 	incOSDScaleAct->change(tr("Size &+"));
1936 	decOSDScaleAct->change(tr("Size &-"));
1937 
1938 #ifdef MPV_SUPPORT
1939 	OSDFractionsAct->change(tr("Show times with &milliseconds"));
1940 #endif
1941 
1942 	// Playlist
1943 	playNextAct->change( tr("&Next") );
1944 	playPrevAct->change( tr("Pre&vious") );
1945 
1946 	playNextAct->setIcon( Images::icon("next") );
1947 	playPrevAct->setIcon( Images::icon("previous") );
1948 
1949 
1950 	// Actions not in menus or buttons
1951 	// Volume 2
1952 #if !USE_MULTIPLE_SHORTCUTS
1953 	decVolume2Act->change( tr("Dec volume (2)") );
1954 	incVolume2Act->change( tr("Inc volume (2)") );
1955 #endif
1956 	// Exit fullscreen
1957 	exitFullscreenAct->change( tr("Exit fullscreen") );
1958 
1959 	nextOSDAct->change( tr("OSD - Next level") );
1960 	decContrastAct->change( tr("Dec contrast") );
1961 	incContrastAct->change( tr("Inc contrast") );
1962 	decBrightnessAct->change( tr("Dec brightness") );
1963 	incBrightnessAct->change( tr("Inc brightness") );
1964 	decHueAct->change( tr("Dec hue") );
1965 	incHueAct->change( tr("Inc hue") );
1966 	decSaturationAct->change( tr("Dec saturation") );
1967 	incSaturationAct->change( tr("Inc saturation") );
1968 	decGammaAct->change( tr("Dec gamma") );
1969 	incGammaAct->change( tr("Inc gamma") );
1970 	prevVideoAct->change( tr("Previous video") );
1971 	nextVideoAct->change( tr("Next video") );
1972 	prevAudioAct->change( tr("Previous audio") );
1973 	nextAudioAct->change( tr("Next audio") );
1974 	prevSubtitleAct->change( tr("Previous subtitle") );
1975 	nextSubtitleAct->change( tr("Next subtitle") );
1976 	nextChapterAct->change( tr("Next chapter") );
1977 	prevChapterAct->change( tr("Previous chapter") );
1978 	doubleSizeAct->change( tr("&Toggle double size") );
1979 	resetVideoEqualizerAct->change( tr("Reset video equalizer") );
1980 	resetAudioEqualizerAct->change( tr("Reset audio equalizer") );
1981 	showContextMenuAct->change( tr("Show context menu") );
1982 	nextAspectAct->change( Images::icon("next_aspect"), tr("Next aspect ratio") );
1983 	nextWheelFunctionAct->change( Images::icon("next_wheel_function"), tr("Next wheel function") );
1984 
1985 	showFilenameAct->change( tr("Show filename on OSD") );
1986 	showMediaInfoAct->change( tr("Show &info on OSD") );
1987 	showTimeAct->change( tr("Show playback time on OSD") );
1988 
1989 	toggleDeinterlaceAct->change( tr("Toggle deinterlacing") );
1990 
1991 
1992 	// Action groups
1993 
1994 	osdNoneAct->change( tr("Subtitles onl&y") );
1995 	osdSeekAct->change( tr("Volume + &Seek") );
1996 	osdTimerAct->change( tr("Volume + Seek + &Timer") );
1997 	osdTotalAct->change( tr("Volume + Seek + Timer + T&otal time") );
1998 
1999 
2000 	// MENUS
2001 	openMenu->menuAction()->setText( tr("&Open") );
2002 	playMenu->menuAction()->setText( tr("&Play") );
2003 	videoMenu->menuAction()->setText( tr("&Video") );
2004 	audioMenu->menuAction()->setText( tr("&Audio") );
2005 	subtitlesMenu->menuAction()->setText( tr("&Subtitles") );
2006 	browseMenu->menuAction()->setText( tr("&Browse") );
2007 	viewMenu->menuAction()->setText( tr("Vie&w") );
2008 	optionsMenu->menuAction()->setText( tr("Op&tions") );
2009 	helpMenu->menuAction()->setText( tr("&Help") );
2010 
2011 	/*
2012 	openMenuAct->setIcon( Images::icon("open_menu") );
2013 	playMenuAct->setIcon( Images::icon("play_menu") );
2014 	videoMenuAct->setIcon( Images::icon("video_menu") );
2015 	audioMenuAct->setIcon( Images::icon("audio_menu") );
2016 	subtitlesMenuAct->setIcon( Images::icon("subtitles_menu") );
2017 	browseMenuAct->setIcon( Images::icon("browse_menu") );
2018 	optionsMenuAct->setIcon( Images::icon("options_menu") );
2019 	helpMenuAct->setIcon( Images::icon("help_menu") );
2020 	*/
2021 
2022 	// Menu Open
2023 	recentfiles_menu->menuAction()->setText( tr("&Recent files") );
2024 	recentfiles_menu->menuAction()->setIcon( Images::icon("recents") );
2025 	clearRecentsAct->change( Images::icon("delete"), tr("&Clear") );
2026 
2027 	disc_menu->menuAction()->setText( tr("&Disc") );
2028 	disc_menu->menuAction()->setIcon( Images::icon("open_disc") );
2029 
2030 	/* favorites->menuAction()->setText( tr("&Favorites") ); */
2031 	favorites->menuAction()->setText( tr("F&avorites") );
2032 	favorites->menuAction()->setIcon( Images::icon("open_favorites") );
2033 
2034 #ifdef TV_SUPPORT
2035 	tvlist->menuAction()->setText( tr("&TV") );
2036 	tvlist->menuAction()->setIcon( Images::icon("open_tv") );
2037 
2038 	radiolist->menuAction()->setText( tr("Radi&o") );
2039 	radiolist->menuAction()->setIcon( Images::icon("open_radio") );
2040 #endif
2041 
2042 	// Menu Play
2043 	speed_menu->menuAction()->setText( tr("Sp&eed") );
2044 	speed_menu->menuAction()->setIcon( Images::icon("speed") );
2045 
2046 	ab_menu->menuAction()->setText( tr("&A-B section") );
2047 	ab_menu->menuAction()->setIcon( Images::icon("ab_menu") );
2048 
2049 	// Menu Video
2050 	videotrack_menu->menuAction()->setText( tr("&Track", "video") );
2051 	videotrack_menu->menuAction()->setIcon( Images::icon("video_track") );
2052 
2053 	videosize_menu->menuAction()->setText( tr("Si&ze") );
2054 	videosize_menu->menuAction()->setIcon( Images::icon("video_size") );
2055 
2056 	/*
2057 	panscan_menu->menuAction()->setText( tr("&Pan && scan") );
2058 	panscan_menu->menuAction()->setIcon( Images::icon("panscan") );
2059 	*/
2060 	zoom_menu->menuAction()->setText( tr("Zoo&m") );
2061 	zoom_menu->menuAction()->setIcon( Images::icon("zoom") );
2062 
2063 	aspect_menu->menuAction()->setText( tr("&Aspect ratio") );
2064 	aspect_menu->menuAction()->setIcon( Images::icon("aspect") );
2065 
2066 	deinterlace_menu->menuAction()->setText( tr("&Deinterlace") );
2067 	deinterlace_menu->menuAction()->setIcon( Images::icon("deinterlace") );
2068 
2069 	videofilter_menu->menuAction()->setText( tr("F&ilters") );
2070 	videofilter_menu->menuAction()->setIcon( Images::icon("video_filters") );
2071 
2072 	rotate_menu->menuAction()->setText( tr("&Rotate") );
2073 	rotate_menu->menuAction()->setIcon( Images::icon("rotate") );
2074 
2075 	ontop_menu->menuAction()->setText( tr("S&tay on top") );
2076 	ontop_menu->menuAction()->setIcon( Images::icon("ontop") );
2077 
2078 #if USE_ADAPTER
2079 	screen_menu->menuAction()->setText( tr("Scree&n") );
2080 	screen_menu->menuAction()->setIcon( Images::icon("screen") );
2081 #endif
2082 
2083 	denoise_menu->menuAction()->setText( tr("De&noise") );
2084 	denoise_menu->menuAction()->setIcon( Images::icon("denoise") );
2085 
2086 	unsharp_menu->menuAction()->setText( tr("Blur/S&harp") );
2087 	unsharp_menu->menuAction()->setIcon( Images::icon("unsharp") );
2088 
2089 	aspectDetectAct->change( tr("&Auto") );
2090 	aspect11Act->change( "1&:1" );
2091 	aspect32Act->change( "&3:2" );
2092 	aspect43Act->change( "&4:3" );
2093 	aspect118Act->change( "11:&8" );
2094 	aspect54Act->change( "&5:4" );
2095 	aspect149Act->change( "&14:9" );
2096 	aspect1410Act->change( "1&4:10" );
2097 	aspect169Act->change( "16:&9" );
2098 	aspect1610Act->change( "1&6:10" );
2099 	aspect235Act->change( "&2.35:1" );
2100 	aspectNoneAct->change( tr("&Disabled") );
2101 
2102 	deinterlaceNoneAct->change( tr("&None") );
2103 	deinterlaceL5Act->change( tr("&Lowpass5") );
2104 	deinterlaceYadif0Act->change( tr("&Yadif (normal)") );
2105 	deinterlaceYadif1Act->change( tr("Y&adif (double framerate)") );
2106 	deinterlaceLBAct->change( tr("Linear &Blend") );
2107 	deinterlaceKernAct->change( tr("&Kerndeint") );
2108 
2109 	denoiseNoneAct->change( tr("&Off", "denoise menu") );
2110 	denoiseNormalAct->change( tr("&Normal","denoise menu") );
2111 	denoiseSoftAct->change( tr("&Soft", "denoise menu") );
2112 
2113 	unsharpNoneAct->change( tr("&None", "unsharp menu") );
2114 	blurAct->change( tr("&Blur", "unsharp menu") );
2115 	sharpenAct->change( tr("&Sharpen", "unsharp menu") );
2116 
2117 	rotateNoneAct->change( tr("&Off") );
2118 	rotateClockwiseFlipAct->change( tr("&Rotate by 90 degrees clockwise and flip") );
2119 	rotateClockwiseAct->change( tr("Rotate by 90 degrees &clockwise") );
2120 	rotateCounterclockwiseAct->change( tr("Rotate by 90 degrees counterclock&wise") );
2121 	rotateCounterclockwiseFlipAct->change( tr("Rotate by 90 degrees counterclockwise and &flip") );
2122 	rotate180Act->change( tr("Rotate by 1&80 degrees") );
2123 
2124 	onTopAlwaysAct->change( tr("&Always") );
2125 	onTopNeverAct->change( tr("&Never") );
2126 	onTopWhilePlayingAct->change( tr("While &playing") );
2127 	toggleStayOnTopAct->change( tr("Toggle stay on top") );
2128 
2129 #if USE_ADAPTER
2130 	screenDefaultAct->change( tr("&Default") );
2131 #endif
2132 
2133 	// Menu Audio
2134 	audiotrack_menu->menuAction()->setText( tr("&Track", "audio") );
2135 	audiotrack_menu->menuAction()->setIcon( Images::icon("audio_track") );
2136 	audiotrack_menu->menuAction()->setToolTip(tr("Select audio track"));
2137 
2138 	audiofilter_menu->menuAction()->setText( tr("&Filters") );
2139 	audiofilter_menu->menuAction()->setIcon( Images::icon("audio_filters") );
2140 
2141 	audiochannels_menu->menuAction()->setText( tr("&Channels") );
2142 	audiochannels_menu->menuAction()->setIcon( Images::icon("audio_channels") );
2143 
2144 	stereomode_menu->menuAction()->setText( tr("&Stereo mode") );
2145 	stereomode_menu->menuAction()->setIcon( Images::icon("stereo_mode") );
2146 
2147 	channelsDefaultAct->change( tr("&Default") );
2148 	channelsStereoAct->change( tr("&Stereo") );
2149 	channelsSurroundAct->change( tr("&4.0 Surround") );
2150 	channelsFull51Act->change( tr("&5.1 Surround") );
2151 	channelsFull61Act->change( tr("&6.1 Surround") );
2152 	channelsFull71Act->change( tr("&7.1 Surround") );
2153 
2154 	stereoAct->change( tr("&Stereo") );
2155 	leftChannelAct->change( tr("&Left channel") );
2156 	rightChannelAct->change( tr("&Right channel") );
2157 	monoAct->change( tr("&Mono") );
2158 	reverseAct->change( tr("Re&verse") );
2159 
2160 	// Menu Subtitle
2161 #ifdef MPV_SUPPORT
2162 	subtitles_track_menu->menuAction()->setText( tr("Prim&ary track") );
2163 #else
2164 	subtitles_track_menu->menuAction()->setText( tr("&Select") );
2165 #endif
2166 	subtitles_track_menu->menuAction()->setIcon( Images::icon("sub") );
2167 	subtitles_track_menu->menuAction()->setToolTip(tr("Select subtitle track"));
2168 
2169 #ifdef MPV_SUPPORT
2170 	secondary_subtitles_track_menu->menuAction()->setText( tr("Secondary trac&k") );
2171 	secondary_subtitles_track_menu->menuAction()->setIcon( Images::icon("secondary_sub") );
2172 	secondary_subtitles_track_menu->menuAction()->setToolTip(tr("Select secondary subtitle track"));
2173 #endif
2174 
2175 	closed_captions_menu->menuAction()->setText( tr("&Closed captions") );
2176 	closed_captions_menu->menuAction()->setIcon( Images::icon("closed_caption") );
2177 
2178 	subfps_menu->menuAction()->setText( tr("F&rames per second") );
2179 	subfps_menu->menuAction()->setIcon( Images::icon("subfps") );
2180 
2181 	// Menu Browse
2182 	titles_menu->menuAction()->setText( tr("&Title") );
2183 	titles_menu->menuAction()->setIcon( Images::icon("title") );
2184 
2185 	chapters_menu->menuAction()->setText( tr("&Chapter") );
2186 	chapters_menu->menuAction()->setIcon( Images::icon("chapter") );
2187 
2188 	angles_menu->menuAction()->setText( tr("&Angle") );
2189 	angles_menu->menuAction()->setIcon( Images::icon("angle") );
2190 
2191 #ifdef BOOKMARKS
2192 	bookmark_menu->menuAction()->setText( tr("&Bookmarks") );
2193 	bookmark_menu->menuAction()->setIcon( Images::icon("bookmarks") );
2194 #endif
2195 
2196 #if PROGRAM_SWITCH
2197 	programtrack_menu->menuAction()->setText( tr("P&rogram", "program") );
2198 	programtrack_menu->menuAction()->setIcon( Images::icon("program_track") );
2199 #endif
2200 
2201 #ifdef BOOKMARKS
2202 	addBookmarkAct->change(Images::icon("add_bookmark"), tr("&Add new bookmark"));
2203 	editBookmarksAct->change(Images::icon("edit_bookmarks"), tr("&Edit bookmarks"));
2204 	prevBookmarkAct->change(Images::icon("prev_bookmark"), tr("Previous bookmark"));
2205 	nextBookmarkAct->change(Images::icon("next_bookmark"), tr("Next bookmark"));
2206 #endif
2207 
2208 #if DVDNAV_SUPPORT
2209 	dvdnavUpAct->change(Images::icon("dvdnav_up"), tr("DVD menu, move up"));
2210 	dvdnavDownAct->change(Images::icon("dvdnav_down"), tr("DVD menu, move down"));
2211 	dvdnavLeftAct->change(Images::icon("dvdnav_left"), tr("DVD menu, move left"));
2212 	dvdnavRightAct->change(Images::icon("dvdnav_right"), tr("DVD menu, move right"));
2213 	dvdnavMenuAct->change(Images::icon("dvdnav_menu"), tr("DVD &menu"));
2214 	dvdnavSelectAct->change(Images::icon("dvdnav_select"), tr("DVD menu, select option"));
2215 	dvdnavPrevAct->change(Images::icon("dvdnav_prev"), tr("DVD &previous menu"));
2216 	dvdnavMouseAct->change(Images::icon("dvdnav_mouse"), tr("DVD menu, mouse click"));
2217 #endif
2218 
2219 	// Menu Options
2220 	osd_menu->menuAction()->setText( tr("&OSD") );
2221 	osd_menu->menuAction()->setIcon( Images::icon("osd") );
2222 
2223 #ifdef SHARE_MENU
2224 	share_menu->menuAction()->setText( tr("S&hare SMPlayer with your friends") );
2225 	share_menu->menuAction()->setIcon( Images::icon("share") );
2226 #endif
2227 
2228 #if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER)
2229 	//logs_menu->menuAction()->setText( tr("&View logs") );
2230 	//logs_menu->menuAction()->setIcon( Images::icon("logs") );
2231 #endif
2232 
2233 	// Access menu
2234 	access_menu->menuAction()->setText( tr("Quick access menu") );
2235 	access_menu->menuAction()->setIcon( Images::icon("quick_access_menu") );
2236 
2237 	// To be sure that the "<empty>" string is translated
2238 	initializeMenus();
2239 
2240 	// Other things
2241 #ifdef LOG_MPLAYER
2242 	mplayer_log_window->setWindowTitle( tr("%1 log").arg(PLAYER_NAME) );
2243 #endif
2244 #ifdef LOG_SMPLAYER
2245 	smplayer_log_window->setWindowTitle( tr("SMPlayer log") );
2246 #endif
2247 
2248 	updateRecents();
2249 	updateWidgets();
2250 
2251 	// Update actions view in preferences
2252 	// It has to be done, here. The actions are translated after the
2253 	// preferences dialog.
2254 	if (pref_dialog) pref_dialog->mod_input()->actions_editor->updateView();
2255 }
2256 
setJumpTexts()2257 void BaseGui::setJumpTexts() {
2258 	rewind1Act->change( tr("-%1").arg(Helper::timeForJumps(pref->seeking1)) );
2259 	rewind2Act->change( tr("-%1").arg(Helper::timeForJumps(pref->seeking2)) );
2260 	rewind3Act->change( tr("-%1").arg(Helper::timeForJumps(pref->seeking3)) );
2261 
2262 	forward1Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking1)) );
2263 	forward2Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking2)) );
2264 	forward3Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking3)) );
2265 
2266 	rewind1Act->setIcon( Images::icon("rewind10s") );
2267 	rewind2Act->setIcon( Images::icon("rewind1m") );
2268 	rewind3Act->setIcon( Images::icon("rewind10m") );
2269 
2270 	forward1Act->setIcon( Images::icon("forward10s") );
2271 	forward2Act->setIcon( Images::icon("forward1m") );
2272 	forward3Act->setIcon( Images::icon("forward10m") );
2273 }
2274 
setWindowCaption(const QString & title)2275 void BaseGui::setWindowCaption(const QString & title) {
2276 	setWindowTitle(title);
2277 }
2278 
createCore()2279 void BaseGui::createCore() {
2280 	core = new Core( mplayerwindow, this );
2281 
2282 	connect( core, SIGNAL(menusNeedInitialize()),
2283              this, SLOT(initializeMenus()) );
2284 	connect( core, SIGNAL(widgetsNeedUpdate()),
2285              this, SLOT(updateWidgets()) );
2286 	connect( core, SIGNAL(videoEqualizerNeedsUpdate()),
2287              this, SLOT(updateVideoEqualizer()) );
2288 
2289 	connect( core, SIGNAL(audioEqualizerNeedsUpdate()),
2290              this, SLOT(updateAudioEqualizer()) );
2291 
2292 	connect( core, SIGNAL(showFrame(int)),
2293              this, SIGNAL(frameChanged(int)) );
2294 
2295 	connect( core, SIGNAL(ABMarkersChanged(int,int)),
2296              this, SIGNAL(ABMarkersChanged(int,int)) );
2297 
2298 	connect( core, SIGNAL(showTime(double)),
2299              this, SLOT(gotCurrentTime(double)) );
2300 
2301 	connect( core, SIGNAL(needResize(int, int)),
2302              this, SLOT(resizeWindow(int,int)) );
2303 
2304 	connect( core, SIGNAL(needResize(int, int)),
2305              this, SLOT(centerWindow()) );
2306 
2307 	connect( core, SIGNAL(showMessage(QString,int)),
2308              this, SLOT(displayMessage(QString,int)) );
2309 	connect( core, SIGNAL(showMessage(QString)),
2310              this, SLOT(displayMessage(QString)) );
2311 
2312 	connect( core, SIGNAL(stateChanged(Core::State)),
2313              this, SLOT(displayState(Core::State)) );
2314 	connect( core, SIGNAL(stateChanged(Core::State)),
2315              this, SLOT(checkStayOnTop(Core::State)), Qt::QueuedConnection );
2316 
2317 	connect( core, SIGNAL(mediaStartPlay()),
2318              this, SLOT(enterFullscreenOnPlay()), Qt::QueuedConnection );
2319 	connect( core, SIGNAL(mediaStoppedByUser()),
2320              this, SLOT(exitFullscreenOnStop()) );
2321 
2322 	connect( core, SIGNAL(mediaStoppedByUser()),
2323              mplayerwindow, SLOT(showLogo()) );
2324 
2325 	connect( core, SIGNAL(mediaLoaded()),
2326              this, SLOT(enableActionsOnPlaying()) );
2327 
2328 	connect( core, SIGNAL(noFileToPlay()), this, SLOT(gotNoFileToPlay()) );
2329 
2330 #if NOTIFY_AUDIO_CHANGES
2331 	connect( core, SIGNAL(audioTracksInitialized()),
2332              this, SLOT(enableActionsOnPlaying()) );
2333 #endif
2334 	connect( core, SIGNAL(mediaFinished()),
2335              this, SLOT(disableActionsOnStop()) );
2336 	connect( core, SIGNAL(mediaStoppedByUser()),
2337              this, SLOT(disableActionsOnStop()) );
2338 
2339 	connect( core, SIGNAL(stateChanged(Core::State)),
2340              this, SLOT(togglePlayAction(Core::State)) );
2341 
2342 	connect( core, SIGNAL(mediaStartPlay()),
2343              this, SLOT(newMediaLoaded()), Qt::QueuedConnection );
2344 	connect( core, SIGNAL(mediaInfoChanged()),
2345              this, SLOT(updateMediaInfo()) );
2346 
2347 	connect( core, SIGNAL(mediaStartPlay()),
2348              this, SLOT(checkPendingActionsToRun()), Qt::QueuedConnection );
2349 #if REPORT_OLD_MPLAYER
2350 	connect( core, SIGNAL(mediaStartPlay()),
2351              this, SLOT(checkMplayerVersion()), Qt::QueuedConnection );
2352 #endif
2353 	connect( core, SIGNAL(failedToParseMplayerVersion(QString)),
2354              this, SLOT(askForMplayerVersion(QString)) );
2355 
2356 	connect( core, SIGNAL(mplayerFailed(QProcess::ProcessError)),
2357              this, SLOT(showErrorFromMplayer(QProcess::ProcessError)) );
2358 
2359 	connect( core, SIGNAL(mplayerFinishedWithError(int)),
2360              this, SLOT(showExitCodeFromMplayer(int)) );
2361 
2362 	// Hide mplayer window
2363 #if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
2364 	if (pref->hide_video_window_on_audio_files) {
2365 		connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
2366 	} else {
2367 		connect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(showLogo()) );
2368 	}
2369 #else
2370 	connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
2371 #endif
2372 
2373 	// Log mplayer output
2374 #ifdef LOG_MPLAYER
2375 	connect( core, SIGNAL(aboutToStartPlaying()),
2376              this, SLOT(clearMplayerLog()) );
2377 	connect( core, SIGNAL(logLineAvailable(QString)),
2378              this, SLOT(recordMplayerLog(QString)) );
2379 
2380 	connect( core, SIGNAL(mediaLoaded()),
2381              this, SLOT(autosaveMplayerLog()) );
2382 #endif
2383 
2384 #ifdef YOUTUBE_SUPPORT
2385 	#ifdef YT_CODEDOWNLOADER
2386 	connect(core, SIGNAL(YTprocessFailedToStart()), this, SLOT(YTFailedToStart()));
2387 	connect(core, SIGNAL(YTUrlNotFound()), this, SLOT(YTUrlNotFound()));
2388 	#ifdef Q_OS_WIN
2389 	connect(core, SIGNAL(YTDLLNotFound()), this, SLOT(YTDLLNotFound()));
2390 	#endif
2391 	#endif
2392 #endif
2393 	connect(core, SIGNAL(receivedForbidden()), this, SLOT(gotForbidden()));
2394 }
2395 
createMplayerWindow()2396 void BaseGui::createMplayerWindow() {
2397 	mplayerwindow = new MplayerWindow(panel);
2398 	mplayerwindow->show();
2399 	mplayerwindow->setObjectName("mplayerwindow");
2400 #if USE_COLORKEY
2401 	mplayerwindow->setColorKey( pref->color_key );
2402 #endif
2403 	mplayerwindow->allowVideoMovement( pref->allow_video_movement );
2404 	mplayerwindow->delayLeftClick(pref->delay_left_click);
2405 
2406 #if LOGO_ANIMATION
2407 	mplayerwindow->setAnimatedLogo( pref->animated_logo);
2408 #endif
2409 
2410 #ifdef SHARE_WIDGET
2411 	sharewidget = new ShareWidget(Global::settings, mplayerwindow);
2412 	mplayerwindow->setCornerWidget(sharewidget);
2413 	//#ifdef SHARE_ACTIONS
2414 	connect(sharewidget, SIGNAL(supportClicked()), this, SLOT(helpDonate()));
2415 	//#endif
2416 #endif
2417 
2418 	QVBoxLayout * layout = new QVBoxLayout;
2419 	layout->setSpacing(0);
2420 	layout->setMargin(0);
2421 	layout->addWidget(mplayerwindow);
2422 	panel->setLayout(layout);
2423 
2424 	// mplayerwindow
2425 	/*
2426     connect( mplayerwindow, SIGNAL(rightButtonReleased(QPoint)),
2427 	         this, SLOT(showPopupMenu(QPoint)) );
2428 	*/
2429 
2430 	// mplayerwindow mouse events
2431 	connect( mplayerwindow, SIGNAL(doubleClicked()),
2432              this, SLOT(doubleClickFunction()) );
2433 	connect( mplayerwindow, SIGNAL(leftClicked()),
2434              this, SLOT(leftClickFunction()) );
2435 	connect( mplayerwindow, SIGNAL(rightClicked()),
2436              this, SLOT(rightClickFunction()) );
2437 	connect( mplayerwindow, SIGNAL(middleClicked()),
2438              this, SLOT(middleClickFunction()) );
2439 	connect( mplayerwindow, SIGNAL(xbutton1Clicked()),
2440              this, SLOT(xbutton1ClickFunction()) );
2441 	connect( mplayerwindow, SIGNAL(xbutton2Clicked()),
2442              this, SLOT(xbutton2ClickFunction()) );
2443 
2444 	connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)),
2445              this, SLOT(processMouseMovedDiff(QPoint)), Qt::QueuedConnection );
2446 #ifdef MOUSE_GESTURES
2447 	mplayerwindow->activateMouseDragTracking(true);
2448 #else
2449 	mplayerwindow->activateMouseDragTracking(pref->drag_function == Preferences::MoveWindow);
2450 #endif
2451 }
2452 
createVideoEqualizer()2453 void BaseGui::createVideoEqualizer() {
2454 	// Equalizer
2455 	video_equalizer = new VideoEqualizer(this);
2456 	connect( video_equalizer, SIGNAL(contrastChanged(int)),
2457              core, SLOT(setContrast(int)) );
2458 	connect( video_equalizer, SIGNAL(brightnessChanged(int)),
2459              core, SLOT(setBrightness(int)) );
2460 	connect( video_equalizer, SIGNAL(hueChanged(int)),
2461              core, SLOT(setHue(int)) );
2462 	connect( video_equalizer, SIGNAL(saturationChanged(int)),
2463              core, SLOT(setSaturation(int)) );
2464 	connect( video_equalizer, SIGNAL(gammaChanged(int)),
2465              core, SLOT(setGamma(int)) );
2466 
2467 	connect( video_equalizer, SIGNAL(visibilityChanged()),
2468              this, SLOT(updateWidgets()) );
2469 	connect( video_equalizer, SIGNAL(requestToChangeDefaultValues()),
2470              this, SLOT(setDefaultValuesFromVideoEqualizer()) );
2471 	connect( video_equalizer, SIGNAL(bySoftwareChanged(bool)),
2472              this, SLOT(changeVideoEqualizerBySoftware(bool)) );
2473 }
2474 
createAudioEqualizer()2475 void BaseGui::createAudioEqualizer() {
2476 	// Audio Equalizer
2477 	audio_equalizer = new AudioEqualizer(this);
2478 
2479 	connect( audio_equalizer->eq[0], SIGNAL(valueChanged(int)),
2480              core, SLOT(setAudioEq0(int)) );
2481 	connect( audio_equalizer->eq[1], SIGNAL(valueChanged(int)),
2482              core, SLOT(setAudioEq1(int)) );
2483 	connect( audio_equalizer->eq[2], SIGNAL(valueChanged(int)),
2484              core, SLOT(setAudioEq2(int)) );
2485 	connect( audio_equalizer->eq[3], SIGNAL(valueChanged(int)),
2486              core, SLOT(setAudioEq3(int)) );
2487 	connect( audio_equalizer->eq[4], SIGNAL(valueChanged(int)),
2488              core, SLOT(setAudioEq4(int)) );
2489 	connect( audio_equalizer->eq[5], SIGNAL(valueChanged(int)),
2490              core, SLOT(setAudioEq5(int)) );
2491 	connect( audio_equalizer->eq[6], SIGNAL(valueChanged(int)),
2492              core, SLOT(setAudioEq6(int)) );
2493 	connect( audio_equalizer->eq[7], SIGNAL(valueChanged(int)),
2494              core, SLOT(setAudioEq7(int)) );
2495 	connect( audio_equalizer->eq[8], SIGNAL(valueChanged(int)),
2496              core, SLOT(setAudioEq8(int)) );
2497 	connect( audio_equalizer->eq[9], SIGNAL(valueChanged(int)),
2498              core, SLOT(setAudioEq9(int)) );
2499 
2500 	connect( audio_equalizer, SIGNAL(applyClicked(AudioEqualizerList)),
2501              core, SLOT(setAudioAudioEqualizerRestart(AudioEqualizerList)) );
2502 
2503 	connect( audio_equalizer, SIGNAL(valuesChanged(AudioEqualizerList)),
2504              core, SLOT(setAudioEqualizer(AudioEqualizerList)) );
2505 
2506 	connect( audio_equalizer, SIGNAL(visibilityChanged()),
2507              this, SLOT(updateWidgets()) );
2508 }
2509 
createPlaylist()2510 void BaseGui::createPlaylist() {
2511 	playlist = new Playlist(0);
2512 	playlist->setConfigPath(Paths::configPath());
2513 
2514 	connect( playlist, SIGNAL(playlistEnded()),
2515              this, SLOT(playlistHasFinished()) );
2516 
2517 	connect( playlist, SIGNAL(playlistEnded()),
2518              mplayerwindow, SLOT(showLogo()) );
2519 
2520 	connect(playlist, SIGNAL(requestToPlayFile(const QString &, int)),
2521             core, SLOT(open(const QString &, int)));
2522 
2523 	connect(playlist, SIGNAL(requestToPlayStream(const QString &, QStringList)),
2524             core, SLOT(openStream(const QString &, QStringList)));
2525 
2526 	connect(playlist, SIGNAL(requestToAddCurrentFile()), this, SLOT(addToPlaylistCurrentFile()));
2527 
2528 	connect( core, SIGNAL(mediaFinished()), playlist, SLOT(playNextAuto()), Qt::QueuedConnection );
2529 
2530 	connect( core, SIGNAL(mplayerFailed(QProcess::ProcessError)), playlist, SLOT(playerFailed(QProcess::ProcessError)) );
2531 	connect( core, SIGNAL(mplayerFinishedWithError(int)), playlist, SLOT(playerFinishedWithError(int)) );
2532 	connect(core, SIGNAL(mediaDataReceived(const MediaData &)), playlist, SLOT(getMediaInfo(const MediaData &)));
2533 
2534 #ifdef PLAYLIST_DOWNLOAD
2535 	playlist->setMaxItemsUrlHistory( pref->history_urls->maxItems() );
2536 #endif
2537 }
2538 
createPanel()2539 void BaseGui::createPanel() {
2540 	panel = new QWidget( this );
2541 	panel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
2542 	panel->setMinimumSize( QSize(1,1) );
2543 	panel->setFocusPolicy( Qt::StrongFocus );
2544 	panel->setObjectName("panel");
2545 
2546 	// panel
2547 	/*
2548 	panel->setAutoFillBackground(true);
2549 	ColorUtils::setBackgroundColor( panel, QColor(0,0,0) );
2550 	*/
2551 
2552 #ifndef CHANGE_WIDGET_COLOR
2553 	panel->setStyleSheet("#panel { background-color: black; }");
2554 #endif
2555 }
2556 
createPreferencesDialog()2557 void BaseGui::createPreferencesDialog() {
2558 	QApplication::setOverrideCursor(Qt::WaitCursor);
2559 	pref_dialog = new PreferencesDialog(this);
2560 	pref_dialog->setModal(false);
2561 	/* pref_dialog->mod_input()->setActionsList( actions_list ); */
2562 	connect( pref_dialog, SIGNAL(applied()),
2563              this, SLOT(applyNewPreferences()) );
2564 	QApplication::restoreOverrideCursor();
2565 }
2566 
createFilePropertiesDialog()2567 void BaseGui::createFilePropertiesDialog() {
2568 	qDebug("BaseGui::createFilePropertiesDialog");
2569 	QApplication::setOverrideCursor(Qt::WaitCursor);
2570 	file_dialog = new FilePropertiesDialog(this);
2571 	file_dialog->setModal(false);
2572 	connect( file_dialog, SIGNAL(applied()),
2573              this, SLOT(applyFileProperties()) );
2574 	QApplication::restoreOverrideCursor();
2575 }
2576 
2577 
createMenus()2578 void BaseGui::createMenus() {
2579 	// Submenus
2580 
2581 	// Recents submenu
2582 	recentfiles_menu = new QMenu(this);
2583 	recentfiles_menu->menuAction()->setObjectName("recents_menu");
2584 
2585 	// Disc submenu
2586 	disc_menu = new QMenu(this);
2587 	disc_menu->menuAction()->setObjectName("disc_menu");
2588 	disc_menu->addAction(openDVDAct);
2589 	disc_menu->addAction(openDVDFolderAct);
2590 	#ifdef BLURAY_SUPPORT
2591 	disc_menu->addAction(openBluRayAct);
2592 	disc_menu->addAction(openBluRayFolderAct);
2593 	#endif
2594 	disc_menu->addAction(openVCDAct);
2595 	disc_menu->addAction(openAudioCDAct);
2596 
2597 	// Speed submenu
2598 	speed_menu = new QMenu(this);
2599 	speed_menu->menuAction()->setObjectName("speed_menu");
2600 	speed_menu->addAction(normalSpeedAct);
2601 	foreach(QAction *a, speed_acts) speed_menu->addAction(a);
2602 	speed_menu->addSeparator();
2603 	speed_menu->addAction(halveSpeedAct);
2604 	speed_menu->addAction(doubleSpeedAct);
2605 	speed_menu->addSeparator();
2606 	speed_menu->addAction(decSpeed10Act);
2607 	speed_menu->addAction(incSpeed10Act);
2608 	speed_menu->addSeparator();
2609 	speed_menu->addAction(decSpeed4Act);
2610 	speed_menu->addAction(incSpeed4Act);
2611 	speed_menu->addSeparator();
2612 	speed_menu->addAction(decSpeed1Act);
2613 	speed_menu->addAction(incSpeed1Act);
2614 
2615 	// A-B submenu
2616 	ab_menu = new QMenu(this);
2617 	ab_menu->menuAction()->setObjectName("ab_menu");
2618 	ab_menu->addAction(setAMarkerAct);
2619 	ab_menu->addAction(setBMarkerAct);
2620 	ab_menu->addAction(clearABMarkersAct);
2621 	ab_menu->addSeparator();
2622 	ab_menu->addAction(repeatAct);
2623 
2624 	// Video track submenu
2625 	videotrack_menu = new QMenu(this);
2626 	videotrack_menu->menuAction()->setObjectName("videotrack_menu");
2627 
2628 #if USE_ADAPTER
2629 	// Screen submenu
2630 	screen_menu = new QMenu(this);
2631 	screen_menu->menuAction()->setObjectName("screen_menu");
2632 	screen_menu->addActions(screenGroup->actions());
2633 #endif
2634 
2635 	// Video size submenu
2636 	videosize_menu = new QMenu(this);
2637 	videosize_menu->menuAction()->setObjectName("videosize_menu");
2638 	videosize_menu->addActions(sizeGroup->actions());
2639 	videosize_menu->addSeparator();
2640 	videosize_menu->addAction(doubleSizeAct);
2641 
2642 	// Zoom submenu
2643 	zoom_menu = new QMenu(this);
2644 	zoom_menu->menuAction()->setObjectName("zoom_menu");
2645 	zoom_menu->addAction(resetZoomAct);
2646 	zoom_menu->addSeparator();
2647 	zoom_menu->addAction(autoZoomAct);
2648 	zoom_menu->addAction(autoZoom169Act);
2649 	zoom_menu->addAction(autoZoom235Act);
2650 	zoom_menu->addSeparator();
2651 	zoom_menu->addAction(decZoomAct);
2652 	zoom_menu->addAction(incZoomAct);
2653 	zoom_menu->addSeparator();
2654 	zoom_menu->addAction(moveLeftAct);
2655 	zoom_menu->addAction(moveRightAct);
2656 	zoom_menu->addAction(moveUpAct);
2657 	zoom_menu->addAction(moveDownAct);
2658 
2659 	// Aspect submenu
2660 	aspect_menu = new QMenu(this);
2661 	aspect_menu->menuAction()->setObjectName("aspect_menu");
2662 	aspect_menu->addActions(aspectGroup->actions());
2663 
2664 	// Deinterlace submenu
2665 	deinterlace_menu = new QMenu(this);
2666 	deinterlace_menu->menuAction()->setObjectName("deinterlace_menu");
2667 	deinterlace_menu->addActions(deinterlaceGroup->actions());
2668 
2669 	// Video filter submenu
2670 	videofilter_menu = new QMenu(this);
2671 	videofilter_menu->menuAction()->setObjectName("videofilter_menu");
2672 	videofilter_menu->addAction(postProcessingAct);
2673 	videofilter_menu->addAction(deblockAct);
2674 	videofilter_menu->addAction(deringAct);
2675 	videofilter_menu->addAction(gradfunAct);
2676 	videofilter_menu->addAction(addNoiseAct);
2677 	videofilter_menu->addAction(addLetterboxAct);
2678 	videofilter_menu->addAction(upscaleAct);
2679 	videofilter_menu->addAction(phaseAct);
2680 
2681 	// Denoise submenu
2682 	denoise_menu = new QMenu(this);
2683 	denoise_menu->menuAction()->setObjectName("denoise_menu");
2684 	denoise_menu->addActions(denoiseGroup->actions());
2685 	videofilter_menu->addMenu(denoise_menu);
2686 
2687 	// Unsharp submenu
2688 	unsharp_menu = new QMenu(this);
2689 	unsharp_menu->menuAction()->setObjectName("unsharp_menu");
2690 	unsharp_menu->addActions(unsharpGroup->actions());
2691 	videofilter_menu->addMenu(unsharp_menu);
2692 
2693 	// Rotate submenu
2694 	rotate_menu = new QMenu(this);
2695 	rotate_menu->menuAction()->setObjectName("rotate_menu");
2696 	rotate_menu->addActions(rotateGroup->actions());
2697 
2698 	// Ontop submenu
2699 	ontop_menu = new QMenu(this);
2700 	ontop_menu->menuAction()->setObjectName("ontop_menu");
2701 	ontop_menu->addActions(onTopActionGroup->actions());
2702 
2703 
2704 	// Audio track submenu
2705 	audiotrack_menu = new QMenu(this);
2706 	audiotrack_menu->menuAction()->setObjectName("audiotrack_menu");
2707 
2708 	// Audio filter submenu
2709 	audiofilter_menu = new QMenu(this);
2710 	audiofilter_menu->menuAction()->setObjectName("audiofilter_menu");
2711 	audiofilter_menu->addAction(extrastereoAct);
2712 	audiofilter_menu->addAction(karaokeAct);
2713 	#ifdef MPV_SUPPORT
2714 	audiofilter_menu->addAction(earwaxAct);
2715 	#endif
2716 	audiofilter_menu->addAction(volnormAct);
2717 
2718 	// Audio channels submenu
2719 	audiochannels_menu = new QMenu(this);
2720 	audiochannels_menu->menuAction()->setObjectName("audiochannels_menu");
2721 	audiochannels_menu->addActions(channelsGroup->actions());
2722 
2723 	// Stereo mode submenu
2724 	stereomode_menu = new QMenu(this);
2725 	stereomode_menu->menuAction()->setObjectName("stereomode_menu");
2726 	stereomode_menu->addActions(stereoGroup->actions());
2727 
2728 
2729 	// Subtitles track submenu
2730 	subtitles_track_menu = new QMenu(this);
2731 	subtitles_track_menu->menuAction()->setObjectName("subtitlestrack_menu");
2732 
2733 	// Subtitles secondary track submenu
2734 	#ifdef MPV_SUPPORT
2735 	secondary_subtitles_track_menu = new QMenu(this);
2736 	secondary_subtitles_track_menu->menuAction()->setObjectName("secondary_subtitles_track_menu");
2737 	#endif
2738 
2739 	// Subtitles fps submenu
2740 	subfps_menu = new QMenu(this);
2741 	subfps_menu->menuAction()->setObjectName("subfps_menu");
2742 	subfps_menu->addAction( subFPSNoneAct );
2743 	/* subfps_menu->addAction( subFPS23Act ); */
2744 	subfps_menu->addAction( subFPS23976Act );
2745 	subfps_menu->addAction( subFPS24Act );
2746 	subfps_menu->addAction( subFPS25Act );
2747 	subfps_menu->addAction( subFPS29970Act );
2748 	subfps_menu->addAction( subFPS30Act );
2749 
2750 	// Closed captions submenu
2751 	closed_captions_menu = new QMenu(this);
2752 	closed_captions_menu->menuAction()->setObjectName("closed_captions_menu");
2753 	closed_captions_menu->addAction( ccNoneAct);
2754 	closed_captions_menu->addAction( ccChannel1Act);
2755 	closed_captions_menu->addAction( ccChannel2Act);
2756 	closed_captions_menu->addAction( ccChannel3Act);
2757 	closed_captions_menu->addAction( ccChannel4Act);
2758 
2759 
2760 	// Titles submenu
2761 	titles_menu = new QMenu(this);
2762 	titles_menu->menuAction()->setObjectName("titles_menu");
2763 
2764 	// Chapters submenu
2765 	chapters_menu = new QMenu(this);
2766 	chapters_menu->menuAction()->setObjectName("chapters_menu");
2767 
2768 	// Angles submenu
2769 	angles_menu = new QMenu(this);
2770 	angles_menu->menuAction()->setObjectName("angles_menu");
2771 
2772 	// Bookmarks submenu
2773 	#ifdef BOOKMARKS
2774 	bookmark_menu = new QMenu(this);
2775 	bookmark_menu->menuAction()->setObjectName("bookmarks_menu");
2776 	#endif
2777 
2778 	// Program submenu
2779 	#if PROGRAM_SWITCH
2780 	programtrack_menu = new QMenu(this);
2781 	programtrack_menu->menuAction()->setObjectName("programtrack_menu");
2782 	#endif
2783 
2784 
2785 	// OSD submenu
2786 	osd_menu = new QMenu(this);
2787 	osd_menu->menuAction()->setObjectName("osd_menu");
2788 	osd_menu->addActions(osdGroup->actions());
2789 	osd_menu->addSeparator();
2790 	osd_menu->addAction(showMediaInfoAct);
2791 	osd_menu->addSeparator();
2792 	osd_menu->addAction(decOSDScaleAct);
2793 	osd_menu->addAction(incOSDScaleAct);
2794 #ifdef MPV_SUPPORT
2795 	osd_menu->addSeparator();
2796 	osd_menu->addAction(OSDFractionsAct);
2797 #endif
2798 
2799 	// Share submenu
2800 	#ifdef SHARE_MENU
2801 	share_menu = new QMenu(this);
2802 	share_menu->addAction(facebookAct);
2803 	share_menu->addAction(twitterAct);
2804 	share_menu->addAction(gmailAct);
2805 	share_menu->addAction(hotmailAct);
2806 	share_menu->addAction(yahooAct);
2807 	#endif
2808 
2809 	// MENUS
2810 	openMenu = menuBar()->addMenu("Open");
2811 	playMenu = menuBar()->addMenu("Play");
2812 	videoMenu = menuBar()->addMenu("Video");
2813 	audioMenu = menuBar()->addMenu("Audio");
2814 	subtitlesMenu = menuBar()->addMenu("Subtitles");
2815 	/* menuBar()->addMenu(favorites); */
2816 	browseMenu = menuBar()->addMenu("Browse");
2817 	viewMenu = menuBar()->addMenu("View");
2818 	optionsMenu = menuBar()->addMenu("Options");
2819 	helpMenu = menuBar()->addMenu("Help");
2820 
2821 	// POPUP MENU
2822 	if (!popup)
2823 		popup = new QMenu(this);
2824 	else
2825 		popup->clear();
2826 
2827 	popup->addMenu( openMenu );
2828 	popup->addMenu( playMenu );
2829 	popup->addMenu( videoMenu );
2830 	popup->addMenu( audioMenu );
2831 	popup->addMenu( subtitlesMenu );
2832 	popup->addMenu( favorites );
2833 	popup->addMenu( browseMenu );
2834 	popup->addMenu( viewMenu );
2835 	popup->addMenu( optionsMenu );
2836 
2837 	// Access menu
2838 	access_menu = new QMenu(this);
2839 	access_menu->menuAction()->setObjectName("quick_access_menu");
2840 
2841 	//populateMainMenu();
2842 
2843 	// let's show something, even a <empty> entry
2844 	initializeMenus();
2845 }
2846 
populateMainMenu()2847 void BaseGui::populateMainMenu() {
2848 	qDebug("BaseGui::populateMainMenu");
2849 
2850 	openMenu->clear();
2851 	playMenu->clear();
2852 	videoMenu->clear();
2853 	audioMenu->clear();
2854 	subtitlesMenu->clear();
2855 	browseMenu->clear();
2856 	viewMenu->clear();
2857 	optionsMenu->clear();
2858 	helpMenu->clear();
2859 
2860 	// OPEN MENU
2861 	openMenu->addAction(openFileAct);
2862 	openMenu->addMenu(recentfiles_menu);
2863 	openMenu->addMenu(favorites);
2864 	openMenu->addAction(openDirectoryAct);
2865 	openMenu->addAction(openPlaylistAct);
2866 	if (!pref->tablet_mode) {
2867 		openMenu->addMenu(disc_menu);
2868 	}
2869 	openMenu->addAction(openURLAct);
2870 #ifdef TV_SUPPORT
2871 	if (!pref->tablet_mode) {
2872 		openMenu->addMenu(tvlist);
2873 		openMenu->addMenu(radiolist);
2874 	}
2875 #endif
2876 	openMenu->addSeparator();
2877 	openMenu->addAction(exitAct);
2878 
2879 	// PLAY MENU
2880 	if (!pref->tablet_mode) {
2881 		playMenu->addAction(playAct);
2882 		playMenu->addAction(pauseAct);
2883 		/* playMenu->addAction(playOrPauseAct); */
2884 		playMenu->addAction(stopAct);
2885 	}
2886 	playMenu->addAction(frameStepAct);
2887 	playMenu->addAction(frameBackStepAct);
2888 	playMenu->addSeparator();
2889 	if (!pref->tablet_mode) {
2890 		playMenu->addAction(rewind1Act);
2891 		playMenu->addAction(forward1Act);
2892 	}
2893 	playMenu->addAction(rewind2Act);
2894 	playMenu->addAction(forward2Act);
2895 	playMenu->addAction(rewind3Act);
2896 	playMenu->addAction(forward3Act);
2897 	playMenu->addSeparator();
2898 	playMenu->addMenu(speed_menu);
2899 	playMenu->addSeparator();
2900 	if (!pref->tablet_mode) {
2901 		playMenu->addMenu(ab_menu);
2902 		playMenu->addSeparator();
2903 		playMenu->addAction(gotoAct);
2904 		playMenu->addSeparator();
2905 	}
2906 	playMenu->addAction(playPrevAct);
2907 	playMenu->addAction(playNextAct);
2908 
2909 	// VIDEO MENU
2910 	videoMenu->addMenu(videotrack_menu);
2911 	videoMenu->addAction(fullscreenAct);
2912 	if (!pref->tablet_mode) {
2913 		videoMenu->addAction(compactAct);
2914 		#if USE_ADAPTER
2915 		videoMenu->addMenu(screen_menu);
2916 		#endif
2917 	}
2918 	videoMenu->addMenu(videosize_menu);
2919 	videoMenu->addMenu(zoom_menu);
2920 	videoMenu->addMenu(aspect_menu);
2921 	videoMenu->addMenu(deinterlace_menu);
2922 	videoMenu->addMenu(videofilter_menu);
2923 	videoMenu->addMenu(rotate_menu);
2924 	videoMenu->addAction(flipAct);
2925 	videoMenu->addAction(mirrorAct);
2926 	if (!pref->tablet_mode) {
2927 		videoMenu->addAction(stereo3dAct);
2928 		videoMenu->addSeparator();
2929 	}
2930 	videoMenu->addAction(videoEqualizerAct);
2931 	videoMenu->addAction(screenshotAct);
2932 	if (!pref->tablet_mode) {
2933 		videoMenu->addAction(screenshotsAct);
2934 		videoMenu->addMenu(ontop_menu);
2935 	}
2936 	#ifdef VIDEOPREVIEW
2937 	videoMenu->addSeparator();
2938 	videoMenu->addAction(videoPreviewAct);
2939 	#endif
2940 
2941 	// AUDIO MENU
2942 	audioMenu->addMenu(audiotrack_menu);
2943 	audioMenu->addAction(loadAudioAct);
2944 	audioMenu->addAction(unloadAudioAct);
2945 	audioMenu->addMenu(audiofilter_menu);
2946 	if (!pref->tablet_mode) {
2947 		audioMenu->addMenu(audiochannels_menu);
2948 		audioMenu->addMenu(stereomode_menu);
2949 	}
2950 	audioMenu->addAction(audioEqualizerAct);
2951 	audioMenu->addSeparator();
2952 	if (!pref->tablet_mode) {
2953 		audioMenu->addAction(muteAct);
2954 		audioMenu->addSeparator();
2955 		audioMenu->addAction(decVolumeAct);
2956 		audioMenu->addAction(incVolumeAct);
2957 		audioMenu->addSeparator();
2958 	}
2959 	audioMenu->addAction(decAudioDelayAct);
2960 	audioMenu->addAction(incAudioDelayAct);
2961 	audioMenu->addAction(audioDelayAct);
2962 
2963 
2964 	// SUBTITLES MENU
2965 	subtitlesMenu->addMenu(subtitles_track_menu);
2966 	#ifdef MPV_SUPPORT
2967 	subtitlesMenu->addMenu(secondary_subtitles_track_menu);
2968 	#endif
2969 	subtitlesMenu->addSeparator();
2970 	subtitlesMenu->addAction(loadSubsAct);
2971 	subtitlesMenu->addAction(unloadSubsAct);
2972 	if (!pref->tablet_mode) {
2973 		subtitlesMenu->addMenu(subfps_menu);
2974 		subtitlesMenu->addSeparator();
2975 		subtitlesMenu->addMenu(closed_captions_menu);
2976 	}
2977 	subtitlesMenu->addSeparator();
2978 	subtitlesMenu->addAction(decSubDelayAct);
2979 	subtitlesMenu->addAction(incSubDelayAct);
2980 	subtitlesMenu->addAction(subDelayAct);
2981 	subtitlesMenu->addSeparator();
2982 	if (!pref->tablet_mode) {
2983 		subtitlesMenu->addAction(decSubPosAct);
2984 		subtitlesMenu->addAction(incSubPosAct);
2985 		subtitlesMenu->addSeparator();
2986 		subtitlesMenu->addAction(decSubScaleAct);
2987 		subtitlesMenu->addAction(incSubScaleAct);
2988 		subtitlesMenu->addSeparator();
2989 		subtitlesMenu->addAction(decSubStepAct);
2990 		subtitlesMenu->addAction(incSubStepAct);
2991 		#ifdef MPV_SUPPORT
2992 		subtitlesMenu->addSeparator();
2993 		subtitlesMenu->addAction(seekPrevSubAct);
2994 		subtitlesMenu->addAction(seekNextSubAct);
2995 		#endif
2996 		subtitlesMenu->addSeparator();
2997 		subtitlesMenu->addAction(useForcedSubsOnlyAct);
2998 		subtitlesMenu->addSeparator();
2999 	}
3000 	subtitlesMenu->addAction(subVisibilityAct);
3001 	subtitlesMenu->addSeparator();
3002 	subtitlesMenu->addAction(useCustomSubStyleAct);
3003 	#ifdef FIND_SUBTITLES
3004 	subtitlesMenu->addSeparator();
3005 	subtitlesMenu->addAction(showFindSubtitlesDialogAct);
3006 	if (!pref->tablet_mode) {
3007 		subtitlesMenu->addAction(openUploadSubtitlesPageAct);
3008 	}
3009 	#endif
3010 
3011 	// BROWSE MENU
3012 	if (!pref->tablet_mode) {
3013 		browseMenu->addMenu(titles_menu);
3014 	}
3015 	browseMenu->addMenu(chapters_menu);
3016 	if (!pref->tablet_mode) {
3017 		browseMenu->addMenu(angles_menu);
3018 	}
3019 	#ifdef BOOKMARKS
3020 	browseMenu->addMenu(bookmark_menu);
3021 	#endif
3022 	#if DVDNAV_SUPPORT
3023 	if (!pref->tablet_mode) {
3024 		browseMenu->addSeparator();
3025 		browseMenu->addAction(dvdnavMenuAct);
3026 		browseMenu->addAction(dvdnavPrevAct);
3027 	}
3028 	#endif
3029 	#if PROGRAM_SWITCH
3030 	if (!pref->tablet_mode) {
3031 		browseMenu->addSeparator();
3032 		browseMenu->addMenu(programtrack_menu);
3033 	}
3034 	#endif
3035 
3036 	// VIEW MENU
3037 	viewMenu->addAction(showPropertiesAct);
3038 	viewMenu->addAction(showPlaylistAct);
3039 	#ifdef YOUTUBE_SUPPORT
3040 	if (!pref->tablet_mode) {
3041 		viewMenu->addAction(showTubeBrowserAct);
3042 	}
3043 	#endif
3044 	viewMenu->addMenu(osd_menu);
3045 	#if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER)
3046 	if (!pref->tablet_mode) {
3047 		viewMenu->addSeparator()->setText(tr("Logs"));
3048 		#ifdef LOG_MPLAYER
3049 		viewMenu->addAction(showLogMplayerAct);
3050 		#endif
3051 		#ifdef LOG_SMPLAYER
3052 		viewMenu->addAction(showLogSmplayerAct);
3053 		#endif
3054 	}
3055 	#endif
3056 
3057 	// OPTIONS MENU
3058 	optionsMenu->addAction(showPreferencesAct);
3059 	optionsMenu->addAction(tabletModeAct);
3060 
3061 	// HELP MENU
3062 	#ifdef SHARE_MENU
3063 	if (!pref->tablet_mode) {
3064 		helpMenu->addMenu(share_menu);
3065 		helpMenu->addSeparator();
3066 	}
3067 	#endif
3068 	if (!pref->tablet_mode) {
3069 		helpMenu->addAction(showFirstStepsAct);
3070 		helpMenu->addAction(showFAQAct);
3071 		helpMenu->addAction(showCLOptionsAct);
3072 		helpMenu->addSeparator();
3073 	}
3074 	helpMenu->addAction(showCheckUpdatesAct);
3075 	#ifdef YT_CODEDOWNLOADER
3076 	helpMenu->addAction(updateYTAct);
3077 	#endif
3078 	helpMenu->addSeparator();
3079 	if (!pref->tablet_mode) {
3080 		helpMenu->addAction(showConfigAct);
3081 		helpMenu->addSeparator();
3082 	}
3083 	helpMenu->addAction(donateAct);
3084 	helpMenu->addSeparator();
3085 	helpMenu->addAction(aboutThisAct);
3086 
3087 	// Access menu
3088 	access_menu->clear();
3089 	access_menu->addAction(openFileAct);
3090 	access_menu->addAction(openURLAct);
3091 	access_menu->addMenu(recentfiles_menu);
3092 	access_menu->addMenu(favorites);
3093 	access_menu->addSeparator();
3094 	access_menu->addAction(playPrevAct);
3095 	access_menu->addAction(playNextAct);
3096 	access_menu->addSeparator();
3097 	access_menu->addMenu(audiotrack_menu);
3098 	access_menu->addMenu(subtitles_track_menu);
3099 	access_menu->addSeparator();
3100 	access_menu->addMenu(aspect_menu);
3101 	access_menu->addSeparator();
3102 	access_menu->addAction(showPlaylistAct);
3103 	access_menu->addAction(showPreferencesAct);
3104 	access_menu->addAction(tabletModeAct);
3105 }
3106 
3107 /*
3108 void BaseGui::closeEvent( QCloseEvent * e )  {
3109 	qDebug("BaseGui::closeEvent");
3110 
3111 	qDebug("mplayer_log_window: %d x %d", mplayer_log_window->width(), mplayer_log_window->height() );
3112 	qDebug("smplayer_log_window: %d x %d", smplayer_log_window->width(), smplayer_log_window->height() );
3113 
3114 	mplayer_log_window->close();
3115 	smplayer_log_window->close();
3116 	playlist->close();
3117 	equalizer->close();
3118 
3119 	core->stop();
3120 	e->accept();
3121 }
3122 */
3123 
3124 
closeWindow()3125 void BaseGui::closeWindow() {
3126 	qDebug("BaseGui::closeWindow");
3127 
3128 	if (core->state() != Core::Stopped) {
3129 		core->stop();
3130 	}
3131 
3132 	//qApp->quit();
3133 	emit quitSolicited();
3134 }
3135 
showPlaylist()3136 void BaseGui::showPlaylist() {
3137 	showPlaylist( !playlist->isVisible() );
3138 }
3139 
showPlaylist(bool b)3140 void BaseGui::showPlaylist(bool b) {
3141 	if ( !b ) {
3142 		playlist->hide();
3143 	} else {
3144 		exitFullscreenIfNeeded();
3145 		playlist->show();
3146 	}
3147 	//updateWidgets();
3148 }
3149 
showVideoEqualizer()3150 void BaseGui::showVideoEqualizer() {
3151 	showVideoEqualizer( !video_equalizer->isVisible() );
3152 }
3153 
showVideoEqualizer(bool b)3154 void BaseGui::showVideoEqualizer(bool b) {
3155 	if (!b) {
3156 		video_equalizer->hide();
3157 	} else {
3158 		// Exit fullscreen, otherwise dialog is not visible
3159 		exitFullscreenIfNeeded();
3160 		video_equalizer->show();
3161 	}
3162 	updateWidgets();
3163 }
3164 
showAudioEqualizer()3165 void BaseGui::showAudioEqualizer() {
3166 	showAudioEqualizer( !audio_equalizer->isVisible() );
3167 }
3168 
showAudioEqualizer(bool b)3169 void BaseGui::showAudioEqualizer(bool b) {
3170 	if (!b) {
3171 		audio_equalizer->hide();
3172 	} else {
3173 		// Exit fullscreen, otherwise dialog is not visible
3174 		exitFullscreenIfNeeded();
3175 		audio_equalizer->show();
3176 	}
3177 	updateWidgets();
3178 }
3179 
showPreferencesDialog()3180 void BaseGui::showPreferencesDialog() {
3181 	qDebug("BaseGui::showPreferencesDialog");
3182 
3183 	exitFullscreenIfNeeded();
3184 
3185 	if (!pref_dialog) {
3186 		createPreferencesDialog();
3187 	}
3188 
3189 	pref_dialog->setData(pref);
3190 
3191 	pref_dialog->mod_input()->actions_editor->clear();
3192 	pref_dialog->mod_input()->actions_editor->addActions(this);
3193 
3194 	if (playlist->isWindow()) { // No dockable
3195 		pref_dialog->mod_input()->actions_editor->addActions(playlist);
3196 	}
3197 
3198 	// Set playlist preferences
3199 	PrefPlaylist * pl = pref_dialog->mod_playlist();
3200 	pl->setDirectoryRecursion(playlist->directoryRecursion());
3201 	pl->setAutoGetInfo(playlist->autoGetInfo());
3202 	pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit());
3203 	pl->setPlayFilesFromStart(playlist->playFilesFromStart());
3204 	pl->setPlayOnLoad(playlist->startPlayOnLoad());
3205 	pl->setPlayNextAutomatically(playlist->automaticallyPlayNext());
3206 	pl->setIgnorePlayerErrors(playlist->ignorePlayerErrors());
3207 	pl->setAutoSort(playlist->autoSort());
3208 	pl->setFilterCaseSensitive(playlist->filterCaseSensitive());
3209 
3210 #ifdef PLAYLIST_DELETE_FROM_DISK
3211 	pl->allowDeleteFromDisk(playlist->isDeleteFromDiskAllowed());
3212 #endif
3213 
3214 	pref_dialog->show();
3215 }
3216 
3217 // The user has pressed OK in preferences dialog
applyNewPreferences()3218 void BaseGui::applyNewPreferences() {
3219 	qDebug("BaseGui::applyNewPreferences");
3220 
3221 	bool need_update_language = false;
3222 	bool need_apply_styles = false;
3223 
3224 	PlayerID::Player old_player_type = PlayerID::player(pref->mplayer_bin);
3225 
3226 	pref_dialog->getData(pref);
3227 
3228 	// Setup proxy
3229 	setupNetworkProxy();
3230 
3231 	PrefGeneral *_general = pref_dialog->mod_general();
3232 	if (_general->fileSettingsMethodChanged()) {
3233 		core->changeFileSettingsMethod(pref->file_settings_method);
3234 	}
3235 
3236 	PrefInterface *_interface = pref_dialog->mod_interface();
3237 	if (_interface->recentsChanged()) {
3238 		updateRecents();
3239 	}
3240 	if (_interface->languageChanged()) need_update_language = true;
3241 
3242 	if (_interface->iconsetChanged()) {
3243 		need_update_language = true;
3244 		// Stylesheet
3245 		#if ALLOW_CHANGE_STYLESHEET
3246 		if (!_interface->guiChanged()) need_apply_styles = true;
3247 		#endif
3248 	}
3249 
3250 	if (_interface->fontChanged()) need_apply_styles = true;
3251 
3252 	MyFileDialog::setNative(pref->use_native_open_dialog);
3253 
3254 #ifndef MOUSE_GESTURES
3255 	mplayerwindow->activateMouseDragTracking(pref->drag_function == Preferences::MoveWindow);
3256 #endif
3257 	mplayerwindow->delayLeftClick(pref->delay_left_click);
3258 
3259 #if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
3260 	if (pref->hide_video_window_on_audio_files) {
3261 		connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
3262 		disconnect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(hideLogo()) );
3263 	} else {
3264 		disconnect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
3265 		connect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(showLogo()) );
3266 		if (!panel->isVisible()) {
3267 			resize( width(), height() + 200);
3268 			panel->show();
3269 		}
3270 	}
3271 #endif
3272 
3273 	PrefAdvanced *advanced = pref_dialog->mod_advanced();
3274 #if REPAINT_BACKGROUND_OPTION
3275 	if (advanced->repaintVideoBackgroundChanged()) {
3276 		mplayerwindow->setRepaintBackground(pref->repaint_video_background);
3277 	}
3278 #endif
3279 #if USE_COLORKEY
3280 	if (advanced->colorkeyChanged()) {
3281 		mplayerwindow->setColorKey( pref->color_key );
3282 	}
3283 #endif
3284 	if (advanced->monitorAspectChanged()) {
3285 		mplayerwindow->setMonitorAspect( pref->monitor_aspect_double() );
3286 	}
3287 #if ALLOW_DEMUXER_CODEC_CHANGE
3288 	if (advanced->lavfDemuxerChanged()) {
3289 		core->mset.forced_demuxer = pref->use_lavf_demuxer ? "lavf" : "";
3290 	}
3291 #endif
3292 
3293 	// Update playlist preferences
3294 	PrefPlaylist * pl = pref_dialog->mod_playlist();
3295 	playlist->setDirectoryRecursion(pl->directoryRecursion());
3296 	playlist->setAutoGetInfo(pl->autoGetInfo());
3297 	playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit());
3298 	playlist->setPlayFilesFromStart(pl->playFilesFromStart());
3299 	playlist->setStartPlayOnLoad(pl->playOnLoad());
3300 	playlist->setAutomaticallyPlayNext(pl->playNextAutomatically());
3301 	playlist->setIgnorePlayerErrors(pl->ignorePlayerErrors());
3302 	playlist->setAutoSort(pl->autoSort());
3303 	playlist->setFilterCaseSensitive(pl->filterCaseSensitive());
3304 
3305 #ifdef PLAYLIST_DELETE_FROM_DISK
3306 	playlist->allowDeleteFromDisk(pl->isDeleteFromDiskAllowed());
3307 #endif
3308 
3309 #ifdef PLAYLIST_DOWNLOAD
3310 	playlist->setMaxItemsUrlHistory( pref->history_urls->maxItems() );
3311 #endif
3312 
3313 	if (need_update_language) {
3314 		translator->load(pref->language);
3315 	}
3316 
3317 	setJumpTexts(); // Update texts in menus
3318 	updateWidgets(); // Update the screenshot action
3319 
3320 #if STYLE_SWITCHING
3321 	if (_interface->styleChanged()) {
3322 		need_apply_styles = true;
3323 	}
3324 #endif
3325 
3326 	if (need_apply_styles) applyStyles();
3327 
3328 	// Restart the video if needed
3329 	if (pref_dialog->requiresRestart())
3330 		core->restart();
3331 
3332 	// Update actions
3333 	pref_dialog->mod_input()->actions_editor->applyChanges();
3334 	saveActions();
3335 
3336 	pref->save();
3337 
3338 	emit preferencesChanged();
3339 
3340 	bool need_restart_gui = (_interface->guiChanged() || pl->dockableChanged() ||
3341                              old_player_type != PlayerID::player(pref->mplayer_bin));
3342 	qDebug() << "BaseGui::applyNewPreferences: need_restart_gui:" << need_restart_gui;
3343 
3344 	if (need_restart_gui) {
3345 		#ifdef GUI_CHANGE_ON_RUNTIME
3346 		if (core->state() != Core::Stopped) core->stop();
3347 		emit guiChanged(pref->gui);
3348 		#else
3349 		QMessageBox::information(this, tr("Information"),
3350 			tr("You need to restart SMPlayer in order to apply the new preferences.") );
3351 		#endif
3352 	}
3353 }
3354 
3355 
showFilePropertiesDialog()3356 void BaseGui::showFilePropertiesDialog() {
3357 	qDebug("BaseGui::showFilePropertiesDialog");
3358 
3359 	exitFullscreenIfNeeded();
3360 
3361 	if (!file_dialog) {
3362 		createFilePropertiesDialog();
3363 	}
3364 
3365 	setDataToFileProperties();
3366 
3367 	file_dialog->show();
3368 }
3369 
setDataToFileProperties()3370 void BaseGui::setDataToFileProperties() {
3371 #if ALLOW_DEMUXER_CODEC_CHANGE
3372 	InfoReader *i = InfoReader::obj();
3373 	i->getInfo();
3374 	file_dialog->setCodecs( i->vcList(), i->acList(), i->demuxerList() );
3375 
3376 	// Save a copy of the original values
3377 	if (core->mset.original_demuxer.isEmpty())
3378 		core->mset.original_demuxer = core->mdat.demuxer;
3379 
3380 	if (core->mset.original_video_codec.isEmpty())
3381 		core->mset.original_video_codec = core->mdat.video_codec;
3382 
3383 	if (core->mset.original_audio_codec.isEmpty())
3384 		core->mset.original_audio_codec = core->mdat.audio_codec;
3385 
3386 	QString demuxer = core->mset.forced_demuxer;
3387 	if (demuxer.isEmpty()) demuxer = core->mdat.demuxer;
3388 
3389 	QString ac = core->mset.forced_audio_codec;
3390 	if (ac.isEmpty()) ac = core->mdat.audio_codec;
3391 
3392 	QString vc = core->mset.forced_video_codec;
3393 	if (vc.isEmpty()) vc = core->mdat.video_codec;
3394 
3395 	file_dialog->setDemuxer(demuxer, core->mset.original_demuxer);
3396 	file_dialog->setAudioCodec(ac, core->mset.original_audio_codec);
3397 	file_dialog->setVideoCodec(vc, core->mset.original_video_codec);
3398 #endif
3399 
3400 	file_dialog->setMplayerAdditionalArguments( core->mset.mplayer_additional_options );
3401 	file_dialog->setMplayerAdditionalVideoFilters( core->mset.mplayer_additional_video_filters );
3402 	file_dialog->setMplayerAdditionalAudioFilters( core->mset.mplayer_additional_audio_filters );
3403 
3404 	file_dialog->setMediaData( core->mdat, core->mset.videos, core->mset.audios, core->mset.subs);
3405 }
3406 
applyFileProperties()3407 void BaseGui::applyFileProperties() {
3408 	qDebug("BaseGui::applyFileProperties");
3409 
3410 	bool need_restart = false;
3411 
3412 #undef TEST_AND_SET
3413 #define TEST_AND_SET( Pref, Dialog ) \
3414 	if ( Pref != Dialog ) { Pref = Dialog; need_restart = true; }
3415 
3416 #if ALLOW_DEMUXER_CODEC_CHANGE
3417 	bool demuxer_changed = false;
3418 
3419 	QString prev_demuxer = core->mset.forced_demuxer;
3420 
3421 	QString demuxer = file_dialog->demuxer();
3422 	if (demuxer == core->mset.original_demuxer) demuxer="";
3423 	TEST_AND_SET(core->mset.forced_demuxer, demuxer);
3424 
3425 	if (prev_demuxer != core->mset.forced_demuxer) {
3426 		// Demuxer changed
3427 		demuxer_changed = true;
3428 		core->mset.current_audio_id = MediaSettings::NoneSelected;
3429 		core->mset.current_subtitle_track = MediaSettings::NoneSelected;
3430 	}
3431 
3432 	QString ac = file_dialog->audioCodec();
3433 	if (ac == core->mset.original_audio_codec) ac="";
3434 	TEST_AND_SET(core->mset.forced_audio_codec, ac);
3435 
3436 	QString vc = file_dialog->videoCodec();
3437 	if (vc == core->mset.original_video_codec) vc="";
3438 	TEST_AND_SET(core->mset.forced_video_codec, vc);
3439 #endif
3440 
3441 	TEST_AND_SET(core->mset.mplayer_additional_options, file_dialog->mplayerAdditionalArguments());
3442 	TEST_AND_SET(core->mset.mplayer_additional_video_filters, file_dialog->mplayerAdditionalVideoFilters());
3443 	TEST_AND_SET(core->mset.mplayer_additional_audio_filters, file_dialog->mplayerAdditionalAudioFilters());
3444 
3445 #if ALLOW_DEMUXER_CODEC_CHANGE
3446 	// Restart the video to apply
3447 	if (need_restart) {
3448 		if (demuxer_changed) {
3449 			core->reload();
3450 		} else {
3451 			core->restart();
3452 		}
3453 	}
3454 #endif
3455 }
3456 
3457 
updateMediaInfo()3458 void BaseGui::updateMediaInfo() {
3459 	qDebug("BaseGui::updateMediaInfo");
3460 
3461 	if (file_dialog) {
3462 		if (file_dialog->isVisible()) setDataToFileProperties();
3463 	}
3464 
3465 	setWindowCaption( core->mdat.displayName(pref->show_tag_in_window_title) + " - SMPlayer" );
3466 
3467 	emit videoInfoChanged(core->mdat.video_width, core->mdat.video_height, core->mdat.video_fps.toDouble());
3468 }
3469 
newMediaLoaded()3470 void BaseGui::newMediaLoaded() {
3471 	qDebug("BaseGui::newMediaLoaded");
3472 
3473 	QString stream_title = core->mdat.stream_title;
3474 	qDebug("BaseGui::newMediaLoaded: mdat.stream_title: %s", stream_title.toUtf8().constData());
3475 
3476 	if (!stream_title.isEmpty()) {
3477 		pref->history_recents->addItem( core->mdat.filename, stream_title );
3478 		//pref->history_recents->list();
3479 	} else {
3480 		pref->history_recents->addItem( core->mdat.filename );
3481 	}
3482 	updateRecents();
3483 
3484 	// If a VCD, Audio CD or DVD, add items to playlist
3485 	bool is_disc = ( (core->mdat.type == TYPE_VCD) || (core->mdat.type == TYPE_DVD) || (core->mdat.type == TYPE_AUDIO_CD) );
3486 #if DVDNAV_SUPPORT
3487 	// Don't add the list of titles if using dvdnav
3488 	if ((core->mdat.type == TYPE_DVD) && (core->mdat.filename.startsWith("dvdnav:"))) is_disc = false;
3489 #endif
3490 	if (pref->auto_add_to_playlist && is_disc)
3491 	{
3492 		int first_title = 1;
3493 		if (core->mdat.type == TYPE_VCD) first_title = pref->vcd_initial_title;
3494 
3495 		QString type = "dvd"; // FIXME: support dvdnav
3496 		if (core->mdat.type == TYPE_VCD) type="vcd";
3497 		else
3498 		if (core->mdat.type == TYPE_AUDIO_CD) type="cdda";
3499 
3500 		if (core->mset.current_title_id == first_title) {
3501 			playlist->clear();
3502 			QStringList l;
3503 			QString s;
3504 			QString folder;
3505 			if (core->mdat.type == TYPE_DVD) {
3506 				DiscData disc_data = DiscName::split(core->mdat.filename);
3507 				folder = disc_data.device;
3508 			}
3509 			for (int n=0; n < core->mdat.titles.numItems(); n++) {
3510 				s = type + "://" + QString::number(core->mdat.titles.itemAt(n).ID());
3511 				if ( !folder.isEmpty() ) {
3512 					s += "/" + folder; // FIXME: dvd names are not created as they should
3513 				}
3514 				l.append(s);
3515 			}
3516 			playlist->addFiles(l);
3517 			//playlist->setModified(false); // Not a real playlist
3518 		}
3519 	} /*else {
3520 		playlist->clear();
3521 		playlist->addCurrentFile();
3522 	}*/
3523 
3524 	// Automatically add files to playlist
3525 	if ((core->mdat.type == TYPE_FILE) && (pref->auto_add_to_playlist)) {
3526 		//qDebug("BaseGui::newMediaLoaded: playlist count: %d", playlist->count());
3527 		QStringList files_to_add;
3528 		if (playlist->count() == 1) {
3529 			files_to_add = Helper::filesForPlaylist(core->mdat.filename, pref->media_to_add_to_playlist);
3530 		}
3531 		if (!files_to_add.empty()) playlist->addFiles(files_to_add);
3532 	}
3533 }
3534 
gotNoFileToPlay()3535 void BaseGui::gotNoFileToPlay() {
3536 	//qDebug("BaseGui::gotNoFileToPlay");
3537 	playlist->resumePlay();
3538 }
3539 
3540 #ifdef LOG_MPLAYER
clearMplayerLog()3541 void BaseGui::clearMplayerLog() {
3542 	mplayer_log.clear();
3543 	if (mplayer_log_window->isVisible()) mplayer_log_window->clear();
3544 }
3545 
recordMplayerLog(QString line)3546 void BaseGui::recordMplayerLog(QString line) {
3547 	if (pref->log_mplayer) {
3548 		if ( (line.indexOf("A:")==-1) && (line.indexOf("V:")==-1) ) {
3549 			line.append("\n");
3550 			mplayer_log.append(line);
3551 			if (mplayer_log_window->isVisible()) mplayer_log_window->appendText(line);
3552 		}
3553 	}
3554 }
3555 
3556 /*!
3557 	Save the mplayer log to a file, so it can be used by external
3558 	applications.
3559 */
autosaveMplayerLog()3560 void BaseGui::autosaveMplayerLog() {
3561 	qDebug("BaseGui::autosaveMplayerLog");
3562 
3563 	if (pref->autosave_mplayer_log) {
3564 		if (!pref->mplayer_log_saveto.isEmpty()) {
3565 			QFile file( pref->mplayer_log_saveto );
3566 			if ( file.open( QIODevice::WriteOnly ) ) {
3567 				QTextStream strm( &file );
3568 				strm << mplayer_log;
3569 				file.close();
3570 			}
3571 		}
3572 	}
3573 }
3574 
showMplayerLog()3575 void BaseGui::showMplayerLog() {
3576 	qDebug("BaseGui::showMplayerLog");
3577 
3578 	exitFullscreenIfNeeded();
3579 
3580 	mplayer_log_window->setText( mplayer_log );
3581 	mplayer_log_window->show();
3582 }
3583 #endif
3584 
3585 #ifdef LOG_SMPLAYER
recordSmplayerLog(QString line)3586 void BaseGui::recordSmplayerLog(QString line) {
3587 	if (pref->log_smplayer) {
3588 		line.append("\n");
3589 		smplayer_log.append(line);
3590 		if (smplayer_log_window->isVisible()) smplayer_log_window->appendText(line);
3591 	}
3592 }
3593 
showLog()3594 void BaseGui::showLog() {
3595 	qDebug("BaseGui::showLog");
3596 
3597 	exitFullscreenIfNeeded();
3598 
3599 	smplayer_log_window->setText( smplayer_log );
3600 	smplayer_log_window->show();
3601 }
3602 #endif
3603 
3604 
initializeMenus()3605 void BaseGui::initializeMenus() {
3606 	qDebug("BaseGui::initializeMenus");
3607 
3608 #define EMPTY 1
3609 
3610 	int n;
3611 
3612 	// Subtitles
3613 	subtitleTrackGroup->clear(true);
3614 	QAction * subNoneAct = subtitleTrackGroup->addAction( tr("&None") );
3615 	subNoneAct->setData(MediaSettings::SubNone);
3616 	subNoneAct->setCheckable(true);
3617 	for (n=0; n < core->mset.subs.numItems(); n++) {
3618 		QAction *a = new QAction(subtitleTrackGroup);
3619 		a->setCheckable(true);
3620 		a->setText(core->mset.subs.itemAt(n).displayName());
3621 		a->setData(n);
3622 	}
3623 	subtitles_track_menu->addActions( subtitleTrackGroup->actions() );
3624 
3625 #ifdef MPV_SUPPORT
3626 	// Secondary Subtitles
3627 	secondarySubtitleTrackGroup->clear(true);
3628 	QAction * subSecNoneAct = secondarySubtitleTrackGroup->addAction( tr("&None") );
3629 	subSecNoneAct->setData(MediaSettings::SubNone);
3630 	subSecNoneAct->setCheckable(true);
3631 	for (n=0; n < core->mset.subs.numItems(); n++) {
3632 		QAction *a = new QAction(secondarySubtitleTrackGroup);
3633 		a->setCheckable(true);
3634 		a->setText(core->mset.subs.itemAt(n).displayName());
3635 		a->setData(n);
3636 	}
3637 	secondary_subtitles_track_menu->addActions( secondarySubtitleTrackGroup->actions() );
3638 #endif
3639 
3640 	// Audio
3641 	audioTrackGroup->clear(true);
3642 	// If using an external audio file, show the file in the menu, but disabled.
3643 	if (!core->mset.external_audio.isEmpty()) {
3644 		QAction * a = audioTrackGroup->addAction( QFileInfo(core->mset.external_audio).fileName() );
3645 		a->setEnabled(false);
3646 		a->setCheckable(true);
3647 		a->setChecked(true);
3648 	}
3649 	else
3650 	if (core->mset.audios.numItems()==0) {
3651 		QAction * a = audioTrackGroup->addAction( tr("<empty>") );
3652 		a->setEnabled(false);
3653 	} else {
3654 		for (n=0; n < core->mset.audios.numItems(); n++) {
3655 			QAction *a = new QAction(audioTrackGroup);
3656 			a->setCheckable(true);
3657 			a->setText(core->mset.audios.itemAt(n).displayName());
3658 			a->setData(core->mset.audios.itemAt(n).ID());
3659 		}
3660 	}
3661 	audiotrack_menu->addActions( audioTrackGroup->actions() );
3662 
3663 #if PROGRAM_SWITCH
3664 	// Program
3665 	programTrackGroup->clear(true);
3666 	if (core->mdat.programs.numItems()==0) {
3667 		QAction * a = programTrackGroup->addAction( tr("<empty>") );
3668 		a->setEnabled(false);
3669 	} else {
3670 		for (n=0; n < core->mdat.programs.numItems(); n++) {
3671 			QAction *a = new QAction(programTrackGroup);
3672 			a->setCheckable(true);
3673 			a->setText(core->mdat.programs.itemAt(n).displayName());
3674 			a->setData(core->mdat.programs.itemAt(n).ID());
3675 		}
3676 	}
3677 	programtrack_menu->addActions( programTrackGroup->actions() );
3678 #endif
3679 
3680 	// Video
3681 	videoTrackGroup->clear(true);
3682 	if (core->mset.videos.numItems()==0) {
3683 		QAction * a = videoTrackGroup->addAction( tr("<empty>") );
3684 		a->setEnabled(false);
3685 	} else {
3686 		for (n=0; n < core->mset.videos.numItems(); n++) {
3687 			QAction *a = new QAction(videoTrackGroup);
3688 			a->setCheckable(true);
3689 			a->setText(core->mset.videos.itemAt(n).displayName());
3690 			a->setData(core->mset.videos.itemAt(n).ID());
3691 		}
3692 	}
3693 	videotrack_menu->addActions( videoTrackGroup->actions() );
3694 
3695 	// Titles
3696 	titleGroup->clear(true);
3697 	if (core->mdat.titles.numItems()==0) {
3698 		QAction * a = titleGroup->addAction( tr("<empty>") );
3699 		a->setEnabled(false);
3700 	} else {
3701 		for (n=0; n < core->mdat.titles.numItems(); n++) {
3702 			QAction *a = new QAction(titleGroup);
3703 			a->setCheckable(true);
3704 			a->setText(core->mdat.titles.itemAt(n).displayName());
3705 			a->setData(core->mdat.titles.itemAt(n).ID());
3706 		}
3707 	}
3708 	titles_menu->addActions( titleGroup->actions() );
3709 
3710 	// Chapters
3711 	chapterGroup->clear(true);
3712 	//qDebug("BaseGui::initializeMenus: mdat.chapters.numItems: %d", core->mdat.chapters.numItems());
3713 	if (core->mdat.chapters.numItems() > 0) {
3714 		for (n=0; n < core->mdat.chapters.numItems(); n++) {
3715 			QAction *a = new QAction(chapterGroup);
3716 			//a->setCheckable(true);
3717 			//qDebug("BaseGui::initializeMenus: chapter %d name: %s", n, core->mdat.chapters.itemAt(n).name().toUtf8().constData());
3718 			a->setText(core->mdat.chapters.itemAt(n).name());
3719 			a->setData(core->mdat.chapters.itemAt(n).ID());
3720 		}
3721 	}
3722 	else
3723 	if (core->mdat.n_chapters > 0) {
3724 		for (n=0; n < core->mdat.n_chapters; n++) {
3725 			QAction *a = new QAction(chapterGroup);
3726 			//a->setCheckable(true);
3727 			a->setText( QString::number(n+1) );
3728 			a->setData( n + Core::firstChapter() );
3729 		}
3730 	}
3731 	else {
3732 		QAction * a = chapterGroup->addAction( tr("<empty>") );
3733 		a->setEnabled(false);
3734 	}
3735 	chapters_menu->addActions( chapterGroup->actions() );
3736 
3737 	// Angles
3738 	angleGroup->clear(true);
3739 	int n_angles = 0;
3740 	if (core->mset.current_angle_id > 0) {
3741 		int i = core->mdat.titles.find(core->mset.current_angle_id);
3742 		if (i > -1) n_angles = core->mdat.titles.itemAt(i).angles();
3743 	}
3744 	if (n_angles > 0) {
3745 		for (n=1; n <= n_angles; n++) {
3746 			QAction *a = new QAction(angleGroup);
3747 			a->setCheckable(true);
3748 			a->setText( QString::number(n) );
3749 			a->setData( n );
3750 		}
3751 	} else {
3752 		QAction * a = angleGroup->addAction( tr("<empty>") );
3753 		a->setEnabled(false);
3754 	}
3755 	angles_menu->addActions( angleGroup->actions() );
3756 
3757 #ifdef BOOKMARKS
3758 	updateBookmarks();
3759 #endif
3760 }
3761 
3762 #ifdef BOOKMARKS
updateBookmarks()3763 void BaseGui::updateBookmarks() {
3764 	qDebug("BaseGui::updateBookmarks");
3765 
3766 	// Bookmarks
3767 	bookmarkGroup->clear(true);
3768 	int n_bookmarks = core->mset.bookmarks.size();
3769 	if (n_bookmarks > 0) {
3770 		QMap<int, QString>::const_iterator i = core->mset.bookmarks.constBegin();
3771 		while (i != core->mset.bookmarks.constEnd()) {
3772 			QString name = i.value();
3773 			int time = i.key();
3774 			QAction *a = new QAction(bookmarkGroup);
3775 			QString text;
3776 			if (name.isEmpty()) {
3777 				text = Helper::formatTime(time);
3778 			} else {
3779 				text = QString("%1 (%2)").arg(name).arg(Helper::formatTime(time));
3780 			}
3781 			a->setCheckable(false);
3782 			a->setText(text);
3783 			a->setData(time);
3784 			i++;
3785 		}
3786 	}
3787 	bookmark_menu->clear();
3788 	bookmark_menu->addAction(addBookmarkAct);
3789 	bookmark_menu->addAction(editBookmarksAct);
3790 	bookmark_menu->addSeparator();
3791 	bookmark_menu->addActions(bookmarkGroup->actions());
3792 }
3793 #endif
3794 
updateRecents()3795 void BaseGui::updateRecents() {
3796 	qDebug("BaseGui::updateRecents");
3797 
3798 	recentfiles_menu->clear();
3799 
3800 	int current_items = 0;
3801 
3802 	if (pref->history_recents->count() > 0) {
3803 		for (int n=0; n < pref->history_recents->count(); n++) {
3804 			QString i = QString::number( n+1 );
3805 			QString fullname = pref->history_recents->item(n);
3806 			QString filename = fullname;
3807 			QFileInfo fi(fullname);
3808 			//if (fi.exists()) filename = fi.fileName(); // Can be slow
3809 
3810 			// Let's see if it looks like a file (no dvd://1 or something)
3811 			if (fullname.indexOf(QRegExp("^.*://.*")) == -1) filename = fi.fileName();
3812 
3813 			if (filename.size() > 85) {
3814 				filename = filename.left(80) + "...";
3815 			}
3816 
3817 			QString show_name = filename;
3818 			QString title = pref->history_recents->title(n);
3819 			if (!title.isEmpty()) show_name = title;
3820 
3821 			QAction * a = recentfiles_menu->addAction( QString("%1. " + show_name ).arg( i.insert( i.size()-1, '&' ), 3, ' ' ));
3822 			a->setStatusTip(fullname);
3823 			a->setData(n);
3824 			connect(a, SIGNAL(triggered()), this, SLOT(openRecent()));
3825 			current_items++;
3826 		}
3827 	} else {
3828 		QAction * a = recentfiles_menu->addAction( tr("<empty>") );
3829 		a->setEnabled(false);
3830 	}
3831 
3832 	recentfiles_menu->menuAction()->setVisible( current_items > 0 );
3833 	if (current_items  > 0) {
3834 		recentfiles_menu->addSeparator();
3835 		recentfiles_menu->addAction( clearRecentsAct );
3836 	}
3837 }
3838 
clearRecentsList()3839 void BaseGui::clearRecentsList() {
3840 	int ret = QMessageBox::question(this, tr("Confirm deletion - SMPlayer"),
3841 				tr("Delete the list of recent files?"),
3842 				QMessageBox::Cancel, QMessageBox::Ok);
3843 
3844 	if (ret == QMessageBox::Ok) {
3845 		// Delete items in menu
3846 		pref->history_recents->clear();
3847 		updateRecents();
3848 	}
3849 }
3850 
updateWidgets()3851 void BaseGui::updateWidgets() {
3852 	qDebug("BaseGui::updateWidgets");
3853 
3854 	// Subtitles menu
3855 	subtitleTrackGroup->setChecked( core->mset.current_subtitle_track );
3856 
3857 #ifdef MPV_SUPPORT
3858 	// Secondary subtitles menu
3859 	secondarySubtitleTrackGroup->setChecked( core->mset.current_secondary_subtitle_track );
3860 #endif
3861 
3862 	// Disable the unload subs action if there's no external subtitles
3863 	unloadSubsAct->setEnabled( !core->mset.external_subtitles.isEmpty() );
3864 
3865 	subFPSGroup->setEnabled( !core->mset.external_subtitles.isEmpty() );
3866 
3867 	// Closed caption menu
3868 	ccGroup->setChecked( core->mset.closed_caption_channel );
3869 
3870 	// Subfps menu
3871 	subFPSGroup->setChecked( core->mset.external_subtitles_fps );
3872 
3873 	// Audio menu
3874 	audioTrackGroup->setChecked( core->mset.current_audio_id );
3875 	channelsGroup->setChecked( core->mset.audio_use_channels );
3876 	stereoGroup->setChecked( core->mset.stereo_mode );
3877 	// Disable the unload audio file action if there's no external audio file
3878 	unloadAudioAct->setEnabled( !core->mset.external_audio.isEmpty() );
3879 
3880 #if PROGRAM_SWITCH
3881 	// Program menu
3882 	programTrackGroup->setChecked( core->mset.current_program_id );
3883 #endif
3884 
3885 	// Video menu
3886 	videoTrackGroup->setChecked( core->mset.current_video_id );
3887 
3888 	// Aspect ratio
3889 	aspectGroup->setChecked( core->mset.aspect_ratio_id );
3890 
3891 	// Rotate
3892 	rotateGroup->setChecked( core->mset.rotate );
3893 
3894 #if USE_ADAPTER
3895 	screenGroup->setChecked( pref->adapter );
3896 #endif
3897 
3898 	// OSD
3899 	osdGroup->setChecked( pref->osd );
3900 
3901 #ifdef MPV_SUPPORT
3902 	OSDFractionsAct->setChecked(pref->osd_fractions);
3903 #endif
3904 
3905 	// Titles
3906 	titleGroup->setChecked( core->mset.current_title_id );
3907 
3908 	// Angles
3909 	angleGroup->setChecked( core->mset.current_angle_id );
3910 
3911 	// Deinterlace menu
3912 	deinterlaceGroup->setChecked( core->mset.current_deinterlacer );
3913 
3914 	// Video size menu
3915 	sizeGroup->setChecked( pref->size_factor );
3916 
3917 	// Auto phase
3918 	phaseAct->setChecked( core->mset.phase_filter );
3919 
3920 	// Deblock
3921 	deblockAct->setChecked( core->mset.deblock_filter );
3922 
3923 	// Dering
3924 	deringAct->setChecked( core->mset.dering_filter );
3925 
3926 	// Gradfun
3927 	gradfunAct->setChecked( core->mset.gradfun_filter );
3928 
3929 	// Add noise
3930 	addNoiseAct->setChecked( core->mset.noise_filter );
3931 
3932 	// Letterbox
3933 	addLetterboxAct->setChecked( core->mset.add_letterbox );
3934 
3935 	// Upscaling
3936 	upscaleAct->setChecked( core->mset.upscaling_filter );
3937 
3938 
3939 	// Postprocessing
3940 	postProcessingAct->setChecked( core->mset.postprocessing_filter );
3941 
3942 	// Denoise submenu
3943 	denoiseGroup->setChecked( core->mset.current_denoiser );
3944 
3945 	// Unsharp submenu
3946 	unsharpGroup->setChecked( core->mset.current_unsharp );
3947 
3948 	/*
3949 	// Fullscreen button
3950 	fullscreenbutton->setOn(pref->fullscreen);
3951 
3952 	// Mute button
3953 	mutebutton->setOn(core->mset.mute);
3954 	if (core->mset.mute)
3955 		mutebutton->setPixmap( Images::icon("mute_small") );
3956 	else
3957 		mutebutton->setPixmap( Images::icon("volume_small") );
3958 
3959 	// Volume slider
3960 	volumeslider->setValue( core->mset.volume );
3961 	*/
3962 
3963 	// Mute menu option
3964 	muteAct->setChecked( (pref->global_volume ? pref->mute : core->mset.mute) );
3965 
3966 	// Karaoke menu option
3967 	karaokeAct->setChecked( core->mset.karaoke_filter );
3968 
3969 	// Extrastereo menu option
3970 	extrastereoAct->setChecked( core->mset.extrastereo_filter );
3971 
3972 	// Volnorm menu option
3973 	volnormAct->setChecked( core->mset.volnorm_filter );
3974 
3975 #ifdef MPV_SUPPORT
3976 	// Earwax menu option
3977 	earwaxAct->setChecked( core->mset.earwax_filter );
3978 #endif
3979 
3980 	// Repeat menu option
3981 	repeatAct->setChecked( core->mset.loop );
3982 
3983 	// Fullscreen action
3984 	fullscreenAct->setChecked( pref->fullscreen );
3985 
3986 	// Time slider
3987 	if (core->state()==Core::Stopped) {
3988 		//FIXME
3989 		//timeslider->setValue( (int) core->mset.current_sec );
3990 	}
3991 
3992 	// Video equalizer
3993 	videoEqualizerAct->setChecked( video_equalizer->isVisible() );
3994 	video_equalizer->setBySoftware( pref->use_soft_video_eq );
3995 
3996 	// Audio equalizer
3997 	audioEqualizerAct->setChecked( audio_equalizer->isVisible() );
3998 
3999 	// Playlist
4000 	if (!playlist->isWindow()) { // Dockable
4001 		showPlaylistAct->setChecked( playlist->isVisible() );
4002 	}
4003 
4004 	// Compact mode
4005 	compactAct->setChecked( pref->compact_mode );
4006 
4007 	// Stay on top
4008 	onTopActionGroup->setChecked( (int) pref->stay_on_top );
4009 
4010 	// Flip
4011 	flipAct->setChecked( core->mset.flip );
4012 
4013 	// Mirror
4014 	mirrorAct->setChecked( core->mset.mirror );
4015 
4016 	// Use custom style
4017 	useCustomSubStyleAct->setChecked( pref->enable_ass_styles );
4018 
4019 	// Forced subs
4020 	useForcedSubsOnlyAct->setChecked( pref->use_forced_subs_only );
4021 
4022 	// Subtitle visibility
4023 	subVisibilityAct->setChecked(pref->sub_visibility);
4024 
4025 	// Enable or disable subtitle options
4026 	bool e = ((core->mset.current_subtitle_track != MediaSettings::SubNone) &&
4027               (core->mset.current_subtitle_track != MediaSettings::NoneSelected));
4028 
4029 	if (core->mset.closed_caption_channel !=0 ) e = true; // Enable if using closed captions
4030 
4031 	decSubDelayAct->setEnabled(e);
4032 	incSubDelayAct->setEnabled(e);
4033 	subDelayAct->setEnabled(e);
4034 	decSubPosAct->setEnabled(e);
4035 	incSubPosAct->setEnabled(e);
4036 	decSubScaleAct->setEnabled(e);
4037 	incSubScaleAct->setEnabled(e);
4038 	decSubStepAct->setEnabled(e);
4039 	incSubStepAct->setEnabled(e);
4040 #ifdef MPV_SUPPORT
4041 	seekNextSubAct->setEnabled(e);
4042 	seekPrevSubAct->setEnabled(e);
4043 #endif
4044 
4045 	tabletModeAct->setChecked(pref->tablet_mode);
4046 
4047 #if defined(MPV_SUPPORT) && defined(MPLAYER_SUPPORT)
4048 	if (PlayerID::player(pref->mplayer_bin) == PlayerID::MPLAYER) {
4049 		secondary_subtitles_track_menu->setEnabled(false);
4050 		frameBackStepAct->setEnabled(false);
4051 		OSDFractionsAct->setEnabled(false);
4052 		earwaxAct->setEnabled(false);
4053 	} else {
4054 		//karaokeAct->setEnabled(false);
4055 	}
4056 #endif
4057 }
4058 
updateVideoEqualizer()4059 void BaseGui::updateVideoEqualizer() {
4060 	// Equalizer
4061 	video_equalizer->setContrast( core->mset.contrast );
4062 	video_equalizer->setBrightness( core->mset.brightness );
4063 	video_equalizer->setHue( core->mset.hue );
4064 	video_equalizer->setSaturation( core->mset.saturation );
4065 	video_equalizer->setGamma( core->mset.gamma );
4066 }
4067 
updateAudioEqualizer()4068 void BaseGui::updateAudioEqualizer() {
4069 	// Audio Equalizer
4070 	AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : core->mset.audio_equalizer;
4071 	audio_equalizer->blockSignals(true);
4072 	audio_equalizer->setEqualizer(l);
4073 	audio_equalizer->blockSignals(false);
4074 }
4075 
setDefaultValuesFromVideoEqualizer()4076 void BaseGui::setDefaultValuesFromVideoEqualizer() {
4077 	qDebug("BaseGui::setDefaultValuesFromVideoEqualizer");
4078 
4079 	pref->initial_contrast = video_equalizer->contrast();
4080 	pref->initial_brightness = video_equalizer->brightness();
4081 	pref->initial_hue = video_equalizer->hue();
4082 	pref->initial_saturation = video_equalizer->saturation();
4083 	pref->initial_gamma = video_equalizer->gamma();
4084 
4085 	QMessageBox::information(this, tr("Information"),
4086                              tr("The current values have been stored to be "
4087                                 "used as default.") );
4088 }
4089 
changeVideoEqualizerBySoftware(bool b)4090 void BaseGui::changeVideoEqualizerBySoftware(bool b) {
4091 	qDebug("BaseGui::changeVideoEqualizerBySoftware: %d", b);
4092 
4093 	if (b != pref->use_soft_video_eq) {
4094 		pref->use_soft_video_eq = b;
4095 		core->restart();
4096 	}
4097 }
4098 
setSpeed()4099 void BaseGui::setSpeed() {
4100 	QAction *a = qobject_cast<QAction *> (sender());
4101 	if (a) {
4102 		double speed = a->data().toDouble();
4103 		core->setSpeed(speed);
4104 	}
4105 }
4106 
4107 /*
4108 void BaseGui::openRecent(int item) {
4109 	qDebug("BaseGui::openRecent: %d", item);
4110 	if ((item > -1) && (item < RECENTS_CLEAR)) { // 1000 = Clear item
4111 		open( recents->item(item) );
4112 	}
4113 }
4114 */
4115 
openRecent()4116 void BaseGui::openRecent() {
4117 	QAction *a = qobject_cast<QAction *> (sender());
4118 	if (a) {
4119 		int item = a->data().toInt();
4120 		qDebug("BaseGui::openRecent: %d", item);
4121 		QString file = pref->history_recents->item(item);
4122 
4123 		if (pref->auto_add_to_playlist) {
4124 			if (playlist->maybeSave()) {
4125 				playlist->clear();
4126 				playlist->addFile(file, Playlist::NoGetInfo);
4127 
4128 				open( file );
4129 			}
4130 		} else {
4131 			open( file );
4132 		}
4133 
4134 	}
4135 }
4136 
open(QString file)4137 void BaseGui::open(QString file) {
4138 	qDebug("BaseGui::open: '%s'", file.toUtf8().data());
4139 
4140 	// If file is a playlist, open that playlist
4141 	QString extension = QFileInfo(file).suffix().toLower();
4142 	if ( ((extension=="m3u") || (extension=="m3u8")) && (QFile::exists(file)) ) {
4143 		playlist->load_m3u(file);
4144 	}
4145 	else
4146 	if (extension=="pls") {
4147 		playlist->load_pls(file);
4148 	}
4149 	else
4150 	if (extension=="xspf") {
4151 		playlist->loadXSPF(file);
4152 	}
4153 	else
4154 #ifdef YT_PLAYLIST_SUPPORT
4155 	if (playlist->isYTPlaylist(file)) {
4156 		playlist->openUrl(file);
4157 	}
4158 	else
4159 #endif
4160 	if (QFileInfo(file).isDir()) {
4161 		openDirectory(file);
4162 	}
4163 	else {
4164 		// Let the core to open it, autodetecting the file type
4165 		//if (playlist->maybeSave()) {
4166 		//	playlist->clear();
4167 		//	playlist->addFile(file);
4168 
4169 			core->open(file);
4170 		//}
4171 	}
4172 
4173 	if (QFile::exists(file)) pref->latest_dir = QFileInfo(file).absolutePath();
4174 }
4175 
openFiles(QStringList files)4176 void BaseGui::openFiles(QStringList files) {
4177 	qDebug("BaseGui::openFiles");
4178 	if (files.empty()) return;
4179 
4180 	#ifdef Q_OS_WIN
4181 	files = Helper::resolveSymlinks(files); // Check for Windows shortcuts
4182 	#endif
4183 
4184 	if (files.count()==1) {
4185 		if (pref->auto_add_to_playlist) {
4186 			if (playlist->maybeSave()) {
4187 				playlist->clear();
4188 				playlist->addFile(files[0], Playlist::NoGetInfo);
4189 
4190 				open(files[0]);
4191 			}
4192 		} else {
4193 			open(files[0]);
4194 		}
4195 	} else {
4196 		if (playlist->maybeSave()) {
4197 			playlist->clear();
4198 			playlist->addFiles(files);
4199 			open(files[0]);
4200 		}
4201 	}
4202 }
4203 
openFavorite(QString file)4204 void BaseGui::openFavorite(QString file) {
4205 	qDebug("BaseGui::openFavorite");
4206 
4207 	QUrl url(file);
4208 	if (url.isValid() && url.scheme().toLower() == "file") {
4209 		file = url.toLocalFile();
4210 	}
4211 
4212 	openFiles(QStringList() << file);
4213 }
4214 
openURL()4215 void BaseGui::openURL() {
4216 	qDebug("BaseGui::openURL");
4217 
4218 	exitFullscreenIfNeeded();
4219 
4220 	/*
4221     bool ok;
4222     QString s = QInputDialog::getText(this,
4223             tr("SMPlayer - Enter URL"), tr("URL:"), QLineEdit::Normal,
4224             pref->last_url, &ok );
4225 
4226     if ( ok && !s.isEmpty() ) {
4227 
4228 		//playlist->clear();
4229 		//playlistdock->hide();
4230 
4231 		openURL(s);
4232     } else {
4233         // user entered nothing or pressed Cancel
4234     }
4235 	*/
4236 
4237 	InputURL d(this);
4238 
4239 	// Get url from clipboard
4240 	QString clipboard_text = QApplication::clipboard()->text();
4241 	if ((!clipboard_text.isEmpty()) && (clipboard_text.contains("://")) /*&& (QUrl(clipboard_text).isValid())*/) {
4242 		d.setURL(clipboard_text);
4243 	}
4244 
4245 	for (int n=0; n < pref->history_urls->count(); n++) {
4246 		d.setURL( pref->history_urls->url(n) );
4247 	}
4248 
4249 	if (d.exec() == QDialog::Accepted ) {
4250 		QString url = d.url();
4251 		if (!url.isEmpty()) {
4252 			pref->history_urls->addUrl(url);
4253 			openURL(url);
4254 		}
4255 	}
4256 }
4257 
openURL(QString url)4258 void BaseGui::openURL(QString url) {
4259 #ifdef YT_PLAYLIST_SUPPORT
4260 	if (playlist->isYTPlaylist(url)) {
4261 		playlist->openUrl(url);
4262 		return;
4263 	}
4264 #endif
4265 
4266 	if (!url.isEmpty()) {
4267 		//pref->history_urls->addUrl(url);
4268 
4269 		if (pref->auto_add_to_playlist) {
4270 			if (playlist->maybeSave()) {
4271 				core->openStream(url);
4272 
4273 				playlist->clear();
4274 				playlist->addFile(url, Playlist::NoGetInfo);
4275 			}
4276 		} else {
4277 			core->openStream(url);
4278 		}
4279 	}
4280 }
4281 
4282 
openFile()4283 void BaseGui::openFile() {
4284 	qDebug("BaseGui::openFile");
4285 
4286 	exitFullscreenIfNeeded();
4287 
4288 	Extensions e;
4289     QString s = MyFileDialog::getOpenFileName(
4290                        this, tr("Choose a file"), pref->latest_dir,
4291                        tr("Multimedia") + e.allPlayable().forFilter()+";;" +
4292                        tr("Video") + e.video().forFilter()+";;" +
4293                        tr("Audio") + e.audio().forFilter()+";;" +
4294                        tr("Playlists") + e.playlist().forFilter()+";;" +
4295                        tr("All files") +" (*.*)" );
4296 
4297     if ( !s.isEmpty() ) {
4298 		openFile(s);
4299 	}
4300 }
4301 
openFile(QString file)4302 void BaseGui::openFile(QString file) {
4303 	qDebug() << "BaseGui::openFile:" << file;
4304 
4305    if ( !file.isEmpty() ) {
4306 
4307 		#ifdef Q_OS_WIN
4308 		// Check for Windows shortcuts
4309 		QFileInfo fi(file);
4310 		if (fi.isSymLink()) {
4311 			file = fi.symLinkTarget();
4312 		}
4313 		#endif
4314 
4315 		//playlist->clear();
4316 		//playlistdock->hide();
4317 
4318 		// If file is a playlist, open that playlist
4319 		QString extension = QFileInfo(file).suffix().toLower();
4320 		if ( (extension=="m3u") || (extension=="m3u8") ) {
4321 			playlist->load_m3u(file);
4322 		}
4323 		else
4324 		if (extension=="pls") {
4325 			playlist->load_pls(file);
4326 		}
4327 		else
4328 		if (extension=="xspf") {
4329 			playlist->loadXSPF(file);
4330 		}
4331 		else
4332 		if (extension=="iso") {
4333 			if (playlist->maybeSave()) {
4334 				core->open(file);
4335 			}
4336 		}
4337 		else {
4338 			if (pref->auto_add_to_playlist) {
4339 				if (playlist->maybeSave()) {
4340 					core->openFile(file);
4341 
4342 					playlist->clear();
4343 					playlist->addFile(file, Playlist::NoGetInfo);
4344 				}
4345 			} else {
4346 				core->openFile(file);
4347 			}
4348 		}
4349 		if (QFile::exists(file)) pref->latest_dir = QFileInfo(file).absolutePath();
4350 	}
4351 }
4352 
configureDiscDevices()4353 void BaseGui::configureDiscDevices() {
4354 	QMessageBox::information( this, tr("SMPlayer - Information"),
4355 			tr("The CDROM / DVD drives are not configured yet.\n"
4356 			   "The configuration dialog will be shown now, "
4357                "so you can do it."), QMessageBox::Ok);
4358 
4359 	showPreferencesDialog();
4360 	pref_dialog->showSection( PreferencesDialog::Drives );
4361 }
4362 
openVCD()4363 void BaseGui::openVCD() {
4364 	qDebug("BaseGui::openVCD");
4365 
4366 	if ( (pref->dvd_device.isEmpty()) ||
4367          (pref->cdrom_device.isEmpty()) )
4368 	{
4369 		configureDiscDevices();
4370 	} else {
4371 		if (playlist->maybeSave()) {
4372 			core->openVCD( pref->vcd_initial_title );
4373 		}
4374 	}
4375 }
4376 
openAudioCD()4377 void BaseGui::openAudioCD() {
4378 	qDebug("BaseGui::openAudioCD");
4379 
4380 	if ( (pref->dvd_device.isEmpty()) ||
4381          (pref->cdrom_device.isEmpty()) )
4382 	{
4383 		configureDiscDevices();
4384 	} else {
4385 		if (playlist->maybeSave()) {
4386 			core->openAudioCD();
4387 		}
4388 	}
4389 }
4390 
openDVD()4391 void BaseGui::openDVD() {
4392 	qDebug("BaseGui::openDVD");
4393 
4394 	if ( (pref->dvd_device.isEmpty()) ||
4395          (pref->cdrom_device.isEmpty()) )
4396 	{
4397 		configureDiscDevices();
4398 	} else {
4399 		if (playlist->maybeSave()) {
4400 #if DVDNAV_SUPPORT
4401 			int first_title = 0;
4402 			if (!pref->use_dvdnav) first_title = core->firstDVDTitle();
4403 			core->openDVD( DiscName::joinDVD(first_title, pref->dvd_device, pref->use_dvdnav) );
4404 #else
4405 			core->openDVD( DiscName::joinDVD(core->firstDVDTitle(), pref->dvd_device, false) );
4406 #endif
4407 		}
4408 	}
4409 }
4410 
openDVDFromFolder()4411 void BaseGui::openDVDFromFolder() {
4412 	qDebug("BaseGui::openDVDFromFolder");
4413 
4414 	if (playlist->maybeSave()) {
4415 		InputDVDDirectory *d = new InputDVDDirectory(this);
4416 		d->setFolder( pref->last_dvd_directory );
4417 
4418 		if (d->exec() == QDialog::Accepted) {
4419 			qDebug("BaseGui::openDVDFromFolder: accepted");
4420 			openDVDFromFolder( d->folder() );
4421 		}
4422 
4423 		delete d;
4424 	}
4425 }
4426 
openDVDFromFolder(QString directory)4427 void BaseGui::openDVDFromFolder(QString directory) {
4428 	pref->last_dvd_directory = directory;
4429 #if DVDNAV_SUPPORT
4430 	int first_title = 0;
4431 	if (!pref->use_dvdnav) first_title = core->firstDVDTitle();
4432 	core->openDVD( DiscName::joinDVD(first_title, directory, pref->use_dvdnav) );
4433 #else
4434 	core->openDVD( DiscName::joinDVD(core->firstDVDTitle(), directory, false) );
4435 #endif
4436 }
4437 
4438 #ifdef BLURAY_SUPPORT
4439 /**
4440  * Minimal BaseGui abstraction for calling openBluRay. It's called from
4441  * OpenBluRayFromFolder()
4442  */
openBluRayFromFolder(QString directory)4443 void BaseGui::openBluRayFromFolder(QString directory) {
4444 	pref->last_dvd_directory = directory;
4445 	core->openBluRay( DiscName::join(DiscName::BLURAY, core->firstBlurayTitle(), directory) );
4446 }
4447 
4448 /**
4449  * Attempts to open a bluray from pref->bluray_device. If not set, calls configureDiscDevices.
4450  * If successful, calls Core::OpenBluRay(QString)
4451  */
openBluRay()4452 void BaseGui::openBluRay() {
4453 	qDebug("BaseGui::openBluRay");
4454 
4455 	if ( (pref->dvd_device.isEmpty()) ||
4456          (pref->cdrom_device.isEmpty()) || pref->bluray_device.isEmpty())
4457 	{
4458 		configureDiscDevices();
4459 	} else {
4460 		core->openBluRay( DiscName::join(DiscName::BLURAY, core->firstBlurayTitle(), pref->bluray_device) );
4461 	}
4462 }
4463 
openBluRayFromFolder()4464 void BaseGui::openBluRayFromFolder() {
4465 	qDebug("BaseGui::openBluRayFromFolder");
4466 
4467 	if (playlist->maybeSave()) {
4468 		QString dir = MyFileDialog::getExistingDirectory(this, tr("Select the Blu-ray folder"),
4469                           pref->last_dvd_directory, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
4470 		if (!dir.isEmpty()) {
4471 			openBluRayFromFolder(dir);
4472 		}
4473 	}
4474 }
4475 #endif
4476 
openDirectory()4477 void BaseGui::openDirectory() {
4478 	qDebug("BaseGui::openDirectory");
4479 
4480 	QString s = MyFileDialog::getExistingDirectory(
4481                     this, tr("Choose a directory"),
4482                     pref->latest_dir );
4483 
4484 	if (!s.isEmpty()) {
4485 		openDirectory(s);
4486 	}
4487 }
4488 
openDirectory(QString directory)4489 void BaseGui::openDirectory(QString directory) {
4490 	qDebug("BaseGui::openDirectory: '%s'", directory.toUtf8().data());
4491 
4492 	if (Helper::directoryContainsDVD(directory)) {
4493 		core->open(directory);
4494 	}
4495 	else {
4496 		QFileInfo fi(directory);
4497 		if ( (fi.exists()) && (fi.isDir()) ) {
4498 			playlist->clear();
4499 			//playlist->addDirectory(directory);
4500 			playlist->addDirectory( fi.absoluteFilePath() );
4501 			playlist->startPlay();
4502 		} else {
4503 			qDebug("BaseGui::openDirectory: directory is not valid");
4504 		}
4505 	}
4506 }
4507 
loadSub()4508 void BaseGui::loadSub() {
4509 	qDebug("BaseGui::loadSub");
4510 
4511 	exitFullscreenIfNeeded();
4512 
4513 	Extensions e;
4514     QString s = MyFileDialog::getOpenFileName(
4515         this, tr("Choose a file"),
4516 	    pref->latest_dir,
4517         tr("Subtitles") + e.subtitles().forFilter()+ ";;" +
4518         tr("All files") +" (*.*)" );
4519 
4520 	if (!s.isEmpty()) core->loadSub(s);
4521 }
4522 
setInitialSubtitle(const QString & subtitle_file)4523 void BaseGui::setInitialSubtitle(const QString & subtitle_file) {
4524 	qDebug("BaseGui::setInitialSubtitle: '%s'", subtitle_file.toUtf8().constData());
4525 
4526 	core->setInitialSubtitle(subtitle_file);
4527 }
4528 
setInitialSecond(int second)4529 void BaseGui::setInitialSecond(int second) {
4530 	qDebug("BaseGui::setInitialSecond: %d", second);
4531 	core->setInitialSecond(second);
4532 }
4533 
loadAudioFile()4534 void BaseGui::loadAudioFile() {
4535 	qDebug("BaseGui::loadAudioFile");
4536 
4537 	exitFullscreenIfNeeded();
4538 
4539 	Extensions e;
4540 	QString s = MyFileDialog::getOpenFileName(
4541         this, tr("Choose a file"),
4542 	    pref->latest_dir,
4543         tr("Audio") + e.audio().forFilter()+";;" +
4544         tr("All files") +" (*.*)" );
4545 
4546 	if (!s.isEmpty()) core->loadAudioFile(s);
4547 }
4548 
helpFirstSteps()4549 void BaseGui::helpFirstSteps() {
4550 	QDesktopServices::openUrl(QString(URL_FIRST_STEPS "?version=%1").arg(Version::printable()));
4551 }
4552 
helpFAQ()4553 void BaseGui::helpFAQ() {
4554 	QString url = URL_FAQ;
4555 	/* if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); */
4556 	QDesktopServices::openUrl( QUrl(url) );
4557 }
4558 
helpCLOptions()4559 void BaseGui::helpCLOptions() {
4560 	if (clhelp_window == 0) {
4561 		clhelp_window = new InfoWindow(this);
4562 	}
4563 	clhelp_window->setWindowTitle( tr("SMPlayer command line options") );
4564 	clhelp_window->setWindowIcon( Images::icon("logo") );
4565 	clhelp_window->setHtml(CLHelp::help(true));
4566 	clhelp_window->show();
4567 }
4568 
helpCheckUpdates()4569 void BaseGui::helpCheckUpdates() {
4570 #ifdef UPDATE_CHECKER
4571 	update_checker->check();
4572 #else
4573 	QString url = QString(URL_CHANGES "?version=%1").arg(Version::with_revision());
4574 	QDesktopServices::openUrl( QUrl(url) );
4575 #endif
4576 }
4577 
helpShowConfig()4578 void BaseGui::helpShowConfig() {
4579 	QDesktopServices::openUrl(QUrl::fromLocalFile(Paths::configPath()));
4580 }
4581 
4582 #ifdef SHARE_ACTIONS
helpDonate()4583 void BaseGui::helpDonate() {
4584 	ShareDialog d(this);
4585 	d.showRemindCheck(false);
4586 
4587 	#ifdef SHARE_WIDGET
4588 	d.setActions(sharewidget->actions());
4589 	#endif
4590 
4591 	d.exec();
4592 	int action = d.actions();
4593 	qDebug("BaseGui::helpDonate: action: %d", action);
4594 
4595 	if (action > 0) {
4596 		#ifdef SHARE_WIDGET
4597 		sharewidget->setActions(action);
4598 		#else
4599 		QSettings * set = Global::settings;
4600 		set->beginGroup("reminder");
4601 		set->setValue("action", action);
4602 		set->endGroup();
4603 		#endif
4604 	}
4605 }
4606 #else
helpDonate()4607 void BaseGui::helpDonate() {
4608 	qDebug("BaseGui::helpDonate");
4609 
4610 	int action = 0;
4611 	bool accepted;
4612 	showHelpDonateDialog(&accepted);
4613 	if (accepted) action = 1;
4614 
4615 	if (action > 0) {
4616 		QSettings * set = Global::settings;
4617 		set->beginGroup("reminder");
4618 		set->setValue("action", action);
4619 		set->endGroup();
4620 	}
4621 }
4622 
showHelpDonateDialog(bool * accepted)4623 void BaseGui::showHelpDonateDialog(bool * accepted) {
4624 	bool result = false;
4625 
4626 	QMessageBox d(this);
4627 	d.setIconPixmap(Images::icon("donate"));
4628 	d.setWindowTitle(tr("Support SMPlayer"));
4629 
4630 	QPushButton * ok_button = d.addButton(tr("Donate"), QMessageBox::YesRole);
4631 	d.addButton(tr("No"), QMessageBox::NoRole);
4632 	d.setDefaultButton(ok_button);
4633 
4634 	d.setText("<h1>" + tr("SMPlayer needs you") + "</h1><p>" +
4635 		tr("SMPlayer is free software. However the development requires a lot of time and a lot of work.") + "<p>" +
4636 		tr("In order to keep developing SMPlayer with new features we need your help.") + "<p>" +
4637 		tr("Please consider to support the SMPlayer project by sending a donation.") + " " +
4638 		tr("Even the smallest amount will help a lot.")
4639 	);
4640 	d.exec();
4641 	if (d.clickedButton() == ok_button) {
4642 		QDesktopServices::openUrl(QUrl(URL_DONATE));
4643 		result = true;
4644 	}
4645 	if (accepted != 0) *accepted = result;
4646 }
4647 #endif
4648 
helpAbout()4649 void BaseGui::helpAbout() {
4650 	About d(this);
4651 	d.exec();
4652 }
4653 
4654 #ifdef SHARE_MENU
shareSMPlayer()4655 void BaseGui::shareSMPlayer() {
4656 	QString text = QString("SMPlayer - Free Media Player with built-in codecs that can play and download Youtube videos").replace(" ","+");
4657 	QString url = URL_HOMEPAGE;
4658 
4659 	if (sender() == twitterAct) {
4660 		QDesktopServices::openUrl(QUrl("http://twitter.com/intent/tweet?text=" + text + "&url=" + url + "/&via=smplayer_dev"));
4661 	}
4662 	else
4663 	if (sender() == gmailAct) {
4664 		QDesktopServices::openUrl(QUrl("https://mail.google.com/mail/?view=cm&fs=1&to&su=" + text + "&body=" + url + "&ui=2&tf=1&shva=1"));
4665 	}
4666 	else
4667 	if (sender() == yahooAct) {
4668 		QDesktopServices::openUrl(QUrl("http://compose.mail.yahoo.com/?To=&Subject=" + text + "&body=" + url));
4669 	}
4670 	else
4671 	if (sender() == hotmailAct) {
4672 		QDesktopServices::openUrl(QUrl("http://www.hotmail.msn.com/secure/start?action=compose&to=&subject=" + text + "&body=" + url));
4673 	}
4674 	else
4675 	if (sender() == facebookAct) {
4676 		QDesktopServices::openUrl(QUrl("http://www.facebook.com/sharer.php?u=" + url + "&t=" + text));
4677 
4678 		#ifdef SHARE_ACTIONS
4679 		QSettings * set = Global::settings;
4680 		set->beginGroup("reminder");
4681 		set->setValue("action", 2);
4682 		set->endGroup();
4683 		#endif
4684 	}
4685 }
4686 #endif
4687 
showGotoDialog()4688 void BaseGui::showGotoDialog() {
4689 	TimeDialog d(this);
4690 	d.setMaximumTime( (int) core->mdat.duration);
4691 	d.setTime( (int) core->mset.current_sec);
4692 	if (d.exec() == QDialog::Accepted) {
4693 		core->goToSec( d.time() );
4694 	}
4695 }
4696 
showAudioDelayDialog()4697 void BaseGui::showAudioDelayDialog() {
4698 	bool ok;
4699 	#if QT_VERSION >= 0x050000
4700 	int delay = QInputDialog::getInt(this, tr("SMPlayer - Audio delay"),
4701                                      tr("Audio delay (in milliseconds):"), core->mset.audio_delay,
4702                                      -3600000, 3600000, 1, &ok);
4703 	#else
4704 	int delay = QInputDialog::getInteger(this, tr("SMPlayer - Audio delay"),
4705                                          tr("Audio delay (in milliseconds):"), core->mset.audio_delay,
4706                                          -3600000, 3600000, 1, &ok);
4707 	#endif
4708 	if (ok) {
4709 		core->setAudioDelay(delay);
4710 	}
4711 }
4712 
showSubDelayDialog()4713 void BaseGui::showSubDelayDialog() {
4714 	bool ok;
4715 	#if QT_VERSION >= 0x050000
4716 	int delay = QInputDialog::getInt(this, tr("SMPlayer - Subtitle delay"),
4717                                      tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay,
4718                                      -3600000, 3600000, 1, &ok);
4719 	#else
4720 	int delay = QInputDialog::getInteger(this, tr("SMPlayer - Subtitle delay"),
4721                                          tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay,
4722                                          -3600000, 3600000, 1, &ok);
4723 	#endif
4724 	if (ok) {
4725 		core->setSubDelay(delay);
4726 	}
4727 }
4728 
showStereo3dDialog()4729 void BaseGui::showStereo3dDialog() {
4730 	Stereo3dDialog d(this);
4731 	d.setInputFormat(core->mset.stereo3d_in);
4732 	d.setOutputFormat(core->mset.stereo3d_out);
4733 
4734 	if (d.exec() == QDialog::Accepted) {
4735 		core->changeStereo3d(d.inputFormat(), d.outputFormat());
4736 	}
4737 }
4738 
4739 #ifdef BOOKMARKS
showAddBookmarkDialog()4740 void BaseGui::showAddBookmarkDialog() {
4741 	InputBookmark d(this);
4742 	d.setTime( (int) core->mset.current_sec);
4743 	if (d.exec() == QDialog::Accepted) {
4744 		core->mset.bookmarks.insert(d.time(), d.name());
4745 		updateBookmarks();
4746 		core->saveBookmarks();
4747 	}
4748 }
4749 
showBookmarkDialog()4750 void BaseGui::showBookmarkDialog() {
4751 	qDebug("BaseGui::showBookmarkDialog");
4752 	BookmarkDialog d(this);
4753 	d.setBookmarks(core->mset.bookmarks);
4754 	if (d.exec() == QDialog::Accepted) {
4755 		core->mset.bookmarks = d.bookmarks();
4756 		updateBookmarks();
4757 		core->saveBookmarks();
4758 	}
4759 }
4760 #endif
4761 
exitFullscreen()4762 void BaseGui::exitFullscreen() {
4763 	if (pref->fullscreen) {
4764 		toggleFullscreen(false);
4765 	}
4766 }
4767 
toggleFullscreen()4768 void BaseGui::toggleFullscreen() {
4769 	qDebug("BaseGui::toggleFullscreen");
4770 
4771 	toggleFullscreen(!pref->fullscreen);
4772 }
4773 
toggleFullscreen(bool b)4774 void BaseGui::toggleFullscreen(bool b) {
4775 	qDebug("BaseGui::toggleFullscreen: %d", b);
4776 
4777 	if (b==pref->fullscreen) {
4778 		// Nothing to do
4779 		qDebug("BaseGui::toggleFullscreen: nothing to do, returning");
4780 		return;
4781 	}
4782 
4783 	pref->fullscreen = b;
4784 
4785 	// If using mplayer window
4786 	if (pref->use_mplayer_window) {
4787 		core->changeFullscreenMode(b);
4788 		updateWidgets();
4789 		return;
4790 	}
4791 
4792 	if (!panel->isVisible()) return; // mplayer window is not used.
4793 
4794 	if (pref->fullscreen) {
4795 		compactAct->setEnabled(false);
4796 
4797 		if (pref->restore_pos_after_fullscreen) {
4798 			win_pos = pos();
4799 			win_size = size();
4800 		}
4801 
4802 		was_maximized = isMaximized();
4803 		qDebug("BaseGui::toggleFullscreen: was_maximized: %d", was_maximized);
4804 
4805 		aboutToEnterFullscreen();
4806 
4807 		#ifdef Q_OS_WIN
4808 		// Hack to avoid the windows taskbar to be visible on Windows XP
4809 		if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
4810 			if (!pref->pause_when_hidden) hide();
4811 		}
4812 		#endif
4813 
4814 		showFullScreen();
4815 
4816 	} else {
4817 		showNormal();
4818 
4819 		if (was_maximized) showMaximized(); // It has to be called after showNormal()
4820 
4821 		aboutToExitFullscreen();
4822 
4823 		if (pref->restore_pos_after_fullscreen) {
4824 			move( win_pos );
4825 			resize( win_size );
4826 		}
4827 
4828 		compactAct->setEnabled(true);
4829 	}
4830 
4831 	updateWidgets();
4832 
4833 #ifdef ADD_BLACKBORDERS_FS
4834 	if ((pref->add_blackborders_on_fullscreen) &&
4835         (!core->mset.add_letterbox))
4836 	{
4837 		core->changeLetterboxOnFullscreen(b);
4838 		/* core->restart(); */
4839 	}
4840 #endif
4841 
4842 	setFocus(); // Fixes bug #2493415
4843 }
4844 
4845 
aboutToEnterFullscreen()4846 void BaseGui::aboutToEnterFullscreen() {
4847 	if (pref->stay_on_top == Preferences::WhilePlayingOnTop && core->state() == Core::Playing) {
4848 		setStayOnTop(false);
4849 	}
4850 
4851 	if (!pref->compact_mode) {
4852 		menuBar()->hide();
4853 		statusBar()->hide();
4854 	}
4855 }
4856 
aboutToExitFullscreen()4857 void BaseGui::aboutToExitFullscreen() {
4858 	if (!pref->compact_mode) {
4859 		menuBar()->show();
4860 		statusBar()->show();
4861 	}
4862 
4863 	if (pref->stay_on_top == Preferences::WhilePlayingOnTop) {
4864 		#if QT_VERSION < 0x050000
4865 		qApp->processEvents();
4866 		#endif
4867 		setStayOnTop(core->state() == Core::Playing);
4868 	}
4869 }
4870 
4871 
leftClickFunction()4872 void BaseGui::leftClickFunction() {
4873 	qDebug("BaseGui::leftClickFunction");
4874 
4875 	if (!pref->mouse_left_click_function.isEmpty()) {
4876 		processFunction(pref->mouse_left_click_function);
4877 	}
4878 }
4879 
rightClickFunction()4880 void BaseGui::rightClickFunction() {
4881 	qDebug("BaseGui::rightClickFunction");
4882 
4883 	if (!pref->mouse_right_click_function.isEmpty()) {
4884 		processFunction(pref->mouse_right_click_function);
4885 	}
4886 }
4887 
doubleClickFunction()4888 void BaseGui::doubleClickFunction() {
4889 	qDebug("BaseGui::doubleClickFunction");
4890 
4891 	if (!pref->mouse_double_click_function.isEmpty()) {
4892 		processFunction(pref->mouse_double_click_function);
4893 	}
4894 }
4895 
middleClickFunction()4896 void BaseGui::middleClickFunction() {
4897 	qDebug("BaseGui::middleClickFunction");
4898 
4899 	if (!pref->mouse_middle_click_function.isEmpty()) {
4900 		processFunction(pref->mouse_middle_click_function);
4901 	}
4902 }
4903 
xbutton1ClickFunction()4904 void BaseGui::xbutton1ClickFunction() {
4905 	qDebug("BaseGui::xbutton1ClickFunction");
4906 
4907 	if (!pref->mouse_xbutton1_click_function.isEmpty()) {
4908 		processFunction(pref->mouse_xbutton1_click_function);
4909 	}
4910 }
4911 
xbutton2ClickFunction()4912 void BaseGui::xbutton2ClickFunction() {
4913 	qDebug("BaseGui::xbutton2ClickFunction");
4914 
4915 	if (!pref->mouse_xbutton2_click_function.isEmpty()) {
4916 		processFunction(pref->mouse_xbutton2_click_function);
4917 	}
4918 }
4919 
processFunction(QString function)4920 void BaseGui::processFunction(QString function) {
4921 	qDebug("BaseGui::processFunction: '%s'", function.toUtf8().data());
4922 
4923 	//parse args for checkable actions
4924 	QRegExp func_rx("(.*) (true|false)");
4925 	bool value = false;
4926 	bool checkableFunction = false;
4927 
4928 	if(func_rx.indexIn(function) > -1){
4929 		function = func_rx.cap(1);
4930 		value = (func_rx.cap(2) == "true");
4931 		checkableFunction = true;
4932 	} //end if
4933 
4934 	QAction * action = ActionsEditor::findAction(this, function);
4935 	if (!action) action = ActionsEditor::findAction(playlist, function);
4936 
4937 	if (action) {
4938 		qDebug("BaseGui::processFunction: action found");
4939 
4940 		if (!action->isEnabled()) {
4941 			qDebug("BaseGui::processFunction: action is disabled, doing nothing");
4942 			return;
4943 		}
4944 
4945 		if (action->isCheckable()){
4946 			if(checkableFunction)
4947 				action->setChecked(value);
4948 			else
4949 				//action->toggle();
4950 				action->trigger();
4951 		}else{
4952 			action->trigger();
4953 		}
4954 	}
4955 }
4956 
runActions(QString actions)4957 void BaseGui::runActions(QString actions) {
4958 	qDebug("BaseGui::runActions");
4959 
4960 	actions = actions.simplified(); // Remove white space
4961 
4962 	QAction * action;
4963 	QStringList actionsList = actions.split(" ");
4964 
4965 	for (int n = 0; n < actionsList.count(); n++) {
4966 		QString actionStr = actionsList[n];
4967 		QString par = ""; //the parameter which the action takes
4968 
4969 		//set par if the next word is a boolean value
4970 		if ( (n+1) < actionsList.count() ) {
4971 			if ( (actionsList[n+1].toLower() == "true") || (actionsList[n+1].toLower() == "false") ) {
4972 				par = actionsList[n+1].toLower();
4973 				n++;
4974 			} //end if
4975 		} //end if
4976 
4977 		action = ActionsEditor::findAction(this, actionStr);
4978 		if (!action) action = ActionsEditor::findAction(playlist, actionStr);
4979 
4980 		if (action) {
4981 			qDebug("BaseGui::runActions: running action: '%s' (par: '%s')",
4982 				   actionStr.toUtf8().data(), par.toUtf8().data() );
4983 
4984 			if (action->isCheckable()) {
4985 				if (par.isEmpty()) {
4986 					//action->toggle();
4987 					action->trigger();
4988 				} else {
4989 					action->setChecked( (par == "true") );
4990 				} //end if
4991 			} else {
4992 				action->trigger();
4993 			} //end if
4994 		} else {
4995 			qWarning("BaseGui::runActions: action: '%s' not found",actionStr.toUtf8().data());
4996 		} //end if
4997 	} //end for
4998 }
4999 
checkPendingActionsToRun()5000 void BaseGui::checkPendingActionsToRun() {
5001 	qDebug("BaseGui::checkPendingActionsToRun");
5002 
5003 	QString actions;
5004 	if (!pending_actions_to_run.isEmpty()) {
5005 		actions = pending_actions_to_run;
5006 		pending_actions_to_run.clear();
5007 		if (!pref->actions_to_run.isEmpty()) {
5008 			actions = pref->actions_to_run +" "+ actions;
5009 		}
5010 	} else {
5011 		actions = pref->actions_to_run;
5012 	}
5013 
5014 	if (!actions.isEmpty()) {
5015 		qDebug("BaseGui::checkPendingActionsToRun: actions: '%s'", actions.toUtf8().constData());
5016 		runActions(actions);
5017 	}
5018 }
5019 
5020 #if REPORT_OLD_MPLAYER
checkMplayerVersion()5021 void BaseGui::checkMplayerVersion() {
5022 	qDebug("BaseGui::checkMplayerVersion");
5023 
5024 	// Qt 4.3.5 is crazy, I can't popup a messagebox here, it calls
5025 	// this function once and again when the messagebox is shown
5026 
5027 	if ( (pref->mplayer_detected_version > 0) && (!MplayerVersion::isMplayerAtLeast(25158)) ) {
5028 		QTimer::singleShot(1000, this, SLOT(displayWarningAboutOldMplayer()));
5029 	}
5030 }
5031 
displayWarningAboutOldMplayer()5032 void BaseGui::displayWarningAboutOldMplayer() {
5033 	qDebug("BaseGui::displayWarningAboutOldMplayer");
5034 
5035 	if (!pref->reported_mplayer_is_old) {
5036 		QMessageBox::warning(this, tr("Warning - Using old MPlayer"),
5037 			tr("The version of MPlayer (%1) installed on your system "
5038                "is obsolete. SMPlayer can't work well with it: some "
5039                "options won't work, subtitle selection may fail...")
5040                .arg(MplayerVersion::toString(pref->mplayer_detected_version)) +
5041             "<br><br>" +
5042             tr("Please, update your MPlayer.") +
5043             "<br><br>" +
5044             tr("(This warning won't be displayed anymore)") );
5045 
5046 		pref->reported_mplayer_is_old = true;
5047 	}
5048 	//else
5049 	//statusBar()->showMessage( tr("Using an old MPlayer, please update it"), 10000 );
5050 }
5051 #endif
5052 
5053 #ifdef CHECK_UPGRADED
checkIfUpgraded()5054 void BaseGui::checkIfUpgraded() {
5055 	qDebug("BaseGui::checkIfUpgraded");
5056 
5057 	if ( (pref->check_if_upgraded) && (pref->smplayer_stable_version != Version::stable()) ) {
5058 		// Running a new version
5059 		qDebug("BaseGui::checkIfUpgraded: running a new version: %s", Version::stable().toUtf8().constData());
5060 		QString os = "other";
5061 		#ifdef Q_OS_WIN
5062 		os = "win";
5063 		#endif
5064 		#ifdef Q_OS_LINUX
5065 		os = "linux";
5066 		#endif
5067 		QDesktopServices::openUrl(QString(URL_THANK_YOU "?version=%1&so=%2").arg(Version::printable()).arg(os));
5068 	}
5069 	pref->smplayer_stable_version = Version::stable();
5070 }
5071 #endif
5072 
5073 #ifdef DONATE_REMINDER
checkReminder()5074 void BaseGui::checkReminder() {
5075 	qDebug("BaseGui::checkReminder");
5076 
5077 	if (core->state() == Core::Playing) return;
5078 
5079 	QSettings * set = Global::settings;
5080 	set->beginGroup("reminder");
5081 	int count = set->value("count", 0).toInt();
5082 	count++;
5083 	set->setValue("count", count);
5084 	int action = set->value("action", 0).toInt();
5085 	bool dont_show = set->value("dont_show_anymore", false).toBool();
5086 	set->endGroup();
5087 
5088 #if 1
5089 	if (dont_show) return;
5090 
5091 	if (action != 0) return;
5092 	if ((count != 25) && (count != 45)) return;
5093 #endif
5094 
5095 #ifdef SHARE_ACTIONS
5096 	ShareDialog d(this);
5097 	//d.showRemindCheck(false);
5098 	d.exec();
5099 	action = d.actions();
5100 	qDebug("BaseGui::checkReminder: action: %d", action);
5101 
5102 	if (!d.isRemindChecked()) {
5103 		set->beginGroup("reminder");
5104 		set->setValue("dont_show_anymore", true);
5105 		set->endGroup();
5106 	}
5107 #else
5108 	action = 0;
5109 	bool accepted;
5110 	showHelpDonateDialog(&accepted);
5111 	if (accepted) action = 1;
5112 #endif
5113 
5114 	if (action > 0) {
5115 		set->beginGroup("reminder");
5116 		set->setValue("action", action);
5117 		set->endGroup();
5118 	}
5119 
5120 	//qDebug() << "size:" << d.size();
5121 }
5122 #endif
5123 
5124 #ifdef YT_CODEDOWNLOADER
YTUpdate()5125 void BaseGui::YTUpdate() {
5126 	QString path;
5127 	#ifdef YT_BIN_ON_CONFIG_DIR
5128 	path = Paths::configPath();
5129 	#endif
5130 	CodeDownloader::askAndDownload(this, CodeDownloader::NoError, path, pref->yt_ytdl_bin);
5131 }
5132 
YTFailedToStart()5133 void BaseGui::YTFailedToStart() {
5134 	QString path;
5135 	#ifdef YT_BIN_ON_CONFIG_DIR
5136 	path = Paths::configPath();
5137 	#endif
5138 	CodeDownloader::askAndDownload(this, CodeDownloader::FailedToRun, path, pref->yt_ytdl_bin);
5139 }
5140 
YTUrlNotFound()5141 void BaseGui::YTUrlNotFound() {
5142 	QString path;
5143 	#ifdef YT_BIN_ON_CONFIG_DIR
5144 	path = Paths::configPath();
5145 	#endif
5146 	CodeDownloader::askAndDownload(this, CodeDownloader::UrlNotFound, path, pref->yt_ytdl_bin);
5147 }
5148 
5149 #ifdef Q_OS_WIN
YTDLLNotFound()5150 void BaseGui::YTDLLNotFound() {
5151 	qDebug("BaseGui::YTDLLNotFound");
5152 	QMessageBox::warning(this, tr("Error detected"),
5153 		tr("The youtube-dl process failed because of missing libraries.") +"<br>"+
5154 		tr("You'll probably need to install %1.").
5155 		arg("<a href=\"https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe\">%1</a>").
5156 		arg(tr("the Microsoft Visual C++ 2010 Redistributable Package"))
5157 		);
5158 }
5159 #endif
5160 #endif
5161 
gotForbidden()5162 void BaseGui::gotForbidden() {
5163 	qDebug("BaseGui::gotForbidden");
5164 
5165 	if (!pref->report_mplayer_crashes) {
5166 		qDebug("BaseGui::gotForbidden: not displaying error dialog");
5167 		return;
5168 	}
5169 
5170 	static bool busy = false;
5171 
5172 	if (busy) return;
5173 
5174 	busy = true;
5175 #if defined(YOUTUBE_SUPPORT) && defined(YT_OBSOLETE)
5176 	if (core->mdat.filename.contains("youtube.com")) {
5177 		YTNoSignature("");
5178 	} else
5179 #endif
5180 	{
5181 		QMessageBox::warning(this, tr("Error detected"),
5182 			tr("Unfortunately this video can't be played.") +"<br>"+
5183 			tr("The server returned '%1'").arg("403: Forbidden"));
5184 	}
5185 	busy = false;
5186 }
5187 
dragEnterEvent(QDragEnterEvent * e)5188 void BaseGui::dragEnterEvent( QDragEnterEvent *e ) {
5189 	qDebug("BaseGui::dragEnterEvent");
5190 
5191 	if (e->mimeData()->hasUrls()) {
5192 		e->acceptProposedAction();
5193 	}
5194 }
5195 
5196 
5197 
dropEvent(QDropEvent * e)5198 void BaseGui::dropEvent( QDropEvent *e ) {
5199 	qDebug("BaseGui::dropEvent");
5200 
5201 	QStringList files;
5202 
5203 	if (e->mimeData()->hasUrls()) {
5204 		QList <QUrl> l = e->mimeData()->urls();
5205 		QString s;
5206 		for (int n=0; n < l.count(); n++) {
5207 			if (l[n].isValid()) {
5208 				qDebug() << "BaseGui::dropEvent: scheme:" << l[n].scheme();
5209 				if (l[n].scheme() == "file")
5210 					s = l[n].toLocalFile();
5211 				else
5212 					s = l[n].toString();
5213 				/*
5214 				qDebug(" * '%s'", l[n].toString().toUtf8().data());
5215 				qDebug(" * '%s'", l[n].toLocalFile().toUtf8().data());
5216 				*/
5217 				qDebug() << "BaseGui::dropEvent: file:" << s;
5218 				files.append(s);
5219 			}
5220 		}
5221 	}
5222 
5223 	QStringList file_list;
5224 	QStringList dir_list;
5225 	QString sub_file;
5226 
5227 #ifdef Q_OS_WIN
5228 	if (files.count() > 0) {
5229 		files = Helper::resolveSymlinks(files); // Check for Windows shortcuts
5230 	}
5231 #endif
5232 	files.sort();
5233 
5234 	Extensions ext;
5235 	QRegExp ext_sub(ext.subtitles().forRegExp());
5236 	ext_sub.setCaseSensitivity(Qt::CaseInsensitive);
5237 
5238 	foreach (QString file, files) {
5239 		QFileInfo fi(file);
5240 		if (fi.isDir()) {
5241 			// Folder
5242 			dir_list << file;
5243 		}
5244 		else
5245 		if (ext_sub.indexIn(fi.suffix()) > -1) {
5246 			// Subtitle file
5247 			if (sub_file.isEmpty()) sub_file = file;
5248 		}
5249 		else {
5250 			// File (or something else)
5251 			file_list << file;
5252 		}
5253 	}
5254 
5255 	qDebug() << "BaseGui::dropEvent: list of dirs:" << dir_list;
5256 	qDebug() << "BaseGui::dropEvent: list of files:" << file_list;
5257 	qDebug() << "BaseGui::dropEvent: subtitle file:" << sub_file;
5258 
5259 	/* If only one file is dropped and it's not a folder nor a subtitle,
5260        open it with openFile so that it remembers the position */
5261 	if (dir_list.isEmpty() && sub_file.isEmpty() && file_list.count() == 1 && QFile::exists(file_list[0])) {
5262 		openFile(file_list[0]);
5263 		return;
5264 	}
5265 
5266 	if (!sub_file.isEmpty()) {
5267 		core->loadSub(sub_file);
5268 		return;
5269 	}
5270 
5271 	if (file_list.isEmpty() && dir_list.isEmpty()) {
5272 		return;
5273 	}
5274 
5275 	if (dir_list.count() == 1 && file_list.isEmpty()) {
5276 		openDirectory(dir_list[0]);
5277 		return;
5278 	}
5279 
5280 	if (pref->auto_add_to_playlist) {
5281 		if (!playlist->maybeSave()) return;
5282 		playlist->clear();
5283 
5284 		if (!dir_list.isEmpty()) {
5285 			// Add directories to the playlist
5286 			foreach(QString dir, dir_list) playlist->addDirectory(dir);
5287 		}
5288 
5289 		if (!file_list.isEmpty()) {
5290 			// Add files to the playlist
5291 			playlist->addFiles(file_list, Playlist::NoGetInfo);
5292 		}
5293 
5294 		// All files are in the playlist, let's start to play
5295 		playlist->startPlay();
5296 	} else {
5297 		// It wasn't possible to add files to the list
5298 		// Let's open the first directory or file
5299 		if (!dir_list.isEmpty()) openDirectory(dir_list[0]); // Bug? This actually modifies the playlist...
5300 		else
5301 		if (!file_list.isEmpty()) open(file_list[0]);
5302 	}
5303 }
5304 
showPopupMenu()5305 void BaseGui::showPopupMenu() {
5306 	showPopupMenu(QCursor::pos());
5307 }
5308 
showPopupMenu(QPoint p)5309 void BaseGui::showPopupMenu( QPoint p ) {
5310 	//qDebug("BaseGui::showPopupMenu: %d, %d", p.x(), p.y());
5311 	popup->move( p );
5312 	popup->show();
5313 }
5314 
5315 /*
5316 void BaseGui::mouseReleaseEvent( QMouseEvent * e ) {
5317 	qDebug("BaseGui::mouseReleaseEvent");
5318 
5319 	if (e->button() == Qt::LeftButton) {
5320 		e->accept();
5321 		emit leftClicked();
5322 	}
5323 	else
5324 	if (e->button() == Qt::MidButton) {
5325 		e->accept();
5326 		emit middleClicked();
5327 	}
5328 	//
5329 	//else
5330 	//if (e->button() == Qt::RightButton) {
5331 	//	showPopupMenu( e->globalPos() );
5332     //}
5333 	//
5334 	else
5335 		e->ignore();
5336 }
5337 
5338 void BaseGui::mouseDoubleClickEvent( QMouseEvent * e ) {
5339 	e->accept();
5340 	emit doubleClicked();
5341 }
5342 */
5343 
5344 /*
5345 void BaseGui::wheelEvent( QWheelEvent * e ) {
5346 	qDebug("BaseGui::wheelEvent: delta: %d", e->delta());
5347 	e->accept();
5348 
5349 	if (e->orientation() == Qt::Vertical) {
5350 	    if (e->delta() >= 0)
5351 	        emit wheelUp();
5352 	    else
5353 	        emit wheelDown();
5354 	} else {
5355 		qDebug("BaseGui::wheelEvent: horizontal event received, doing nothing");
5356 	}
5357 }
5358 */
5359 
5360 // Called when a video has started to play
enterFullscreenOnPlay()5361 void BaseGui::enterFullscreenOnPlay() {
5362 	qDebug("BaseGui::enterFullscreenOnPlay: arg_start_in_fullscreen: %d, pref->start_in_fullscreen: %d", arg_start_in_fullscreen, pref->start_in_fullscreen);
5363 
5364 	if (arg_start_in_fullscreen != 0) {
5365 		if ((arg_start_in_fullscreen == 1 || pref->start_in_fullscreen) && !core->mdat.novideo) {
5366 			if (!pref->fullscreen) toggleFullscreen(true);
5367 		}
5368 	}
5369 }
5370 
5371 // Called when the playlist has stopped
exitFullscreenOnStop()5372 void BaseGui::exitFullscreenOnStop() {
5373     if (pref->fullscreen) {
5374 		toggleFullscreen(false);
5375 	}
5376 }
5377 
playlistHasFinished()5378 void BaseGui::playlistHasFinished() {
5379 	qDebug("BaseGui::playlistHasFinished");
5380 	core->stop();
5381 
5382 	exitFullscreenOnStop();
5383 
5384 	qDebug("BaseGui::playlistHasFinished: arg_close_on_finish: %d, pref->close_on_finish: %d", arg_close_on_finish, pref->close_on_finish);
5385 
5386 	if (arg_close_on_finish != 0) {
5387 		if ((arg_close_on_finish == 1) || (pref->close_on_finish)) {
5388 			#ifdef AUTO_SHUTDOWN_PC
5389 			if (pref->auto_shutdown_pc) {
5390 				ShutdownDialog d(this);
5391 				if (d.exec() == QDialog::Accepted) {
5392 					qDebug("BaseGui::playlistHasFinished: the PC will shut down");
5393 					Shutdown::shutdown();
5394 				} else {
5395 					qDebug("BaseGui::playlistHasFinished: shutdown aborted");
5396 				}
5397 			}
5398 			#endif
5399 			exitAct->trigger();
5400 		}
5401 	}
5402 }
5403 
addToPlaylistCurrentFile()5404 void BaseGui::addToPlaylistCurrentFile() {
5405 	qDebug("BaseGui::addToPlaylistCurrentFile");
5406 	if (!core->mdat.filename.isEmpty()) {
5407 		playlist->addItem(core->mdat.filename, "", 0);
5408 		playlist->setModified(true);
5409 		playlist->getMediaInfo(core->mdat);
5410 	}
5411 }
5412 
displayState(Core::State state)5413 void BaseGui::displayState(Core::State state) {
5414 	qDebug() << "BaseGui::displayState:" << core->stateToString();
5415 
5416 	switch (state) {
5417 		//case Core::Playing:	statusBar()->showMessage( tr("Playing %1").arg(core->mdat.filename), 2000); break;
5418 		case Core::Playing:	statusBar()->showMessage(""); break;
5419 		case Core::Paused:	statusBar()->showMessage( tr("Pause") ); break;
5420 		case Core::Stopped:	statusBar()->showMessage( tr("Stop") , 2000); break;
5421 		case Core::Buffering: /* statusBar()->showMessage(tr("Buffering...")); */ break;
5422 	}
5423 
5424 	if (state == Core::Stopped) setWindowCaption( "SMPlayer" );
5425 
5426 #ifdef AVOID_SCREENSAVER
5427 	/* Disable screensaver by event */
5428 	just_stopped = false;
5429 
5430 	if (state == Core::Stopped) {
5431 		just_stopped = true;
5432 		int time = 1000 * 60; // 1 minute
5433 		QTimer::singleShot( time, this, SLOT(clear_just_stopped()) );
5434 	}
5435 #endif
5436 }
5437 
displayMessage(QString message,int time)5438 void BaseGui::displayMessage(QString message, int time) {
5439 	statusBar()->showMessage(message, time);
5440 }
5441 
displayMessage(QString message)5442 void BaseGui::displayMessage(QString message) {
5443 	displayMessage(message, 2000);
5444 }
5445 
gotCurrentTime(double sec)5446 void BaseGui::gotCurrentTime(double sec) {
5447 	//qDebug() << "BaseGui::gotCurrentTime:" << sec;
5448 
5449 	static int last_second = 0;
5450 
5451 	if (qFloor(sec) == last_second) return; // Update only once per second
5452 	last_second = qFloor(sec);
5453 
5454 	QString time = Helper::formatTime( (int) sec ) + " / " +
5455                            Helper::formatTime( (int) core->mdat.duration );
5456 
5457 	emit timeChanged(sec);
5458 	emit timeChanged(time);
5459 }
5460 
changeSizeFactor(int factor)5461 void BaseGui::changeSizeFactor(int factor) {
5462 	// If fullscreen, don't resize!
5463 	if (pref->fullscreen) return;
5464 
5465 	if (isMaximized()) showNormal();
5466 
5467 	if (!pref->use_mplayer_window) {
5468 		pref->size_factor = factor;
5469 		resizeMainWindow(core->mset.win_width, core->mset.win_height);
5470 	}
5471 }
5472 
toggleDoubleSize()5473 void BaseGui::toggleDoubleSize() {
5474 	if (pref->size_factor != 100) changeSizeFactor(100); else changeSizeFactor(200);
5475 }
5476 
resizeWindow(int w,int h)5477 void BaseGui::resizeWindow(int w, int h) {
5478 	qDebug("BaseGui::resizeWindow: %d, %d", w, h);
5479 
5480 	// If fullscreen or maximized, don't resize!
5481 	if (pref->fullscreen || isMaximized()) return;
5482 
5483 	if ( (pref->resize_method==Preferences::Never) && (panel->isVisible()) ) {
5484 		return;
5485 	}
5486 
5487 	if (!panel->isVisible()) {
5488 		panel->show();
5489 
5490 		// Enable compact mode
5491 		//compactAct->setEnabled(true);
5492 	}
5493 
5494 	resizeMainWindow(w, h);
5495 }
5496 
resizeMainWindow(int w,int h)5497 void BaseGui::resizeMainWindow(int w, int h) {
5498 	if (pref->size_factor != 100) {
5499 		w = w * pref->size_factor / 100;
5500 		h = h * pref->size_factor / 100;
5501 	}
5502 
5503 	qDebug("BaseGui::resizeWindow: size to scale: %d, %d", w, h);
5504 
5505 	QSize video_size(w,h);
5506 
5507 	if (video_size == panel->size()) {
5508 		qDebug("BaseGui::resizeWindow: the panel size is already the required size. Doing nothing.");
5509 		return;
5510 	}
5511 
5512 	int diff_width = this->width() - panel->width();
5513 	int diff_height = this->height() - panel->height();
5514 
5515 #if 1
5516 	QRect desktop_rect = QApplication::desktop()->availableGeometry(this);
5517 	QSize desktop_size = QSize(desktop_rect.width(), desktop_rect.height());
5518 
5519 	if (w + diff_width > desktop_size.width() || h + diff_height > desktop_size.height()) {
5520 		qDebug("BaseGui::resizeWindow: video size is larger than desktop");
5521 		qDebug() << "BaseGui::resizeWindow: desktop size:" << desktop_size;
5522 		int spacing =  desktop_size.width() * 0.05;
5523 		int max_width = desktop_size.width() - diff_width - spacing;
5524 		int max_height = desktop_size.height() - diff_height - spacing;
5525 		qDebug("BaseGui::resizeWindow: max_size: %d %d", max_width, max_height);
5526 		double wr = (double) w / max_width;
5527 		double hr = (double) h / max_height;
5528 		double m = wr;
5529 		if (hr > wr) m = hr;
5530 		qDebug("BaseGui::resizeWindow: wr: %f hr: %f m: %f", wr, hr, m);
5531 		w =  w / m;
5532 		h = h / m;
5533 		qDebug("BaseGui::resizeWindow: new size to scale: %d, %d", w, h);
5534 	}
5535 #endif
5536 
5537 	int new_width = w + diff_width;
5538 	int new_height = h + diff_height;
5539 
5540 #if USE_MINIMUMSIZE
5541 	int minimum_width = minimumSizeHint().width();
5542 	if (pref->gui_minimum_width != 0) minimum_width = pref->gui_minimum_width;
5543 	if (new_width < minimum_width) {
5544 		qDebug("BaseGui::resizeWindow: width is too small, setting width to %d", minimum_width);
5545 		new_width = minimum_width;
5546 	}
5547 #endif
5548 
5549 	qDebug("BaseGui::resizeWindow: new_width: %d new_height: %d", new_width, new_height);
5550 
5551 #if 0
5552 	QRect desktop_rect = QApplication::desktop()->availableGeometry(this);
5553 	QSize desktop_size = QSize(desktop_rect.width(), desktop_rect.height());
5554 	//desktop_size.setWidth(1000); desktop_size.setHeight(1000); // test
5555 	if (new_width > desktop_size.width()) {
5556 		//double aspect = (double) new_width / new_height;
5557 		qDebug("BaseGui::resizeWindow: width (%d) is larger than desktop width (%d)", new_width, desktop_size.width());
5558 		new_width = desktop_size.width();
5559 		/*
5560 		new_height = new_width / aspect;
5561 		qDebug() << "BaseGui::resizeWindow: aspect:" << aspect;
5562 		qDebug("BaseGui::resizeWindow: height: %d", new_height);
5563 		*/
5564 	}
5565 	if (new_height > desktop_size.height()) {
5566 		qDebug("BaseGui::resizeWindow: height (%d) is larger than desktop height (%d)", new_height, desktop_size.height());
5567 		new_height = desktop_size.height();
5568 	}
5569 #endif
5570 
5571 	resize(new_width, new_height);
5572 
5573 	qDebug("BaseGui::resizeWindow: done: window size: %d, %d", this->width(), this->height());
5574 	qDebug("BaseGui::resizeWindow: done: panel->size: %d, %d",
5575            panel->size().width(),
5576            panel->size().height() );
5577 	qDebug("BaseGui::resizeWindow: done: mplayerwindow->size: %d, %d",
5578            mplayerwindow->size().width(),
5579            mplayerwindow->size().height() );
5580 
5581 	// Check if a part of the window is outside of the desktop
5582 	// and center the window in that case
5583 	if ((pref->center_window_if_outside) && (!core->mdat.novideo)) {
5584 		QRect screen_rect = QApplication::desktop()->availableGeometry(this);
5585 		QPoint right_bottom = QPoint(this->pos().x() + this->width(), this->pos().y() + this->height());
5586 		qDebug("BaseGui::resizeWindow: right bottom point: %d, %d", right_bottom.x(), right_bottom.y());;
5587 		if (!screen_rect.contains(right_bottom) || !screen_rect.contains(this->pos())) {
5588 			qDebug("BaseGui::resizeWindow: the window is outside of the desktop, it will be moved");
5589 			//move(screen_rect.x(), screen_rect.y());
5590 			int x = screen_rect.x() + ((screen_rect.width() - width()) / 2);
5591 			int y = screen_rect.y() + ((screen_rect.height() - height()) / 2);
5592 			//qDebug() << "BaseGui::resizeWindow: screen_rect.x:" << screen_rect.x() << "screen_rect.y:" << screen_rect.y();
5593 			//qDebug() << "BaseGui::resizeWindow: width:" << ((screen_rect.width() - width()) / 2);
5594 			//qDebug() << "BaseGui::resizeWindow: height:" << ((screen_rect.height() - height()) / 2);
5595 			if (x < screen_rect.x()) x = screen_rect.x();
5596 			if (y < screen_rect.y()) y = screen_rect.y();
5597 			//qDebug() << "BaseGui::resizeWindow: x:" << x << "y:" << y;
5598 			move(x, y);
5599 		}
5600 	}
5601 
5602 }
5603 
hidePanel()5604 void BaseGui::hidePanel() {
5605 	qDebug("BaseGui::hidePanel");
5606 
5607 	if (panel->isVisible()) {
5608 		if (isMaximized()) showNormal();
5609 
5610 		// Exit from fullscreen mode
5611 		if (pref->fullscreen) { toggleFullscreen(false); update(); }
5612 
5613 		// Exit from compact mode first
5614 		if (pref->compact_mode) toggleCompactMode(false);
5615 
5616 		//resizeWindow( size().width(), 0 );
5617 		int width = size().width();
5618 		if (width > pref->default_size.width()) width = pref->default_size.width();
5619 		resize( width, size().height() - panel->size().height() );
5620 		panel->hide();
5621 
5622 		// Disable compact mode
5623 		//compactAct->setEnabled(false);
5624 	}
5625 }
5626 
centerWindow()5627 void BaseGui::centerWindow() {
5628 	qDebug("BaseGui::centerWindow");
5629 	if (pref->center_window && !pref->fullscreen && isVisible()) {
5630 		QRect r = QApplication::desktop()->screenGeometry(this);
5631 		// r.setX(500); r.setY(150); // Test
5632 		qDebug() << "BaseGui::centerWindow: desktop rect:" << r;
5633 		int x = r.x() + ((r.width() - width()) / 2);
5634 		int y = r.y() + ((r.height() - height()) / 2);
5635 		move(x, y);
5636 	}
5637 }
5638 
displayGotoTime(int t)5639 void BaseGui::displayGotoTime(int t) {
5640 #ifdef SEEKBAR_RESOLUTION
5641 	int jump_time = (int)core->mdat.duration * t / SEEKBAR_RESOLUTION;
5642 #else
5643 	int jump_time = (int)core->mdat.duration * t / 100;
5644 #endif
5645 	QString s = tr("Jump to %1").arg( Helper::formatTime(jump_time) );
5646 	statusBar()->showMessage( s, 1000 );
5647 
5648 	if (pref->fullscreen) {
5649 		core->displayTextOnOSD( s );
5650 	}
5651 }
5652 
goToPosOnDragging(int t)5653 void BaseGui::goToPosOnDragging(int t) {
5654 	if (pref->update_while_seeking) {
5655 #if ENABLE_DELAYED_DRAGGING
5656 		#ifdef SEEKBAR_RESOLUTION
5657 		core->goToPosition(t);
5658 		#else
5659 		core->goToPos(t);
5660 		#endif
5661 #else
5662 		if ( ( t % 4 ) == 0 ) {
5663 			qDebug("BaseGui::goToPosOnDragging: %d", t);
5664 			#ifdef SEEKBAR_RESOLUTION
5665 			core->goToPosition(t);
5666 			#else
5667 			core->goToPos(t);
5668 			#endif
5669 		}
5670 #endif
5671 	}
5672 }
5673 
toggleCompactMode()5674 void BaseGui::toggleCompactMode() {
5675 	toggleCompactMode( !pref->compact_mode );
5676 }
5677 
toggleCompactMode(bool b)5678 void BaseGui::toggleCompactMode(bool b) {
5679 	qDebug("BaseGui::toggleCompactMode: %d", b);
5680 
5681 	if (b)
5682 		aboutToEnterCompactMode();
5683 	else
5684 		aboutToExitCompactMode();
5685 
5686 	pref->compact_mode = b;
5687 	updateWidgets();
5688 }
5689 
aboutToEnterCompactMode()5690 void BaseGui::aboutToEnterCompactMode() {
5691 	menuBar()->hide();
5692 	statusBar()->hide();
5693 }
5694 
aboutToExitCompactMode()5695 void BaseGui::aboutToExitCompactMode() {
5696 	menuBar()->show();
5697 	statusBar()->show();
5698 }
5699 
setStayOnTop(bool b)5700 void BaseGui::setStayOnTop(bool b) {
5701 	qDebug("BaseGui::setStayOnTop: %d", b);
5702 
5703 	if ( (b && (windowFlags() & Qt::WindowStaysOnTopHint)) ||
5704          (!b && (!(windowFlags() & Qt::WindowStaysOnTopHint))) )
5705 	{
5706 		// identical do nothing
5707 		qDebug("BaseGui::setStayOnTop: nothing to do");
5708 		return;
5709 	}
5710 
5711 	ignore_show_hide_events = true;
5712 
5713 	bool visible = isVisible();
5714 
5715 	QPoint old_pos = pos();
5716 
5717 	if (b) {
5718 		setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
5719 	}
5720 	else {
5721 		setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
5722 	}
5723 
5724 	move(old_pos);
5725 
5726 	if (visible) {
5727 		show();
5728 	}
5729 
5730 	ignore_show_hide_events = false;
5731 }
5732 
changeStayOnTop(int stay_on_top)5733 void BaseGui::changeStayOnTop(int stay_on_top) {
5734 	switch (stay_on_top) {
5735 		case Preferences::AlwaysOnTop : setStayOnTop(true); break;
5736 		case Preferences::NeverOnTop  : setStayOnTop(false); break;
5737 		case Preferences::WhilePlayingOnTop : setStayOnTop((core->state() == Core::Playing)); break;
5738 	}
5739 
5740 	pref->stay_on_top = (Preferences::OnTop) stay_on_top;
5741 	updateWidgets();
5742 }
5743 
checkStayOnTop(Core::State state)5744 void BaseGui::checkStayOnTop(Core::State state) {
5745 	qDebug("BaseGui::checkStayOnTop");
5746 	if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) {
5747 		if (state != Core::Buffering) {
5748 			setStayOnTop((state == Core::Playing));
5749 		}
5750 	}
5751 }
5752 
toggleStayOnTop()5753 void BaseGui::toggleStayOnTop() {
5754 	if (pref->stay_on_top == Preferences::AlwaysOnTop)
5755 		changeStayOnTop(Preferences::NeverOnTop);
5756 	else
5757 	if (pref->stay_on_top == Preferences::NeverOnTop)
5758 		changeStayOnTop(Preferences::AlwaysOnTop);
5759 }
5760 
5761 // Called when a new window (equalizer, preferences..) is opened.
exitFullscreenIfNeeded()5762 void BaseGui::exitFullscreenIfNeeded() {
5763 	/*
5764 	if (pref->fullscreen) {
5765 		toggleFullscreen(false);
5766 	}
5767 	*/
5768 }
5769 
5770 #if ALLOW_CHANGE_STYLESHEET
loadQss(QString filename)5771 QString BaseGui::loadQss(QString filename) {
5772 	qDebug("BaseGui::loadQss: %s", filename.toUtf8().constData());
5773 
5774 	QFile file( filename );
5775 	file.open(QFile::ReadOnly);
5776 	QString stylesheet = QLatin1String(file.readAll());
5777 
5778 	QString path;
5779 #ifdef USE_RESOURCES
5780 	Images::setTheme(pref->iconset);
5781 	if (Images::has_rcc || Images::is_internal) {
5782 		path = ":/" + pref->iconset;
5783 	} else {
5784 		QDir current = QDir::current();
5785 		QString td = Images::themesDirectory();
5786 		path = current.relativeFilePath(td);
5787 	}
5788 #else
5789 	if (Images::is_internal) {
5790 		path = ":/" + pref->iconset;
5791 	} else {
5792 		QDir current = QDir::current();
5793 		QString td = Images::themesDirectory();
5794 		path = current.relativeFilePath(td);
5795 	}
5796 #endif
5797 	stylesheet.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
5798 						QString("url(%1\\1)").arg(path + "/"));
5799 	//qDebug("BaseGui::loadQss: styleSheet: %s", stylesheet.toUtf8().constData());
5800 	return stylesheet;
5801 }
5802 
changeStyleSheet(QString style)5803 void BaseGui::changeStyleSheet(QString style) {
5804 	qDebug() << "BaseGui::changeStyleSheet:" << style;
5805 
5806 	// Load default stylesheet
5807 	QString stylesheet = loadQss(":/default-theme/style.qss");
5808 
5809 	if (!style.isEmpty()) {
5810 		// Check main.css
5811 		QString qss_file = Paths::configPath() + "/themes/" + pref->iconset + "/main.css";
5812 		if (!QFile::exists(qss_file)) {
5813 			qss_file = Paths::themesPath() +"/"+ pref->iconset + "/main.css";
5814 		}
5815 
5816 		// Check style.qss
5817 		if (!QFile::exists(qss_file)) {
5818 			QString ifile = ":/" + pref->iconset + "/style.qss";
5819 			if (QFile::exists(ifile)) {
5820 				qss_file = ifile;
5821 			}
5822 		}
5823 
5824 		if (!QFile::exists(qss_file)) {
5825 			qss_file = Paths::configPath() + "/themes/" + pref->iconset + "/style.qss";
5826 			if (!QFile::exists(qss_file)) {
5827 				qss_file = Paths::themesPath() +"/"+ pref->iconset + "/style.qss";
5828 			}
5829 		}
5830 
5831 		// Load style file
5832 		if (QFile::exists(qss_file)) {
5833 			qDebug() << "BaseGui::changeStyleSheet:" <<  qss_file;
5834 			stylesheet += loadQss(qss_file);
5835 		}
5836 	}
5837 
5838 	if (pref->tablet_mode) {
5839 		QString tf = Images::file("tabletmode.css");
5840 		qDebug() << "BaseGui::changeStyleSheet: tablet stylesheet file:" << tf;
5841 
5842 		QFile file(tf);
5843 		if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
5844 			stylesheet += file.readAll();
5845 		}
5846 	}
5847 
5848 	// Use the user specified font
5849 	if (!pref->default_font.isEmpty()) {
5850 		QFont f;
5851 		f.fromString( pref->default_font );
5852 		QString fstyle = QString("QWidget { font: %1 %2 %3pt %4; }")
5853 			.arg(f.bold() ? "bold" :"").arg(f.italic() ? "italic" : "")
5854 			.arg(f.pointSize()).arg(f.family());
5855 		stylesheet = fstyle + stylesheet;
5856 	}
5857 	//qDebug() << "BaseGui::changeStyleSheet: styleSheet:" << stylesheet;
5858 	qApp->setStyleSheet(stylesheet);
5859 }
5860 #endif
5861 
applyStyles()5862 void BaseGui::applyStyles() {
5863 	qDebug("BaseGui::applyStyles");
5864 
5865 #if !ALLOW_CHANGE_STYLESHEET
5866 	if (!pref->default_font.isEmpty()) {
5867 		QFont f;
5868 		f.fromString( pref->default_font );
5869 		if (QApplication::font() != f) {
5870 			qDebug() << "BaseGui::applyStyles: setting new font:" << pref->default_font;
5871 			QApplication::setFont(f);
5872 		}
5873 	}
5874 #endif
5875 
5876 #if ALLOW_CHANGE_STYLESHEET
5877 	qDebug() << "BaseGui::applyStyles: stylesheet:" << pref->iconset;
5878 	changeStyleSheet(pref->iconset);
5879 #endif
5880 
5881 #if STYLE_SWITCHING
5882 	QString style = pref->style;
5883 	if (style.isEmpty()) style = default_style;
5884 	qDebug() << "BaseGui::applyStyles: style:" << style;
5885 	if (!style.isEmpty()) {
5886 		#ifdef OS_UNIX_NOT_MAC
5887 		MyApplication * app = static_cast<MyApplication *>(qApp);
5888 		app->changeStyle(style);
5889 		#else
5890 		qApp->setStyle(style);
5891 		#endif
5892 		#ifdef Q_OS_WIN
5893 		qApp->setPalette(qApp->style()->standardPalette());
5894 		#endif
5895 	}
5896 #endif
5897 
5898 }
5899 
setTabletMode(bool b)5900 void BaseGui::setTabletMode(bool b) {
5901 	qDebug() << "BaseGui::setTabletMode:" << b;
5902 	pref->tablet_mode = b;
5903 	populateMainMenu();
5904 	applyStyles();
5905 
5906 	emit tabletModeChanged(b);
5907 }
5908 
5909 
loadActions()5910 void BaseGui::loadActions() {
5911 	qDebug("BaseGui::loadActions");
5912 	ActionsEditor::loadFromConfig(this, settings);
5913 
5914 	if (playlist->isWindow()) { // No dockable
5915 		ActionsEditor::loadFromConfig(playlist, settings);
5916 	}
5917 
5918 	actions_list = ActionsEditor::actionsNames(this);
5919 
5920 	if (playlist->isWindow()) { // No dockable
5921 		actions_list += ActionsEditor::actionsNames(playlist);
5922 	}
5923 }
5924 
saveActions()5925 void BaseGui::saveActions() {
5926 	qDebug("BaseGui::saveActions");
5927 
5928 	ActionsEditor::saveToConfig(this, settings);
5929 
5930 	if (playlist->isWindow()) { // No dockable
5931 		ActionsEditor::saveToConfig(playlist, settings);
5932 	}
5933 }
5934 
processMouseMovedDiff(QPoint diff)5935 void BaseGui::processMouseMovedDiff(QPoint diff) {
5936 	//qDebug() << "BaseGui::processMouseMovedDiff" << diff;
5937 
5938 #ifdef MOUSE_GESTURES
5939 	#ifdef MG_DELAYED_SEEK
5940 	if (delayed_seek_timer == 0) {
5941 		delayed_seek_timer = new QTimer(this);
5942 		delayed_seek_timer->setSingleShot(true);
5943 		delayed_seek_timer->setInterval(250);
5944 		connect(delayed_seek_timer, SIGNAL(timeout()), this, SLOT(delayedSeek()));
5945 	}
5946 	#endif
5947 
5948 	if (pref->drag_function == Preferences::Gestures || pref->tablet_mode) {
5949 		if (core->state() == Core::Stopped) return;
5950 
5951 		int t = 1;
5952 
5953 		int h_desp = qAbs(diff.x());
5954 		int v_desp = qAbs(diff.y());
5955 
5956 		int d = qAbs(h_desp - v_desp);
5957 
5958 		//qDebug() << "BaseGui::processMouseMovedDiff: h_desp:" << h_desp << "v_desp:" << v_desp << "d:" << d;
5959 		if (d < 2) return;
5960 
5961 		if (h_desp > v_desp) {
5962 			// Horizontal
5963 			if (diff.x() > t) {
5964 				#ifdef MG_DELAYED_SEEK
5965 				delayed_seek_value += h_desp;
5966 				delayed_seek_timer->start();
5967 				#else
5968 				core->sforward();
5969 				#endif
5970 			}
5971 			else
5972 			if (diff.x() < -t) {
5973 				#ifdef MG_DELAYED_SEEK
5974 				delayed_seek_value -= h_desp;
5975 				delayed_seek_timer->start();
5976 				#else
5977 				core->srewind();
5978 				#endif
5979 			}
5980 			#ifdef MG_DELAYED_SEEK
5981 			/*
5982 			int time = qAbs(delayed_seek_value);
5983 			int minutes = time / 60;
5984 			int seconds = time - (minutes * 60);
5985 			QString s;
5986 			if (delayed_seek_value >= 0) s = "+"; else s = "-";
5987 			s += QString("%1").arg(minutes, 2, 10, QChar('0')) + ":";
5988 			s += QString("%1").arg(seconds, 2, 10, QChar('0'));
5989 			*/
5990 			int time = core->mset.current_sec + delayed_seek_value;
5991 			if (time < 0) time = 0;
5992 			QString s;
5993 			s = tr("Jump to %1").arg(Helper::formatTime(time));
5994 			if (pref->fullscreen) {
5995 				core->displayTextOnOSD(s, 1000);
5996 			} else {
5997 				displayMessage(s, 1000);
5998 			}
5999 			#endif
6000 		}
6001 		else
6002 		if (h_desp < v_desp) {
6003 			// Vertical
6004 			if (diff.y() > t) core->decVolume(1);
6005 			else
6006 			if (diff.y() < -t) core->incVolume(1);
6007 		}
6008 	}
6009 #endif
6010 
6011 	if (pref->drag_function == Preferences::MoveWindow && !pref->tablet_mode) {
6012 		moveWindowDiff(diff);
6013 	}
6014 }
6015 
moveWindowDiff(QPoint diff)6016 void BaseGui::moveWindowDiff(QPoint diff) {
6017 	//qDebug() << "BaseGui::moveWindowDiff:" << diff;
6018 
6019 	QWidget * w = this;
6020 	if (mplayerwindow->parent() == 0) w = mplayerwindow;
6021 
6022 	if (pref->fullscreen || isMaximized()) {
6023 		return;
6024 	}
6025 
6026 #if QT_VERSION >= 0x050000
6027 	// Move the window with some delay.
6028 	// Seems to work better with Qt 5
6029 
6030 	static QPoint d;
6031 	static int count = 0;
6032 
6033 	d += diff;
6034 	count++;
6035 
6036 	if (count > 3) {
6037 		//qDebug() << "BaseGui::moveWindowDiff:" << d;
6038 		QPoint new_pos = w->pos() + d;
6039 		/*
6040 		if (new_pos.y() < 0) new_pos.setY(0);
6041 		if (new_pos.x() < 0) new_pos.setX(0);
6042 		*/
6043 		//qDebug() << "BaseGui::moveWindowDiff: new_pos:" << new_pos;
6044 		w->move(new_pos);
6045 		count = 0;
6046 		d = QPoint(0,0);
6047 	}
6048 #else
6049 	//qDebug() << "BaseGui::moveWindowDiff:" << diff;
6050 	w->move(w->pos() + diff);
6051 #endif
6052 }
6053 
6054 #ifdef MG_DELAYED_SEEK
delayedSeek()6055 void BaseGui::delayedSeek() {
6056 	qDebug() << "BaseGui::delayedSeek:" << delayed_seek_value;
6057 	if (delayed_seek_value != 0) {
6058 		core->seek(delayed_seek_value);
6059 		delayed_seek_value = 0;
6060 	}
6061 }
6062 #endif
6063 
6064 
6065 #ifndef DETECT_MINIMIZE_WORKAROUND
showEvent(QShowEvent *)6066 void BaseGui::showEvent( QShowEvent * ) {
6067 	qDebug("BaseGui::showEvent");
6068 
6069 	if (ignore_show_hide_events) return;
6070 
6071 	//qDebug("BaseGui::showEvent: pref->pause_when_hidden: %d", pref->pause_when_hidden);
6072 	if ((pref->pause_when_hidden) && (core->state() == Core::Paused)) {
6073 		qDebug("BaseGui::showEvent: unpausing");
6074 		core->pause(); // Unpauses
6075 	}
6076 }
6077 
hideEvent(QHideEvent *)6078 void BaseGui::hideEvent( QHideEvent * ) {
6079 	qDebug("BaseGui::hideEvent");
6080 
6081 	if (ignore_show_hide_events) return;
6082 
6083 	//qDebug("BaseGui::hideEvent: pref->pause_when_hidden: %d", pref->pause_when_hidden);
6084 	if ((pref->pause_when_hidden) && (core->state() == Core::Playing)) {
6085 		qDebug("BaseGui::hideEvent: pausing");
6086 		core->pause();
6087 	}
6088 }
6089 #else
6090 // Qt 5 doesn't call showEvent / hideEvent when the window is minimized or unminimized
event(QEvent * e)6091 bool BaseGui::event(QEvent * e) {
6092 	//qDebug("BaseGui::event: %d", e->type());
6093 
6094 	bool result = QMainWindow::event(e);
6095 	if ((ignore_show_hide_events) || (!pref->pause_when_hidden)) return result;
6096 
6097 	if (e->type() == QEvent::WindowStateChange) {
6098 		qDebug("BaseGui::event: WindowStateChange");
6099 
6100 		if (isMinimized()) {
6101 			was_minimized = true;
6102 			if (core->state() == Core::Playing) {
6103 				qDebug("BaseGui::event: pausing");
6104 				core->pause();
6105 			}
6106 		}
6107 	}
6108 
6109 	if ((e->type() == QEvent::ActivationChange) && (isActiveWindow())) {
6110 		qDebug("BaseGui::event: ActivationChange: %d", was_minimized);
6111 
6112 		if ((!isMinimized()) && (was_minimized)) {
6113 			was_minimized = false;
6114 			if (core->state() == Core::Paused) {
6115 				qDebug("BaseGui::showEvent: unpausing");
6116 				core->pause(); // Unpauses
6117 			}
6118 		}
6119 	}
6120 
6121 	return result;
6122 }
6123 #endif
6124 
askForMplayerVersion(QString line)6125 void BaseGui::askForMplayerVersion(QString line) {
6126 	qDebug("BaseGui::askForMplayerVersion: %s", line.toUtf8().data());
6127 
6128 	if (pref->mplayer_user_supplied_version <= 0) {
6129 		InputMplayerVersion d(this);
6130 		d.setVersion( pref->mplayer_user_supplied_version );
6131 		d.setVersionFromOutput(line);
6132 		if (d.exec() == QDialog::Accepted) {
6133 			pref->mplayer_user_supplied_version = d.version();
6134 			qDebug("BaseGui::askForMplayerVersion: user supplied version: %d", pref->mplayer_user_supplied_version);
6135 		}
6136 	} else {
6137 		qDebug("BaseGui::askForMplayerVersion: already have a version supplied by user, so no asking");
6138 	}
6139 }
6140 
showExitCodeFromMplayer(int exit_code)6141 void BaseGui::showExitCodeFromMplayer(int exit_code) {
6142 	qDebug("BaseGui::showExitCodeFromMplayer: %d", exit_code);
6143 
6144 	if (!pref->report_mplayer_crashes) {
6145 		qDebug("BaseGui::showExitCodeFromMplayer: not displaying error dialog");
6146 		statusBar()->showMessage(tr("%1 has finished unexpectedly.").arg(PLAYER_NAME) +" "+ tr("More info in the log."));
6147 		return;
6148 	}
6149 
6150 	if (exit_code != 255 ) {
6151 		ErrorDialog d(this);
6152 		d.setWindowTitle(tr("%1 Error").arg(PLAYER_NAME));
6153 		QString text = tr("%1 has finished unexpectedly.").arg(PLAYER_NAME) + " " +
6154 					   tr("Exit code: %1").arg(exit_code);
6155 
6156 		#if defined(Q_OS_WIN) && defined(LOG_MPLAYER)
6157 		bool ytdl_fails = false;
6158 
6159 		QString ytdl_bin = QFileInfo(pref->mplayer_bin).absolutePath() +"/youtube-dl.exe";
6160 		qDebug() << "BaseGui::showExitCodeFromMplayer: youtube-dl path:" << ytdl_bin;
6161 
6162 		#if 1
6163 		// Newer versions of mpv display this message
6164 		if (mplayer_log.contains("youtube-dl failed")) {
6165 			int code = QProcess::execute(ytdl_bin, QStringList() << "--version");
6166 			qDebug() << "BaseGui::showExitCodeFromMplayer: youtube-dl exit code:" << code;
6167 			if (code == -1) ytdl_fails = true;
6168 		}
6169 		else
6170 		#endif
6171 		if (mplayer_log.contains("youtube-dl not found, not executable, or broken")) {
6172 			bool exists_ytdl = QFile::exists(ytdl_bin);
6173 			qDebug() << "BaseGui::showExitCodeFromMplayer: check if" << ytdl_bin << "exists:" << exists_ytdl;
6174 			if (exists_ytdl) ytdl_fails = true;
6175 		}
6176 
6177 		if (ytdl_fails) {
6178 			text += "<br><br>" + tr("The component youtube-dl failed to run.") +" "+
6179 					tr("Installing the Microsoft Visual C++ 2010 Redistributable Package (x86) may fix the problem.") +
6180 					"<br><a href=\"https://www.microsoft.com/en-US/download/details.aspx?id=5555\">" +
6181 					tr("Click here to get it") + "</a>.";
6182 		}
6183 		#endif
6184 
6185 		d.setText(text);
6186 
6187 		#ifdef LOG_MPLAYER
6188 		d.setLog( mplayer_log );
6189 		#endif
6190 		d.exec();
6191 	}
6192 }
6193 
showErrorFromMplayer(QProcess::ProcessError e)6194 void BaseGui::showErrorFromMplayer(QProcess::ProcessError e) {
6195 	qDebug("BaseGui::showErrorFromMplayer");
6196 
6197 	if (!pref->report_mplayer_crashes) {
6198 		qDebug("BaseGui::showErrorFromMplayer: not displaying error dialog");
6199 		statusBar()->showMessage(tr("%1 failed to start.").arg(PLAYER_NAME) +" "+ tr("More info in the log."));
6200 		return;
6201 	}
6202 
6203 	if ((e == QProcess::FailedToStart) || (e == QProcess::Crashed)) {
6204 		ErrorDialog d(this);
6205 		d.setWindowTitle(tr("%1 Error").arg(PLAYER_NAME));
6206 		if (e == QProcess::FailedToStart) {
6207 			d.setText(tr("%1 failed to start.").arg(PLAYER_NAME) + " " +
6208                          tr("Please check the %1 path in preferences.").arg(PLAYER_NAME));
6209 		} else {
6210 			d.setText(tr("%1 has crashed.").arg(PLAYER_NAME) + " " +
6211                       tr("See the log for more info."));
6212 		}
6213 #ifdef LOG_MPLAYER
6214 		d.setLog( mplayer_log );
6215 #endif
6216 		d.exec();
6217 	}
6218 }
6219 
6220 
6221 #ifdef FIND_SUBTITLES
showFindSubtitlesDialog()6222 void BaseGui::showFindSubtitlesDialog() {
6223 	qDebug("BaseGui::showFindSubtitlesDialog");
6224 
6225 	if (!find_subs_dialog) {
6226 		find_subs_dialog = new FindSubtitlesWindow(0);
6227 		find_subs_dialog->setSettings(Global::settings);
6228 		find_subs_dialog->setWindowIcon(windowIcon());
6229 #if DOWNLOAD_SUBS
6230 		connect(find_subs_dialog, SIGNAL(subtitleDownloaded(const QString &)),
6231                 core, SLOT(loadSub(const QString &)));
6232 #endif
6233 	}
6234 
6235 	find_subs_dialog->show();
6236 	find_subs_dialog->setMovie(core->mdat.filename);
6237 }
6238 
openUploadSubtitlesPage()6239 void BaseGui::openUploadSubtitlesPage() {
6240 	QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/upload") );
6241 }
6242 #endif
6243 
6244 #ifdef VIDEOPREVIEW
showVideoPreviewDialog()6245 void BaseGui::showVideoPreviewDialog() {
6246 	qDebug("BaseGui::showVideoPreviewDialog");
6247 
6248 	if (video_preview == 0) {
6249 		video_preview = new VideoPreview( pref->mplayer_bin, this );
6250 		video_preview->setSettings(Global::settings);
6251 	}
6252 
6253 	if (!core->mdat.filename.isEmpty()) {
6254 		video_preview->setVideoFile(core->mdat.filename);
6255 
6256 		// DVD
6257 		if (core->mdat.type==TYPE_DVD) {
6258 			QString file = core->mdat.filename;
6259 			DiscData disc_data = DiscName::split(file);
6260 			QString dvd_folder = disc_data.device;
6261 			if (dvd_folder.isEmpty()) dvd_folder = pref->dvd_device;
6262 			int dvd_title = disc_data.title;
6263 			file = disc_data.protocol + "://" + QString::number(dvd_title);
6264 
6265 			video_preview->setVideoFile(file);
6266 			video_preview->setDVDDevice(dvd_folder);
6267 		} else {
6268 			video_preview->setDVDDevice("");
6269 		}
6270 	}
6271 
6272 	video_preview->setMplayerPath(pref->mplayer_bin);
6273 
6274 	if ( (video_preview->showConfigDialog(this)) && (video_preview->createThumbnails()) ) {
6275 		video_preview->show();
6276 		video_preview->adjustWindowSize();
6277 	}
6278 }
6279 #endif
6280 
6281 #ifdef YOUTUBE_SUPPORT
showTubeBrowser()6282 void BaseGui::showTubeBrowser() {
6283 	qDebug("BaseGui::showTubeBrowser");
6284 #ifdef USE_SMTUBE_LIB
6285 	if (browser_window == 0) {
6286 		browser_window = new BrowserWindow(Paths::configPath(), 0);
6287 		connect(browser_window, SIGNAL(requestOpenUrl(const QString &)),
6288                 this, SLOT(open(QString)));
6289 		browser_window->loadHomePage();
6290 	}
6291 	browser_window->show();
6292 #else
6293 	#ifdef Q_OS_WIN
6294 	QString exec = Paths::appPath() + "/smtube.exe";
6295 	#else
6296 	#ifdef Q_OS_MACX
6297 	QString exec = Paths::appPath() + "/smtube";
6298 	#else
6299 	QString exec = Helper::findExecutable("smtube");
6300 	#endif
6301 	#endif
6302 
6303 	if (exec.isEmpty() || !QFile::exists(exec)) {
6304 		QMessageBox::warning(this, "SMPlayer",
6305 			tr("The YouTube Browser is not installed.") +"<br>"+
6306 			tr("Visit %1 to get it.").arg("<a href=http://www.smtube.org>http://www.smtube.org</a>"));
6307 		return;
6308 	}
6309 
6310 	QStringList args;
6311 	if (!pref->language.isEmpty()) args << "-lang" << pref->language;
6312 	qDebug() << "BaseGui::showTubeBrowser: exec:" << exec << "args:" << args;
6313 
6314 	if (!QProcess::startDetached(exec, args)) {
6315 		QMessageBox::warning(this, "SMPlayer",
6316 			tr("The YouTube Browser failed to run.") +"<br>"+
6317 			tr("Be sure it's installed correctly.") +"<br>"+
6318 			tr("Visit %1 to get it.").arg("<a href=http://www.smtube.org>http://www.smtube.org</a>"));
6319 	}
6320 #endif
6321 }
6322 #endif
6323 
6324 // Language change stuff
changeEvent(QEvent * e)6325 void BaseGui::changeEvent(QEvent *e) {
6326 	if (e->type() == QEvent::LanguageChange) {
6327 		retranslateStrings();
6328 	} else {
6329 		QMainWindow::changeEvent(e);
6330 	}
6331 }
6332 
6333 #ifdef NUMPAD_WORKAROUND
6334 // Due to a bug in Qt 5 on linux, accelerators in numeric keypad don't work
6335 // This catches the key presses in the numeric keypad and calls the associated action
keyPressEvent(QKeyEvent * event)6336 void BaseGui::keyPressEvent(QKeyEvent *event) {
6337 	if (event->modifiers().testFlag(Qt::KeypadModifier)) {
6338 		qDebug() << "BaseGui::keyPressEvent: key:" << event->key() << "modifiers:" << event->modifiers();
6339 
6340 		QKeySequence ks(event->key());
6341 		QList<QAction *> actions = this->actions();
6342 		foreach(QAction * action, actions) {
6343 			QList<QKeySequence> shortcuts = action->shortcuts();
6344 			foreach(QKeySequence s, shortcuts) {
6345 				bool match = (s == ks);
6346 				if (match) {
6347 					qDebug() << "BaseGui::keyPressEvent: action found:" << action->objectName() << "enabled:" << action->isEnabled();
6348 				}
6349 				if (match && action->isEnabled()) {
6350 					if (action->isCheckable() && action->objectName() != "play_or_pause") {
6351 						action->toggle();
6352 					} else {
6353 						action->trigger();
6354 					}
6355 					return;
6356 				}
6357 			}
6358 		}
6359 	}
6360 
6361 	QMainWindow::keyPressEvent(event);
6362 }
6363 #endif
6364 
6365 #ifdef Q_OS_WIN
6366 
6367 #ifndef SM_CONVERTIBLESLATEMODE
6368 #define SM_CONVERTIBLESLATEMODE 0x2003
6369 #endif
6370 
6371 #ifndef SM_SYSTEMDOCKED
6372 #define SM_SYSTEMDOCKED 0x2004
6373 #endif
6374 
winEvent(MSG * m,long * result)6375 bool BaseGui::winEvent ( MSG * m, long * result ) {
6376 	//qDebug() << "BaseGui::winEvent:" << m;
6377 	if (m && m->message == WM_SETTINGCHANGE && m->lParam) {
6378 		QString text = QString::fromWCharArray((TCHAR*)m->lParam);
6379 		qDebug() << "BaseGui::winEvent: WM_SETTINGCHANGE:" << text;
6380 
6381 		#if ((QT_VERSION >= 0x040807 && QT_VERSION < 0x050000) || (QT_VERSION >= 0x050500))
6382 		if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10) {
6383 			// Windows 10 check
6384 			if (text == "UserInteractionMode") {
6385 				QTimer::singleShot(1000, this, SLOT(checkSystemTabletMode()));
6386 			}
6387 		}
6388 		else
6389 		if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8_1) {
6390 			if (text == "ConvertibleSlateMode") checkSystemTabletMode();
6391 		}
6392 		#endif
6393 
6394 		*result = 0;
6395 		return true;
6396 	}
6397 #ifdef AVOID_SCREENSAVER
6398 	else
6399 	if (m->message==WM_SYSCOMMAND) {
6400 		if ((m->wParam & 0xFFF0)==SC_SCREENSAVE || (m->wParam & 0xFFF0)==SC_MONITORPOWER) {
6401 			qDebug("BaseGui::winEvent: received SC_SCREENSAVE or SC_MONITORPOWER");
6402 			qDebug("BaseGui::winEvent: avoid_screensaver: %d", pref->avoid_screensaver);
6403 			qDebug("BaseGui::winEvent: playing: %d", core->state()==Core::Playing);
6404 			qDebug("BaseGui::winEvent: video: %d", !core->mdat.novideo);
6405 
6406 			if ((pref->avoid_screensaver) && (core->state()==Core::Playing) && (!core->mdat.novideo)) {
6407 				qDebug("BaseGui::winEvent: not allowing screensaver");
6408 				(*result) = 0;
6409 				return true;
6410 			} else {
6411 				if ((pref->avoid_screensaver) && (just_stopped)) {
6412 					qDebug("BaseGui::winEvent: file just stopped, so not allowing screensaver for a while");
6413 					(*result) = 0;
6414 					return true;
6415 				} else {
6416 					qDebug("BaseGui::winEvent: allowing screensaver");
6417 					return false;
6418 				}
6419 			}
6420 		}
6421 	}
6422 #endif
6423 	return false;
6424 }
6425 
6426 #if QT_VERSION >= 0x050000
nativeEvent(const QByteArray & eventType,void * message,long * result)6427 bool BaseGui::nativeEvent(const QByteArray &eventType, void * message, long * result) {
6428 	//qDebug() << "BaseGui::nativeEvent:" << eventType;
6429 
6430 	if (eventType == "windows_generic_MSG") {
6431 		MSG * m = static_cast<MSG *>(message);
6432 		return winEvent(m, result);
6433 	}
6434 
6435 	return false;
6436 }
6437 #endif
6438 
checkSystemTabletMode()6439 void BaseGui::checkSystemTabletMode() {
6440 	#if ((QT_VERSION >= 0x040807 && QT_VERSION < 0x050000) || (QT_VERSION >= 0x050500))
6441 	if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10) {
6442 		// Windows 10 code (don't know if this works on Windows 8)
6443 		QSettings set("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ImmersiveShell", QSettings::NativeFormat);
6444 		QVariant v = set.value("TabletMode");
6445 		if (v.isValid()) {
6446 			bool system_tablet_mode = (v.toInt() == 1);
6447 			qDebug() << "BaseGui::checkSystemTabletMode: system_tablet_mode:" << system_tablet_mode;
6448 			systemTabletModeChanged(system_tablet_mode);
6449 		}
6450 	}
6451 	else
6452 	if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8_1 ||
6453         QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8)
6454 	{
6455 		bool slate_mode = (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0);
6456 		qDebug() << "BaseGui::checkSystemTabletMode: slate_mode:" << slate_mode;
6457 		/*
6458 		bool docked = (GetSystemMetrics(SM_SYSTEMDOCKED) != 0);
6459 		qDebug() << "BaseGui::checkSystemTabletMode: docked:" << docked;
6460 		*/
6461 		bool system_tablet_mode = slate_mode;
6462 		systemTabletModeChanged(system_tablet_mode);
6463 	}
6464 	#endif
6465 }
6466 
systemTabletModeChanged(bool system_tablet_mode)6467 void BaseGui::systemTabletModeChanged(bool system_tablet_mode) {
6468 	qDebug() << "BaseGui::systemTabletModeChanged:" << system_tablet_mode;
6469 
6470 	if (pref->tablet_mode != system_tablet_mode) {
6471 		qDebug("BaseGui::systemTabletModeChanged: tablet mode should be changed");
6472 
6473 		if (pref->tablet_mode_change_answer == "yes") {
6474 			setTabletMode(system_tablet_mode);
6475 		}
6476 		else
6477 		if (pref->tablet_mode_change_answer == "no") {
6478 			return;
6479 		}
6480 		else {
6481 			// Ask the user
6482 			QString text;
6483 			if (system_tablet_mode)
6484 				text = tr("The system has switched to tablet mode. Should SMPlayer change to tablet mode as well?");
6485 			else
6486 				text = tr("The system has exited tablet mode. Should SMPlayer turn off the tablet mode as well?");
6487 
6488 			QMessageBox mb(QMessageBox::Question, "SMPlayer", text, QMessageBox::Yes | QMessageBox::No);
6489 			#if QT_VERSION >= 0x050200
6490 			QCheckBox cb(tr("Remember my decision and don't ask again"));
6491 			mb.setCheckBox(&cb);
6492 			#endif
6493 			if (mb.exec() == QMessageBox::Yes) {
6494 				setTabletMode(system_tablet_mode);
6495 			}
6496 			#if QT_VERSION >= 0x050200
6497 			if (cb.isChecked()) {
6498 				pref->tablet_mode_change_answer = (mb.result() == QMessageBox::Yes ? "yes" : "no");
6499 			}
6500 			#endif
6501 		}
6502 		// Update action button
6503 		tabletModeAct->setChecked(pref->tablet_mode);
6504 	}
6505 }
6506 
6507 #ifdef AVOID_SCREENSAVER
clear_just_stopped()6508 void BaseGui::clear_just_stopped() {
6509 	qDebug("BaseGui::clear_just_stopped");
6510 	just_stopped = false;
6511 }
6512 #endif
6513 
6514 #endif // Q_OS_WIN
6515 
6516 #include "moc_basegui.cpp"
6517