1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "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 Q_OS_WIN
|
---|
27 | #include "favorites.h"
|
---|
28 | #else
|
---|
29 | #include "tvlist.h"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include "widgetactions.h"
|
---|
33 |
|
---|
34 | #include <QMenu>
|
---|
35 | #include <QCloseEvent>
|
---|
36 | #include <QApplication>
|
---|
37 | #include <QDesktopWidget>
|
---|
38 |
|
---|
39 | #if DOCK_PLAYLIST
|
---|
40 | #include <QDockWidget>
|
---|
41 | #include "playlistdock.h"
|
---|
42 | #include "desktopinfo.h"
|
---|
43 |
|
---|
44 | #define PLAYLIST_ON_SIDES 1
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | using namespace Global;
|
---|
48 |
|
---|
49 | BaseGuiPlus::BaseGuiPlus( bool use_server, QWidget * parent, Qt::WindowFlags flags)
|
---|
50 | : BaseGui( use_server, parent, flags )
|
---|
51 | {
|
---|
52 | // Initialize variables
|
---|
53 | mainwindow_visible = true;
|
---|
54 | //infowindow_visible = false;
|
---|
55 | trayicon_playlist_was_visible = false;
|
---|
56 | widgets_size = 0;
|
---|
57 | #if DOCK_PLAYLIST
|
---|
58 | fullscreen_playlist_was_visible = false;
|
---|
59 | fullscreen_playlist_was_floating = false;
|
---|
60 | compact_playlist_was_visible = false;
|
---|
61 | ignore_playlist_events = false;
|
---|
62 | #endif
|
---|
63 |
|
---|
64 |
|
---|
65 | mainwindow_pos = pos();
|
---|
66 |
|
---|
67 | tray = new QSystemTrayIcon( Images::icon("logo", 22), this );
|
---|
68 |
|
---|
69 | tray->setToolTip( "SMPlayer" );
|
---|
70 | connect( tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
---|
71 | this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
|
---|
72 |
|
---|
73 | quitAct = new MyAction(QKeySequence("Ctrl+Q"), this, "quit");
|
---|
74 | connect( quitAct, SIGNAL(triggered()), this, SLOT(quit()) );
|
---|
75 | openMenu->addAction(quitAct);
|
---|
76 |
|
---|
77 | showTrayAct = new MyAction(this, "show_tray_icon" );
|
---|
78 | showTrayAct->setCheckable(true);
|
---|
79 | connect( showTrayAct, SIGNAL(toggled(bool)),
|
---|
80 | tray, SLOT(setVisible(bool)) );
|
---|
81 |
|
---|
82 | #ifndef Q_OS_OS2
|
---|
83 | optionsMenu->addAction(showTrayAct);
|
---|
84 | #else
|
---|
85 | trayAvailable();
|
---|
86 | connect( optionsMenu, SIGNAL(aboutToShow()),
|
---|
87 | this, SLOT(trayAvailable()) );
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | showAllAct = new MyAction(this, "restore/hide");
|
---|
91 | connect( showAllAct, SIGNAL(triggered()),
|
---|
92 | this, SLOT(toggleShowAll()) );
|
---|
93 |
|
---|
94 |
|
---|
95 | context_menu = new QMenu(this);
|
---|
96 | context_menu->addAction(showAllAct);
|
---|
97 | context_menu->addSeparator();
|
---|
98 | context_menu->addAction(openFileAct);
|
---|
99 | context_menu->addMenu(recentfiles_menu);
|
---|
100 | context_menu->addAction(openDirectoryAct);
|
---|
101 | context_menu->addAction(openDVDAct);
|
---|
102 | context_menu->addAction(openURLAct);
|
---|
103 | context_menu->addMenu(favorites);
|
---|
104 | #ifndef Q_OS_WIN
|
---|
105 | context_menu->addMenu(tvlist);
|
---|
106 | context_menu->addMenu(radiolist);
|
---|
107 | #endif
|
---|
108 | context_menu->addSeparator();
|
---|
109 | context_menu->addAction(playOrPauseAct);
|
---|
110 | context_menu->addAction(stopAct);
|
---|
111 | context_menu->addSeparator();
|
---|
112 | context_menu->addAction(playPrevAct);
|
---|
113 | context_menu->addAction(playNextAct);
|
---|
114 | context_menu->addSeparator();
|
---|
115 | context_menu->addAction(showPlaylistAct);
|
---|
116 | context_menu->addAction(showPreferencesAct);
|
---|
117 | context_menu->addSeparator();
|
---|
118 | context_menu->addAction(quitAct);
|
---|
119 |
|
---|
120 | tray->setContextMenu( context_menu );
|
---|
121 |
|
---|
122 | #if DOCK_PLAYLIST
|
---|
123 | // Playlistdock
|
---|
124 | playlistdock = new PlaylistDock(this);
|
---|
125 | playlistdock->setObjectName("playlistdock");
|
---|
126 | playlistdock->setFloating(false); // To avoid that the playlist is visible for a moment
|
---|
127 | playlistdock->setWidget(playlist);
|
---|
128 | playlistdock->setAllowedAreas(Qt::TopDockWidgetArea |
|
---|
129 | Qt::BottomDockWidgetArea
|
---|
130 | #if PLAYLIST_ON_SIDES
|
---|
131 | | Qt::LeftDockWidgetArea |
|
---|
132 | Qt::RightDockWidgetArea
|
---|
133 | #endif
|
---|
134 | );
|
---|
135 | addDockWidget(Qt::BottomDockWidgetArea, playlistdock);
|
---|
136 | playlistdock->hide();
|
---|
137 | playlistdock->setFloating(true); // Floating by default
|
---|
138 |
|
---|
139 | connect( playlistdock, SIGNAL(closed()), this, SLOT(playlistClosed()) );
|
---|
140 | #if USE_DOCK_TOPLEVEL_EVENT
|
---|
141 | connect( playlistdock, SIGNAL(topLevelChanged(bool)),
|
---|
142 | this, SLOT(dockTopLevelChanged(bool)) );
|
---|
143 | #else
|
---|
144 | connect( playlistdock, SIGNAL(visibilityChanged(bool)),
|
---|
145 | this, SLOT(dockVisibilityChanged(bool)) );
|
---|
146 | #endif // USE_DOCK_TOPLEVEL_EVENT
|
---|
147 |
|
---|
148 | ignore_playlist_events = false;
|
---|
149 | #endif // DOCK_PLAYLIST
|
---|
150 |
|
---|
151 | retranslateStrings();
|
---|
152 |
|
---|
153 | loadConfig();
|
---|
154 | }
|
---|
155 |
|
---|
156 | BaseGuiPlus::~BaseGuiPlus() {
|
---|
157 | saveConfig();
|
---|
158 | }
|
---|
159 |
|
---|
160 | bool BaseGuiPlus::startHidden() {
|
---|
161 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
---|
162 | return false;
|
---|
163 | #else
|
---|
164 | if ( (!showTrayAct->isChecked()) || (mainwindow_visible) )
|
---|
165 | return false;
|
---|
166 | else
|
---|
167 | return true;
|
---|
168 | #endif
|
---|
169 | }
|
---|
170 |
|
---|
171 | void BaseGuiPlus::closeEvent( QCloseEvent * e ) {
|
---|
172 | qDebug("BaseGuiPlus::closeEvent");
|
---|
173 | e->ignore();
|
---|
174 | closeWindow();
|
---|
175 | }
|
---|
176 |
|
---|
177 | void BaseGuiPlus::closeWindow() {
|
---|
178 | qDebug("BaseGuiPlus::closeWindow");
|
---|
179 |
|
---|
180 | if (tray->isVisible()) {
|
---|
181 | //e->ignore();
|
---|
182 | exitFullscreen();
|
---|
183 | showAll(false); // Hide windows
|
---|
184 | if (core->state() == Core::Playing) core->stop();
|
---|
185 |
|
---|
186 | if (pref->balloon_count > 0) {
|
---|
187 | tray->showMessage( "SMPlayer",
|
---|
188 | tr("SMPlayer is still running here"),
|
---|
189 | QSystemTrayIcon::Information, 3000 );
|
---|
190 | pref->balloon_count--;
|
---|
191 | }
|
---|
192 |
|
---|
193 | } else {
|
---|
194 | BaseGui::closeWindow();
|
---|
195 | }
|
---|
196 | //tray->hide();
|
---|
197 |
|
---|
198 | }
|
---|
199 |
|
---|
200 | void BaseGuiPlus::quit() {
|
---|
201 | qDebug("BaseGuiPlus::quit");
|
---|
202 | BaseGui::closeWindow();
|
---|
203 | }
|
---|
204 |
|
---|
205 | void BaseGuiPlus::retranslateStrings() {
|
---|
206 | BaseGui::retranslateStrings();
|
---|
207 |
|
---|
208 | quitAct->change( Images::icon("exit"), tr("&Quit") );
|
---|
209 | showTrayAct->change( Images::icon("systray"), tr("S&how icon in system tray") );
|
---|
210 |
|
---|
211 | updateShowAllAct();
|
---|
212 |
|
---|
213 | #if DOCK_PLAYLIST
|
---|
214 | playlistdock->setWindowTitle( tr("Playlist") );
|
---|
215 | #endif
|
---|
216 | }
|
---|
217 |
|
---|
218 | void BaseGuiPlus::updateShowAllAct() {
|
---|
219 | if (isVisible())
|
---|
220 | showAllAct->change( tr("&Hide") );
|
---|
221 | else
|
---|
222 | showAllAct->change( tr("&Restore") );
|
---|
223 | }
|
---|
224 |
|
---|
225 | void BaseGuiPlus::saveConfig() {
|
---|
226 | qDebug("BaseGuiPlus::saveConfig");
|
---|
227 |
|
---|
228 | QSettings * set = settings;
|
---|
229 |
|
---|
230 | set->beginGroup( "base_gui_plus");
|
---|
231 |
|
---|
232 | set->setValue( "show_tray_icon", showTrayAct->isChecked() );
|
---|
233 | set->setValue( "mainwindow_visible", isVisible() );
|
---|
234 |
|
---|
235 | set->setValue( "trayicon_playlist_was_visible", trayicon_playlist_was_visible );
|
---|
236 | set->setValue( "widgets_size", widgets_size );
|
---|
237 | #if DOCK_PLAYLIST
|
---|
238 | set->setValue( "fullscreen_playlist_was_visible", fullscreen_playlist_was_visible );
|
---|
239 | set->setValue( "fullscreen_playlist_was_floating", fullscreen_playlist_was_floating );
|
---|
240 | set->setValue( "compact_playlist_was_visible", compact_playlist_was_visible );
|
---|
241 | set->setValue( "ignore_playlist_events", ignore_playlist_events );
|
---|
242 | #endif
|
---|
243 |
|
---|
244 | /*
|
---|
245 | #if DOCK_PLAYLIST
|
---|
246 | set->setValue( "playlist_and_toolbars_state", saveState() );
|
---|
247 | #endif
|
---|
248 | */
|
---|
249 |
|
---|
250 | set->endGroup();
|
---|
251 | }
|
---|
252 |
|
---|
253 | void BaseGuiPlus::loadConfig() {
|
---|
254 | qDebug("BaseGuiPlus::loadConfig");
|
---|
255 |
|
---|
256 | QSettings * set = settings;
|
---|
257 |
|
---|
258 | set->beginGroup( "base_gui_plus");
|
---|
259 |
|
---|
260 | bool show_tray_icon = set->value( "show_tray_icon", false).toBool();
|
---|
261 | showTrayAct->setChecked( show_tray_icon );
|
---|
262 | //tray->setVisible( show_tray_icon );
|
---|
263 |
|
---|
264 | mainwindow_visible = set->value("mainwindow_visible", true).toBool();
|
---|
265 |
|
---|
266 | trayicon_playlist_was_visible = set->value( "trayicon_playlist_was_visible", trayicon_playlist_was_visible ).toBool();
|
---|
267 | widgets_size = set->value( "widgets_size", widgets_size ).toInt();
|
---|
268 | #if DOCK_PLAYLIST
|
---|
269 | fullscreen_playlist_was_visible = set->value( "fullscreen_playlist_was_visible", fullscreen_playlist_was_visible ).toBool();
|
---|
270 | fullscreen_playlist_was_floating = set->value( "fullscreen_playlist_was_floating", fullscreen_playlist_was_floating ).toBool();
|
---|
271 | compact_playlist_was_visible = set->value( "compact_playlist_was_visible", compact_playlist_was_visible ).toBool();
|
---|
272 | ignore_playlist_events = set->value( "ignore_playlist_events", ignore_playlist_events ).toBool();
|
---|
273 | #endif
|
---|
274 |
|
---|
275 | /*
|
---|
276 | #if DOCK_PLAYLIST
|
---|
277 | restoreState( set->value( "playlist_and_toolbars_state" ).toByteArray() );
|
---|
278 | #endif
|
---|
279 | */
|
---|
280 |
|
---|
281 | set->endGroup();
|
---|
282 |
|
---|
283 | updateShowAllAct();
|
---|
284 | }
|
---|
285 |
|
---|
286 |
|
---|
287 | void BaseGuiPlus::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
---|
288 | qDebug("DefaultGui::trayIconActivated: %d", reason);
|
---|
289 |
|
---|
290 | updateShowAllAct();
|
---|
291 |
|
---|
292 | if (reason == QSystemTrayIcon::Trigger) {
|
---|
293 | toggleShowAll();
|
---|
294 | }
|
---|
295 | else
|
---|
296 | if (reason == QSystemTrayIcon::MiddleClick) {
|
---|
297 | core->pause();
|
---|
298 | }
|
---|
299 | }
|
---|
300 |
|
---|
301 | void BaseGuiPlus::toggleShowAll() {
|
---|
302 | // Ignore if tray is not visible
|
---|
303 | if (tray->isVisible()) {
|
---|
304 | showAll( !isVisible() );
|
---|
305 | }
|
---|
306 | }
|
---|
307 |
|
---|
308 | void BaseGuiPlus::showAll(bool b) {
|
---|
309 | if (!b) {
|
---|
310 | // Hide all
|
---|
311 | #if DOCK_PLAYLIST
|
---|
312 | trayicon_playlist_was_visible = (playlistdock->isVisible() &&
|
---|
313 | playlistdock->isFloating() );
|
---|
314 | if (trayicon_playlist_was_visible)
|
---|
315 | playlistdock->hide();
|
---|
316 |
|
---|
317 | /*
|
---|
318 | trayicon_playlist_was_visible = playlistdock->isVisible();
|
---|
319 | playlistdock->hide();
|
---|
320 | */
|
---|
321 | #else
|
---|
322 | trayicon_playlist_was_visible = playlist->isVisible();
|
---|
323 | playlist_pos = playlist->pos();
|
---|
324 | playlist->hide();
|
---|
325 | #endif
|
---|
326 |
|
---|
327 | mainwindow_pos = pos();
|
---|
328 | hide();
|
---|
329 |
|
---|
330 | /*
|
---|
331 | infowindow_visible = info_window->isVisible();
|
---|
332 | infowindow_pos = info_window->pos();
|
---|
333 | info_window->hide();
|
---|
334 | */
|
---|
335 | } else {
|
---|
336 | // Show all
|
---|
337 | move(mainwindow_pos);
|
---|
338 | show();
|
---|
339 |
|
---|
340 | #if DOCK_PLAYLIST
|
---|
341 | if (trayicon_playlist_was_visible) {
|
---|
342 | playlistdock->show();
|
---|
343 | }
|
---|
344 | #else
|
---|
345 | if (trayicon_playlist_was_visible) {
|
---|
346 | playlist->move(playlist_pos);
|
---|
347 | playlist->show();
|
---|
348 | }
|
---|
349 | #endif
|
---|
350 |
|
---|
351 | /*
|
---|
352 | if (infowindow_visible) {
|
---|
353 | info_window->show();
|
---|
354 | info_window->move(infowindow_pos);
|
---|
355 | }
|
---|
356 | */
|
---|
357 | }
|
---|
358 | updateShowAllAct();
|
---|
359 | }
|
---|
360 |
|
---|
361 | void BaseGuiPlus::resizeWindow(int w, int h) {
|
---|
362 | qDebug("BaseGuiPlus::resizeWindow: %d, %d", w, h);
|
---|
363 |
|
---|
364 | if ( (tray->isVisible()) && (!isVisible()) ) showAll(true);
|
---|
365 |
|
---|
366 | BaseGui::resizeWindow(w, h );
|
---|
367 | }
|
---|
368 |
|
---|
369 | void BaseGuiPlus::updateMediaInfo() {
|
---|
370 | qDebug("BaseGuiPlus::updateMediaInfo");
|
---|
371 | BaseGui::updateMediaInfo();
|
---|
372 |
|
---|
373 | tray->setToolTip( windowTitle() );
|
---|
374 | }
|
---|
375 |
|
---|
376 | void BaseGuiPlus::setWindowCaption(const QString & title) {
|
---|
377 | tray->setToolTip( title );
|
---|
378 |
|
---|
379 | BaseGui::setWindowCaption( title );
|
---|
380 | }
|
---|
381 |
|
---|
382 |
|
---|
383 | // Playlist stuff
|
---|
384 | void BaseGuiPlus::aboutToEnterFullscreen() {
|
---|
385 | qDebug("BaseGuiPlus::aboutToEnterFullscreen");
|
---|
386 |
|
---|
387 | BaseGui::aboutToEnterFullscreen();
|
---|
388 |
|
---|
389 | #if DOCK_PLAYLIST
|
---|
390 | playlistdock->setAllowedAreas(Qt::NoDockWidgetArea);
|
---|
391 |
|
---|
392 | int playlist_screen = QApplication::desktop()->screenNumber(playlistdock);
|
---|
393 | int mainwindow_screen = QApplication::desktop()->screenNumber(this);
|
---|
394 | qDebug("BaseGuiPlus::aboutToEnterFullscreen: mainwindow screen: %d, playlist screen: %d", mainwindow_screen, playlist_screen);
|
---|
395 |
|
---|
396 | fullscreen_playlist_was_visible = playlistdock->isVisible();
|
---|
397 | fullscreen_playlist_was_floating = playlistdock->isFloating();
|
---|
398 |
|
---|
399 | ignore_playlist_events = true;
|
---|
400 |
|
---|
401 | // Hide the playlist if it's in the same screen as the main window
|
---|
402 | if ((playlist_screen == mainwindow_screen) /* ||
|
---|
403 | (!fullscreen_playlist_was_floating) */ )
|
---|
404 | {
|
---|
405 | playlistdock->setFloating(true);
|
---|
406 | playlistdock->hide();
|
---|
407 | }
|
---|
408 | #endif
|
---|
409 | }
|
---|
410 |
|
---|
411 | void BaseGuiPlus::aboutToExitFullscreen() {
|
---|
412 | qDebug("BaseGuiPlus::aboutToExitFullscreen");
|
---|
413 |
|
---|
414 | BaseGui::aboutToExitFullscreen();
|
---|
415 |
|
---|
416 | #if DOCK_PLAYLIST
|
---|
417 | playlistdock->setAllowedAreas(Qt::TopDockWidgetArea |
|
---|
418 | Qt::BottomDockWidgetArea
|
---|
419 | #if PLAYLIST_ON_SIDES
|
---|
420 | | Qt::LeftDockWidgetArea |
|
---|
421 | Qt::RightDockWidgetArea
|
---|
422 | #endif
|
---|
423 | );
|
---|
424 |
|
---|
425 | if (fullscreen_playlist_was_visible) {
|
---|
426 | playlistdock->show();
|
---|
427 | }
|
---|
428 | playlistdock->setFloating( fullscreen_playlist_was_floating );
|
---|
429 | ignore_playlist_events = false;
|
---|
430 | #endif
|
---|
431 | }
|
---|
432 |
|
---|
433 | void BaseGuiPlus::aboutToEnterCompactMode() {
|
---|
434 | #if DOCK_PLAYLIST
|
---|
435 | compact_playlist_was_visible = (playlistdock->isVisible() &&
|
---|
436 | !playlistdock->isFloating());
|
---|
437 | if (compact_playlist_was_visible)
|
---|
438 | playlistdock->hide();
|
---|
439 | #endif
|
---|
440 |
|
---|
441 | widgets_size = height() - panel->height();
|
---|
442 | qDebug("BaseGuiPlus::aboutToEnterCompactMode: widgets_size: %d", widgets_size);
|
---|
443 |
|
---|
444 | BaseGui::aboutToEnterCompactMode();
|
---|
445 |
|
---|
446 | if (pref->resize_method == Preferences::Always) {
|
---|
447 | resize( width(), height() - widgets_size );
|
---|
448 | }
|
---|
449 | }
|
---|
450 |
|
---|
451 | void BaseGuiPlus::aboutToExitCompactMode() {
|
---|
452 | BaseGui::aboutToExitCompactMode();
|
---|
453 |
|
---|
454 | if (pref->resize_method == Preferences::Always) {
|
---|
455 | resize( width(), height() + widgets_size );
|
---|
456 | }
|
---|
457 |
|
---|
458 | #if DOCK_PLAYLIST
|
---|
459 | if (compact_playlist_was_visible)
|
---|
460 | playlistdock->show();
|
---|
461 | #endif
|
---|
462 | }
|
---|
463 |
|
---|
464 | #if DOCK_PLAYLIST
|
---|
465 | void BaseGuiPlus::showPlaylist(bool b) {
|
---|
466 | qDebug("BaseGuiPlus::showPlaylist: %d", b);
|
---|
467 | qDebug("BaseGuiPlus::showPlaylist (before): playlist visible: %d", playlistdock->isVisible());
|
---|
468 | qDebug("BaseGuiPlus::showPlaylist (before): playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
469 | qDebug("BaseGuiPlus::showPlaylist (before): playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
470 |
|
---|
471 | if ( !b ) {
|
---|
472 | playlistdock->hide();
|
---|
473 | } else {
|
---|
474 | exitFullscreenIfNeeded();
|
---|
475 | playlistdock->show();
|
---|
476 |
|
---|
477 | // Check if playlist is outside of the screen
|
---|
478 | if (playlistdock->isFloating()) {
|
---|
479 | if (!DesktopInfo::isInsideScreen(playlistdock)) {
|
---|
480 | qWarning("BaseGuiPlus::showPlaylist: playlist is outside of the screen");
|
---|
481 | playlistdock->move(0,0);
|
---|
482 | }
|
---|
483 | }
|
---|
484 | }
|
---|
485 | //updateWidgets();
|
---|
486 |
|
---|
487 | qDebug("BaseGuiPlus::showPlaylist (after): playlist visible: %d", playlistdock->isVisible());
|
---|
488 | qDebug("BaseGuiPlus::showPlaylist (after): playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
489 | qDebug("BaseGuiPlus::showPlaylist (after): playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
490 |
|
---|
491 | }
|
---|
492 |
|
---|
493 | void BaseGuiPlus::playlistClosed() {
|
---|
494 | showPlaylistAct->setChecked(false);
|
---|
495 | }
|
---|
496 |
|
---|
497 | #if !USE_DOCK_TOPLEVEL_EVENT
|
---|
498 | void BaseGuiPlus::dockVisibilityChanged(bool visible) {
|
---|
499 | qDebug("BaseGuiPlus::dockVisibilityChanged: %d", visible);
|
---|
500 |
|
---|
501 | if (!playlistdock->isFloating()) {
|
---|
502 | if (!visible) shrinkWindow(); else stretchWindow();
|
---|
503 | }
|
---|
504 | }
|
---|
505 |
|
---|
506 | #else
|
---|
507 |
|
---|
508 | void BaseGuiPlus::dockTopLevelChanged(bool floating) {
|
---|
509 | qDebug("BaseGuiPlus::dockTopLevelChanged: %d", floating);
|
---|
510 |
|
---|
511 | if (floating) shrinkWindow(); else stretchWindow();
|
---|
512 | }
|
---|
513 | #endif
|
---|
514 |
|
---|
515 | void BaseGuiPlus::stretchWindow() {
|
---|
516 | qDebug("BaseGuiPlus::stretchWindow");
|
---|
517 | if ((ignore_playlist_events) || (pref->resize_method!=Preferences::Always)) return;
|
---|
518 |
|
---|
519 | qDebug("BaseGuiPlus::stretchWindow: dockWidgetArea: %d", (int) dockWidgetArea(playlistdock) );
|
---|
520 |
|
---|
521 | if ( (dockWidgetArea(playlistdock) == Qt::TopDockWidgetArea) ||
|
---|
522 | (dockWidgetArea(playlistdock) == Qt::BottomDockWidgetArea) )
|
---|
523 | {
|
---|
524 | int new_height = height() + playlistdock->height();
|
---|
525 |
|
---|
526 | //if (new_height > DesktopInfo::desktop_size(this).height())
|
---|
527 | // new_height = DesktopInfo::desktop_size(this).height() - 20;
|
---|
528 |
|
---|
529 | qDebug("BaseGuiPlus::stretchWindow: stretching: new height: %d", new_height);
|
---|
530 | resize( width(), new_height );
|
---|
531 |
|
---|
532 | //resizeWindow(core->mset.win_width, core->mset.win_height);
|
---|
533 | }
|
---|
534 |
|
---|
535 | else
|
---|
536 |
|
---|
537 | if ( (dockWidgetArea(playlistdock) == Qt::LeftDockWidgetArea) ||
|
---|
538 | (dockWidgetArea(playlistdock) == Qt::RightDockWidgetArea) )
|
---|
539 | {
|
---|
540 | int new_width = width() + playlistdock->width();
|
---|
541 |
|
---|
542 | qDebug("BaseGuiPlus::stretchWindow: stretching: new width: %d", new_width);
|
---|
543 | resize( new_width, height() );
|
---|
544 | }
|
---|
545 | }
|
---|
546 |
|
---|
547 | void BaseGuiPlus::shrinkWindow() {
|
---|
548 | qDebug("BaseGuiPlus::shrinkWindow");
|
---|
549 | if ((ignore_playlist_events) || (pref->resize_method!=Preferences::Always)) return;
|
---|
550 |
|
---|
551 | qDebug("BaseGuiPlus::shrinkWindow: dockWidgetArea: %d", (int) dockWidgetArea(playlistdock) );
|
---|
552 |
|
---|
553 | if ( (dockWidgetArea(playlistdock) == Qt::TopDockWidgetArea) ||
|
---|
554 | (dockWidgetArea(playlistdock) == Qt::BottomDockWidgetArea) )
|
---|
555 | {
|
---|
556 | int new_height = height() - playlistdock->height();
|
---|
557 | qDebug("DefaultGui::shrinkWindow: shrinking: new height: %d", new_height);
|
---|
558 | resize( width(), new_height );
|
---|
559 |
|
---|
560 | //resizeWindow(core->mset.win_width, core->mset.win_height);
|
---|
561 | }
|
---|
562 |
|
---|
563 | else
|
---|
564 |
|
---|
565 | if ( (dockWidgetArea(playlistdock) == Qt::LeftDockWidgetArea) ||
|
---|
566 | (dockWidgetArea(playlistdock) == Qt::RightDockWidgetArea) )
|
---|
567 | {
|
---|
568 | int new_width = width() - playlistdock->width();
|
---|
569 |
|
---|
570 | qDebug("BaseGuiPlus::shrinkWindow: shrinking: new width: %d", new_width);
|
---|
571 | resize( new_width, height() );
|
---|
572 | }
|
---|
573 | }
|
---|
574 |
|
---|
575 | #endif
|
---|
576 |
|
---|
577 | // Convenience functions intended for other GUI's
|
---|
578 | TimeSliderAction * BaseGuiPlus::createTimeSliderAction(QWidget * parent) {
|
---|
579 | TimeSliderAction * timeslider_action = new TimeSliderAction( parent );
|
---|
580 | timeslider_action->setObjectName("timeslider_action");
|
---|
581 |
|
---|
582 | #ifdef SEEKBAR_RESOLUTION
|
---|
583 | connect( timeslider_action, SIGNAL( posChanged(int) ),
|
---|
584 | core, SLOT(goToPosition(int)) );
|
---|
585 | connect( core, SIGNAL(positionChanged(int)),
|
---|
586 | timeslider_action, SLOT(setPos(int)) );
|
---|
587 | #else
|
---|
588 | connect( timeslider_action, SIGNAL( posChanged(int) ),
|
---|
589 | core, SLOT(goToPos(int)) );
|
---|
590 | connect( core, SIGNAL(posChanged(int)),
|
---|
591 | timeslider_action, SLOT(setPos(int)) );
|
---|
592 | #endif
|
---|
593 | connect( timeslider_action, SIGNAL( draggingPos(int) ),
|
---|
594 | this, SLOT(displayGotoTime(int)) );
|
---|
595 | #if ENABLE_DELAYED_DRAGGING
|
---|
596 | timeslider_action->setDragDelay( pref->time_slider_drag_delay );
|
---|
597 |
|
---|
598 | connect( timeslider_action, SIGNAL( delayedDraggingPos(int) ),
|
---|
599 | this, SLOT(goToPosOnDragging(int)) );
|
---|
600 | #else
|
---|
601 | connect( timeslider_action, SIGNAL( draggingPos(int) ),
|
---|
602 | this, SLOT(goToPosOnDragging(int)) );
|
---|
603 | #endif
|
---|
604 | return timeslider_action;
|
---|
605 | }
|
---|
606 |
|
---|
607 | VolumeSliderAction * BaseGuiPlus::createVolumeSliderAction(QWidget * parent) {
|
---|
608 | VolumeSliderAction * volumeslider_action = new VolumeSliderAction(parent);
|
---|
609 | volumeslider_action->setObjectName("volumeslider_action");
|
---|
610 |
|
---|
611 | connect( volumeslider_action, SIGNAL( valueChanged(int) ),
|
---|
612 | core, SLOT( setVolume(int) ) );
|
---|
613 | connect( core, SIGNAL(volumeChanged(int)),
|
---|
614 | volumeslider_action, SLOT(setValue(int)) );
|
---|
615 |
|
---|
616 | return volumeslider_action;
|
---|
617 | }
|
---|
618 |
|
---|
619 | #ifdef Q_OS_OS2
|
---|
620 | // we test if xcenter is available at all. if not disable the tray action. this is possible when xcenter is not opened or crashed
|
---|
621 | void BaseGuiPlus::trayAvailable() {
|
---|
622 | if (!tray->isSystemTrayAvailable()) {
|
---|
623 | optionsMenu->removeAction(showTrayAct);
|
---|
624 | }
|
---|
625 | else {
|
---|
626 | optionsMenu->addAction(showTrayAct);
|
---|
627 | }
|
---|
628 | }
|
---|
629 | #endif
|
---|
630 |
|
---|
631 | #include "moc_baseguiplus.cpp"
|
---|