void Inputs::add() { QWidget *parent = qobject_cast< QWidget * >( sender()->parent() ); if ( sender()->objectName() == "actCD" ) { AudioCD audioCD( *this, *cdioDestroyTimer ); QStringList drives = audioCD.getDevices(); if ( !drives.isEmpty() ) { QDialog chooseCD( parent ); chooseCD.setWindowIcon( QIcon( ":/cd" ) ); chooseCD.setWindowTitle( "Wybierz napęd" ); QLabel drvL( tr( "Ścieżka" ) + ":" ); drvL.setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) ); QComboBox drvB; QLineEdit drvE; connect( &drvB, SIGNAL( currentIndexChanged( const QString & ) ), &drvE, SLOT( setText( const QString & ) ) ); drvB.addItems( drives ); QToolButton browseB; connect( &browseB, SIGNAL( clicked() ), this, SLOT( browseCDImage() ) ); browseB.setIcon( QMPlay2Core.getIconFromTheme( "folder-open" ) ); QDialogButtonBox bb( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal ); connect( &bb, SIGNAL( accepted() ), &chooseCD, SLOT( accept() ) ); connect( &bb, SIGNAL( rejected() ), &chooseCD, SLOT( reject() ) ); QGridLayout layout( &chooseCD ); layout.addWidget( &drvB, 0, 0, 1, 3 ); layout.addWidget( &drvL, 1, 0, 1, 1 ); layout.addWidget( &drvE, 1, 1, 1, 1 ); layout.addWidget( &browseB, 1, 2, 1, 1 ); layout.addWidget( &bb, 2, 0, 1, 3 ); layout.setMargin( 2 ); chooseCD.resize( 400, 0 ); if ( chooseCD.exec() == QDialog::Accepted ) { emit QMPlay2Core.waitCursor(); QList< Playlist::Entry > entries = audioCD.getTracks( drvE.text() ); emit QMPlay2Core.restoreCursor(); if ( !entries.isEmpty() ) { if ( Playlist::write( entries, "file://" + AudioCDPlaylist ) ) emit QMPlay2Core.processParam( "open", AudioCDPlaylist ); } else QMessageBox::information( parent, AudioCDName, tr( "Brak płyty AudioCD w napędzie!" ) ); } }
void AudioCD::add() { QWidget *parent = qobject_cast< QWidget * >(sender()->parent()); QStringList drives = AudioCDDemux::getDevices(); if (!drives.isEmpty()) { QDialog chooseCD(parent); chooseCD.setWindowIcon(QIcon(":/AudioCD")); chooseCD.setWindowTitle(tr("Choose the drive")); QLabel drvL(tr("Path") + ":"); drvL.setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); QComboBox drvB; QLineEdit drvE; connect(&drvB, SIGNAL(currentIndexChanged(const QString &)), &drvE, SLOT(setText(const QString &))); drvB.addItems(drives); QToolButton browseB; connect(&browseB, SIGNAL(clicked()), this, SLOT(browseCDImage())); browseB.setIcon(QMPlay2Core.getIconFromTheme("folder-open")); QDialogButtonBox bb(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal); connect(&bb, SIGNAL(accepted()), &chooseCD, SLOT(accept())); connect(&bb, SIGNAL(rejected()), &chooseCD, SLOT(reject())); QGridLayout layout(&chooseCD); layout.addWidget(&drvB, 0, 0, 1, 3); layout.addWidget(&drvL, 1, 0, 1, 1); layout.addWidget(&drvE, 1, 1, 1, 1); layout.addWidget(&browseB, 1, 2, 1, 1); layout.addWidget(&bb, 2, 0, 1, 3); layout.setMargin(2); chooseCD.resize(400, 0); if (chooseCD.exec() == QDialog::Accepted) { QString drvPth = drvE.text(); #ifdef Q_OS_WIN if (drvPth.length() == 2 && !drvPth.endsWith("/")) drvPth += "/"; #endif emit QMPlay2Core.processParam("open", AudioCDName "://" + drvPth); } }