Example #1
1
void MainWindow::on_actionAgregar_Arista_triggered()
{
   QInputDialog insert;
   QString nodo1;
   QString nodo2;
   double peso;

   nodo1 = insert.getText(this,"Insertar Arista","Ingrese el Nombre del Primer Nodo.").toUpper().trimmed();

   if(!nodo1.isEmpty()){
     nodo2 = insert.getText(this,"Agregar Arista","Ingrese el Nombre del Segundo Nodo.").toUpper().trimmed();

        if(!nodo2.isEmpty())
             peso = insert.getDouble(this,"Agregar Arista","Ingrese el Peso de La Arista",0.1,1);
        else
            return;
    }else
        return;


   QString dia = this->ui->cb_Dias->currentText().toUpper();
   QString hora = this->ui->cb_Hora->currentText().toUpper();

   int n1,n2;

   n1 = this->consul->mg->getIndexNodo(nodo1);
   n2 = this->consul->mg->getIndexNodo(nodo2);

   qDebug()<<"nodo1: "<<n1<<" nodo2:"<<n2;

   if(n1==-1 || n2==-1){
       if(n1==-1)
           QMessageBox::critical(this,"Error","El nombre "+nodo1+" no existe!!");
       if(n2==-1)
           QMessageBox::critical(this,"Error","El nombre "+nodo2+" no existe!!");
      return;
  }

   this->consul->mg->addArista(n1,n2,dia,hora,(float)peso);
   this->mostrarFloy();
   this->ui->gridLayoutWidget->update();
}
Example #2
0
void BookmarkWidget::createFolder()
{
    if(!mw()->VTKA() ) return;
    bool ok = true;

    QString path = getBookmarkFilepath();
    QFile bf(path);
    if(!bf.open(QFile::ReadWrite | QFile::Text)) {
        showFileOpenError();
        bf.close();
        return;
    }

    QDomDocument doc;
    QDomElement root;
    QDomNodeList list;
    if(bf.size() == 0) {
        buildDOMDocument(doc, root);
    } else {
        qDebug() << bf.size();
        doc.setContent(&bf);
        list = doc.elementsByTagName(BOOKMARK_XML_ROOT);
        if(list.isEmpty()) {
            showInvalidFileError();
            return;
        }
        root = list.at(0).toElement();
    }

    QInputDialog* titleBox = new QInputDialog(this);
    QString title;
    do
    {
        title = titleBox->getText(this, tr("New Folder"),
                                  tr("Enter the title for your new folder:"), QLineEdit::Normal, "", &ok);
    } while(title.isEmpty() && ok);

    if(!ok) return;

    QDomElement fldr = doc.createElement(FOLDER_NAME);
    fldr.setAttribute(TITLE, title);
    QString dt = QDateTime::currentDateTimeUtc().toString();
    fldr.setAttribute(DATE_CREATED, dt);
    fldr.setAttribute(DATE_MODIFIED, dt);
    fldr.setAttribute(DATE_ACCESSED, dt);
    fldr.setAttribute(UUID_NAME, QUuid::createUuid());
    fldr.setAttribute(FOLDED, "yes");
    root.appendChild(fldr);

    saveDOMToFile(doc);
    refreshBookmarkList();
}
Example #3
0
void ContextMenu::rename()
{
    QInputDialog* inputDialog = new QInputDialog();
    inputDialog->setOptions(QInputDialog::NoButtons);

    QString oldName = getNearestPointName(_lastPosImage);

    QString newName = inputDialog->getText(NULL, tr("Rename"), tr("Point name:"), QLineEdit::Normal, oldName);

    if (!newName.isEmpty() && (newName != oldName))

        emit changeName(oldName, newName);
}
Example #4
0
void BookmarkWidget::createBookmark()
{
    if(!mw()->VTKA() ) return;

    QString path = getBookmarkFilepath();
    QFile bf(path);
    if(!bf.open(QFile::ReadWrite | QFile::Text)) {
        showFileOpenError();
        bf.close();
        return;
    }

    QDomDocument doc;
    QDomElement root;
    QDomNodeList list;

    if(bf.size() == 0) {
        buildDOMDocument(doc, root);
    } else {
        doc.setContent(&bf);
        list = doc.elementsByTagName(BOOKMARK_XML_ROOT);
        if(list.isEmpty()) {
            showInvalidFileError();
            return;
        }
        root = list.at(0).toElement();
    }

    QInputDialog* captionBox = new QInputDialog(this);
    QString caption;
    bool ok = true;
    do
    {
        caption = captionBox->getText(this, tr("Bookmark View"),
                                      tr("Enter a caption for this viewpoint:"), QLineEdit::Normal, "", &ok);
    } while(caption.isEmpty() && ok);

    if(!ok) return;

    QUuid uuid = QUuid::createUuid();
    createBookmarkSubclass(caption, doc, root, uuid);

    root.setAttribute(DATE_MODIFIED, QDateTime::currentDateTimeUtc().toString());
    saveDOMToFile(doc);
    if(mw()->VTKA()->mQVTKWidget) mw()->VTKA()->mQVTKWidget->update();
    refreshBookmarkList();
    QString bookmarkFolder = mw()->VTKA()->mProjectPath;
    bookmarkFolder.append(QDir::separator() + QString("BookMark"));
    emit addNavigationItem(bookmarkFolder, caption, uuid.toString());
}
void MainWindow::connectToServer()
{
    if (m_renderController)
        return;

    bool ok;
    QInputDialog *input = new QInputDialog(this);

    QString result = input->getText(this, "Local port",
                                          "Please enter the local UDP port",
                                          QLineEdit::Normal,
                                          "127.0.0.1:5000", &ok);

    delete input;

    if (!ok || result.isEmpty())
        return;

    serverIpAddr = result.section(':', 0, 0);
    serverPort = result.section(':', 1, 1).toInt(&ok);

    if (!ok)
        serverPort = 5555;

    QStringList list = serverIpAddr.split(".");
    if (list.length() != 4)
        return;

    m_renderController = new AllocationRenderController(serverIpAddr, serverPort, m_saveToFileAction->isChecked());

    connect(m_renderController, SIGNAL(newSurfacePool(SceneController*, char*)), this, SLOT(newRenderTarget(SceneController*, char*)));
    connect(m_renderController, SIGNAL(missingInformation(unsigned int)), this, SLOT(missingInformation(unsigned int)));
    connect(m_renderController, SIGNAL(lostPackets(unsigned int, unsigned int)), this, SLOT(lostPackets(unsigned int, unsigned int)));
    connect(m_renderController, SIGNAL(finished()), this, SLOT(finished()));

    connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));

    m_connectAction->setEnabled(false);
    m_stopAction->setEnabled(true);
    m_playbackTraceAction->setEnabled(false);

    m_lostPackets = 0;
    m_connectedSender = 0;

    ui->label->setText("Initializing...");
    m_renderController->connect();
}
Example #6
0
void BookmarkWidget::editItem(QTreeWidgetItem* item)
{
    if(!item) {
        QList<QTreeWidgetItem *> selected = bTreeWidget->selectedItems();
        if(selected.isEmpty()) return;
        item = selected.at(0);
        if(!item) return;
    }

    int type = item->data(TITLE_COLUMN, Qt::UserRole).toInt();
    QString uuid = item->text(UUID_COLUMN);
    QString oldTitle = item->text(TITLE_COLUMN);

    QString header, message;
    if(type == FOLDER) {
        header = tr("Edit Folder");
        message = tr("Enter a new title for this folder:");
    }
    else if(type == BOOKMARK) {
        header = tr("Edit Bookmark");
        message = tr("Enter a new caption for this viewpoint:");
    }
    if(header.isEmpty() || message.isEmpty()) return;

    QInputDialog* titleBox = new QInputDialog(this);
    QString title;
    bool ok = true;
    do
    {
        title = titleBox->getText(this, header, message, QLineEdit::Normal, oldTitle, &ok);
    } while(title.isEmpty() && ok);

    if(!ok) return;

    QDomDocument doc;
    QDomElement elt = findElementbyUUID(doc, uuid, type);
    if(elt.isNull()) return;
    elt.setAttribute(TITLE, title);
    elt.setAttribute(DATE_MODIFIED, QDateTime::currentDateTimeUtc().toString());
    QString bookmarkFolder = mw()->VTKA()->mProjectPath;
    bookmarkFolder.append(QDir::separator() + QString("BookMark"));
    emit editNavigationItem(bookmarkFolder, title, uuid);
    saveDOMToFile(doc);
    refreshBookmarkList();
}
Example #7
0
void dCacheMainWindow::showPassword()
{
	/**
	 * Show an input Dialog box to enter the proxy password
	 */

	bool ok;
	QInputDialog* inputDialog = new QInputDialog();
	inputDialog->setOptions(QInputDialog::NoButtons);
	QString password = inputDialog->getText(this, tr("Enter password"),
			tr("Password:"******""), &ok);

	if(ok && !password.isEmpty())
	{
		m_proxy->setPassword(password);//send the password to the process that creates the grid proxy
	}
}
Example #8
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QDialogSlots q;

    //languages can only be set after set QApplication
    if(QLocale::system().name().toStdString() == "zh_CN"){
        q.trans_.load(":/lang/zh_CN.qm");
        QApplication::installTranslator(&(q.trans_));
        q.ui->retranslateUi(&q);
    }else{
        q.trans_.load(":/lang/en_US.qm");
        QApplication::installTranslator(&(q.trans_));
        q.ui->retranslateUi(&q);
    }
    q.refresh_main();

