~ubuntu-branches/debian/sid/smplayer/sid

« back to all changes in this revision

Viewing changes to src/baseguiplus.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mto: (1.1.9 upstream) (3.1.2 squeeze)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-nsklbxenl2hf2n6h
Tags: upstream-0.6.7
ImportĀ upstreamĀ versionĀ 0.6.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  smplayer, GUI front-end for mplayer.
2
 
    Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
 
2
    Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org>
3
3
 
4
4
    This program is free software; you can redistribute it and/or modify
5
5
    it under the terms of the GNU General Public License as published by
27
27
 
28
28
#include <QMenu>
29
29
#include <QCloseEvent>
 
30
#include <QApplication>
 
31
#include <QDesktopWidget>
30
32
 
31
33
#if DOCK_PLAYLIST
32
34
#include <QDockWidget>
76
78
        connect( showAllAct, SIGNAL(triggered()),
77
79
             this, SLOT(toggleShowAll()) );
78
80
 
 
81
 
79
82
        context_menu = new QMenu(this);
80
83
        context_menu->addAction(showAllAct);
81
84
        context_menu->addSeparator();
116
119
        playlistdock->setFloating(true); // Floating by default
117
120
 
118
121
        connect( playlistdock, SIGNAL(closed()), this, SLOT(playlistClosed()) );
119
 
        connect( playlistdock, SIGNAL(docked()), this, SLOT(stretchWindow()) );
120
 
        connect( playlistdock, SIGNAL(undocked()), this, SLOT(shrinkWindow()) );
 
122
#if USE_DOCK_TOPLEVEL_EVENT
 
123
        connect( playlistdock, SIGNAL(topLevelChanged(bool)), 
 
124
             this, SLOT(dockTopLevelChanged(bool)) );
 
125
#else
 
126
        connect( playlistdock, SIGNAL(visibilityChanged(bool)), 
 
127
             this, SLOT(dockVisibilityChanged(bool)) );
 
128
#endif // USE_DOCK_TOPLEVEL_EVENT
121
129
 
122
130
        ignore_playlist_events = false;
123
 
#endif
 
131
#endif // DOCK_PLAYLIST
124
132
 
125
133
        retranslateStrings();
126
134
 
361
369
        BaseGui::aboutToEnterFullscreen();
362
370
 
363
371
#if DOCK_PLAYLIST
 
372
        playlistdock->setAllowedAreas(Qt::NoDockWidgetArea);
 
373
 
 
374
        int playlist_screen = QApplication::desktop()->screenNumber(playlistdock);
 
375
        int mainwindow_screen = QApplication::desktop()->screenNumber(this);
 
376
        qDebug("BaseGuiPlus::aboutToEnterFullscreen: mainwindow screen: %d, playlist screen: %d", mainwindow_screen, playlist_screen);
 
377
 
364
378
        fullscreen_playlist_was_visible = playlistdock->isVisible();
365
379
        fullscreen_playlist_was_floating = playlistdock->isFloating();
366
 
        //showPlaylistAct->setEnabled(false);
 
380
 
367
381
        ignore_playlist_events = true;
368
 
        playlistdock->setFloating(true);
369
 
        playlistdock->hide();
370
 
        //showPlaylistAct->setChecked(false);
371
 
        //playlist_state = saveState();
 
382
 
 
383
        // Hide the playlist if it's in the same screen as the main window
 
384
        if ((playlist_screen == mainwindow_screen) /* || 
 
385
        (!fullscreen_playlist_was_floating) */ ) 
 
386
        {
 
387
                playlistdock->setFloating(true);
 
388
                playlistdock->hide();
 
389
        }
372
390
#endif
373
391
}
374
392
 
378
396
        BaseGui::aboutToExitFullscreen();
379
397
 
380
398
#if DOCK_PLAYLIST
 
399
        playlistdock->setAllowedAreas(Qt::TopDockWidgetArea | 
 
400
                                  Qt::BottomDockWidgetArea
 
401
                                  #if PLAYLIST_ON_SIDES
 
402
                                  | Qt::LeftDockWidgetArea | 
 
403
                                  Qt::RightDockWidgetArea
 
404
                                  #endif
 
405
                                  );
 
406
 
381
407
        if (fullscreen_playlist_was_visible) {
382
408
                playlistdock->show();
383
409
        }
384
410
        playlistdock->setFloating( fullscreen_playlist_was_floating );
385
 
        //restoreState( playlist_state );
386
411
        ignore_playlist_events = false;
387
 
        //showPlaylistAct->setEnabled(true);
388
412
#endif
389
413
}
390
414
 
421
445
 
