~ubuntu-branches/ubuntu/dapper/kdemultimedia/dapper

« back to all changes in this revision

Viewing changes to kscd/kscd.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-01-23 14:26:07 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060123142607-4cj5fiu4gef3wypf
Tags: 4:3.5.1-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <qvbox.h>
30
30
#include <qapplication.h>
31
31
#include <qgroupbox.h>
 
32
#include <qsqlpropertymap.h>
32
33
 
33
34
#include <dcopclient.h>
34
35
#include <kaboutdata.h>
130
131
  // the volume slider
131
132
  volumeIcon->setPixmap(SmallIcon("player_volume"));
132
133
  volumeSlider->setValue(Prefs::volume());
 
134
  QString str;
 
135
  str = QString::fromUtf8( QCString().sprintf(i18n("Vol: %02d%%").utf8(), Prefs::volume()) );
 
136
  volumelabel->setText(str);
133
137
  connect(volumeSlider, SIGNAL(valueChanged(int)), SLOT(volChanged(int)));
134
138
 
135
139
  /* FIXME check for return value */
137
141
  connect(m_cd, SIGNAL(trackPlaying(unsigned, unsigned)), this, SLOT(trackUpdate(unsigned, unsigned)));
138
142
  connect(m_cd, SIGNAL(trackPaused(unsigned, unsigned)), this, SLOT(trackUpdate(unsigned, unsigned)));
139
143
  connect(m_cd, SIGNAL(trackChanged(unsigned, unsigned)), this, SLOT(trackChanged(unsigned, unsigned)));
 
144
  connect(m_cd, SIGNAL(discStopped()), this, SLOT(discStopped()));
140
145
  connect(m_cd, SIGNAL(discChanged(unsigned)), this, SLOT(discChanged(unsigned)));
141
146
  connect( &queryledtimer, SIGNAL(timeout()),  SLOT(togglequeryled()) );
142
147
  connect( &titlelabeltimer, SIGNAL(timeout()),  SLOT(titlelabeltimeout()) );
186
191
  m_actions->readShortcutSettings("Shortcuts");
187
192
  
188
193
  m_actions->action( "options_configure_globals" )->setText( i18n( "Configure &Global Shortcuts..." ) );
 
194
 
 
195
  kapp->installKDEPropertyMap();
 
196
  QSqlPropertyMap *map = QSqlPropertyMap::defaultMap();
 
197
  map->insert("KComboBox", "currentText");
189
198
  
190
199
  initGlobalShortcuts();
191
200
  
377
386
 
378
387
    if (!m_cd->isPlaying())
379
388
    {
380
 
        setLEDs(0);
381
 
        resetTimeSlider(true);
382
389
        kapp->processEvents();
383
390
        kapp->flushX();
384
391
 
389
396
        }
390
397
        else
391
398
        {
 
399
            setLEDs(0);
 
400
            resetTimeSlider(true);
 
401
 
392
402
            if(Prefs::randomPlay())
393
403
            {
394
404
                make_random_list();
424
434
{
425
435
    if (shuffle == 2) {
426
436
        if(Prefs::randomPlay() && m_cd->tracks() > 0) {
 
437
            shufflePB->blockSignals(true);
 
438
            shufflePB->setOn(true);
 
439
            shufflePB->blockSignals(false);
427
440
            make_random_list(); /* koz: Build a unique, once, random list */
428
441
            if(m_cd->isPlaying())
429
442
                nextClicked();
459
472
 
460
473
    if (Prefs::randomPlay()) {
461
474
        track = prev_randomtrack();
462
 
        if (track == 0) {
 
475
        if (track == -1) {
463
476
            return;
464
477
        }
465
478
    } else {
476
489
 
477
490
    kapp->processEvents();
478
491
    kapp->flushX();
479
 
    m_cd->play(track, playlist.isEmpty() ? 0 : track);
 
492
    m_cd->play(track, 0, playlist.isEmpty() ? 0 : track);
480
493
} // prevClicked()
481
494
 
482
495
bool KSCD::nextClicked()
504
517
 
505
518
    kapp->processEvents();
506
519
    kapp->flushX();
507
 
    m_cd->play(track, playlist.isEmpty() ? 0 : track + 1);
 
520
    m_cd->play(track, 0, Prefs::randomPlay() || !playlist.isEmpty() ? track + 1 : 0);
508
521
    return true;
509
522
} // nextClicked()
510
523
 
538
551
            QToolTip::remove(songListCB);
539
552
            QToolTip::add(songListCB, i18n("Current track: %1").arg(justTheName));
540
553
        }
 
554
        timeSlider->blockSignals(true);
541
555
        timeSlider->setRange(0, trackLength ? trackLength - 1 : 0);
 
556
        timeSlider->blockSignals(false);
542
557
        QString str;
543
558
        str.sprintf("%02d/%02d", track, m_cd->tracks());
544
559
        tracklabel->setText(str);
552
567
} //trackChanged(int track)
553
568
 
554
569
 
555
 
void KSCD::jumpToTime(int seconds, bool forcePlay)
 
570
void KSCD::jumpToTime(int ms, bool forcePlay)
556
571
{
557
572
    kapp->processEvents();
558
573
    kapp->flushX();
559
574
 
560
575
    int track = m_cd->track();
561
576
    if ((m_cd->isPlaying() || forcePlay) &&
562
 
        seconds < (int)m_cd->trackLength())
 
577
        ms < (int)m_cd->trackLength())
563
578
    {
564
579
        if(Prefs::randomPlay() || !playlist.isEmpty())
565
580
        {
566
 
            m_cd->play(track, seconds, track + 1);
 
581
            m_cd->play(track, ms, track + 1);
567
582
        }
568
583
        else
569
584
        {
570
 
            m_cd->play(track, seconds);
 
585
            m_cd->play(track, ms);
571
586
        }
572
587
    }
573
 
} // jumpToTime(int seconds)
 
588
} // jumpToTime(int ms)
574
589
 
575
590
void KSCD::timeSliderPressed()
576
591
{
749
764
 
750
765
    updateConfigDialog(confWidget);
751
766
 
752
 
    connect(configDialog, SIGNAL(settingsChanged()), confWidget, SLOT(configDone()));
753
767
    connect(configDialog, SIGNAL(settingsChanged()), this, SLOT(configDone()));
754
768
    configDialog -> show();
755
769
} // showConfig()
781
795
void KSCD::setDevicePaths()
782
796
{
783
797
    if (!m_cd->setDevice(Prefs::cdDevice(), Prefs::volume(), Prefs::digitalPlayback(),
784
 
                Prefs::audioSystem(), Prefs::audioDevice()))
 
798
                         Prefs::audioSystem(), Prefs::audioDevice()))
