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