~ubuntu-branches/ubuntu/natty/kdemultimedia/natty-proposed

« back to all changes in this revision

Viewing changes to kscd/kscd.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Debian Qt/KDE Maintainers
  • Date: 2011-05-26 02:41:36 UTC
  • mfrom: (0.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: james.westby@ubuntu.com-20110526024136-jjwsigfy402jhupm
Tags: upstream-4.6.3
ImportĀ upstreamĀ versionĀ 4.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
 
50
50
        new CDPlayerAdaptor( this );
51
51
 
52
 
        QDBusConnection::sessionBus().registerObject("/CDPlayer", this);
 
52
        QDBusConnection::sessionBus().registerObject(QLatin1String( "/CDPlayer" ), this);
53
53
 
54
54
 
55
55
        devices = new HWControler();
84
84
void KSCD::setupActions()
85
85
{
86
86
        m_actions = new KActionCollection(this);
87
 
        m_actions->setConfigGroup("Configuration");
 
87
        m_actions->setConfigGroup(QLatin1String( "Configuration" ));
88
88
 
89
89
        m_configureShortcutsAction = m_actions->addAction(i18n("Configure Shortcuts..."));
90
90
        m_configureShortcutsAction->setText(i18n("Configure Shortcuts..."));
108
108
        connect(m_downloadAction, SIGNAL(triggered()), m_MBManager, SLOT(discLookup()));
109
109
 
110
110
        //upload info
111
 
        m_uploadAction = m_actions->addAction("Upload Info");
 
111
        m_uploadAction = m_actions->addAction( QLatin1String( "Upload Info" ));
112
112
        m_uploadAction->setText(i18n("Upload Info"));
113
113
        addAction(m_uploadAction);
114
114
        connect(m_uploadAction, SIGNAL(triggered()), m_MBManager, SLOT(discUpload()));
115
115
 
116
116
        //play/pause
117
 
        m_playPauseAction = m_actions->addAction("Play/Pause");
 
117
        m_playPauseAction = m_actions->addAction( QLatin1String( "Play/Pause" ));
118
118
        m_playPauseAction->setText(i18n("Play/Pause"));
119
119
        m_playPauseAction->setShortcut(Qt::Key_Space);
120
120
        connect(m_playPauseAction, SIGNAL(triggered()), this, SLOT(playShortcut()));
121
121
        addAction(m_playPauseAction);
122
122
 
123
123
        //stop
124
 
        m_stopAction = m_actions->addAction("Stop");
 
124
        m_stopAction = m_actions->addAction( QLatin1String( "Stop" ));
125
125
        m_stopAction->setText(i18n("Stop"));
126
126
        addAction(m_stopAction);
127
127
        m_stopAction->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_V);
128
128
        connect(m_stopAction, SIGNAL(triggered()), devices, SLOT(stop()));
129
129
 
130
130
        //next
131
 
        m_nextAction = m_actions->addAction("next");
 
131
        m_nextAction = m_actions->addAction( QLatin1String( "next" ));
132
132
        m_nextAction->setText(i18nc( "This action allow user to pass to the following track","Next" ));
133
133
        addAction(m_nextAction);
134
134
        m_nextAction->setShortcut(Qt::Key_Right);
135
135
        connect(m_nextAction, SIGNAL(triggered()), devices, SLOT(nextTrack()));
136
136
 
137
137
        //previous
138
 
        m_previousAction = m_actions->addAction("previous");
 
138
        m_previousAction = m_actions->addAction( QLatin1String( "previous" ));
139
139
        m_previousAction->setText(i18nc( "This action allow the user to pass to the preceding track", "Previous" ) );
140
140
        addAction(m_previousAction);
141
141
        m_previousAction->setShortcut(Qt::Key_Left);
142
142
        connect(m_previousAction, SIGNAL(triggered()), devices, SLOT(prevTrack()));
143
143
 
144
144
        //eject
145
 
        m_ejectAction = m_actions->addAction("eject");
 
145
        m_ejectAction = m_actions->addAction( QLatin1String( "eject" ));
146
146
        m_ejectAction->setText(i18nc( " This action allow to eject the inserted disc", "Eject"));
147
147
        addAction(m_ejectAction);
148
148
        m_ejectAction->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_E);
