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