1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "baseguiplus.h"
|
---|
20 | #include "config.h"
|
---|
21 | #include "myaction.h"
|
---|
22 | #include "global.h"
|
---|
23 | #include "images.h"
|
---|
24 | #include "playlist.h"
|
---|
25 |
|
---|
26 | #ifdef TV_SUPPORT
|
---|
27 | #include "tvlist.h"
|
---|
28 | #else
|
---|
29 | #include "favorites.h"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include "widgetactions.h"
|
---|
33 | #include "myactiongroup.h"
|
---|
34 |
|
---|
35 | #include <QMenu>
|
---|
36 | #include <QCloseEvent>
|
---|
37 | #include <QApplication>
|
---|
38 | #include <QDesktopWidget>
|
---|
39 |
|
---|
40 | #if DOCK_PLAYLIST
|
---|
41 | #include <QDockWidget>
|
---|
42 | #include "playlistdock.h"
|
---|
43 | #include "desktopinfo.h"
|
---|
44 |
|
---|
45 | #define PLAYLIST_ON_SIDES 1
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #ifdef SCREENS_SUPPORT
|
---|
49 | #include <QVBoxLayout>
|
---|
50 | #include <QLabel>
|
---|
51 | #include "mplayerwindow.h"
|
---|
52 | #include "infowindow.h"
|
---|
53 |
|
---|
54 | #if QT_VERSION >= 0x050000
|
---|
55 | #include <QScreen>
|
---|
56 | #include <QWindow>
|
---|
57 | #endif
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | #ifdef GLOBALSHORTCUTS
|
---|
61 | #include "globalshortcuts/globalshortcuts.h"
|
---|
62 | #include "preferencesdialog.h"
|
---|
63 | #include "prefinput.h"
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #ifdef CHROMECAST_SUPPORT
|
---|
67 | #include "chromecast.h"
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | using namespace Global;
|
---|
71 |
|
---|
72 | BaseGuiPlus::BaseGuiPlus( QWidget * parent, Qt::WindowFlags flags)
|
---|
73 | : BaseGui( parent, flags )
|
---|
74 | #ifdef SCREENS_SUPPORT
|
---|
75 | , screens_info_window(0)
|
---|
76 | , detached_label(0)
|
---|
77 | #endif
|
---|
78 | , mainwindow_visible(true)
|
---|
79 | , trayicon_playlist_was_visible(false)
|
---|
80 | , widgets_size(0)
|
---|
81 | #if DOCK_PLAYLIST
|
---|
82 | , fullscreen_playlist_was_visible(false)
|
---|
83 | , fullscreen_playlist_was_floating(false)
|
---|
84 | , compact_playlist_was_visible(false)
|
---|
85 | , ignore_playlist_events(false)
|
---|
86 | #endif
|
---|
87 | {
|
---|
88 | // Initialize variables
|
---|
89 | //infowindow_visible = false;
|
---|
90 | mainwindow_pos = pos();
|
---|
91 |
|
---|
92 | tray = new QSystemTrayIcon(this);
|
---|
93 |
|
---|
94 | tray->setToolTip( "SMPlayer" );
|
---|
95 | connect( tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
---|
96 | this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
|
---|
97 |
|
---|
98 | quitAct = new MyAction(QKeySequence("Ctrl+Q"), this, "quit");
|
---|
99 | connect( quitAct, SIGNAL(triggered()), this, SLOT(quit()) );
|
---|
100 |
|
---|
101 | showTrayAct = new MyAction(this, "show_tray_icon" );
|
---|
102 | showTrayAct->setCheckable(true);
|
---|
103 | connect( showTrayAct, SIGNAL(toggled(bool)),
|
---|
104 | tray, SLOT(setVisible(bool)) );
|
---|
105 |
|
---|
106 | showAllAct = new MyAction(this, "restore/hide");
|
---|
107 | connect( showAllAct, SIGNAL(triggered()),
|
---|
108 | this, SLOT(toggleShowAll()) );
|
---|
109 |
|
---|
110 | context_menu = new QMenu(this);
|
---|
111 | context_menu->addAction(showAllAct);
|
---|
112 | context_menu->addSeparator();
|
---|
113 | context_menu->addAction(openFileAct);
|
---|
114 | context_menu->addMenu(recentfiles_menu);
|
---|
115 | context_menu->addAction(openDirectoryAct);
|
---|
116 | context_menu->addAction(openDVDAct);
|
---|
117 | context_menu->addAction(openURLAct);
|
---|
118 | context_menu->addMenu(favorites);
|
---|
119 | #if defined(TV_SUPPORT) && !defined(Q_OS_WIN)
|
---|
120 | context_menu->addMenu(tvlist);
|
---|
121 | context_menu->addMenu(radiolist);
|
---|
122 | #endif
|
---|
123 | context_menu->addSeparator();
|
---|
124 | context_menu->addAction(playOrPauseAct);
|
---|
125 | context_menu->addAction(stopAct);
|
---|
126 | context_menu->addSeparator();
|
---|
127 | context_menu->addAction(playPrevAct);
|
---|
128 | context_menu->addAction(playNextAct);
|
---|
129 | context_menu->addSeparator();
|
---|
130 | context_menu->addAction(showPlaylistAct);
|
---|
131 | context_menu->addAction(showPreferencesAct);
|
---|
132 | context_menu->addSeparator();
|
---|
133 | context_menu->addAction(quitAct);
|
---|
134 |
|
---|
135 | tray->setContextMenu( context_menu );
|
---|
136 |
|
---|
137 | #if DOCK_PLAYLIST
|
---|
138 | // Playlistdock
|
---|
139 | playlistdock = new PlaylistDock(this);
|
---|
140 | playlistdock->setObjectName("playlistdock");
|
---|
141 | playlistdock->setFloating(false); // To avoid that the playlist is visible for a moment
|
---|
142 | playlistdock->setWidget(playlist);
|
---|
143 | playlistdock->setWindowTitle(playlist->windowTitle());
|
---|
144 | playlistdock->setAllowedAreas(Qt::TopDockWidgetArea |
|
---|
145 | Qt::BottomDockWidgetArea
|
---|
146 | #if PLAYLIST_ON_SIDES
|
---|
147 | | Qt::LeftDockWidgetArea |
|
---|
148 | Qt::RightDockWidgetArea
|
---|
149 | #endif
|
---|
150 | );
|
---|
151 | addDockWidget(Qt::BottomDockWidgetArea, playlistdock);
|
---|
152 | playlistdock->hide();
|
---|
153 | playlistdock->setFloating(true); // Floating by default
|
---|
154 |
|
---|
155 | connect( playlistdock, SIGNAL(closed()), this, SLOT(playlistClosed()) );
|
---|
156 | connect(playlist, SIGNAL(windowTitleChanged(const QString &)), playlistdock, SLOT(setWindowTitle(const QString &)));
|
---|
157 | #if USE_DOCK_TOPLEVEL_EVENT
|
---|
158 | connect( playlistdock, SIGNAL(topLevelChanged(bool)),
|
---|
159 | this, SLOT(dockTopLevelChanged(bool)) );
|
---|
160 | #else
|
---|
161 | connect( playlistdock, SIGNAL(visibilityChanged(bool)),
|
---|
162 | this, SLOT(dockVisibilityChanged(bool)) );
|
---|
163 | #endif // USE_DOCK_TOPLEVEL_EVENT
|
---|
164 |
|
---|
165 | connect(this, SIGNAL(openFileRequested()), this, SLOT(showAll()));
|
---|
166 |
|
---|
167 | ignore_playlist_events = false;
|
---|
168 | #endif // DOCK_PLAYLIST
|
---|
169 |
|
---|
170 | #ifdef DETACH_VIDEO_OPTION
|
---|
171 | detachVideoAct = new MyAction(this, "detach_video");
|
---|
172 | detachVideoAct->setCheckable(true);
|
---|
173 | connect(detachVideoAct, SIGNAL(toggled(bool)), this, SLOT(detachVideo(bool)));
|
---|
174 | #endif
|
---|
175 |
|
---|
176 | #ifdef CHROMECAST_SUPPORT
|
---|
177 | playOnChromecastAct = new MyAction(this, "play_on_chromecast");
|
---|
178 | connect(playOnChromecastAct, SIGNAL(triggered()), this, SLOT(playOnChromecast()));
|
---|
179 | #endif
|
---|
180 |
|
---|
181 | #ifdef SCREENS_SUPPORT
|
---|
182 | sendToScreen_menu = new QMenu(this);
|
---|
183 | sendToScreen_menu->menuAction()->setObjectName("send_to_screen_menu");
|
---|
184 |
|
---|
185 | sendToScreenGroup = new MyActionGroup(this);
|
---|
186 | connect(sendToScreenGroup, SIGNAL(activated(int)), this, SLOT(sendVideoToScreen(int)));
|
---|
187 |
|
---|
188 | updateSendToScreen();
|
---|
189 |
|
---|
190 | showScreensInfoAct = new MyAction(this, "screens_info");
|
---|
191 | connect(showScreensInfoAct, SIGNAL(triggered()), this, SLOT(showScreensInfo()));
|
---|
192 |
|
---|
193 | #if QT_VERSION >= 0x040600 && QT_VERSION < 0x050000
|
---|
194 | connect(qApp->desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(updateSendToScreen()));
|
---|
195 | #endif
|
---|
196 | #if QT_VERSION >= 0x050000
|
---|
197 | connect(qApp, SIGNAL(screenAdded(QScreen *)), this, SLOT(updateSendToScreen()));
|
---|
198 | #endif
|
---|
199 | #if QT_VERSION >= 0x050400
|
---|
200 | connect(qApp, SIGNAL(screenRemoved(QScreen *)), this, SLOT(updateSendToScreen()));
|
---|
201 | #endif
|
---|
202 | #if QT_VERSION >= 0x050600
|
---|
203 | connect(qApp, SIGNAL(primaryScreenChanged(QScreen *)), this, SLOT(updateSendToScreen()));
|
---|
204 | #endif
|
---|
205 |
|
---|
206 | // Label that replaces the mplayerwindow when detached
|
---|
207 | detached_label = new QLabel(panel);
|
---|
208 | detached_label->setAlignment(Qt::AlignCenter);
|
---|
209 | panel->layout()->addWidget(detached_label);
|
---|
210 | detached_label->hide();
|
---|
211 | #endif
|
---|
212 |
|
---|
213 | #ifdef SEND_AUDIO_OPTION
|
---|
214 | sendAudio_menu = new QMenu(this);
|
---|
215 | sendAudio_menu->menuAction()->setObjectName("send_audio_menu");
|
---|
216 | updateSendAudioMenu();
|
---|
217 | #endif
|
---|
218 |
|
---|
219 | #ifdef GLOBALSHORTCUTS
|
---|
220 | global_shortcuts = new GlobalShortcuts(this);
|
---|
221 | global_shortcuts->setEnabled(pref->use_global_shortcuts);
|
---|
222 | connect(this, SIGNAL(preferencesChanged()), this, SLOT(updateGlobalShortcuts()));
|
---|
223 | #endif
|
---|
224 |
|
---|
225 | #ifdef CHROMECAST_SUPPORT
|
---|
226 | Chromecast::instance()->setSettings(settings);
|
---|
227 | #endif
|
---|
228 |
|
---|
229 | retranslateStrings();
|
---|
230 | loadConfig();
|
---|
231 | }
|
---|
232 |
|
---|
233 | BaseGuiPlus::~BaseGuiPlus() {
|
---|
234 | saveConfig();
|
---|
235 | tray->hide();
|
---|
236 |
|
---|
237 | #ifdef CHROMECAST_SUPPORT
|
---|
238 | Chromecast::deleteInstance();
|
---|
239 | #endif
|
---|
240 | }
|
---|
241 |
|
---|
242 | void BaseGuiPlus::populateMainMenu() {
|
---|
243 | qDebug("BaseGuiPlus::populateMainMenu");
|
---|
244 |
|
---|
245 | BaseGui::populateMainMenu();
|
---|
246 |
|
---|
247 | if (!pref->tablet_mode) {
|
---|
248 | openMenu->addAction(quitAct);
|
---|
249 | optionsMenu->addAction(showTrayAct);
|
---|
250 | }
|
---|
251 |
|
---|
252 | #ifdef DETACH_VIDEO_OPTION
|
---|
253 | optionsMenu->addAction(detachVideoAct);
|
---|
254 | #endif
|
---|
255 |
|
---|
256 | #ifdef SCREENS_SUPPORT
|
---|
257 | videoMenu->insertMenu(videosize_menu->menuAction(), sendToScreen_menu);
|
---|
258 |
|
---|
259 | if (!pref->tablet_mode) {
|
---|
260 | viewMenu->addSeparator();
|
---|
261 | viewMenu->addAction(showScreensInfoAct);
|
---|
262 | }
|
---|
263 |
|
---|
264 | access_menu->insertMenu(tabletModeAct, sendToScreen_menu);
|
---|
265 | #endif
|
---|
266 |
|
---|
267 | #ifdef SEND_AUDIO_OPTION
|
---|
268 | audioMenu->insertMenu(audiofilter_menu->menuAction(), sendAudio_menu);
|
---|
269 | #endif
|
---|
270 |
|
---|
271 | #ifdef CHROMECAST_SUPPORT
|
---|
272 | playMenu->addSeparator();
|
---|
273 | playMenu->addAction(playOnChromecastAct);
|
---|
274 | #endif
|
---|
275 | }
|
---|
276 |
|
---|
277 | bool BaseGuiPlus::startHidden() {
|
---|
278 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
---|
279 | return false;
|
---|
280 | #else
|
---|
281 | if ( (!showTrayAct->isChecked()) || (mainwindow_visible) )
|
---|
282 | return false;
|
---|
283 | else
|
---|
284 | return true;
|
---|
285 | #endif
|
---|
286 | }
|
---|
287 |
|
---|
288 | void BaseGuiPlus::closeEvent( QCloseEvent * e ) {
|
---|
289 | qDebug("BaseGuiPlus::closeEvent");
|
---|
290 | e->ignore();
|
---|
291 | closeWindow();
|
---|
292 | }
|
---|
293 |
|
---|
294 | void BaseGuiPlus::updateWidgets() {
|
---|
295 | qDebug("BaseGuiPlus::updateWidgets");
|
---|
296 |
|
---|
297 | BaseGui::updateWidgets();
|
---|
298 |
|
---|
299 | #ifdef CHROMECAST_SUPPORT
|
---|
300 | playOnChromecastAct->setEnabled(!core->mdat.filename.isEmpty());
|
---|
301 | #endif
|
---|
302 | }
|
---|
303 |
|
---|
304 | void BaseGuiPlus::closeWindow() {
|
---|
305 | qDebug("BaseGuiPlus::closeWindow");
|
---|
306 |
|
---|
307 | if (tray->isVisible()) {
|
---|
308 | //e->ignore();
|
---|
309 | exitFullscreen();
|
---|
310 | showAll(false); // Hide windows
|
---|
311 | if (core->state() == Core::Playing) core->stop();
|
---|
312 |
|
---|
313 | if (pref->balloon_count > 0) {
|
---|
314 | tray->showMessage( "SMPlayer",
|
---|
315 | tr("SMPlayer is still running here"),
|
---|
316 | QSystemTrayIcon::Information, 3000 );
|
---|
317 | pref->balloon_count--;
|
---|
318 | }
|
---|
319 |
|
---|
320 | } else {
|
---|
321 | BaseGui::closeWindow();
|
---|
322 | }
|
---|
323 | //tray->hide();
|
---|
324 |
|
---|
325 | }
|
---|
326 |
|
---|
327 | void BaseGuiPlus::quit() {
|
---|
328 | qDebug("BaseGuiPlus::quit");
|
---|
329 | BaseGui::closeWindow();
|
---|
330 | }
|
---|
331 |
|
---|
332 | void BaseGuiPlus::retranslateStrings() {
|
---|
333 | BaseGui::retranslateStrings();
|
---|
334 |
|
---|
335 | tray->setIcon(Images::icon("logo", 22));
|
---|
336 |
|
---|
337 | quitAct->change( Images::icon("exit"), tr("&Quit") );
|
---|
338 | showTrayAct->change( Images::icon("systray"), tr("S&how icon in system tray") );
|
---|
339 |
|
---|
340 | updateShowAllAct();
|
---|
341 |
|
---|
342 | #if DOCK_PLAYLIST
|
---|
343 | // playlistdock->setWindowTitle( tr("Playlist") );
|
---|
344 | #endif
|
---|
345 |
|
---|
346 | #ifdef DETACH_VIDEO_OPTION
|
---|
347 | detachVideoAct->change("Detach video");
|
---|
348 | #endif
|
---|
349 |
|
---|
350 | #ifdef CHROMECAST_SUPPORT
|
---|
351 | playOnChromecastAct->change(Images::icon("chromecast"), tr("Play on &Chromecast"));
|
---|
352 | #endif
|
---|
353 |
|
---|
354 | #ifdef SCREENS_SUPPORT
|
---|
355 | sendToScreen_menu->menuAction()->setText( tr("Send &video to screen") );
|
---|
356 | sendToScreen_menu->menuAction()->setIcon(Images::icon("send_to_screen"));
|
---|
357 | showScreensInfoAct->change(tr("Information about connected &screens"));
|
---|
358 |
|
---|
359 | detached_label->setText("<img src=\"" + Images::file("send_to_screen") + "\">" +
|
---|
360 | "<p style=\"color: white;\">" + tr("Video is sent to an external screen") +"</p");
|
---|
361 | #endif
|
---|
362 |
|
---|
363 | #ifdef SEND_AUDIO_OPTION
|
---|
364 | sendAudio_menu->menuAction()->setText( tr("Send &audio to") );
|
---|
365 | sendAudio_menu->menuAction()->setIcon(Images::icon("send_audio"));
|
---|
366 | #endif
|
---|
367 | }
|
---|
368 |
|
---|
369 | void BaseGuiPlus::updateShowAllAct() {
|
---|
370 | if (isVisible())
|
---|
371 | showAllAct->change( tr("&Hide") );
|
---|
372 | else
|
---|
373 | showAllAct->change( tr("&Restore") );
|
---|
374 | }
|
---|
375 |
|
---|
376 | void BaseGuiPlus::saveConfig() {
|
---|
377 | qDebug("BaseGuiPlus::saveConfig");
|
---|
378 |
|
---|
379 | QSettings * set = settings;
|
---|
380 |
|
---|
381 | set->beginGroup( "base_gui_plus");
|
---|
382 |
|
---|
383 | set->setValue( "show_tray_icon", showTrayAct->isChecked() );
|
---|
384 | set->setValue( "mainwindow_visible", isVisible() );
|
---|
385 |
|
---|
386 | set->setValue( "trayicon_playlist_was_visible", trayicon_playlist_was_visible );
|
---|
387 | set->setValue( "widgets_size", widgets_size );
|
---|
388 | #if DOCK_PLAYLIST
|
---|
389 | set->setValue( "fullscreen_playlist_was_visible", fullscreen_playlist_was_visible );
|
---|
390 | set->setValue( "fullscreen_playlist_was_floating", fullscreen_playlist_was_floating );
|
---|
391 | set->setValue( "compact_playlist_was_visible", compact_playlist_was_visible );
|
---|
392 | set->setValue( "ignore_playlist_events", ignore_playlist_events );
|
---|
393 | #endif
|
---|
394 |
|
---|
395 | /*
|
---|
396 | #if DOCK_PLAYLIST
|
---|
397 | set->setValue( "playlist_and_toolbars_state", saveState() );
|
---|
398 | #endif
|
---|
399 | */
|
---|
400 |
|
---|
401 | set->endGroup();
|
---|
402 | }
|
---|
403 |
|
---|
404 | void BaseGuiPlus::loadConfig() {
|
---|
405 | qDebug("BaseGuiPlus::loadConfig");
|
---|
406 |
|
---|
407 | QSettings * set = settings;
|
---|
408 |
|
---|
409 | set->beginGroup( "base_gui_plus");
|
---|
410 |
|
---|
411 | bool show_tray_icon = set->value( "show_tray_icon", false).toBool();
|
---|
412 | showTrayAct->setChecked( show_tray_icon );
|
---|
413 | //tray->setVisible( show_tray_icon );
|
---|
414 |
|
---|
415 | mainwindow_visible = set->value("mainwindow_visible", true).toBool();
|
---|
416 |
|
---|
417 | trayicon_playlist_was_visible = set->value( "trayicon_playlist_was_visible", trayicon_playlist_was_visible ).toBool();
|
---|
418 | widgets_size = set->value( "widgets_size", widgets_size ).toInt();
|
---|
419 | #if DOCK_PLAYLIST
|
---|
420 | fullscreen_playlist_was_visible = set->value( "fullscreen_playlist_was_visible", fullscreen_playlist_was_visible ).toBool();
|
---|
421 | fullscreen_playlist_was_floating = set->value( "fullscreen_playlist_was_floating", fullscreen_playlist_was_floating ).toBool();
|
---|
422 | compact_playlist_was_visible = set->value( "compact_playlist_was_visible", compact_playlist_was_visible ).toBool();
|
---|
423 | ignore_playlist_events = set->value( "ignore_playlist_events", ignore_playlist_events ).toBool();
|
---|
424 | #endif
|
---|
425 |
|
---|
426 | /*
|
---|
427 | #if DOCK_PLAYLIST
|
---|
428 | restoreState( set->value( "playlist_and_toolbars_state" ).toByteArray() );
|
---|
429 | #endif
|
---|
430 | */
|
---|
431 |
|
---|
432 | set->endGroup();
|
---|
433 |
|
---|
434 | updateShowAllAct();
|
---|
435 | }
|
---|
436 |
|
---|
437 |
|
---|
438 | void BaseGuiPlus::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
---|
439 | qDebug("DefaultGui::trayIconActivated: %d", reason);
|
---|
440 |
|
---|
441 | updateShowAllAct();
|
---|
442 |
|
---|
443 | if (reason == QSystemTrayIcon::Trigger) {
|
---|
444 | toggleShowAll();
|
---|
445 | }
|
---|
446 | else
|
---|
447 | if (reason == QSystemTrayIcon::MiddleClick) {
|
---|
448 | core->pause();
|
---|
449 | }
|
---|
450 | }
|
---|
451 |
|
---|
452 | void BaseGuiPlus::toggleShowAll() {
|
---|
453 | // Ignore if tray is not visible
|
---|
454 | if (tray->isVisible()) {
|
---|
455 | showAll( !isVisible() );
|
---|
456 | }
|
---|
457 | }
|
---|
458 |
|
---|
459 | void BaseGuiPlus::showAll() {
|
---|
460 | if (!isVisible()) showAll(true);
|
---|
461 | }
|
---|
462 |
|
---|
463 | void BaseGuiPlus::showAll(bool b) {
|
---|
464 | if (!b) {
|
---|
465 | // Hide all
|
---|
466 | #if DOCK_PLAYLIST
|
---|
467 | trayicon_playlist_was_visible = (playlistdock->isVisible() &&
|
---|
468 | playlistdock->isFloating() );
|
---|
469 | if (trayicon_playlist_was_visible)
|
---|
470 | playlistdock->hide();
|
---|
471 |
|
---|
472 | /*
|
---|
473 | trayicon_playlist_was_visible = playlistdock->isVisible();
|
---|
474 | playlistdock->hide();
|
---|
475 | */
|
---|
476 | #else
|
---|
477 | trayicon_playlist_was_visible = playlist->isVisible();
|
---|
478 | playlist_pos = playlist->pos();
|
---|
479 | playlist->hide();
|
---|
480 | #endif
|
---|
481 |
|
---|
482 | mainwindow_pos = pos();
|
---|
483 | hide();
|
---|
484 |
|
---|
485 | /*
|
---|
486 | infowindow_visible = info_window->isVisible();
|
---|
487 | infowindow_pos = info_window->pos();
|
---|
488 | info_window->hide();
|
---|
489 | */
|
---|
490 | } else {
|
---|
491 | // Show all
|
---|
492 | move(mainwindow_pos);
|
---|
493 | show();
|
---|
494 |
|
---|
495 | #if DOCK_PLAYLIST
|
---|
496 | if (trayicon_playlist_was_visible) {
|
---|
497 | playlistdock->show();
|
---|
498 | }
|
---|
499 | #else
|
---|
500 | if (trayicon_playlist_was_visible) {
|
---|
501 | playlist->move(playlist_pos);
|
---|
502 | playlist->show();
|
---|
503 | }
|
---|
504 | #endif
|
---|
505 |
|
---|
506 | /*
|
---|
507 | if (infowindow_visible) {
|
---|
508 | info_window->show();
|
---|
509 | info_window->move(infowindow_pos);
|
---|
510 | }
|
---|
511 | */
|
---|
512 | }
|
---|
513 | updateShowAllAct();
|
---|
514 | }
|
---|
515 |
|
---|
516 | void BaseGuiPlus::resizeWindow(int w, int h) {
|
---|
517 | qDebug("BaseGuiPlus::resizeWindow: %d, %d", w, h);
|
---|
518 |
|
---|
519 | if ( (tray->isVisible()) && (!isVisible()) ) showAll(true);
|
---|
520 |
|
---|
521 | BaseGui::resizeWindow(w, h );
|
---|
522 | }
|
---|
523 |
|
---|
524 | void BaseGuiPlus::updateMediaInfo() {
|
---|
525 | qDebug("BaseGuiPlus::updateMediaInfo");
|
---|
526 | BaseGui::updateMediaInfo();
|
---|
527 |
|
---|
528 | tray->setToolTip( windowTitle() );
|
---|
529 | }
|
---|
530 |
|
---|
531 | void BaseGuiPlus::setWindowCaption(const QString & title) {
|
---|
532 | tray->setToolTip( title );
|
---|
533 |
|
---|
534 | BaseGui::setWindowCaption( title );
|
---|
535 | }
|
---|
536 |
|
---|
537 |
|
---|
538 | // Playlist stuff
|
---|
539 | void BaseGuiPlus::aboutToEnterFullscreen() {
|
---|
540 | qDebug("BaseGuiPlus::aboutToEnterFullscreen");
|
---|
541 |
|
---|
542 | BaseGui::aboutToEnterFullscreen();
|
---|
543 |
|
---|
544 | #if DOCK_PLAYLIST
|
---|
545 | playlistdock->setAllowedAreas(Qt::NoDockWidgetArea);
|
---|
546 |
|
---|
547 | int playlist_screen = QApplication::desktop()->screenNumber(playlistdock);
|
---|
548 | int mainwindow_screen = QApplication::desktop()->screenNumber(this);
|
---|
549 | qDebug("BaseGuiPlus::aboutToEnterFullscreen: mainwindow screen: %d, playlist screen: %d", mainwindow_screen, playlist_screen);
|
---|
550 |
|
---|
551 | fullscreen_playlist_was_visible = playlistdock->isVisible();
|
---|
552 | fullscreen_playlist_was_floating = playlistdock->isFloating();
|
---|
553 |
|
---|
554 | ignore_playlist_events = true;
|
---|
555 |
|
---|
556 | // Hide the playlist if it's in the same screen as the main window
|
---|
557 | if ((playlist_screen == mainwindow_screen) /* ||
|
---|
558 | (!fullscreen_playlist_was_floating) */ )
|
---|
559 | {
|
---|
560 | #if QT_VERSION < 0x050000 || !defined(Q_OS_LINUX)
|
---|
561 | playlistdock->setFloating(true);
|
---|
562 | #endif
|
---|
563 | playlistdock->hide();
|
---|
564 | }
|
---|
565 | #endif
|
---|
566 | }
|
---|
567 |
|
---|
568 | void BaseGuiPlus::aboutToExitFullscreen() {
|
---|
569 | qDebug("BaseGuiPlus::aboutToExitFullscreen");
|
---|
570 |
|
---|
571 | BaseGui::aboutToExitFullscreen();
|
---|
572 |
|
---|
573 | #if DOCK_PLAYLIST
|
---|
574 | playlistdock->setAllowedAreas(Qt::TopDockWidgetArea |
|
---|
575 | Qt::BottomDockWidgetArea
|
---|
576 | #if PLAYLIST_ON_SIDES
|
---|
577 | | Qt::LeftDockWidgetArea |
|
---|
578 | Qt::RightDockWidgetArea
|
---|
579 | #endif
|
---|
580 | );
|
---|
581 |
|
---|
582 | if (fullscreen_playlist_was_visible) {
|
---|
583 | playlistdock->show();
|
---|
584 | }
|
---|
585 | playlistdock->setFloating( fullscreen_playlist_was_floating );
|
---|
586 | ignore_playlist_events = false;
|
---|
587 | #endif
|
---|
588 | }
|
---|
589 |
|
---|
590 | void BaseGuiPlus::aboutToEnterCompactMode() {
|
---|
591 | #if DOCK_PLAYLIST
|
---|
592 | compact_playlist_was_visible = (playlistdock->isVisible() &&
|
---|
593 | !playlistdock->isFloating());
|
---|
594 | if (compact_playlist_was_visible)
|
---|
595 | playlistdock->hide();
|
---|
596 | #endif
|
---|
597 |
|
---|
598 | widgets_size = height() - panel->height();
|
---|
599 | qDebug("BaseGuiPlus::aboutToEnterCompactMode: widgets_size: %d", widgets_size);
|
---|
600 |
|
---|
601 | BaseGui::aboutToEnterCompactMode();
|
---|
602 |
|
---|
603 | if (pref->resize_method == Preferences::Always) {
|
---|
604 | resize( width(), height() - widgets_size );
|
---|
605 | }
|
---|
606 | }
|
---|
607 |
|
---|
608 | void BaseGuiPlus::aboutToExitCompactMode() {
|
---|
609 | BaseGui::aboutToExitCompactMode();
|
---|
610 |
|
---|
611 | if (pref->resize_method == Preferences::Always) {
|
---|
612 | resize( width(), height() + widgets_size );
|
---|
613 | }
|
---|
614 |
|
---|
615 | #if DOCK_PLAYLIST
|
---|
616 | if (compact_playlist_was_visible)
|
---|
617 | playlistdock->show();
|
---|
618 | #endif
|
---|
619 | }
|
---|
620 |
|
---|
621 | #if DOCK_PLAYLIST
|
---|
622 | void BaseGuiPlus::showPlaylist(bool b) {
|
---|
623 | qDebug("BaseGuiPlus::showPlaylist: %d", b);
|
---|
624 | qDebug("BaseGuiPlus::showPlaylist (before): playlist visible: %d", playlistdock->isVisible());
|
---|
625 | qDebug("BaseGuiPlus::showPlaylist (before): playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
626 | qDebug("BaseGuiPlus::showPlaylist (before): playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
627 |
|
---|
628 | if ( !b ) {
|
---|
629 | playlistdock->hide();
|
---|
630 | } else {
|
---|
631 | exitFullscreenIfNeeded();
|
---|
632 | playlistdock->show();
|
---|
633 |
|
---|
634 | // Check if playlist is outside of the screen
|
---|
635 | if (playlistdock->isFloating()) {
|
---|
636 | if (!DesktopInfo::isInsideScreen(playlistdock)) {
|
---|
637 | qWarning("BaseGuiPlus::showPlaylist: playlist is outside of the screen");
|
---|
638 | playlistdock->move(0,0);
|
---|
639 | }
|
---|
640 | }
|
---|
641 | }
|
---|
642 | //updateWidgets();
|
---|
643 |
|
---|
644 | qDebug("BaseGuiPlus::showPlaylist (after): playlist visible: %d", playlistdock->isVisible());
|
---|
645 | qDebug("BaseGuiPlus::showPlaylist (after): playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
646 | qDebug("BaseGuiPlus::showPlaylist (after): playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
647 |
|
---|
648 | }
|
---|
649 |
|
---|
650 | void BaseGuiPlus::playlistClosed() {
|
---|
651 | showPlaylistAct->setChecked(false);
|
---|
652 | }
|
---|
653 |
|
---|
654 | #if !USE_DOCK_TOPLEVEL_EVENT
|
---|
655 | void BaseGuiPlus::dockVisibilityChanged(bool visible) {
|
---|
656 | qDebug("BaseGuiPlus::dockVisibilityChanged: %d", visible);
|
---|
657 |
|
---|
658 | if (!playlistdock->isFloating()) {
|
---|
659 | if (!visible) shrinkWindow(); else stretchWindow();
|
---|
660 | }
|
---|
661 | }
|
---|
662 |
|
---|
663 | #else
|
---|
664 |
|
---|
665 | void BaseGuiPlus::dockTopLevelChanged(bool floating) {
|
---|
666 | qDebug("BaseGuiPlus::dockTopLevelChanged: %d", floating);
|
---|
667 |
|
---|
668 | if (floating) shrinkWindow(); else stretchWindow();
|
---|
669 | }
|
---|
670 | #endif
|
---|
671 |
|
---|
672 | void BaseGuiPlus::stretchWindow() {
|
---|
673 | qDebug("BaseGuiPlus::stretchWindow");
|
---|
674 | if ((ignore_playlist_events) || (pref->resize_method!=Preferences::Always)) return;
|
---|
675 |
|
---|
676 | qDebug("BaseGuiPlus::stretchWindow: dockWidgetArea: %d", (int) dockWidgetArea(playlistdock) );
|
---|
677 |
|
---|
678 | if ( (dockWidgetArea(playlistdock) == Qt::TopDockWidgetArea) ||
|
---|
679 | (dockWidgetArea(playlistdock) == Qt::BottomDockWidgetArea) )
|
---|
680 | {
|
---|
681 | int new_height = height() + playlistdock->height();
|
---|
682 |
|
---|
683 | //if (new_height > DesktopInfo::desktop_size(this).height())
|
---|
684 | // new_height = DesktopInfo::desktop_size(this).height() - 20;
|
---|
685 |
|
---|
686 | qDebug("BaseGuiPlus::stretchWindow: stretching: new height: %d", new_height);
|
---|
687 | resize( width(), new_height );
|
---|
688 |
|
---|
689 | //resizeWindow(core->mset.win_width, core->mset.win_height);
|
---|
690 | }
|
---|
691 |
|
---|
692 | else
|
---|
693 |
|
---|
694 | if ( (dockWidgetArea(playlistdock) == Qt::LeftDockWidgetArea) ||
|
---|
695 | (dockWidgetArea(playlistdock) == Qt::RightDockWidgetArea) )
|
---|
696 | {
|
---|
697 | int new_width = width() + playlistdock->width();
|
---|
698 |
|
---|
699 | qDebug("BaseGuiPlus::stretchWindow: stretching: new width: %d", new_width);
|
---|
700 | resize( new_width, height() );
|
---|
701 | }
|
---|
702 | }
|
---|
703 |
|
---|
704 | void BaseGuiPlus::shrinkWindow() {
|
---|
705 | qDebug("BaseGuiPlus::shrinkWindow");
|
---|
706 | if ((ignore_playlist_events) || (pref->resize_method!=Preferences::Always)) return;
|
---|
707 |
|
---|
708 | qDebug("BaseGuiPlus::shrinkWindow: dockWidgetArea: %d", (int) dockWidgetArea(playlistdock) );
|
---|
709 |
|
---|
710 | if ( (dockWidgetArea(playlistdock) == Qt::TopDockWidgetArea) ||
|
---|
711 | (dockWidgetArea(playlistdock) == Qt::BottomDockWidgetArea) )
|
---|
712 | {
|
---|
713 | int new_height = height() - playlistdock->height();
|
---|
714 | qDebug("DefaultGui::shrinkWindow: shrinking: new height: %d", new_height);
|
---|
715 | resize( width(), new_height );
|
---|
716 |
|
---|
717 | //resizeWindow(core->mset.win_width, core->mset.win_height);
|
---|
718 | }
|
---|
719 |
|
---|
720 | else
|
---|
721 |
|
---|
722 | if ( (dockWidgetArea(playlistdock) == Qt::LeftDockWidgetArea) ||
|
---|
723 | (dockWidgetArea(playlistdock) == Qt::RightDockWidgetArea) )
|
---|
724 | {
|
---|
725 | int new_width = width() - playlistdock->width();
|
---|
726 |
|
---|
727 | qDebug("BaseGuiPlus::shrinkWindow: shrinking: new width: %d", new_width);
|
---|
728 | resize( new_width, height() );
|
---|
729 | }
|
---|
730 | }
|
---|
731 |
|
---|
732 | #endif
|
---|
733 |
|
---|
734 | #ifdef GLOBALSHORTCUTS
|
---|
735 | void BaseGuiPlus::showPreferencesDialog() {
|
---|
736 | qDebug("BaseGuiPlus::showPreferencesDialog");
|
---|
737 | global_shortcuts->setEnabled(false);
|
---|
738 | BaseGui::showPreferencesDialog();
|
---|
739 | }
|
---|
740 |
|
---|
741 | void BaseGuiPlus::updateGlobalShortcuts() {
|
---|
742 | qDebug("BaseGuiPlus::updateGlobalShortcuts");
|
---|
743 | global_shortcuts->setEnabled(pref->use_global_shortcuts);
|
---|
744 | }
|
---|
745 | #endif
|
---|
746 |
|
---|
747 |
|
---|
748 | // Convenience functions intended for other GUI's
|
---|
749 | TimeSliderAction * BaseGuiPlus::createTimeSliderAction(QWidget * parent) {
|
---|
750 | TimeSliderAction * timeslider_action = new TimeSliderAction( parent );
|
---|
751 | timeslider_action->setObjectName("timeslider_action");
|
---|
752 |
|
---|
753 | #ifdef SEEKBAR_RESOLUTION
|
---|
754 | connect( timeslider_action, SIGNAL( posChanged(int) ),
|
---|
755 | core, SLOT(goToPosition(int)) );
|
---|
756 | connect( core, SIGNAL(positionChanged(int)),
|
---|
757 | timeslider_action, SLOT(setPos(int)) );
|
---|
758 | #else
|
---|
759 | connect( timeslider_action, SIGNAL( posChanged(int) ),
|
---|
760 | core, SLOT(goToPos(int)) );
|
---|
761 | connect( core, SIGNAL(posChanged(int)),
|
---|
762 | timeslider_action, SLOT(setPos(int)) );
|
---|
763 | #endif
|
---|
764 | connect( timeslider_action, SIGNAL( draggingPos(int) ),
|
---|
765 | this, SLOT(displayGotoTime(int)) );
|
---|
766 | #if ENABLE_DELAYED_DRAGGING
|
---|
767 | timeslider_action->setDragDelay( pref->time_slider_drag_delay );
|
---|
768 |
|
---|
769 | connect( timeslider_action, SIGNAL( delayedDraggingPos(int) ),
|
---|
770 | this, SLOT(goToPosOnDragging(int)) );
|
---|
771 | #else
|
---|
772 | connect( timeslider_action, SIGNAL( draggingPos(int) ),
|
---|
773 | this, SLOT(goToPosOnDragging(int)) );
|
---|
774 | #endif
|
---|
775 |
|
---|
776 | connect(timeslider_action, SIGNAL(wheelUp()), core, SLOT(wheelUp()));
|
---|
777 | connect(timeslider_action, SIGNAL(wheelDown()), core, SLOT(wheelDown()));
|
---|
778 |
|
---|
779 | connect(core, SIGNAL(newDuration(double)), timeslider_action, SLOT(setDuration(double)));
|
---|
780 |
|
---|
781 | return timeslider_action;
|
---|
782 | }
|
---|
783 |
|
---|
784 | VolumeSliderAction * BaseGuiPlus::createVolumeSliderAction(QWidget * parent) {
|
---|
785 | VolumeSliderAction * volumeslider_action = new VolumeSliderAction(parent);
|
---|
786 | volumeslider_action->setObjectName("volumeslider_action");
|
---|
787 |
|
---|
788 | connect( volumeslider_action, SIGNAL( valueChanged(int) ),
|
---|
789 | core, SLOT( setVolume(int) ) );
|
---|
790 | connect( core, SIGNAL(volumeChanged(int)),
|
---|
791 | volumeslider_action, SLOT(setValue(int)) );
|
---|
792 |
|
---|
793 | return volumeslider_action;
|
---|
794 | }
|
---|
795 |
|
---|
796 | TimeLabelAction * BaseGuiPlus::createTimeLabelAction(TimeLabelAction::TimeLabelType type, QWidget * parent) {
|
---|
797 | TimeLabelAction * time_label_action = new TimeLabelAction(type, parent);
|
---|
798 | time_label_action->setObjectName("timelabel_action");
|
---|
799 |
|
---|
800 | connect(this, SIGNAL(timeChanged(double)), time_label_action, SLOT(setCurrentTime(double)));
|
---|
801 | connect(core, SIGNAL(newDuration(double)), time_label_action, SLOT(setTotalTime(double)));
|
---|
802 |
|
---|
803 | return time_label_action;
|
---|
804 | }
|
---|
805 |
|
---|
806 | #ifdef SCREENS_SUPPORT
|
---|
807 | void BaseGuiPlus::showScreensInfo() {
|
---|
808 | qDebug("BaseGuiPlus::showScreensInfo");
|
---|
809 |
|
---|
810 | /*
|
---|
811 | updateSendToScreen();
|
---|
812 | */
|
---|
813 |
|
---|
814 | if (!screens_info_window) {
|
---|
815 | screens_info_window = new InfoWindow(this);
|
---|
816 | screens_info_window->setWindowTitle(tr("Information about connected screens"));
|
---|
817 | }
|
---|
818 |
|
---|
819 | QString t = "<h1>" + tr("Connected screens") + "</h1>";
|
---|
820 | #if QT_VERSION >= 0x050000
|
---|
821 | QList<QScreen *> screen_list = qApp->screens();
|
---|
822 | t += "<p>" + tr("Number of screens: %1").arg(screen_list.count());
|
---|
823 | QString screen_name = qApp->primaryScreen()->name();
|
---|
824 | #ifdef Q_OS_WIN
|
---|
825 | screen_name = screen_name.replace("\\\\.\\","");
|
---|
826 | #endif
|
---|
827 | t += "<p>" + tr("Primary screen: %1").arg(screen_name);
|
---|
828 |
|
---|
829 | t += "<ul>";
|
---|
830 | foreach(QScreen *screen, screen_list) {
|
---|
831 | screen_name = screen->name();
|
---|
832 | #ifdef Q_OS_WIN
|
---|
833 | screen_name = screen_name.replace("\\\\.\\","");
|
---|
834 | #endif
|
---|
835 | t += "<li>" + tr("Information for screen %1").arg(screen_name);
|
---|
836 | t += "<ul>";
|
---|
837 | t += "<li>" + tr("Available geometry: %1 %2 %3 x %4").arg(screen->availableGeometry().x()).arg(screen->availableGeometry().y())
|
---|
838 | .arg(screen->availableGeometry().width()).arg(screen->availableGeometry().height()) + "</li>";
|
---|
839 | t += "<li>" + tr("Available size: %1 x %2").arg(screen->availableSize().width()).arg(screen->availableSize().height()) + "</li>";
|
---|
840 | t += "<li>" + tr("Available virtual geometry: %1 %2 %3 x %4").arg(screen->availableVirtualGeometry().x())
|
---|
841 | .arg(screen->availableVirtualGeometry().y())
|
---|
842 | .arg(screen->availableVirtualGeometry().width())
|
---|
843 | .arg(screen->availableVirtualGeometry().height()) + "</li>";
|
---|
844 | t += "<li>" + tr("Available virtual size: %1 x %2").arg(screen->availableVirtualSize().width())
|
---|
845 | .arg(screen->availableVirtualSize().height()) + "</li>";
|
---|
846 | t += "<li>" + tr("Depth: %1 bits").arg(screen->depth()) + "</li>";
|
---|
847 | t += "<li>" + tr("Geometry: %1 %2 %3 x %4").arg(screen->geometry().x()).arg(screen->geometry().y())
|
---|
848 | .arg(screen->geometry().width()).arg(screen->geometry().height()) + "</li>";
|
---|
849 | t += "<li>" + tr("Logical DPI: %1").arg(screen->logicalDotsPerInch()) + "</li>";
|
---|
850 | //t += "<li>" + tr("Orientation: %1").arg(screen->orientation()) + "</li>";
|
---|
851 | t += "<li>" + tr("Physical DPI: %1").arg(screen->physicalDotsPerInch()) + "</li>";
|
---|
852 | t += "<li>" + tr("Physical size: %1 x %2 mm").arg(screen->physicalSize().width()).arg(screen->physicalSize().height()) + "</li>";
|
---|
853 | //t += "<li>" + tr("Primary orientation: %1").arg(screen->primaryOrientation()) + "</li>";
|
---|
854 | t += "<li>" + tr("Refresh rate: %1 Hz").arg(screen->refreshRate()) + "</li>";
|
---|
855 | t += "<li>" + tr("Size: %1 x %2").arg(screen->size().width()).arg(screen->size().height()) + "</li>";
|
---|
856 | t += "<li>" + tr("Virtual geometry: %1 %2 %3 x %4").arg(screen->virtualGeometry().x()).arg(screen->virtualGeometry().y())
|
---|
857 | .arg(screen->virtualGeometry().width()).arg(screen->virtualGeometry().height()) + "</li>";
|
---|
858 | t += "<li>" + tr("Virtual size: %1 x %2").arg(screen->virtualSize().width()).arg(screen->virtualSize().height()) + "</li>";
|
---|
859 | t += "</ul></li>";
|
---|
860 | }
|
---|
861 | t += "</ul>";
|
---|
862 | #else
|
---|
863 | QDesktopWidget * dw = qApp->desktop();
|
---|
864 | t += "<p>" + tr("Number of screens: %1").arg(dw->screenCount());
|
---|
865 | t += "<p>" + tr("Primary screen: %1").arg(dw->primaryScreen()+1);
|
---|
866 |
|
---|
867 | t += "<ul>";
|
---|
868 | for (int n = 0; n < dw->screenCount(); n++) {
|
---|
869 | t += "<li>" + tr("Information for screen %1").arg(n+1);
|
---|
870 | t += "<ul>";
|
---|
871 | t += "<li>" + tr("Available geometry: %1 %2 %3 x %4").arg(dw->availableGeometry(n).x()).arg(dw->availableGeometry(n).y())
|
---|
872 | .arg(dw->availableGeometry(n).width()).arg(dw->availableGeometry(n).height()) + "</li>";
|
---|
873 | t += "<li>" + tr("Geometry: %1 %2 %3 x %4").arg(dw->screenGeometry(n).x()).arg(dw->screenGeometry(n).y())
|
---|
874 | .arg(dw->screenGeometry(n).width()).arg(dw->screenGeometry(n).height()) + "</li>";
|
---|
875 | t += "</ul></li>";
|
---|
876 | }
|
---|
877 | t += "</ul>";
|
---|
878 | #endif
|
---|
879 |
|
---|
880 | screens_info_window->setHtml(t);
|
---|
881 | screens_info_window->show();
|
---|
882 | }
|
---|
883 |
|
---|
884 | void BaseGuiPlus::updateSendToScreen() {
|
---|
885 | qDebug("BaseGuiPlus::updateSendToScreen");
|
---|
886 |
|
---|
887 | sendToScreenGroup->clear(true);
|
---|
888 |
|
---|
889 | #if QT_VERSION >= 0x050000
|
---|
890 | QList<QScreen *> screen_list = qApp->screens();
|
---|
891 | int n_screens = screen_list.count();
|
---|
892 | #else
|
---|
893 | QDesktopWidget * dw = qApp->desktop();
|
---|
894 | int n_screens = dw->screenCount();
|
---|
895 | #endif
|
---|
896 |
|
---|
897 | for (int n = 0; n < n_screens; n++) {
|
---|
898 | QString name;
|
---|
899 | #if QT_VERSION >= 0x050000
|
---|
900 | name = screen_list[n]->name();
|
---|
901 | #ifdef Q_OS_WIN
|
---|
902 | name = name.replace("\\\\.\\","");
|
---|
903 | #endif
|
---|
904 | bool is_primary_screen = (screen_list[n] == qApp->primaryScreen());
|
---|
905 | #else
|
---|
906 | bool is_primary_screen = (n == dw->primaryScreen());
|
---|
907 | #endif
|
---|
908 | MyAction * screen_item = new MyActionGroupItem(this, sendToScreenGroup, QString("send_to_screen_%1").arg(n+1).toLatin1().constData(), n);
|
---|
909 | QString desc = "&" + QString::number(n+1);
|
---|
910 | if (!name.isEmpty()) desc += " - " + name;
|
---|
911 | if (is_primary_screen) desc += " (" + tr("Primary screen") + ")";
|
---|
912 | screen_item->change(desc);
|
---|
913 | }
|
---|
914 |
|
---|
915 | sendToScreen_menu->clear();
|
---|
916 | sendToScreen_menu->addActions(sendToScreenGroup->actions());
|
---|
917 |
|
---|
918 | if (n_screens == 1 && isVideoDetached()) detachVideo(false);
|
---|
919 | }
|
---|
920 |
|
---|
921 | void BaseGuiPlus::sendVideoToScreen(int screen) {
|
---|
922 | qDebug() << "BaseGuiPlus::sendVideoToScreen:" << screen;
|
---|
923 |
|
---|
924 | #if QT_VERSION >= 0x050000
|
---|
925 | QList<QScreen *> screen_list = qApp->screens();
|
---|
926 | int n_screens = screen_list.count();
|
---|
927 | #else
|
---|
928 | QDesktopWidget * dw = qApp->desktop();
|
---|
929 | int n_screens = dw->screenCount();
|
---|
930 | #endif
|
---|
931 |
|
---|
932 | if (screen < n_screens) {
|
---|
933 | #if QT_VERSION >= 0x050000
|
---|
934 | bool is_primary_screen = (screen_list[screen] == qApp->primaryScreen());
|
---|
935 | QRect geometry = screen_list[screen]->geometry();
|
---|
936 | #else
|
---|
937 | bool is_primary_screen = (screen == dw->primaryScreen());
|
---|
938 | QRect geometry = dw->screenGeometry(screen);
|
---|
939 | qDebug() << "BaseGuiPlus::sendVideoToScreen: screen geometry:" << geometry;
|
---|
940 | #endif
|
---|
941 | qDebug() << "BaseGuiPlus::sendVideoToScreen: is_primary_screen:" << is_primary_screen;
|
---|
942 | //is_primary_screen = false;
|
---|
943 | if (is_primary_screen) {
|
---|
944 | mplayerwindow->showNormal();
|
---|
945 | detachVideo(false);
|
---|
946 | } else {
|
---|
947 | detachVideo(true);
|
---|
948 | //#if QT_VERSION >= 0x050000
|
---|
949 | //mplayerwindow->windowHandle()->setScreen(screen_list[screen]); // Doesn't work
|
---|
950 | //#else
|
---|
951 | mplayerwindow->move(geometry.x(), geometry.y());
|
---|
952 | //#endif
|
---|
953 | qApp->processEvents();
|
---|
954 | //toggleFullscreen(true);
|
---|
955 | mplayerwindow->showFullScreen();
|
---|
956 | }
|
---|
957 | } else {
|
---|
958 | // Error
|
---|
959 | qWarning() << "BaseGuiPlus::sendVideoToScreen: screen" << screen << "is not valid";
|
---|
960 | }
|
---|
961 | }
|
---|
962 |
|
---|
963 | bool BaseGuiPlus::isVideoDetached() {
|
---|
964 | return (mplayerwindow->parent() == 0);
|
---|
965 | }
|
---|
966 |
|
---|
967 | void BaseGuiPlus::detachVideo(bool detach) {
|
---|
968 | qDebug() << "BaseGuiPlus::detachVideo:" << detach;
|
---|
969 |
|
---|
970 | if (detach) {
|
---|
971 | if (!isVideoDetached()) {
|
---|
972 | toggleFullscreen(false);
|
---|
973 | fullscreenAct->setEnabled(false);
|
---|
974 |
|
---|
975 | panel->layout()->removeWidget(mplayerwindow);
|
---|
976 | mplayerwindow->setParent(0);
|
---|
977 | mplayerwindow->setWindowTitle(tr("SMPlayer external screen output"));
|
---|
978 |
|
---|
979 | detached_label->show();
|
---|
980 | }
|
---|
981 | mplayerwindow->show();
|
---|
982 | } else {
|
---|
983 | if (isVideoDetached()) {
|
---|
984 | fullscreenAct->setEnabled(true);
|
---|
985 |
|
---|
986 | detached_label->hide();
|
---|
987 |
|
---|
988 | mplayerwindow->setWindowTitle(QString::null);
|
---|
989 | mplayerwindow->setParent(panel);
|
---|
990 | panel->layout()->addWidget(mplayerwindow);
|
---|
991 | }
|
---|
992 | }
|
---|
993 | }
|
---|
994 |
|
---|
995 | /*
|
---|
996 | void BaseGuiPlus::toggleFullscreen(bool b) {
|
---|
997 | qDebug() << "BaseGuiPlus::toggleFullscreen:" << b;
|
---|
998 | if (!isVideoDetached()) {
|
---|
999 | BaseGui::toggleFullscreen(b);
|
---|
1000 | } else {
|
---|
1001 | if (b == pref->fullscreen) return;
|
---|
1002 | pref->fullscreen = b;
|
---|
1003 |
|
---|
1004 | if (pref->fullscreen) {
|
---|
1005 | //aboutToEnterFullscreen();
|
---|
1006 | mplayerwindow->showFullScreen();
|
---|
1007 | } else {
|
---|
1008 | mplayerwindow->showNormal();
|
---|
1009 | //aboutToExitFullscreen();
|
---|
1010 | }
|
---|
1011 | }
|
---|
1012 | }
|
---|
1013 | */
|
---|
1014 | #endif
|
---|
1015 |
|
---|
1016 | #ifdef SEND_AUDIO_OPTION
|
---|
1017 | void BaseGuiPlus::updateSendAudioMenu() {
|
---|
1018 | qDebug("BaseGuiPlus::updateSendAudioMenu");
|
---|
1019 |
|
---|
1020 | sendAudio_menu->clear();
|
---|
1021 | QAction * a = new QAction(sendAudio_menu);
|
---|
1022 | a->setText(tr("&Default audio device"));
|
---|
1023 | a->setData("");
|
---|
1024 | connect(a, SIGNAL(triggered()), this, SLOT(sendAudioClicked()));
|
---|
1025 | sendAudio_menu->addAction(a);
|
---|
1026 |
|
---|
1027 | #if USE_PULSEAUDIO_DEVICES
|
---|
1028 | addListToSendAudioMenu( DeviceInfo::paDevices(), "pulse");
|
---|
1029 | #endif
|
---|
1030 |
|
---|
1031 | #if USE_ALSA_DEVICES
|
---|
1032 | addListToSendAudioMenu( DeviceInfo::alsaDevices(), "alsa");
|
---|
1033 | #endif
|
---|
1034 |
|
---|
1035 | #if USE_DSOUND_DEVICES
|
---|
1036 | if (PlayerID::player(pref->mplayer_bin) == PlayerID::MPLAYER) {
|
---|
1037 | addListToSendAudioMenu( DeviceInfo::dsoundDevices(), "dsound");
|
---|
1038 | }
|
---|
1039 | #endif
|
---|
1040 |
|
---|
1041 | #if MPV_AUDIO_DEVICES
|
---|
1042 | if (PlayerID::player(pref->mplayer_bin) == PlayerID::MPV) {
|
---|
1043 | DeviceInfo::setMpvBin(pref->mplayer_bin);
|
---|
1044 |
|
---|
1045 | #if USE_MPV_ALSA_DEVICES
|
---|
1046 | addListToSendAudioMenu( DeviceInfo::mpvAlsaDevices(), "alsa");
|
---|
1047 | #endif
|
---|
1048 |
|
---|
1049 | #if USE_MPV_WASAPI_DEVICES
|
---|
1050 | addListToSendAudioMenu( DeviceInfo::mpvWasapiDevices(), "wasapi");
|
---|
1051 | #endif
|
---|
1052 | }
|
---|
1053 | #endif
|
---|
1054 | }
|
---|
1055 |
|
---|
1056 | void BaseGuiPlus::addListToSendAudioMenu(const DeviceList & audio_devices, const QString & device_name) {
|
---|
1057 | for (int n = 0; n < audio_devices.count(); n++) {
|
---|
1058 | QAction * a = new QAction(sendAudio_menu);
|
---|
1059 | a->setText( DeviceInfo::printableName(device_name, audio_devices[n]) );
|
---|
1060 | a->setData( DeviceInfo::internalName(device_name, audio_devices[n]) );
|
---|
1061 | connect(a, SIGNAL(triggered()), this, SLOT(sendAudioClicked()));
|
---|
1062 | sendAudio_menu->addAction(a);
|
---|
1063 | }
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 | void BaseGuiPlus::sendAudioClicked() {
|
---|
1067 | QAction * a = qobject_cast<QAction *> (sender());
|
---|
1068 | if (a) {
|
---|
1069 | QString device = a->data().toString();
|
---|
1070 | qDebug() << "BaseGuiPlus::sendAudioClicked: device:" << device;
|
---|
1071 | core->changeAO(device);
|
---|
1072 | }
|
---|
1073 | }
|
---|
1074 | #endif
|
---|
1075 |
|
---|
1076 | #ifdef CHROMECAST_SUPPORT
|
---|
1077 | void BaseGuiPlus::playOnChromecast() {
|
---|
1078 | qDebug("BaseGuiPlus::playOnChromecast");
|
---|
1079 |
|
---|
1080 | qDebug() << "BaseGuiPlus::playOnChromecast: type:" << core->mdat.type;
|
---|
1081 | qDebug() << "BaseGuiPlus::playOnChromecast: filename:" << core->mdat.filename;
|
---|
1082 | qDebug() << "BaseGuiPlus::playOnChromecast: stream_url:" << core->mdat.stream_url;
|
---|
1083 | qDebug() << "BaseGuiPlus::playOnChromecast: stream_title:" << core->mdat.stream_title;
|
---|
1084 | qDebug() << "BaseGuiPlus::playOnChromecast: stream_path:" << core->mdat.stream_path;
|
---|
1085 |
|
---|
1086 | QString title = core->mdat.displayName(true);
|
---|
1087 | if (core->mdat.type == TYPE_STREAM) {
|
---|
1088 | QString url = core->mdat.filename;
|
---|
1089 | if (!core->mdat.stream_path.isEmpty()) url = core->mdat.stream_path;
|
---|
1090 | Chromecast::instance()->openStream(url, title);
|
---|
1091 | }
|
---|
1092 | else
|
---|
1093 | if (core->mdat.type == TYPE_FILE) {
|
---|
1094 | Chromecast::instance()->openLocal(core->mdat.filename, title);
|
---|
1095 | }
|
---|
1096 | }
|
---|
1097 | #endif
|
---|
1098 |
|
---|
1099 | #include "moc_baseguiplus.cpp"
|
---|