149
149
        connect(m_ejectAction, SIGNAL(triggered()), this, SLOT(ejectShortcut()));
150
150
 
151
151
        //volume up
152
 
        m_volumeUpAction = m_actions->addAction("volume_up");
 
152
        m_volumeUpAction = m_actions->addAction( QLatin1String( "volume_up" ));
153
153
        m_volumeUpAction->setText(i18n("Volume Up"));
154
154
        addAction(m_volumeUpAction);
155
155
        m_volumeUpAction->setShortcut(Qt::Key_Up);
156
156
        connect(m_volumeUpAction, SIGNAL(triggered()), this, SLOT(volumeUpShortcut()));
157
157
 
158
158
        //volume down
159
 
        m_volumeDownAction = m_actions->addAction("volume_down");
 
159
        m_volumeDownAction = m_actions->addAction( QLatin1String( "volume_down" ));
160
160
        m_volumeDownAction->setText(i18n("Volume Down"));
161
161
        addAction(m_volumeDownAction);
162
162
        m_volumeDownAction->setShortcut(Qt::Key_Down);
163
163
        connect(m_volumeDownAction, SIGNAL(triggered()), this, SLOT(volumeDownShortcut()));
164
164
 
165
165
        //random
166
 
        m_randomAction = m_actions->addAction("random");
 
166
        m_randomAction = m_actions->addAction( QLatin1String( "random" ));
167
167
        m_randomAction->setText(i18nc("This action allow the user to listen a random track list","Random"));
168
168
        addAction(m_randomAction);
169
169
        m_randomAction->setShortcut(Qt::CTRL + Qt:: Key_H);
170
170
        connect(m_randomAction, SIGNAL(triggered()), this, SLOT(randomShortcut()));
171
171
 
172
172
        //looptrack
173
 
        m_looptrackAction = m_actions->addAction("looptrack");
 
173
        m_looptrackAction = m_actions->addAction( QLatin1String( "looptrack" ));
174
174
        m_looptrackAction->setText(i18n("Repeat Track"));
175
175
        addAction(m_looptrackAction);
176
176
        m_looptrackAction->setShortcut(Qt::CTRL + Qt::Key_T);
177
177
        connect(m_looptrackAction, SIGNAL(triggered()), this, SLOT(looptrackShortcut()));
178
178
 
179
179
        //loopdisc
180
 
        m_loopdiscAction = m_actions->addAction("loopdisc");
 
180
        m_loopdiscAction = m_actions->addAction( QLatin1String( "loopdisc" ));
181
181
        m_loopdiscAction->setText(i18n("Repeat Album"));
182
182
        addAction(m_loopdiscAction);
183
183
        m_loopdiscAction->setShortcut(Qt::CTRL + Qt::Key_D);
184
184
        connect(m_loopdiscAction, SIGNAL(triggered()), this, SLOT(loopdiscShortcut()));
185
185
 
186
186
        //tracklist
187
 
        m_tracklistAction = m_actions->addAction("tracklist");
 
187
        m_tracklistAction = m_actions->addAction( QLatin1String( "tracklist" ));
188
188
        m_tracklistAction->setText(i18n("Show Tracklist"));
189
189
        addAction(m_tracklistAction);
190
190
        connect(m_tracklistAction, SIGNAL(triggered()), this, SLOT(tracklistShortcut()));
191
191
 
192
192
        //mute
193
 
        m_muteAction = m_actions->addAction("mute");
 
193
        m_muteAction = m_actions->addAction( QLatin1String( "mute" ));
194
194
        m_muteAction->setText(i18n("Mute/Unmute"));
