Exemple #1
1
void MainWindow::tryUnlock(QString _user, QString _password)
{
    //std::cout<<"\nIn Unlock method\n";
    QString encryptedPass;
    QString encryptedUser;

    encryptedUser = QString(QCryptographicHash::hash((_user.toStdString().c_str()), QCryptographicHash::Md5).toHex());
    encryptedPass = QString(QCryptographicHash::hash((_password.toStdString().c_str()),QCryptographicHash::Md5).toHex());

    if (encryptedUser == m_username && encryptedPass == m_password)
    {
        m_loggedIn = true;

        QMessageBox messageBox; 
        messageBox.setWindowTitle(tr("Login Successful!"));
        messageBox.setText("Successful login!");
        messageBox.setStandardButtons(QMessageBox::Ok);

        if (messageBox.exec() == QMessageBox::Ok)
            messageBox.close();
    }//end if

    else
    {
        m_loggedIn = false;
        QMessageBox messageBox;
        messageBox.setWindowIcon(QIcon("questionface.xpm"));
        messageBox.setWindowTitle(tr("Login Failed"));
        messageBox.setText(tr("ERROR: Invalid Login! You cannot modify cash without a valid login!"));
        messageBox.setStandardButtons(QMessageBox::Ok);

        if (messageBox.exec() == QMessageBox::Ok)
            messageBox.close();
    }//invalid login window
}//end void
Exemple #2
0
void proje::sonucKapat()
{
    if(formEkleSonuc.ekleSonucDegisiklikVar==true)
    {
        if(formEkleSonuc.ekleSonucDegisiklikVar==true)
        {
            QMessageBox msgBox;
            msgBox.setText("Değişiklikler kaydedilsin mi?");
            msgBox.setIcon(QMessageBox::Warning);
            QPushButton *tamam = msgBox.addButton("Tamam", QMessageBox::ActionRole);
            QPushButton *iptal = msgBox.addButton("İptal", QMessageBox::ActionRole);
            msgBox.exec();
            if (msgBox.clickedButton() == tamam)
            {
                tamamSonuc();
            }
            else if (msgBox.clickedButton() == iptal)
            {
                formEkleSonuc.ekleSonucDegisiklikVar=false;
                formEkleSonuc.degisenIDOgrenci.clear();
                msgBox.close();
            }
        }
    }
    formEkleSonuc.close();
}
TelaPrincipal::TelaPrincipal(Usuario *usuAtu, QSqlDatabase conn, QWidget *parent) : QMainWindow(parent), ui(new Ui::TelaPrincipal) {
    ui->setupUi(this);
    this->setWindowTitle("Fila de Produção");
    db = conn;

    opDAO = new OrdemDeProducaoDAO(db);
    apontamento = new Apontamento();    
    this->usuAtu = new Usuario(usuAtu);
    apontamento->setUsuario(this->usuAtu);
    if (usuAtu->getGrupo() != "TI")
        ui->menubar->setVisible(false);

    SerialDAO dialogSserialDAO = SerialDAO(db);

    if (dialogSserialDAO.getPortaSerial().size() == 0) {
        std::cout << "Não achou a porta Serial para este Computador." << std::endl;
        QMessageBox erroDeSerial;
        erroDeSerial.setWindowTitle("Erro ao tentar conectar na máquina");
        erroDeSerial.setText("Não foi possível connectar na máquina pois não foi encontrado a porta serial, por gentileza contate o TI.");
        erroDeSerial.setDefaultButton(QMessageBox::Ok);

        if (erroDeSerial.exec() == QMessageBox::Ok) {
            erroDeSerial.close();
        }
    } else {
        portaDeComunicacao = new Serial(dialogSserialDAO.getPortaSerial());
        portaDeComunicacao->bloqueiaMaquina();
        leDadosImpressora = new QTimer();
        connect(ui->actionSelecionar_Porta_Serial,SIGNAL(triggered()),this,SLOT(selecionaPortaSerial()));
        connect(this->leDadosImpressora, SIGNAL(timeout()), this, SLOT(leDados()));

        procuraParadasSemMotivos();
    }
}
Exemple #4
0
void Settings::settingsDefault(){

    QMessageBox msgBox;

    msgBox.setWindowTitle(trUtf8("Zurücksetzen bestätigen"));
    msgBox.setText(trUtf8("Möchten Sie die Werte wirklich auf die "
                          "Standardeinstellungen zurücksetzen?"));
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::Yes);
    int ret = msgBox.exec();
    switch (ret) {
    case QMessageBox::Yes:
        if (tabWidget_Settings->currentIndex() == 0)
            settingsDefaultClamUI();
        else if (tabWidget_Settings->currentIndex() == 1)
            settingsDefaultClamAV();
        break;
    case QMessageBox::No:
        msgBox.close();
        break;
    default:
        break;
    }
}
Exemple #5
0
void viewcart::error(){
	QMessageBox msgBox;
	msgBox.setWindowTitle("Warning");
	msgBox.setText("Please select a product");
	msgBox.setStandardButtons(QMessageBox::Ok);
	msgBox.setDefaultButton(QMessageBox::Ok);
	int userAnswer = msgBox.exec();
	if(userAnswer == QMessageBox::Ok) {
		msgBox.close();
	}
}
void Execut_window::NetworkError()//网络连接错误
{
    closePage();

    QMessageBox qMbox;
    qMbox.setText(QString("对不起,无法上传请稍后"));
    qMbox.show();

    waitTaskInfo(1000);//延时1s
    qMbox.close();
}
Exemple #7
0
void ar::error(){
	QMessageBox msgBox;
	msgBox.setWindowTitle("Warning");
	msgBox.setText("Invalid Date\nValid Year: from 1900 ~ 2015\nValid Month: from 01 ~ 12\nValid Date: from 01 ~ 31");
	msgBox.setStandardButtons(QMessageBox::Ok);
	msgBox.setDefaultButton(QMessageBox::Ok);
	int userAnswer = msgBox.exec();
	if(userAnswer == QMessageBox::Ok) {
		msgBox.close();
	}
}
void SimulateTrafficDialog::showMessageBox(std::string message)
{
    QMessageBox msgBox;
    msgBox.setWindowTitle("Info");
    msgBox.setText(QString::fromUtf8(message.c_str()));
    msgBox.setStandardButtons(QMessageBox::Ok);
    if(msgBox.exec() == QMessageBox::Ok)
    {
      msgBox.close();
    }
}
Exemple #9
0
void Preferences::displayErrorMsg(QString errormsg)
{
	QMessageBox *msgbox;
	QFont msgboxfont;
	msgbox = new QMessageBox( QMessageBox::Critical, tr("Error"), errormsg, QMessageBox::Ok, this);
	msgboxfont = msgbox->font();
	msgboxfont.setPixelSize(12); // 9pts
	msgbox->setFont( msgboxfont );
	msgbox->show();
	msgbox->exec();
	msgbox->close();
	delete msgbox;
}
Exemple #10
0
void ClamUI::slotQuit(){

    checkBoxNoMessage = new QCheckBox;
    checkBoxNoMessage->setText(trUtf8("Die Meldung nicht mehr anzeigen."));

    ClamdProcess clamd;
    FreshClamProcess freshclam;
    QMessageBox msgBox;

    QSettings clamui_conf(QSettings::NativeFormat, QSettings::UserScope,
                             APP_TITLE, APP_NAME);

    if (noMessageOnQuit){
        if (stopClamdOnQuit)
            clamd.stopDaemon();

        if (stopFreshclamOnQuit)
            freshclam.stopFreshclam();

        qApp->quit();
    }

    msgBox.setWindowTitle(trUtf8("Beenden bestätigen"));
    msgBox.setText(trUtf8("Möchten Sie <b>") +
                          APP_TITLE + trUtf8("</b> wirklich beenden?"));
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::Yes);
    msgBox.setCheckBox(checkBoxNoMessage);
    int ret = msgBox.exec();
    switch (ret) {
    case QMessageBox::Yes:
        if (stopClamdOnQuit)
            clamd.stopDaemon();

        if (stopFreshclamOnQuit)
            freshclam.stopFreshclam();

        clamui_conf.beginGroup("ClamUI");
        clamui_conf.setValue("NoMessage", checkBoxNoMessage->isChecked());
        clamui_conf.endGroup();

        qApp->quit();
        break;
    case QMessageBox::No:
        msgBox.close();
        break;
    default:
        break;
    }
}
int GwtCallback::showMessageBox(int type,
                                QString caption,
                                QString message,
                                QString buttons,
                                int defaultButton,
                                int cancelButton)
{
   // cancel other message box if it's visible
   QMessageBox* pMsgBox = qobject_cast<QMessageBox*>(
                        QApplication::activeModalWidget());
   if (pMsgBox != NULL)
      pMsgBox->close();

   QMessageBox msgBox(safeMessageBoxIcon(static_cast<QMessageBox::Icon>(type)),
                       caption,
                       message,
                       QMessageBox::NoButton,
                       pOwner_->asWidget(),
                       Qt::Dialog | Qt::Sheet);
   msgBox.setWindowModality(Qt::WindowModal);
   msgBox.setTextFormat(Qt::PlainText);

   QStringList buttonList = buttons.split(QChar::fromLatin1('|'));

   for (int i = 0; i != buttonList.size(); i++)
   {
      QPushButton* pBtn = msgBox.addButton(buttonList.at(i),
                                           captionToRole(buttonList.at(i)));
      if (defaultButton == i)
         msgBox.setDefaultButton(pBtn);
   }

   msgBox.exec();

   QAbstractButton* button = msgBox.clickedButton();
   if (!button)
      return cancelButton;

   for (int i = 0; i < buttonList.size(); i++)
      if (buttonList.at(i) == button->text())
         return i;

   return cancelButton;
}
Exemple #12
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);
        }
    }
}
Exemple #13
0
void PackageDialog::on_accept_package_clicked(QAbstractButton* button) {
	// OK clicked to accept values
    if (ui->accept_package->button(QDialogButtonBox::Ok) == (QPushButton*)button) {
    	bool ok;
    	QString package = ui->nameLine->text();
    	float length = ui->lengthLine->text().toFloat(&ok);
    	float height = ui->heightLine->text().toFloat();
    	float width = ui->widthLine->text().toFloat();
    	int pins = ui->pinsLine->text().toInt();

        // Check if all inputs are valid
        if(package.length() > 3 && length > 0 && height > 0 && width > 0 && pins > 0){

            // Edit given package
        	if(editPackage) {
        		(*databaseVector)[packageNum].package = package;
        		(*databaseVector)[packageNum].length = length;
        		(*databaseVector)[packageNum].height = height;
        		(*databaseVector)[packageNum].width = width;
        		(*databaseVector)[packageNum].pins = pins;
            // Add a new package
        	} else {
        		databaseEntry newEntry;
            	newEntry.package = package;
            	newEntry.length = length;
            	newEntry.height = height;
            	newEntry.width = width;
            	newEntry.pins = pins;
            	databaseVector->append(newEntry);
        	}
        } else {
    		QMessageBox msgBox;
    		msgBox.setText("Invalid input!");
    		msgBox.exec();
    		msgBox.close();
        }
    } else {
    	this->close();
    }
}
Exemple #14
0
void MysqLoader::on_defaultButton_clicked()
{
	QMessageBox msgBox;

        msgBox.setWindowTitle(trUtf8("Vorgang bestätigen"));
	msgBox.setText(trUtf8("<b>Alle Werte werden auf die "
						  "Standardeinstellungen zurück gesetzt!</b>"));

	msgBox.setIcon(QMessageBox::Question);
	msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
	msgBox.setDefaultButton(QMessageBox::Yes);
	int ret = msgBox.exec();
	switch (ret) {
	case QMessageBox::Yes:
		defaultSettings();
		break;
	case QMessageBox::No:
		msgBox.close();
		break;
	default:
		break;
	}
}
Exemple #15
0
void proje::sonucDoldur()
{
    if(formEkleSonuc.ekleSonucDegisiklikVar==true)
    {
        QMessageBox msgBox;
        msgBox.setText("Değişiklikler kaydedilsin mi?");
        msgBox.setIcon(QMessageBox::Warning);
        QPushButton *tamam = msgBox.addButton("Tamam", QMessageBox::ActionRole);
        QPushButton *iptal = msgBox.addButton("İptal", QMessageBox::ActionRole);
        msgBox.exec();
        if (msgBox.clickedButton() == tamam)
        {
            tamamSonuc();
        }
        else if (msgBox.clickedButton() == iptal)
        {
            formEkleSonuc.degisenIDOgrenci.clear();
            formEkleSonuc.ekleSonucDegisiklikVar=false;
            msgBox.close();
        }
    }

    if(formEkleSonuc.ui->cbSinav->currentIndex()!=-1)//cbSinavda olmayan bir seçenek olursa fonksiyona girmesin
    {
        QString sinavisim=formEkleSonuc.ui->cbSinav->currentText();
        QString dersisim=ui->tableDersler->currentItem()->text();

        formEkleSonuc.ilkAcilis=true;
        formEkleSonuc.ui->tableSonuclar->setRowCount(0);
        formEkleSonuc.ui->tableSonuclar->setColumnCount(0);

        int sira=0;
        int toplamPuan=0;
        QSqlQuery query,query2;

        query.exec(QString("select sorusayisi,sinav.sinavid from sinav,derssinav where sinav.sinavid=derssinav.sinavid and dersid=(select dersid from ders where dersisim='%1') and sinavisim='%2'").arg(dersisim).arg(sinavisim));
        query.next();
        formEkleSonuc.sinavID=query.value(1).toString();

        const int currentRow = formEkleSonuc.ui->tableSonuclar->rowCount();
        formEkleSonuc.ui->tableSonuclar->setRowCount(currentRow + 1);

        for(int i=0;i<=query.value(0).toInt();i++)//sonuc ekranındaki sutun başlıkları
        {
            const int currentColumn = formEkleSonuc.ui->tableSonuclar->columnCount();
            formEkleSonuc.ui->tableSonuclar->setColumnCount(currentColumn + 1);

            query2.exec(QString("select puan from soru where sorunumarasi='%1' and sinavid=(select sinav.sinavid from sinav,derssinav where sinav.sinavid=derssinav.sinavid and dersid=(select dersid from ders where dersisim='%2') and sinavisim='%3')").arg(i).arg(dersisim).arg(sinavisim));
            query2.next();

            QTableWidgetItem *itm=new QTableWidgetItem(QString::number(i)+" ("+query2.value(0).toString()+")");
            formEkleSonuc.ui->tableSonuclar->setItem(0,i,itm);
            itm->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
            kalinFont(itm);

            toplamPuan=toplamPuan+query2.value(0).toInt();
        }

        const int currentColumn = formEkleSonuc.ui->tableSonuclar->columnCount();
        formEkleSonuc.ui->tableSonuclar->setColumnCount(currentColumn + 1);
        QTableWidgetItem *itmt=new QTableWidgetItem("Toplam ("+QString::number(toplamPuan)+")");
        formEkleSonuc.ui->tableSonuclar->setItem(0,currentColumn,itmt);
        itmt->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
        kalinFont(itmt);

        query.exec(QString("select ogrenci.ogrenciid from dersogrenci,ogrenci where dersogrenci.ogrenciid=ogrenci.ogrenciid and dersid=(select dersid from ders where dersisim='%1')").arg(dersisim));
        while(query.next())
        {
            sira=sira+1;
            const int currentRow = formEkleSonuc.ui->tableSonuclar->rowCount();
            formEkleSonuc.ui->tableSonuclar->setRowCount(currentRow + 1);
            QTableWidgetItem *itm=new QTableWidgetItem(query.value(0).toString());
            formEkleSonuc.ui->tableSonuclar->setItem(sira,0,itm);
            itm->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
            kalinFont(itm);
        }

        for(int j=1;j<formEkleSonuc.ui->tableSonuclar->rowCount();j++)
        {
            for(int i=1;i<formEkleSonuc.ui->tableSonuclar->columnCount();i++)
            {
                if(i!=formEkleSonuc.ui->tableSonuclar->columnCount()-1)//toplam sutununda birşey yazmasın
                {
                    query.exec(QString("select alinanpuan from sonuc where ogrenciid='%1' and sorunumarasi='%2' and sinavid=(select sinav.sinavid from sinav,derssinav where sinav.sinavid=derssinav.sinavid and dersid=(select dersid from ders where dersisim='%3') and sinavisim='%4')").arg(formEkleSonuc.ui->tableSonuclar->item(j,0)->text()).arg(i).arg(dersisim).arg(sinavisim));
                    query.next();

                    QTableWidgetItem *itm=new QTableWidgetItem(query.value(0).toString());
                    formEkleSonuc.ui->tableSonuclar->setItem(j,i,itm);
                }
                else//toplamı yazdırıyor
                {
                    query.exec(QString("select toplampuan from sinavogrenci where ogrenciid='%1' and sinavid=(select sinav.sinavid from sinav,derssinav where sinav.sinavid=derssinav.sinavid and dersid=(select dersid from ders where dersisim='%2') and sinavisim='%3')").arg(formEkleSonuc.ui->tableSonuclar->item(j,0)->text()).arg(dersisim).arg(sinavisim));
                    query.next();
                    QTableWidgetItem *itm=new QTableWidgetItem(query.value(0).toString());
                    formEkleSonuc.ui->tableSonuclar->setItem(j,formEkleSonuc.ui->tableSonuclar->columnCount()-1,itm);

                    itm->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
                    kalinFont(itm);
                }
            }
        }
        QTableWidgetItem *itm=new QTableWidgetItem("Öğrenci\\Soru");
        formEkleSonuc.ui->tableSonuclar->setItem(0,0,itm);
        itm->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
        kalinFont(itm);

        formEkleSonuc.ilkAcilis=false; // toplamı yeniden hesaplayan fonk her acilista tekrarlanmasın diye
    }
}
Exemple #16
0
void Preferences::interfacetest()
{
	QMessageBox *msgbox;
	FSSM_WaitMsgBox *waitmsgbox = NULL;
	QFont msgboxfont;
	// PREPARE INTERFACE:
	AbstractDiagInterface *diagInterface = NULL;
	if (_newinterfacetype == AbstractDiagInterface::interface_serialPassThrough)
	{
		diagInterface = new SerialPassThroughDiagInterface;
	}
	else if (_newinterfacetype == AbstractDiagInterface::interface_J2534)
	{
		diagInterface = new J2534DiagInterface;
	}
	else if (_newinterfacetype == AbstractDiagInterface::interface_ATcommandControlled)
	{
		diagInterface = new ATcommandControlledDiagInterface;
	}
	else
	{
		displayErrorMsg(tr("The selected interface is not supported !"));
		displayErrorMsg(tr("Internal error:\nThe interface test for the selected interface is not yet implemented.\n=> Please report this as a bug."));
		return;
	}
	// OPEN INTERFACE:
	if (!diagInterface->open(_newinterfacefilename.toStdString()))
	{
		displayErrorMsg(tr("Couldn't open the diagnostic interface !\nPlease make sure that the device is not in use by another application."));
		delete diagInterface;
		return;
	}
	// DISPLAY INFO MESSAGE:
	int choice = QMessageBox::NoButton;
	msgbox = new QMessageBox( QMessageBox::Information, tr("Interface test"), tr("Please connect diagnostic interface to the vehicles\ndiagnostic connector and switch ignition on."), QMessageBox::NoButton, this);
	msgbox->addButton(tr("Start"), QMessageBox::AcceptRole);
	msgbox->addButton(tr("Cancel"), QMessageBox::RejectRole);
	msgboxfont = msgbox->font();
	msgboxfont.setPixelSize(12); // 9pts
	msgbox->setFont( msgboxfont );
	msgbox->show();
	choice = msgbox->exec();
	msgbox->close();
	delete msgbox;
	if (choice == QMessageBox::AcceptRole)
	{
		// START INTERFACE-TEST:
		bool icresult = false;
		bool retry = true;
		choice = 0;
		bool SSM1configOK = false;
		bool SSM2configOK = false;
		while (retry && !icresult)
		{
			char data = 0;
			// OUTPUT WAIT MESSAGE:
			waitmsgbox = new FSSM_WaitMsgBox(this, tr("Testing interface... Please wait !     "));
			waitmsgbox->show();
			// SSM2:
			SSMP2communication *SSMP2com = new SSMP2communication(diagInterface);
			SSM2configOK = diagInterface->connect(AbstractDiagInterface::protocol_SSM2_ISO14230);
			if (SSM2configOK)
			{
				SSMP2com->setCUaddress(0x10);
				unsigned int addr = 0x61;
				icresult = SSMP2com->readMultipleDatabytes('\x0', &addr, 1, &data);
				if (!icresult)
				{
					SSMP2com->setCUaddress(0x01);
					icresult = SSMP2com->readMultipleDatabytes('\x0', &addr, 1, &data);
					if (!icresult)
					{
						SSMP2com->setCUaddress(0x02);
						icresult = SSMP2com->readMultipleDatabytes('\x0', &addr, 1, &data);
					}
				}
				diagInterface->disconnect();
			}
			if (!icresult)
			{
				SSM2configOK = diagInterface->connect(AbstractDiagInterface::protocol_SSM2_ISO15765);
				if (SSM2configOK)
				{
					SSMP2com->setCUaddress(0x7E0);
					unsigned int addr = 0x61;
					icresult = SSMP2com->readMultipleDatabytes('\x0', &addr, 1, &data);
					diagInterface->disconnect();
				}
			}
			delete SSMP2com;
			// SSM1:
			if (!icresult)
			{
				SSM1configOK = diagInterface->connect(AbstractDiagInterface::protocol_SSM1);
				if (SSM1configOK)
				{
					SSMP1communication *SSMP1com = new SSMP1communication(diagInterface, SSM1_CU_Engine);
					icresult = SSMP1com->readAddress(0x00, &data);
					if (!icresult)
					{
						SSMP1com->selectCU(SSM1_CU_Transmission);
						icresult = SSMP1com->readAddress(0x00, &data);
						delete SSMP1com;
					}
					diagInterface->disconnect();
				}
			}
			// CLOSE WAIT MESSAGE:
			waitmsgbox->close();
			delete waitmsgbox;
			// DISPLAY TEST RESULT:
			QString resultText;
			if (icresult)
				resultText = tr("Interface test successful !");
			else
				resultText = tr("Interface test failed !");
			if (!SSM1configOK && !SSM2configOK)	// => test must have failed
			{
				if (_newinterfacetype == AbstractDiagInterface::interface_serialPassThrough)
					resultText += "\n\n" + tr("The selected serial port can not be configured for the SSM1- and SSM2-protocol.");
				else
					resultText += "\n\n" + tr("The selected interface does not support the SSM1- and SSM2-protocol.");
			}
			else if (!icresult)
			{
				resultText += "\n\n" + tr("Please make sure that the interface is connected properly and ignition is switched ON.");
			}
			if (!SSM1configOK || !SSM2configOK)
			{
				resultText += "\n\n" + tr("WARNING:");
				if (!SSM1configOK)
				{
					if (_newinterfacetype == AbstractDiagInterface::interface_serialPassThrough)
						resultText += '\n' + tr("The selected serial port can not be configured for the SSM1-protocol.");
					else
						resultText += '\n' + tr("The selected interface does not support the SSM1-protocol.");
				}
				else if (!SSM2configOK)
				{
					if (_newinterfacetype == AbstractDiagInterface::interface_serialPassThrough)
						resultText += '\n' + tr("The selected serial port can not be configured for the SSM2-protocol.");
					else
						resultText += '\n' + tr("The selected interface does not support the SSM2-protocol.");
				}
			}
			if (icresult)
				msgbox = new QMessageBox(QMessageBox::Information, tr("Interface test"), resultText, QMessageBox::Ok, this);
			else
			{
				msgbox = new QMessageBox(QMessageBox::Critical, tr("Interface test"), resultText, QMessageBox::NoButton, this);
				msgbox->addButton(tr("Retry"), QMessageBox::AcceptRole);
				msgbox->addButton(tr("Cancel"), QMessageBox::RejectRole);
			}
			msgboxfont = msgbox->font();
			msgboxfont.setPixelSize(12); // 9pts
			msgbox->setFont( msgboxfont );
			msgbox->show();
			choice = msgbox->exec();
			msgbox->close();
			delete msgbox;
			if (!icresult && (choice != QMessageBox::AcceptRole))
				retry = false;
		}
	}
	// CLOSE INTERFACE:
	if (!diagInterface->close())
		displayErrorMsg(tr("Couldn't close the diagnostic interface !"));
	delete diagInterface;
}
Exemple #17
0
void UpdateDlg::doDownload()
{
    url = dUrl;
     QMessageBox msgBox;
     msgBox.setWindowTitle(tr("LimeBible Update Warning"));
     msgBox.setText(tr("This action will download the update, shutdown LimeBible and start the update process. "
                       "Any unsaved work will be lost. Remember, you can always run this updater any other time."
                       ));
     msgBox.setInformativeText(tr("Do you want to Proceed with the Update?"));
     msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
     msgBox.setDefaultButton(QMessageBox::Yes);
     msgBox.setIcon(QMessageBox::Warning);
     int ret = msgBox.exec();
     if(ret){

         switch(ret)
          {
             case QMessageBox::Yes :
            {
                 // Save was clicked.. handle it


              QFileInfo fileInfo(url.path());
              QString fileName = fileInfo.fileName();
              QString fullPath = "";

              fullPath.append(QDir::tempPath());
              fullPath.append("/");
              fullPath.append(fileName);
              if (fileName.isEmpty())
                  fileName = "";

              if (QFile::exists(fullPath)) {
                    QFile::remove(fullPath);
              }

              file = new QFile(fullPath);

              if (!file->open(QIODevice::WriteOnly)) {
                  QMessageBox::information(this, tr("Download LimeBible Updates..."),
                                           tr("Unable to save the file %1: %2.")
                                           .arg(fileName).arg(file->errorString()));
                  delete file;
                  file = 0;
                  return;
              }
              progressDialog = new QProgressDialog(this);
              progressDialog->setWindowTitle(tr("Downloading..."));
              progressDialog->setLabelText(tr("Download LimeBible Updates..."));

              // schedule the request
              startDownload(url);
                }
             break;
             case QMessageBox::No :

              msgBox.close();
              close();

             break;
             default:
                  // should never be reached
             break;
           }
     }

}
Exemple #18
0
void MainWindow::startDcp()
{
    QString     path;
    QString     filename;
    QFileInfo   source;
    QFileInfo   destination;
    QMessageBox msgBox;
    QString     DCP_FAIL_MSG;

    asset_list_t reelList[MAX_REELS];

    opendcp_t *xmlContext = opendcp_create();

    DCP_FAIL_MSG = tr("DCP Creation Failed");

    // process options
    xmlContext->log_level = 0;

    if (ui->digitalSignatureCheckBox->checkState()) {
        xmlContext->xml_signature.sign = 1;
        xmlContext->xml_signature.use_external = 0;
    }

    dcp_log_init(xmlContext->log_level, ".log");
    strcpy(xmlContext->xml.title, ui->cplTitleEdit->text().toStdString().c_str());
    strcpy(xmlContext->xml.annotation, ui->cplAnnotationEdit->text().toStdString().c_str());
    strcpy(xmlContext->xml.issuer, ui->cplIssuerEdit->text().toStdString().c_str());
    strcpy(xmlContext->xml.kind, ui->cplKindComboBox->currentText().toStdString().c_str());
    strcpy(xmlContext->xml.rating, ui->cplRatingComboBox->currentText().toStdString().c_str());

    // check picture track is supplied
    if (ui->reelPictureEdit->text().isEmpty()) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                             tr("An MXF picture track is required."));
        goto Done;
    }

    // check durations
    if ((!ui->reelSoundEdit->text().isEmpty() && ui->reelPictureDurationSpinBox->value() != ui->reelSoundDurationSpinBox->value()) ||
        (!ui->reelSubtitleEdit->text().isEmpty() && ui->reelPictureDurationSpinBox->value() != ui->reelSubtitleDurationSpinBox->value())) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                              tr("The duration of all MXF tracks must be the same."));
        goto Done;
    }

    // copy assets
    reelList->asset_count = 0;
    if (!ui->reelPictureEdit->text().isEmpty()) {
        strcpy(reelList[0].asset_list[0].filename, ui->reelPictureEdit->text().toStdString().c_str());
        reelList->asset_count++;
    }
    if (!ui->reelSoundEdit->text().isEmpty()) {
        strcpy(reelList[0].asset_list[1].filename, ui->reelSoundEdit->text().toStdString().c_str());
        reelList->asset_count++;
    }
    if (!ui->reelSubtitleEdit->text().isEmpty()) {
        strcpy(reelList[0].asset_list[2].filename, ui->reelSubtitleEdit->text().toStdString().c_str());
        reelList->asset_count++;
    }

    // add pkl to the DCP (only one PKL currently support)
    add_pkl(xmlContext);

    // add cpl to the DCP/PKL (only one CPL currently support)
    add_cpl(xmlContext, &xmlContext->pkl[0]);

    if (add_reel(xmlContext, &xmlContext->pkl[0].cpl[0],reelList[0]) != OPENDCP_NO_ERROR) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                              tr("Could not add reel to CPL."));
        goto Done;
    }

    // adjust durations
    xmlContext->pkl[0].cpl[0].reel[0].asset[0].duration = ui->reelPictureDurationSpinBox->value();
    xmlContext->pkl[0].cpl[0].reel[0].asset[0].entry_point = ui->reelPictureOffsetSpinBox->value();
    xmlContext->pkl[0].cpl[0].reel[0].asset[1].duration = ui->reelSoundDurationSpinBox->value();
    xmlContext->pkl[0].cpl[0].reel[0].asset[1].entry_point = ui->reelSoundOffsetSpinBox->value();
    xmlContext->pkl[0].cpl[0].reel[0].asset[2].duration = ui->reelSubtitleDurationSpinBox->value();
    xmlContext->pkl[0].cpl[0].reel[0].asset[2].entry_point = ui->reelSubtitleOffsetSpinBox->value();

    if (validate_reel(xmlContext,&xmlContext->pkl[0].cpl[0],0) != OPENDCP_NO_ERROR) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                              tr("Could not valiate reel."));
        goto Done;
    }

    // set filenames
    path = QFileDialog::getExistingDirectory(this, tr("Choose destination folder"),QString::null);

    if (path.isEmpty()) {
        goto Done;
    }

    filename = path + "/" + xmlContext->pkl[0].cpl[0].uuid + "_cpl.xml";
    strcpy(xmlContext->pkl[0].cpl[0].filename,filename.toStdString().c_str());
    filename = path + "/" + xmlContext->pkl[0].uuid + "_pkl.xml";
    strcpy(xmlContext->pkl[0].filename,filename.toStdString().c_str());
    if (xmlContext->ns == XML_NS_SMPTE) {
        filename = path + "/" + "ASSETMAP.xml";
        strcpy(xmlContext->assetmap.filename,filename.toStdString().c_str());
        filename = path + "/" + "VOLINDEX.xml";
        strcpy(xmlContext->volindex.filename,filename.toStdString().c_str());
    } else {
        filename = path + "/" + "ASSETMAP";
        strcpy(xmlContext->assetmap.filename,filename.toStdString().c_str());
        filename = path + "/" + "VOLINDEX";
        strcpy(xmlContext->volindex.filename,filename.toStdString().c_str());
    }

    // write XML Files
    if (write_cpl(xmlContext,&xmlContext->pkl[0].cpl[0]) != OPENDCP_NO_ERROR) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                              tr("Failed to create composition playlist."));
        goto Done;
    }
    if (write_pkl(xmlContext,&xmlContext->pkl[0]) != OPENDCP_NO_ERROR) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                              tr("Failed to create packaging list."));
        goto Done;
    }
    if (write_volumeindex(xmlContext) != OPENDCP_NO_ERROR) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                              tr("Failed to create volume index."));
        goto Done;
    }
    if (write_assetmap(xmlContext) != OPENDCP_NO_ERROR) {
        QMessageBox::critical(this, DCP_FAIL_MSG,
                              tr("Failed to create assetmap."));
        goto Done;
    }

    // copy the picture mxf files
    source.setFile(xmlContext->pkl[0].cpl[0].reel[0].asset[0].filename);
    destination.setFile(path + "/" + source.fileName());

    if (!ui->reelPictureEdit->text().isEmpty() && source.absoluteFilePath() != destination.absoluteFilePath()) {
        if (destination.isFile()) {
            if (QMessageBox::question(this,tr("Move MXF File"),tr("The destination picture MXF already exists, do you want to replace?"),
                                      QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes) {
                QFile::remove(destination.absoluteFilePath());
            }
        }
        if (ui->rbMoveMxf->isChecked()) {
            QFile::rename(source.absoluteFilePath(), destination.absoluteFilePath());
        } else {
            //QMessageBox* msgBox = new QMessageBox( this );
            //msgBox->setWindowTitle("File Copy");
            //msgBox->setText("Copying picture file...");
            //msgBox->open();
            fileCopy(source.absoluteFilePath(), destination.absoluteFilePath());
            //msgBox->close();;
        }
    }

    // copy the sound mxf files
    source.setFile(xmlContext->pkl[0].cpl[0].reel[0].asset[1].filename);
    destination.setFile(path + "/" + source.fileName());
    if (!ui->reelSoundEdit->text().isEmpty() && source.absoluteFilePath() != destination.absoluteFilePath()) {
        if (destination.isFile()) {
            if (QMessageBox::question(this,tr("Move MXF File"),tr("The destination sound MXF already exists, do you want to replace?"),
                                      QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes) {
                QFile::remove(destination.absoluteFilePath());
            }
        }
        if (ui->rbMoveMxf->isChecked()) {
            QFile::rename(source.absoluteFilePath(), destination.absoluteFilePath());
        } else {
            QMessageBox* msgBox = new QMessageBox( this );
            //msgBox->setAttribute( QWidget::WA_DeleteOnClose );
            msgBox->setWindowTitle("File Copy");
            msgBox->setText("Copying sound file...");
            msgBox->open();
            QFile::copy(source.absoluteFilePath(), destination.absoluteFilePath());
            msgBox->close();
        }
    }

    // copy the subtitle mxf files
    source.setFile(xmlContext->pkl[0].cpl[0].reel[0].asset[2].filename);
    destination.setFile(path + "/" + source.fileName());
    if (!ui->reelSubtitleEdit->text().isEmpty() && source.absoluteFilePath() != destination.absoluteFilePath()) {
        if (destination.isFile()) {
            if (QMessageBox::question(this,tr("Move MXF File"),tr("The destination subtitle MXF already exists, do you want to replace?"),
                                      QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes) {
                QFile::remove(destination.absoluteFilePath());
            }
        }
        if (ui->rbMoveMxf->isChecked()) {
            QFile::rename(source.absoluteFilePath(), destination.absoluteFilePath());
        } else {
            QMessageBox* msgBox = new QMessageBox( this );
            msgBox->setWindowTitle("File Copy");
            msgBox->setText("Copying subtitle file...");
            msgBox->open();
            QFile::copy(source.absoluteFilePath(), destination.absoluteFilePath());
            msgBox->close();;
        }
    }

    msgBox.setText("DCP Created successfully");
    msgBox.exec();


Done:
    opendcp_delete(xmlContext);

    return;
}
Exemple #19
0
//***********************************************************
//* This is the main entry point for an import.  It is passed
//* the file which contains the export data.  It then
//* opens up the file, checks the validity of the data, and
//* then begins to parse through all of the crap.
//***********************************************************
void ImportData::import(QString file) {
    fileName = file;
    errorMessage = "";

    lastError = 0;
    QFile xmlFile(fileName);
    QFile scanFile(fileName);
    if (!xmlFile.open(QIODevice::ReadOnly) || !scanFile.open(QIODevice::ReadOnly)) {
        lastError = 16;
        errorMessage = "Cannot open file.";
        return;
    }

    QTextStream *countReader = new QTextStream(&scanFile);

    int recCnt = 0;
    QMessageBox mb;
    mb.setWindowTitle(tr("Scanning File"));
    mb.setText(QString::number(recCnt) + tr(" notes found."));
    QPushButton *cancelButton = mb.addButton(QMessageBox::Cancel);
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
    mb.show();
    QCoreApplication::processEvents();

    while (!countReader->atEnd() && !stopNow) {
        QString line = countReader->readLine();
        if (line.contains("<note>", Qt::CaseInsensitive)) {
            recCnt++;
            mb.setText(QString::number(recCnt) + tr(" notes found."));
            QCoreApplication::processEvents();
        }
    }

    notebookData.clear();
    progress->setMaximum(recCnt);
    progress->setMinimum(0);
    if (backup) {
        progress->setWindowTitle(tr("Importing"));
        progress->setLabelText(tr("Importing Notes"));
    } else {
        progress->setWindowTitle(tr("Restore"));
        progress->setLabelText(tr("Restoring Notes"));
    }
    progress->setWindowModality(Qt::ApplicationModal);
    connect(progress, SIGNAL(canceled()), this, SLOT(cancel()));
    progress->setVisible(true);
    mb.close();
    progress->show();
    recCnt = 0;

    reader = new QXmlStreamReader(&xmlFile);
    NSqlQuery query(global.db);
    query.exec("begin");
    int commitCount = 100;
    while (!reader->atEnd() && !stopNow) {
        if (commitCount <=  0) {
            query.exec("commit");
            commitCount = 100;
        }
        commitCount--;
        reader->readNext();
        if (reader->hasError()) {
            errorMessage = reader->errorString();
            QLOG_ERROR() << "************************* ERROR READING BACKUP " << errorMessage;
            lastError = 16;
            return;
        }
        if (reader->name().toString().toLower() == "nevernote-export" && reader->isStartElement()) {
            QXmlStreamAttributes attributes = reader->attributes();
            QString version = attributes.value("version").toString();
            QString type = attributes.value("exportType").toString();
            QString application = attributes.value("application").toString();
            if (version != "0.85" && version != "0.86"
                    && version != "0.95") {
                lastError = 1;
                errorMessage = "Unknown backup version = " +version;
                return;
            }
            if (application.toLower() != "nevernote") {
                lastError = 2;
                errorMessage = "This backup is from an unknown application = " +application;
                return;
            }
            if (type.toLower() == "backup" && !backup) {
                lastError = 4;
                errorMessage = "This is backup file, not an export file";
                progress->hide();
                return;
            }
            if (type.toLower() == "export" && backup) {
                lastError = 5;
                errorMessage = "This is an export file, not a backup file";
                return;
            }
        }
        if (reader->name().toString().toLower() == "synchronization" && reader->isStartElement() && backup) {
            processSynchronizationNode();
        }
        if (reader->name().toString().toLower() == "note" && reader->isStartElement()) {
            processNoteNode();
            recCnt++;
            progress->setValue(recCnt);
        }
        if (reader->name().toString().toLower() == "notebook" && reader->isStartElement() && (backup || importNotebooks)) {
            processNotebookNode();
        }
        if (reader->name().toString().toLower() == "tag" && reader->isStartElement() && (backup || importTags)) {
            processTagNode();
        }
        if (reader->name().toString().toLower() == "savedsearch" && reader->isStartElement() && backup) {
            processSavedSearchNode();
        }
        if (reader->name().toString().toLower() == "linkednotebook" && reader->isStartElement() && backup) {
            processLinkedNotebookNode();
        }
        if (reader->name().toString().toLower() == "SharedNotebook" && reader->isStartElement() && backup) {
            processSharedNotebookNode();
        }
    }
    xmlFile.close();
    query.exec("commit");

    // Now we do what is a "ahem" hack.  We need to
    // go through all of the notes & rebuild the NoteTable.  This
    // is because we may have gotten notes & tags before the notebook
    // & tag names existed.  There is probably a more efficient way
    // to do this, but since we don't really do this often this works
    // as well as any other way.

    NoteTable noteTable(global.db);
    for (qint32 i=0; i<noteList.size(); i++) {
        qint32 lid = noteTable.getLid(noteList[i]);
        if (lid > 0) {
            Note note;
            bool dirty = noteTable.isDirty(lid);
            noteTable.get(note, lid, false, false);
            noteTable.updateNoteList(lid, note, dirty, 0);
        }
    }
    query.exec("commit");
    progress->hide();
}
Exemple #20
0
void ImportEnex::import(QString file) {
    fileName = file;
    errorMessage = "";

    lastError = 0;
    QFile xmlFile(fileName);
    QFile scanFile(fileName);
    if (!xmlFile.open(QIODevice::ReadOnly) || !scanFile.open(QIODevice::ReadOnly)) {
        lastError = 16;
        errorMessage = "Cannot open file.";
        return;
    }

    reader = new QXmlStreamReader(&xmlFile);
    QTextStream *countReader = new QTextStream(&scanFile);
    int recCnt = 0;

    QMessageBox mb;
    mb.setWindowTitle(tr("Scanning File"));
    mb.setText(QString::number(recCnt) + tr(" notes found."));
    QPushButton *cancelButton = mb.addButton(QMessageBox::Cancel);
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(canceled()));
    mb.show();
    QCoreApplication::processEvents();

    while (!countReader->atEnd() && !stopNow) {
        QString line = countReader->readLine();
        if (line.contains("<note>")) {
            recCnt++;
            mb.setText(QString::number(recCnt) + tr(" notes found."));
            QCoreApplication::processEvents();
        }
    }

    progress->setMaximum(recCnt);
    progress->setMinimum(0);
    progress->setWindowTitle(tr("Importing Notes"));
    progress->setLabelText(tr("Importing Notes"));
    progress->setWindowModality(Qt::ApplicationModal);
    connect(progress, SIGNAL(canceled()), this, SLOT(canceled()));
    progress->setVisible(true);
    mb.close();
    progress->show();


    NSqlQuery query(global.db);
    query.exec("begin");
    recCnt = 0;
    while (!reader->atEnd() && !stopNow) {
        reader->readNext();
        if (reader->hasError()) {
            errorMessage = reader->errorString();
            QLOG_ERROR() << "************************* ERROR READING BACKUP " << errorMessage;
            lastError = 16;
            return;
        }

        if (reader->name().toString().toLower() == "en-export" && reader->isStartElement()) {
            QXmlStreamAttributes attributes = reader->attributes();
            QString version = attributes.value("version").toString();
            QString application = attributes.value("application").toString();
            // Version 5.x & 6.x are for Windows
            if (version != "5.x" && version != "6.x" && version.toLower() != "evernote mac") {
                lastError = 1;
                errorMessage = "Unknown export version = " +version;
                return;
            }
            if (application.toLower() != "evernote/windows" && application.toLower() != "evernote") {
                lastError = 2;
                errorMessage = "This export is from an unknown application = " +application;
                return;
            }
        }
        if (reader->name().toString().toLower() == "note" && reader->isStartElement()) {
            recCnt++;
            progress->setValue(recCnt);
            QLOG_DEBUG() << "Importing Note " << recCnt;
            processNoteNode();
        }
    }
    xmlFile.close();
    query.exec("commit");
    progress->hide();
}
void busConnection::on_pushButton_3_clicked()
{
    bool boolean = true;
    bool *in= new bool[ventana->ultimo->getCantidadBits()];
    for(int i=0; i<ventana->ultimo->getCantidadBits();++i){
        in[i]=false;
    }
    bool *out= new bool[last->getCantidadBits()];
    for(int i=0; i<last->getCantidadBits();++i){
        out[i]=false;
    }

    for(int i=0;i < blockCounter;++i){
        int izquierdaIn = QSpinBoxBlockInLeft.at(i)->value();
        int derechaIn = QSpinBoxBlockInRight.at(i)->value();
        int izquierdaOut = QSpinBoxBlockOutLeft.at(i)->value();
        int derechaOut = QSpinBoxBlockOutRight.at(i)->value();
        if(checkBoxBlock.at(i)->isChecked()){
            if((QSpinBoxBlockInLeft.at(i)->value() <= QSpinBoxBlockInRight.at(i)->value())&&(QSpinBoxBlockOutLeft.at(i)->value()<=QSpinBoxBlockOutRight.at(i)->value())){
                for(int j=QSpinBoxBlockInLeft.at(i)->value();j<=QSpinBoxBlockInRight.at(i)->value();++j){
                    if(in[j]){
                    ///Se abre una ventana de warning en caso de que un bit se repita
                        QMessageBox msgBox;
                        msgBox.setIcon(QMessageBox::Warning);
                        msgBox.setText("El bit "+QString::number(j)+" de la columna de la izquierda se repite en varias lineas");
                        msgBox.setInformativeText("Esta seguro que quiere continuar?");
                        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
                        msgBox.setDefaultButton(QMessageBox::Yes);
                        int ret = msgBox.exec();
                        switch (ret) {
                            case QMessageBox::Yes:
                                msgBox.close();
                                break;
                            case QMessageBox::No:
                                //Es necesario borrar la conexi[on inicada con anterioridad.
                                boolean=false;
                                msgBox.close();
                                break;
                            default:
                                ///Es necesario borrar la conexión iniciada con anterioridad.
                                this->close();
                                break;
                        }

                    }
                    else{
                        in[j]=true;
                    }
                }
                for(int j=QSpinBoxBlockOutLeft.at(i)->value();j<=QSpinBoxBlockOutRight.at(i)->value();++j){///Se hacen warning en caso de que un bit salga conectado varias veces.
                    if(out[j]){
                        //Se abre una ventana de warning
                        QMessageBox msgBox;
                        msgBox.setIcon(QMessageBox::Warning);
                        msgBox.setText("El bit "+QString::number(j)+" de la columna de la derecha se repite en varias lineas");
                        msgBox.setInformativeText("Esta seguro que quiere continuar?");
                        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
                        msgBox.setDefaultButton(QMessageBox::Yes);
                        int ret = msgBox.exec();
                        switch (ret) {
                            case QMessageBox::Yes:
                                msgBox.close();
                                break;
                            case QMessageBox::No:
                                //Es necesario borrar la conexi[on inicada con anterioridad.
                                msgBox.close();
                                boolean=false;
                                break;
                            default:
                                ///Es necesario borrar la conexión iniciada con anterioridad.
                                this->close();
                                break;
                        }
                    }
                    else{
                        out[j]=true;
                    }
                }
            }
            else{///Se abre un error cuando la cantidad de bits de una columna no coordinan con la otra.
                QMessageBox msgBox;
                msgBox.setIcon(QMessageBox::Critical);
                msgBox.setText("Los rangos en la linea "+QString::number(i)+" tienen un error.");
                msgBox.exec();
                boolean = false;
            }
        }
        if((derechaIn-izquierdaIn)!=(derechaOut-izquierdaOut)){
            QMessageBox msgBox;
            msgBox.setIcon(QMessageBox::Critical);
            msgBox.setText("La cantidad de bits en la columna de la izquierda en la fila "+QString::number(i)+" no concuerda con la columna de la derecha.");
            msgBox.exec();
            boolean = false;
        }
    }
    if(boolean){
        for(int i=0;i < blockCounter;++i){
            int izquierdaIn = QSpinBoxBlockInLeft.at(i)->value();
            int derechaIn = QSpinBoxBlockInRight.at(i)->value();
            int izquierdaOut = QSpinBoxBlockOutLeft.at(i)->value();
            if(checkBoxBlock.at(i)->isChecked()){
                if(ventana->ultimo->getIsInput()){
                    ventana->ultimo->setColor(last->getColor());
                }
                else{
                    last->setColor(ventana->ultimo->getColor());
                }
                int diff=derechaIn-izquierdaIn;
                for(int i=0;i<=diff;++i){
                    ventana->ultimo->addConnection(last,izquierdaIn+i,izquierdaOut+i);
                    last->addConnection(ventana->ultimo,izquierdaOut+i,izquierdaIn+i);
                }
            }
        }
    }
    if(boolean){
    this->close();
    ventana->ultimo=0;
    ventana->isSecondClick=false;
    ventana->isValid=false;
    }
}
Exemple #22
0
// Function which displays a info box and restarts networking
void Utils::restartNetworking()
{
    
   QMessageBox infoBox;
   infoBox.setWindowModality(Qt::ApplicationModal);
   infoBox.setWindowTitle(QObject::tr("Restarting network..."));
   infoBox.setInformativeText(QObject::tr("Network is restarting, please wait..."));
   infoBox.setStandardButtons(QMessageBox::NoButton);
   infoBox.show();

   QProcess cmd;
   cmd.start(QString("/etc/rc.d/netif"), QStringList() << "restart" );
   while ( cmd.state() != QProcess::NotRunning ) {
       cmd.waitForFinished(100);
       QCoreApplication::processEvents();
   }

   // Set the gateway device name
   QString route = getConfFileValue("/etc/rc.conf", "defaultrouter=", 1);
   if ( ! route.isEmpty() ) {
     infoBox.setInformativeText(QObject::tr("Setting default route..."));
     cmd.start(QString("route"), QStringList() << "delete" << "default" );
     while ( cmd.state() != QProcess::NotRunning ) {
         cmd.waitForFinished(100);
         QCoreApplication::processEvents();
     }

     cmd.start(QString("route"), QStringList() << "add" << "default" << route );
     while ( cmd.state() != QProcess::NotRunning ) {
         cmd.waitForFinished(100);
         QCoreApplication::processEvents();
     }
   }

   // Check for any devices to run DHCP on
   QStringList ifs = NetworkInterface::getInterfaces();
   for ( QStringList::Iterator it = ifs.begin(); it != ifs.end(); ++it )
   {
       QString dev = *it;

       // Devices we can safely skip
       if (dev.indexOf("lo") == 0 
           || dev.indexOf("fwe") == 0 
           || dev.indexOf("ipfw") == 0
           || dev.indexOf("plip") == 0
           || dev.indexOf("pfsync") == 0
           || dev.indexOf("pflog") == 0
           || dev.indexOf("usbus") == 0
           || dev.indexOf("vboxnet") == 0
           || dev.indexOf("tun") == 0)
	  continue;

	// Check if this device has DHCP enabled
	if ( Utils::getConfFileValue( "/etc/rc.conf", "ifconfig_" + dev + "=", 1 ).indexOf("DHCP") != -1 )
	{
	   qDebug() << "Running DHCP on " << dev;
           infoBox.setInformativeText(QObject::tr("Running DHCP..."));
     	   cmd.start(QString("/etc/rc.d/dhclient"), QStringList() << "start" << dev );
           while ( cmd.state() != QProcess::NotRunning ) {
             cmd.waitForFinished(100);
             QCoreApplication::processEvents();
           }
	}
   }

   infoBox.close();
}