Exemplo n.º 1
0
MainWindow::MainWindow(QApplication *a, QHostAddress ip, quint16 port, QByteArray l,  QString skin, double mouseSensitivity, QObject *parent) :
    QObject(parent)
{
    app = a;
    repaintTimer = new QTimer;
    repaintTimer->setInterval(16);
    stopBot = false;
    widget = new DrawGl(app, skin, mouseSensitivity);
    widget->legacy = this;
    widget->setMinimumHeight(480);
    widget->setMinimumWidth(640);
    login = l;

    qDebug() << "connecting to " + ip.toString() + ":" + QString::number(port);
    input = new NetworkClass(ip, port, QString::fromLocal8Bit(login));

    QObject::connect(repaintTimer, SIGNAL(timeout()), widget, SLOT(repaint()));
    QObject::connect(input, SIGNAL(gameStart()), this, SLOT(gameStart()));
    QObject::connect(input, SIGNAL(connectionFailed()), this, SLOT(connectionFailed()));
    QObject::connect(input, SIGNAL(successConnection()), this, SLOT(connectedSuccess()));
    QObject::connect(widget, SIGNAL(runCommand(QString)), input, SLOT(runCommand(QString)));
    QObject::connect(widget, SIGNAL(destroyed()), this, SLOT(legalStop()));

    ctrlPressed = false;
    finished = false;
    widget->a = input;
    repaintTimer->start();
    input->start();
    thread = new CalculationThread(widget, input);

    for (int i = 0; i < 100; i++)
        for (int j = 0; j < 100; j++)
            for (int k = 0; k < 100; k++)
                progress[i][j][k] = false;
}
Exemplo n.º 2
0
QSqlError LogisticApplication::slotAddConnection(const QString &user, const QString &passwd)
{   
    QString templateString = QString("DRIVER={SQL Server};Server=%1;Database=%2;Uid=%3;Pwd=%4;");
    QString connectionString = QString(templateString).arg(host()).arg(dbname()).arg(user).arg(passwd);

    database = QSqlDatabase::addDatabase(driver(), "Logistic");
    database.setDatabaseName(connectionString);

#ifndef QT_NO_CURSOR
    QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png")));
#endif
    if (!database.open()) {
#ifndef QT_NO_CURSOR
    QApplication::restoreOverrideCursor();
#endif
        QMessageBox::critical(0, "Ошибка", "Ошибка подключения к базе данных");
        return database.lastError();
    } else {
        emit successConnection();
    }
#ifndef QT_NO_CURSOR
    QApplication::restoreOverrideCursor();
#endif
    return database.lastError();
}
Exemplo n.º 3
0
void startDialog::start() {
    w = new MainWindow(app, QHostAddress(ui->lineEdit_2->text()), ui->spinBox->value(), ui->lineEdit->text().toLocal8Bit(), skinPath + ui->comboBox->currentText(), mouseSensitivity, this);
    connectWindow = new Connection(tr("Connecting to: ") + ui->lineEdit_2->text() + ":" + ui->spinBox->text());
    this->hide();
    connectWindow->show();

    QObject::connect(w, SIGNAL(fail()), this, SLOT(show()));
    QObject::connect(w, SIGNAL(successConnection()), connectWindow, SLOT(hide()));
    QObject::connect(w, SIGNAL(fail()), connectWindow, SLOT(hide()));
    QObject::connect(w, SIGNAL(fail()), w, SLOT(deleteLater()));
    QObject::connect(w, SIGNAL(successConnection()), w->widget, SLOT(show()));

    if (ui->fullScreen->checkState() == Qt::Checked)
        QObject::connect(w, SIGNAL(successConnection()), w->widget, SLOT(showFullScreen()));
    else
        QObject::connect(w, SIGNAL(successConnection()), w->widget, SLOT(showNormal()));
}
Exemplo n.º 4
0
ConnectionDialog *LogisticApplication::connectionDialog(QWidget *parent)
{
    if (!cntnDialog){
        cntnDialog = new ConnectionDialog(parent);
    }
    if (cntnDialog){
        connect(cntnDialog, SIGNAL(sendUserInformation(QString,QString)),
                LogisticApplication::instance(), SLOT(slotAddConnection(QString,QString)));
        connect(LogisticApplication::instance(), SIGNAL(successConnection()),
                cntnDialog, SLOT(slotSuccessConnection()));
        connect(cntnDialog, SIGNAL(setVisibleComponent(bool)),
                LogisticApplication::instance(), SLOT(slotVisibleComponent(bool)));
    }
    setStyleWidget(cntnDialog, "connection.qss");
    return cntnDialog;
}
Exemplo n.º 5
0
void MainWindow::connectedSuccess() {
    qDebug() << "success";
    QObject::connect(widget, SIGNAL(destroyed()), this, SLOT(legalStop()));
    emit successConnection();
}