195
195
        addAction(m_muteAction);
196
196
        connect(m_muteAction, SIGNAL(triggered()), this, SLOT(muteShortcut()));
197
197
 
198
198
        //minimize
199
 
        m_minimizeAction = m_actions->addAction("Minimize");
 
199
        m_minimizeAction = m_actions->addAction( QLatin1String( "Minimize" ));
200
200
        m_minimizeAction->setText(i18n("Minimize"));
201
201
        addAction(m_minimizeAction);
202
202
        connect(m_minimizeAction, SIGNAL(triggered()), this, SLOT(minimizeShortcut()));
271
271
        }
272
272
        else
273
273
        {
274
 
                QString empty = "";
 
274
                QString empty;
275
275
                showArtistLabel(empty);
276
276
        }
277
277
 
280
280
void KSCD::restoreTrackinfoLabel()
281
281
{
282
282
        QString title, length ;
283
 
/*
 
283
 
284
284
        // If disc is inserted
285
285
        int currentTrack = devices->getCurrentTrack();
286
286
        if (devices->getCD()->isCdInserted()  && currentTrack > 0 )
287
287
        {
288
288
 
289
 
                title = QString("%1 - ").arg(currentTrack, 2, 10, QLatin1Char('0')) ;
 
289
            title = QString::fromLatin1("%1 - ").arg(currentTrack, 2, 10, QLatin1Char('0')) ;
290
290
                title.append(m_MBManager->getTrackList()[currentTrack-1].Title);
291
291
                length.append(m_MBManager->getTrackList()[currentTrack-1].Duration);
292
292
 
293
293
                showTrackinfoLabel(title);
294
 
                m_popup = new TitlePopUp(this, "popup");
 
294
                m_popup = new TitlePopUp(this, QLatin1String( "popup" ));
295
295
        }
296
296
        else
297
297
        {
298
298
                showTrackinfoLabel(title);
299
 
        }*/
 
299
        }