#if (defined USE_MOBILE)
    q.showFullScreen();
#else
    q.showNormal();
#endif

#ifdef ROOTTOOL_NEED
#if (defined PASSWORD_NEED)
    QInputDialog passbox;
    bool isok;
    QString passwd = passbox.getText(NULL, QApplication::translate("Util", "Password"),
                                         QApplication::translate("Util", "Please input your root password,defalut alpine."),
                                         QLineEdit::Normal,
                                         "alpine",
                                     &isok);
    if(!isok)
        exit(0);
    //ios need password for su
    RootTools::Configure(passwd, true);
#endif
    RootTools::Instance();
#endif
    //Check if current session have root privileges
    q.check_writable();

    return a.exec();
}
Example #9
0
void MainWindow::ConnectBox()
{
    bool ok;

    if (m_connected) {

        delete m_UdpSocket;

        m_UdpSocket = 0;
        m_connected = false;

        m_mouseAcquired = false;

        releaseMouse();

        ui->action_Connect->setText("Connect...");
    } else {
        QInputDialog *input = new QInputDialog(this);

        QString result = input->getText(this, "Target UDP port",
                                              "Target UDP port",
                                              QLineEdit::Normal,
                                              m_target, &ok);

        delete input;

        if (!ok || result.isEmpty())
            return;

        if (!parseTargetAddress(result))
            return;

        m_UdpSocket = new QUdpSocket();
        m_connected = true;

        m_mouseAcquired = false;

        releaseMouse();

        ui->action_Connect->setText("Disconnect");
    }
}
Example #10
0
void Program::addNewStudent()
{
    QInputDialog message;
    bool ok;
    QString name = message.getText(this, "اضافه کردن دانش آموز",
                                   "نام دانش آموز را وارد کنید", QLineEdit::Normal,
                                   "", &ok);
    if (ok == true && name != "")
    {
        sql.addStudent(sql.maxStudents+1,name);
        std::vector<int> ids = sql.getStudentIDs(user_id);
        std::vector<QString>names = sql.getStudentNames(user_id);
        studentsCombo->clear();
        int numStudents = names.size();
        for (int i = 0; i < numStudents; ++i)
        {
            studentsCombo->addItem(names[i],ids[i]);
        }
    }
}
void Macro::recHit() {
    if(recording == 1)
    {
        recording = 0;
        bool ok;
        QInputDialog *popup = new QInputDialog();
        QString text = popup->getText(0, "Name Macro", "Please name your macro to be saved to file.", QLineEdit::Normal,
                                               "", &ok);
        if(ok)
        {
            writeFile(text);
        }
        qDebug() << "Record Off";
    }
    else
    {
        std::fill(macro, macro+1000, 0);
        recording = 1;
        counter = 0;
        qDebug() << "Record On";

    }
}
Example #12
0
/**
 * Decrypts a text using cipher text and cipher key
 * Chooses between a permanent or a individual password using the preferences
 */
