File indexing completed on 2022-09-20 14:37:47

0001 #include <QObject>
0002 #include <QDebug>
0003 #include <QMetaObject>
0004 #include <QCoreApplication>
0005 #include <QtGlobal>
0006 
0007 #include <kcompactdisc.h>
0008 
0009 class TestKCD : public QObject
0010 {
0011     Q_OBJECT
0012 
0013     public:
0014 
0015     explicit TestKCD(QObject *parent = nullptr) :
0016         QObject(parent),
0017         mKcd(new KCompactDisc(KCompactDisc::Asynchronous))
0018     {}
0019 
0020     ~TestKCD() override
0021     {
0022         mKcd->deleteLater();
0023     }
0024 
0025     public Q_SLOTS:
0026 
0027     void doTest()
0028     {
0029         qDebug() << "Starting test";
0030         mKcd->setDevice(mKcd->defaultCdromDeviceName(), 50, true, QStringLiteral("phonon"));
0031         qDebug() << "";
0032 
0033         qDebug() << "We have" << mKcd->audioSystems().size() << "audo systems available:";
0034         for (auto system: mKcd->audioSystems()) {
0035             qDebug() << system;
0036         }
0037         qDebug() << "";
0038 
0039         qDebug() << "We have" << mKcd->cdromDeviceNames().size() << "cdrom drives available:";
0040         for (auto cdrom: mKcd->cdromDeviceNames()) {
0041             qDebug() << cdrom;
0042         }
0043         qDebug() << "";
0044 
0045         qDebug() << "The current cdrom drive loaded is:" << mKcd->deviceName();
0046         qDebug() << "The disc device node url is:" << mKcd->deviceUrl();
0047         qDebug() << "The disc status is" << mKcd->discStatus();
0048         qDebug() << "Does the drive have a disc in it:" << !mKcd->isNoDisc();
0049         qDebug() << "The number of tracks in the disc:" << mKcd->tracks();
0050         qDebug() << "The current track no:" << mKcd->trackPosition();
0051 
0052         qApp->exit();
0053     }
0054 
0055     private:
0056 
0057     KCompactDisc *mKcd;
0058 };
0059 
0060 int main(int argc, char **argv)
0061 {
0062     QCoreApplication app(argc, argv);
0063 
0064     qDebug() << "Testing libKF5CompactDisc";
0065     TestKCD test;
0066     QMetaObject::invokeMethod(&test, "doTest", Qt::QueuedConnection);
0067 
0068     return app.exec();
0069 }
0070 
0071 #include "testkcd.moc"