422
446
#if DOCK_PLAYLIST
423
447
void BaseGuiPlus::showPlaylist(bool b) {
 
448
        qDebug("BaseGuiPlus::showPlaylist: %d", b);
 
449
        qDebug("BaseGuiPlus::showPlaylist (before): playlist visible: %d", playlistdock->isVisible());
 
450
        qDebug("BaseGuiPlus::showPlaylist (before): playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
 
451
        qDebug("BaseGuiPlus::showPlaylist (before): playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
 
452
 
424
453
        if ( !b ) {
425
454
                playlistdock->hide();
426
455
        } else {
427
456
                exitFullscreenIfNeeded();
428
457
                playlistdock->show();
 
458
 
 
459
                // Check if playlist is outside of the screen
 
460
                if (playlistdock->isFloating()) {
 
461
                        if (!DesktopInfo::isInsideScreen(playlistdock)) {
 
462
                                qWarning("BaseGuiPlus::showPlaylist: playlist is outside of the screen");
 
463
                                playlistdock->move(0,0);
 
464
                        }
 
465
                }
429
466
        }
430
467
        //updateWidgets();
 
468
 
 
469
        qDebug("BaseGuiPlus::showPlaylist (after): playlist visible: %d", playlistdock->isVisible());
 
470
        qDebug("BaseGuiPlus::showPlaylist (after): playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
 
471
        qDebug("BaseGuiPlus::showPlaylist (after): playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
 
472
 
431
473
}
432
474
 
433
475
void BaseGuiPlus::playlistClosed() {
434
476
        showPlaylistAct->setChecked(false);
435
477
}
436
478
 
 
479
#if !USE_DOCK_TOPLEVEL_EVENT
 
480
void BaseGuiPlus::dockVisibilityChanged(bool visible) {
 
481
        qDebug("BaseGuiPlus::dockVisibilityChanged: %d", visible);
 
482
 
 
483
        if (!playlistdock->isFloating()) {
 
484
                if (!visible) shrinkWindow(); else stretchWindow();
 
485
        }
 
486
}
 
487
 
 
488
#else
 
489
 
 
490
void BaseGuiPlus::dockTopLevelChanged(bool floating) {
 
491
        qDebug("BaseGuiPlus::dockTopLevelChanged: %d", floating);
 
492
 
 
493
        if (floating) shrinkWindow(); else stretchWindow();
 
494
}
 
495
#endif
 
496
 
437
497
void BaseGuiPlus::stretchWindow() {
438
498
        qDebug("BaseGuiPlus::stretchWindow");
439
499
        if ((ignore_playlist_events) || (pref->resize_method!=Preferences::Always)) return;
499
559
// Convenience functions intended for other GUI's
500
560
TimeSliderAction * BaseGuiPlus::createTimeSliderAction(QWidget * parent) {
501
561
        TimeSliderAction * timeslider_action = new TimeSliderAction( parent );
 
562
        timeslider_action->setObjectName("timeslider_action");
 
563
 
 
564
#ifdef SEEKBAR_RESOLUTION
 
565
        connect( timeslider_action, SIGNAL( posChanged(int) ), 
 
566
             core, SLOT(goToPosition(int)) );
 
567
        connect( core, SIGNAL(positionChanged(int)), 
 
568
             timeslider_action, SLOT(setPos(int)) );
 
569
#else
502
570
        connect( timeslider_action, SIGNAL( posChanged(int) ), 
503
571
             core, SLOT(goToPos(int)) );
 
572
        connect( core, SIGNAL(posChanged(int)), 
 
573
             timeslider_action, SLOT(setPos(int)) );
 
574
#endif
504
575
        connect( timeslider_action, SIGNAL( draggingPos(int) ), 
505
576
             this, SLOT(displayGotoTime(int)) );
506
 
        connect( core, SIGNAL(posChanged(int)), 
507
 
             timeslider_action, SLOT(setPos(int)) );
508
577
#if ENABLE_DELAYED_DRAGGING
509
578
        timeslider_action->setDragDelay( pref->time_slider_drag_delay );
510
579
 
519
588
 
520
589
VolumeSliderAction * BaseGuiPlus::createVolumeSliderAction(QWidget * parent) {
521
590
        VolumeSliderAction * volumeslider_action = new VolumeSliderAction(parent);
 
591
        volumeslider_action->setObjectName("volumeslider_action");
 
592
 
522
593
        connect( volumeslider_action, SIGNAL( valueChanged(int) ), 
523
594
             core, SLOT( setVolume(int) ) );
524
595
        connect( core, SIGNAL(volumeChanged(int)),