void MainWindow::on_actionDecrypt_triggered()
{
    if (passwordUsed)
    {
        query.prepare("SELECT `Password` FROM `password`;");
        query.exec();
        QString passwordBase;
        while ( query.next() ) {
            passwordBase = query.value(0).toString();
        }
        QByteArray passwordTemp = QByteArray::fromBase64( passwordBase.toUtf8() );
        password = QString(passwordTemp);

        Regex regex;
        QRegExp rePassword( regex.getPassword() );

        if ( !password.isEmpty() && password.contains(rePassword) )
        {
            decrypted = decrypt(password);
            ui->textEdit_mainWindow_surface->setHtml( QString(decrypted) );
        } else
        {
            QMessageBox::critical(this, tr("Error"), tr("An error has ocurred. Please revise your entries and note the following:\n"
                                                        "A Password must contain at least one upper case letter.\n"
                                                        "A Password must contain at least one lower case letter.\n"
                                                        "A Password must contain at least one numeric digit."));
            qDebug() << "Data could not be decrypted because the password requirements were not met.";
        }
    } else
    {
        bool ok = false;

        QInputDialog* inputDialog = new QInputDialog();
        inputDialog->setAttribute(Qt::WA_DeleteOnClose, true);

        inputDialog->setOptions(QInputDialog::NoButtons);

        password = inputDialog->getText(NULL ,tr("Decryption"),
                                                  tr("Password:"******"", &ok);

        if (ok)
        {
            Regex regex;
            QRegExp rePassword( regex.getPassword() );

            if ( !password.isEmpty() && password.contains(rePassword) )
            {
                decrypted = decrypt(password);
                ui->textEdit_mainWindow_surface->setHtml( QString(decrypted) );
            } else
            {
                QMessageBox::critical(this, tr("Error"), tr("An error has ocurred. Please revise your entries and note the following:\n"
                                                            "A Password must contain at least one upper case letter.\n"
                                                            "A Password must contain at least one lower case letter.\n"
                                                            "A Password must contain at least one numeric digit."));
                qDebug() << "Data could not be decrypted because the password requirements were not met.";
            }
        } else
        {

            inputDialog->reject();
        }
        inputDialog->close();
    }
}
void vkUploadImagesForm::on_toolButton_clicked()
{
    QInputDialog dialog;
    QString newfolder = dialog.getText(this,tr("Title of new album"),tr("Please input title of new album"));
    if (!newfolder.isEmpty()) emit addNewAlbum(newfolder);
}