Пример #1
0
void MultiDocumentStrategyPrivate::createNewWithGenerator( AbstractModelDataGenerator* generator )
{
    Q_Q( MultiDocumentStrategy );

    AbstractModelDataGeneratorConfigEditor* configEditor =
        mViewManager->codecViewManager()->createConfigEditor( generator );

    if( configEditor )
    {
        CreateDialog* dialog = new CreateDialog( configEditor );
//         dialog->setData( mModel, selection ); TODO
        if( ! dialog->exec() )
            return;
    }

    QApplication::setOverrideCursor( Qt::WaitCursor );

    ModelDataGenerateThread* generateThread =
        new ModelDataGenerateThread( q, generator );
    generateThread->start();
    while( !generateThread->wait(100) )
        QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers );

    QMimeData* mimeData = generateThread->data();

    delete generateThread;

    const bool setModified = ( generator->flags() & AbstractModelDataGenerator::DynamicGeneration );
    mDocumentManager->createManager()->createNewFromData( mimeData, setModified );

    QApplication::restoreOverrideCursor();
}
Пример #2
0
void CreateDialog::newProfile(ProfileManager *manager)
{
    CreateDialog dialog;
    if (dialog.exec() != QDialog::Accepted)
        return;

    if (!manager->addProfile(Profile(dialog.ui->nameBox->text(), dialog.ui->versionList->currentText())))
        QMessageBox::critical(0, "Error", "A profile with the same name already exists.");
}
Пример #3
0
void Gomoku::on_createButton_clicked() {
    CreateDialog dialog;

    if (dialog.exec() == QDialog::Accepted) {
        server = new QTcpServer(this);
        server->listen(QHostAddress(dialog.getHostIpAddress()), 8888);
        ui->connectButton->setEnabled(false);
        ui->createButton->setEnabled(false);
        QMessageBox *waiting = new QMessageBox(QMessageBox::NoIcon,
                                               tr("waiting"),
                                               dialog.getHostIpAddress() + tr("\nwaiting for new connection..."),
                                               QMessageBox::Cancel,
                                               this);

        bool connecting = false;
        connect(server, &QTcpServer::newConnection, [&]() {
            connecting = true;
            socket = server->nextPendingConnection();
//            ui->undoButton->setEnabled(true);
            ui->saveButton->setEnabled(true);
            ui->loadButton->setEnabled(true);
            ui->quitButton->setEnabled(true);
            ui->createButton->setEnabled(false);
            ui->connectButton->setEnabled(false);
            ui->gameboard->playerColor = Qt::black;
            ui->gameboard->enemyColor = Qt::white;
            ui->gameboard->inRound = true;
            connect(socket, &QTcpSocket::readyRead, this, &Gomoku::readData);
            connect(ui->gameboard, &GameBoard::addChess, this, &Gomoku::sendChessInfo);
            connect(ui->gameboard, &GameBoard::win, this, &Gomoku::sendWin);
            connect(ui->quitButton, &QPushButton::clicked, this, &Gomoku::requestQuit);
            connect(ui->undoButton, &QPushButton::clicked, this, &Gomoku::requestUndo);
            connect(ui->saveButton, &QPushButton::clicked, this, &Gomoku::sendSave);
            connect(ui->loadButton, &QPushButton::clicked, this, &Gomoku::requestLoad);
            waiting->close();
        });

        if (waiting->exec() == QMessageBox::Cancel && !connecting) {
            server->close();
            ui->connectButton->setEnabled(true);
            ui->createButton->setEnabled(true);
        }
    }
}