300
300
}
301
301
void KSCD::changeVolume(qreal value)
302
302
{
311
311
 
312
312
void KSCD::ejectShortcut()
313
313
{
314
 
        QString result = "eject";
 
314
        QString result = QLatin1String( "eject" );
315
315
        actionButton(result);
316
316
}
317
317
 
318
318
void KSCD::quitShortcut()
319
319
{
320
 
        QString result = "close";
 
320
        QString result = QLatin1String( "close" );
321
321
        actionButton(result);
322
322
}
323
323
 
324
324
void KSCD::minimizeShortcut()
325
325
{
326
 
        QString result = "minimize";
 
326
        QString result = QLatin1String( "minimize" );
327
327
        actionButton(result);
328
328
}
329
329
 
330
330
void KSCD::tracklistShortcut()
331
331
{
332
 
        QString result = "tracklist";
 
332
        QString result = QLatin1String( "tracklist" );
333
333
        actionButton(result);
334
334
}
335
335
 
336
336
void KSCD::muteShortcut()
337
337
{
338
 
        QString def = "default";
 
338
        QString def = QLatin1String( "default" );
339
339
        if (!mute)
340
340
        {
341
 
                QString result = "unmute";
 
341
                QString result = QLatin1String( "unmute" );
342
342
                actionButton(result);
343
343
                emit(picture(result,def));
344
344
                //mute = !mute;
345
345
        }
346
346
        else
347
347
        {
348
 
                QString result = "mute";
 
348
                QString result = QLatin1String( "mute" );
349
349
                actionButton(result);
350
350
                emit(picture(result,def));
351
351
                //mute = !mute;
354
354
 
355
355
void KSCD::playShortcut()
356
356
{
357
 
        QString def = "default";
 
357
        QString def = QLatin1String( "default" );
358
358
        if (!play)
359
359
        {
360
 
                QString result = "play";
 
360
                QString result = QLatin1String( "play" );
361
361
                actionButton(result);
362
362
                emit(picture(result,def));
363
363
                //play = !play;
364
364
        }
365
365
        else
366
366
        {
367
 
                QString result = "pause";
 
367
                QString result = QLatin1String( "pause" );
368
368
                actionButton(result);
369
369
                emit(picture(result,def));
370
370
                //play = !play;
373
373
 
374
374
void KSCD::randomShortcut()
375
375
{
376
 
        QString def = "default";
 
376
        QString def = QLatin1String( "default" );
377
377
        if (!random)
378
378
        {
379
 
                QString result = "p_random";
 
379
                QString result = QLatin1String( "p_random" );
380
380
                actionButton(result);
381
381
                emit(picture(result,def));
382
382
                emit(infoPanel(result));
385
385
        }
386
386
        else
387
387
        {
388
 
                QString result = "random";
 
388
                QString result = QLatin1String( "random" );
389
389
                actionButton(result);
390
390
                emit(picture(result,def));
391
391
                emit(infoPanel(result));
395
395
 
396
396
void KSCD::looptrackShortcut()
397
397
{
398
 
        QString def = "default";
 
398
        QString def = QLatin1String( "default" );
399
399
        if (!looptrack)
400
400
        {
401
 
                QString result = "looptrack";
 
401
                QString result = QLatin1String( "looptrack" );
402
402
                actionButton(result);
403
403
                emit(picture(result,def));
404
404
                emit(infoPanel(result));
407
407
        }
408
408
        else
409
409
        {
410
 
                QString result = "loop";
 
410
                QString result = QLatin1String( "loop" );
411
411
                actionButton(result);
412
412
                emit(picture(result,def));
413
413
                emit(infoPanel(result));
418
418
 
419
419
void KSCD::loopdiscShortcut()
420
420
{
421
 
        QString def = "default";
 
421
        QString def = QLatin1String( "default" );
422
422
        if (!loopdisc)
423
423
        {
424
 
                QString result = "loopdisc";
 
424
                QString result = QLatin1String( "loopdisc" );
425
425
                actionButton(result);
426
426
                emit(picture(result,def));
427
427
                emit(infoPanel(result));
430
430
        }
431
431
        else
432
432
        {
433
 
                QString result = "loop";
 
433
                QString result = QLatin1String( "loop" );
434
434
                actionButton(result);
435
435
                emit(picture(result,def));
436
436
                emit(infoPanel(result));
458
458
 
459
459
void KSCD::playTrack(int track)
460
460
{
461
 
        QString result = "play";
462
 
        QString def = "default";
 
461
        QString result = QLatin1String( "play" );
 
462
        QString def = QLatin1String( "default" );
463
463
        kDebug()<<"playtrack enter "<<track;
464
464
        devices->play(track);
465
465
        emit(picture(result,def));
 
466
        restoreArtistLabel();
466
467
}
467
468
 
468
469
/**
471
472
void KSCD::actionButton(const QString & name)
472
473
{
473
474
 
474
 
        QString state = "over";
 
475
        QString state = QLatin1String( "over" );
475
476
        QString result;
476
 
        if (name == "play")
 
477
        if (name == QLatin1String( "play" ))
477
478
        {
478
479
                if( !devices->isDiscValid() || !devices->getCD()->isCdInserted())
479
480
                {
504
505
                emit(picture(name,state));
505
506
                play = !play;
506
507
        }
507
 
        else if (name == "pause")
 
508
        else if (name == QLatin1String( "pause" ))
508
509
        {
509
510
                /*if( !devices->isDiscValid() || !devices->getCD()->isCdInserted())
510
511
                {
523
524
                emit(picture(name,state));
524
525
                play = !play;
525
526
        }
526
 
        else if (name == "next")
 
527
        else if (name == QLatin1String( "next" ))
527
528
        {
528
529
                if( !devices->isDiscValid() || !devices->getCD()->isCdInserted())
529
530
                {
557
558
                }
558
559
                emit(picture(name,state));
559
560
        }
560
 
        else if(name == "previous")
 
561
        else if(name == QLatin1String( "previous" ))
561
562
        {
562
563
                if( !devices->isDiscValid() || !devices->getCD()->isCdInserted())
563
564
                {
591
592
                }
592
593
                emit(picture(name,state));
593
594
        }
594
 
        else if(name == "stop")
 
595
        else if(name == QLatin1String( "stop" ))
595
596
        {
596
597
                if ((devices->getState() == PlayingState)|| (devices->getState() == PausedState))
597
598
                {
600
601
                }
601
602
                emit(picture(name,state));
602
603
        }
603
 
        else if (name == "eject")
 
604
        else if (name == QLatin1String( "eject" ))
604
605
        {
605
606
                m_trackDlg->removeRowsTrackTable(m_MBManager->getTrackList().size());
606
607
                devices->eject();
611
612
//                      m_slider->stop();
612
613
                }
613
614
        }
614
 
        else if (name == "mute")
 
615
        else if (name == QLatin1String( "mute" ))
615
616
        {
616
617
                devices->mute(false);
617
618
                emit(picture(name,state));
618
619
                mute = !mute;
619
620
        }
620
 
        else if (name == "unmute")
 
621
        else if (name == QLatin1String( "unmute" ))
621
622
        {
622
623
                devices->mute(true);
623
624
                emit(picture(name,state));
624
625
                mute = !mute;
625
626
        }
626
 
        else if (name == "random")
 
627
        else if (name == QLatin1String( "random" ))
627
628
        {
628
629
                devices->setRandom(false);
629
630
                emit(picture(name,state));
630
 
                result = "random";
 
631
                result = QLatin1String( "random" );
631
632
                emit(infoPanel(result));
632
633
 
633
634
                random = !random;
634
635
        }
635
 
        else if (name == "p_random")
 
636
        else if (name == QLatin1String( "p_random" ))
636
637
        {
637
638
                devices->setRandom(true);
638
639
                emit(picture(name,state));
639
 
                result = "p_random";
 
640
                result = QLatin1String( "p_random" );
640
641
                emit(infoPanel(result));
641
642
 
642
643
                random = !random;
643
644
        }
644
 
        else if (name == "loop")
 
645
        else if (name == QLatin1String( "loop" ))
645
646
        {
646
647
                devices->setLoopMode(NoLoop);
647
648
                emit(picture(name,state));
648
 
                result = "loop";
 
649
                result = QLatin1String( "loop" );
649
650
                emit(infoPanel(result));
650
651
 
651
652
                looptrack = false;
652
653
                loopdisc = false;
653
654
        }
654
 
        else if (name == "looptrack")
 
655
        else if (name == QLatin1String( "looptrack" ))
655
656
        {
656
657
                devices->setLoopMode(LoopOne);
657
658
                emit(picture(name,state));
658
 
                result = "looptrack";
 
659
                result = QLatin1String( "looptrack" );
659
660
                emit(infoPanel(result));
660
661
 
661
662
                looptrack = true;
662
663
                loopdisc = false;
663
664
        }
664
 
        else if (name == "loopdisc")
 
665
        else if (name == QLatin1String( "loopdisc" ))
665
666
        {
666
667
                devices->setLoopMode(LoopAll);
667
668
                emit(picture(name,state));
670
671
                loopdisc = true;
671
672
                looptrack = false;
672
673
        }
673
 
        else if (name == "minimize")
 
674
        else if (name == QLatin1String( "minimize" ))
674
675
        {
675
676
                showMinimized ();
676
677
                emit(picture(name,state));
677
678
        }
678
 
        else if (name == "close")
 
679
        else if (name == QLatin1String( "close" ))
679
680
        {
680
681
                close();
681
682
                emit(picture(name,state));
682
683
        }
683
 
        else if (name == "tracklist")
 
684
        else if (name == QLatin1String( "tracklist" ))
684
685
        {
685
686
                if(m_stateTrackDialog == true)
686
687
                {
695
696
                        createTrackDialog(list,title);
696
697
                        kDebug()<<"open track window";
697
698
                }
698
 
                QString def = "default";
 
699
                QString def = QLatin1String( "default" );
699
700
                emit(picture(name,def));
700
701
        }
701
 
        else if (name == "configure")
 
702
        else if (name == QLatin1String( "configure" ))
702
703
        {
703
704
                optionsPreferences();
704
705
        }
761
762
        QWidget *generalSettingsDlg = new QWidget;
762
763
        ui_general.setupUi(generalSettingsDlg);
763
764
 
764
 
        dialog->addPage(generalSettingsDlg, i18nc("General option in the configuration dialog","General"), "kscd");
 
765
        dialog->addPage(generalSettingsDlg, i18nc("General option in the configuration dialog","General"), QLatin1String( "kscd" ));
765
766
 
766
767
        QWidget *interfaceSettingsDlg = new QWidget;
767
768
        ui_interface.setupUi(interfaceSettingsDlg);
768
769
 
769
770
        //Filter on the skin url combo box
770
 
        QString pathSkins=KStandardDirs::installPath("data") + "/kscd/skin/";
 
771
        QString pathSkins=KStandardDirs::installPath("data") + QLatin1String( "/kscd/skin/" );
771
772
        QDir directory(pathSkins);
772
773
        QStringList filter;
773
 
        filter << "*.svg";
 
774
        filter << QLatin1String( "*.svg" );
774
775
        directory.setNameFilters(filter);
775
776
        QStringList list = directory.entryList();
776
777
        ui_interface.kcfg_url->addItems(list);
777
778
 
778
 
        dialog->addPage(interfaceSettingsDlg, i18n("Appearance"), "fill-color");
 
779
        dialog->addPage(interfaceSettingsDlg, i18n("Appearance"), QLatin1String( "fill-color" ));
779
780
 
780
781
        connect(dialog, SIGNAL(settingsChanged( const QString &)), this, SLOT(updateSettings()));
781
782
        dialog->setAttribute( Qt::WA_DeleteOnClose );
782
 
        dialog->setHelp(QString(),"kscd");
 
783
        dialog->setHelp(QString(),QLatin1String( "kscd" ));
783
784
        dialog->show();
784
785
}
785
786
 
793
794
        //kDebug()<<"eject setting:"<<Prefs::ejectOnFinish();
794
795
        m_panel->setEjectAct( Prefs::ejectOnFinish() );
795
796
        QString skin;
796
 
        if(Prefs::url().startsWith('/'))
 
797
        if(Prefs::url().startsWith(QLatin1Char( '/' )))
797
798
            skin = Prefs::url();
798
799
        else
799
 
            skin = KStandardDirs::installPath("data") + "kscd/skin/" + Prefs::url();
 
800
            skin = KStandardDirs::installPath("data") + QLatin1String( "kscd/skin/" ) + Prefs::url();
800
801
        setNewSkin( skin );
801
802
}
802
803
 
845
846
            fprintf(stderr, "kscd is already running\n");
846
847
            if (args->count() > 0 || args->isSet("start"))
847
848
            {
848
 
                QDBusInterface kscd("org.kde.kscd", "/CDPlayer", "org.kde.kscd.CDPlayer");
 
849
                QDBusInterface kscd(QLatin1String( "org.kde.kscd" ), QLatin1String( "/CDPlayer" ), QLatin1String( "org.kde.kscd.CDPlayer" ));
849
850
                if(kscd.isValid())
850
851
                {
851
852
                    // Forward the command line args to the running instance.
852
853
                    if (args->isSet("start"))
853
854
                    {
854
 
                        kscd.call("play");
 
855
                        kscd.call(QLatin1String( "play" ));
855
856
                    }
856
857
                }
857
858
                args->clear();