785
799
    {
786
800
        // This device did not seem usable.
787
801
        QString str = i18n("CD-ROM read or access error (or no audio disc in drive).\n"\
788
802
                            "Please make sure you have access permissions to:\n%1").arg(
789
 
                              KCompactDisc::urlToDevice(Prefs::cdDevice()));
 
803
                             KCompactDisc::urlToDevice(Prefs::cdDevice()));
790
804
        KMessageBox::error(this, str, i18n("Error"));
791
805
    }
792
 
    else
793
 
    {
794
 
        if (Prefs::autoplay() && !m_cd->isPlaying())
795
 
        {
796
 
            playClicked();
797
 
        }
798
 
    }
799
806
} // setDevicePath()
800
807
 
801
808
void KSCD::setDocking(bool dock)
852
859
void KSCD::volChanged( int vol )
853
860
{
854
861
    QString str;
855
 
    str = QString::fromUtf8( QCString().sprintf(i18n("Vol: %02d%%").utf8(), Prefs::volume()) );
 
862
    str = QString::fromUtf8( QCString().sprintf(i18n("Vol: %02d%%").utf8(), vol) );
856
863
    volumelabel->setText(str);
857
864
    m_cd->setVolume(vol);
858
865
    Prefs::setVolume(vol);
928
935
    {
929
936
        if(!Prefs::looping())
930
937
        {
931
 
            m_cd->stop();
932
938
            return -1;
933
939
        }
934
940
        else
998
1004
    //totaltimelabel->clear();
999
1005
    totaltimelabel->lower();
1000
1006
 
 
1007
    if ((Prefs::autoplay() || KCmdLineArgs::parsedArgs()->isSet("start"))
 
1008
        && !m_cd->isPlaying())
 
1009
    {
 
1010
        playClicked();
 
1011
    }
 
1012
 
1001
1013
    // We just populated the GUI with what we got from the CD. Now look for
1002
1014
    // more from the Internet...
1003
1015
    lookupCDDB();
1005
1017
 
1006
1018
void KSCD::discStopped()
1007
1019
{
1008
 
    statuslabel->setText(i18n("Stopped"));
1009
1020
    if (Prefs::ejectOnFinish() && !stoppedByUser && (m_cd->discId() != KCompactDisc::missingDisc))
1010
1021
    {
1011
1022
        ejectClicked();
1012
1023
    }
1013
1024
 
 
1025
    if (!stoppedByUser)
 
1026
    {
 
1027
      if (Prefs::randomPlay())
 
1028
      {
 
1029
        // If nextClicked returns false, it was the last
 
1030
        // random track, and the player should be stopped
 
1031
        if (nextClicked())
 
1032
          return;
 
1033
      }
 
1034
      else if (Prefs::looping())
 
1035
      {
 
1036
        playClicked();
 
1037
        return;
 
1038
      }
 
1039
    }
 
1040
    
 
1041
    statuslabel->setText(i18n("Stopped"));
 
1042
    playPB->setText(i18n("Play"));
 
1043
    playPB->setIconSet(SmallIconSet("player_play"));
 
1044
 
1014
1045
    /* reset to initial value, only stopclicked() sets this to true */
1015
1046
    stoppedByUser = false;
1016
1047
 
1330
1361
        tmp = trackPosition;
1331
1362
        break;
1332
1363
    }
1333
 
    setLEDs(tmp);
1334
 
    timeSlider->blockSignals(true);
1335
 
    timeSlider->setValue(trackPosition);
1336
 
    timeSlider->blockSignals(false);
 
1364
    if (updateTime)
 
1365
    {
 
1366
      setLEDs(tmp);
 
1367
      timeSlider->blockSignals(true);
 
1368
      timeSlider->setValue(trackPosition);
 
1369
      timeSlider->blockSignals(false);
 
1370
    }
1337
1371
}
1338
1372
 
1339
1373
void KSCD::cycleplaytimemode()
1642
1676
    }
1643
1677
 
1644
1678
    if (args->count()>0) Prefs::self()->setCdDevice(args->arg(0));
1645
 
    if (args->isSet("start")) Prefs::self()->setAutoplay(true);
1646
1679
 
1647
1680
    return a.exec();
1648
1681
}