Beispiel #1
0
void QSWindow::scoreToWav(){
    ui->tabWidget->setCurrentWidget(ui->scoreTab);
    QSScene* sc = (QSScene*)scoreView->scene();

    if(sc==0 || ! QFileInfo(sc->Name()).isFile()){
        ui->statusBar->showMessage(QString("No current score file!"));
        return;
    }
    saveFile();
    if(saveFileName.isEmpty()){
        return;
    }else{
        WavFile wavOut;
        if(wavOut.fromScore(60.0/80, sc->Name().toStdString().c_str()));
        wavOut.save(saveFileName.toStdString().c_str());
        statusBar()->showMessage(QString("Score to Wave file successful!"));
        openFileName = saveFileName;
        QTimer::singleShot(3000, this, SLOT(addScene()));
        playButton->setEnabled(true);
    }
}
Beispiel #2
0
////////////////////////////////////////////////
/// @brief constructor of QS mainwindow
///
///
///
/// @author wyj
///////////////////////////////////////////////
QSWindow::QSWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::QSWindow),
    openFileName(""),
    saveFileName(""),
    tempFileName(""),
    mediaPlayer(0),
    musicthread(0),
    recorder(new QSRecorder(this)),
    preset(QSPreset::getInstance(this))
{
    //qDebug()<<QSettings(QSAbout::domainName, QSAbout::appName).scope();
    //QSettings(QSAbout::domainName, QSAbout::appName).clear();//remove this line in release version
    ui->setupUi(this);
    preset->readSettings();//ALSO construct ALL Views!!

    //set icon
    QIcon iconQS(":/image/QScore.jpg");
    setWindowIcon(iconQS);
    //initialize

    ui->statusBar->showMessage(QString("Welcome to QtScoreur! ")+QDir::currentPath());
    //setAutoFillBackground(false);


    QPalette winPalette;
    winPalette.setBrush(QPalette::Window, QBrush(QPixmap(QString(":/image/glry.jpg"), "JPG").scaled(900,600)));
    //setPalette(winPalette);

    //music play
    musicInit();
    musicthread = new QSPlayer(openFileName);                                                                                                               ////
    mediaPlayer = musicthread->player;
    musicthread->start();

    preload();//holding all connections needed

    // load sample score from qrc
    QString sampleScore = QDir::homePath()+QString("/QS_tmp/thu_anthem_short");
    QDir::home().mkdir(QString("QS_tmp"));
    QFile fw(sampleScore+QString(".txt")), fd(":/sample/thu_anthem_short.txt");
    fw.open(QFile::WriteOnly);
    fd.open(QFile::ReadOnly);
    QByteArray ba = fd.readAll();
    fw.write(ba.constData(),ba.size());
    fd.close();
    fw.close();

    addScene(staffView);
    addScene(scoreView, sampleScore+QString(".txt"));
    if(! QFileInfo(sampleScore+QString(".wav")).isFile()){
        WavFile wavOut;
        qDebug()<<"THERE";
        if(wavOut.fromScore(60.0/80, (sampleScore+QString(".txt")).toStdString().c_str())){
            qDebug()<<"HERE";
            wavOut.save(sampleScore.toStdString().append(".wav").c_str());
            addScene(wavView, wavOut, sampleScore+QString(".wav"));
            playButton->setEnabled(true);
        }
    }else{
        addScene(wavView, sampleScore+QString(".wav"));
        playButton->setEnabled(true);

    }

    keyScene = new KeyScene(keyView, this);

    //add webView
    webView = new Html5ApplicationViewer(ui->webTab);
    webView->setOrientation(Html5ApplicationViewer::ScreenOrientationAuto);
    webView->resize(900, 400);
    webView->showExpanded();
    webView->loadUrl(QUrl(QLatin1String("http://www.scoreur.net")));




}