Example #1
0
void SshKeyGenerator::generatePkcs8KeyString(const KeyPtr &key, bool privateKey,
    Botan::RandomNumberGenerator &rng)
{
    Pipe pipe;
    pipe.start_msg();
    QByteArray *keyData;
    if (privateKey) {
        QInputDialog d;
        d.setInputMode(QInputDialog::TextInput);
        d.setTextEchoMode(QLineEdit::Password);
        d.setWindowTitle(tr("Password for Private Key"));
        d.setLabelText(tr("It is recommended that you secure your private key\n"
            "with a password, which you can can enter below."));
        d.setOkButtonText(tr("Encrypt key file"));
        d.setCancelButtonText(tr("Do not encrypt key file"));
        int result = QDialog::Accepted;
        QString password;
        while (result == QDialog::Accepted && password.isEmpty()) {
            result = d.exec();
            password = d.textValue();
        }
        if (result == QDialog::Accepted)
            PKCS8::encrypt_key(*key, pipe, rng, password.toLocal8Bit().data());
        else
            PKCS8::encode(*key, pipe);
        keyData = &m_privateKey;
    } else {
        X509::encode(*key, pipe);
        keyData = &m_publicKey;
    }
    pipe.end_msg();
    keyData->resize(pipe.remaining(pipe.message_count() - 1));
    pipe.read(convertByteArray(*keyData), keyData->size(),
        pipe.message_count() - 1);
}
void ThemeSettingsWidget::renameTheme()
{
    int index = d->m_ui->themeComboBox->currentIndex();
    if (index == -1)
        return;
    const ThemeEntry &entry = d->m_themeListModel->themeAt(index);

    maybeSaveTheme();

    QInputDialog *dialog = new QInputDialog(d->m_ui->renameButton->window());
    dialog->setInputMode(QInputDialog::TextInput);
    dialog->setWindowTitle(tr("Rename Theme"));
    dialog->setLabelText(tr("Theme name:"));
    dialog->setTextValue(d->m_ui->editor->model()->m_name);
    int ret = dialog->exec();
    QString newName = dialog->textValue();
    delete dialog;

    if (ret != QDialog::Accepted || newName.isEmpty())
        return;

    // overwrite file with new name
    Theme newTheme(entry.name());
    d->m_ui->editor->model()->toTheme(&newTheme);
    newTheme.setName(newName);
    newTheme.writeSettings(entry.filePath());

    refreshThemeList();
}
Example #3
0
File: gui.cpp Project: Pik-9/qTox
QString GUI::_passwordDialog(const QString& cancel, const QString& body)
{
    // we use a hack. It is considered that closing the dialog without explicitly clicking
    // disable history is confusing. But we can't distinguish between clicking the cancel
    // button and closing the dialog. So instead, we reverse the Ok and Cancel roles,
    // so that nothing but explicitly clicking disable history closes the dialog
    QString ret;
    QInputDialog dialog;
    dialog.setWindowTitle(tr("Enter your password"));
    dialog.setOkButtonText(cancel);
    dialog.setCancelButtonText(tr("Decrypt"));
    dialog.setInputMode(QInputDialog::TextInput);
    dialog.setTextEchoMode(QLineEdit::Password);
    dialog.setLabelText(body);

    // problem with previous hack: the default button is disable history, not decrypt.
    // use another hack to reverse the default buttons.
    // http://www.qtcentre.org/threads/49924-Change-property-of-QInputDialog-button
    QList<QDialogButtonBox*> l = dialog.findChildren<QDialogButtonBox*>();
    if (!l.isEmpty())
    {
        QPushButton* ok     = l.first()->button(QDialogButtonBox::Ok);
        QPushButton* cancel = l.first()->button(QDialogButtonBox::Cancel);
        if (ok && cancel)
        {
            ok->setAutoDefault(false);
            ok->setDefault(false);
            ok->setText(QApplication::tr("Ok"));
            cancel->setAutoDefault(true);
            cancel->setDefault(true);
            cancel->setText(QApplication::tr("Cancel"));
        }
        else
        {
            qWarning() << "PasswordDialog: Missing button!";
        }
    }
    else
    {
        qWarning() << "PasswordDialog: No QDialogButtonBox!";
    }

    // using similar code, set QLabels to wrap
    for (auto* label : dialog.findChildren<QLabel*>())
        label->setWordWrap(true);

    while (true)
    {
        int val = dialog.exec();
        if (val == QDialog::Accepted)
            return QString();

        ret = dialog.textValue();
        if (!ret.isEmpty())
            return ret;

        dialog.setTextValue("");
        dialog.setLabelText(body + "\n\n" + tr("You must enter a non-empty password:"));
    }
}
Example #4
0
void PropertiesDock::addProperty()
{
    QInputDialog *dialog = new QInputDialog(mPropertyBrowser);
    dialog->setInputMode(QInputDialog::TextInput);
    dialog->setLabelText(tr("Name:"));
    dialog->setWindowTitle(tr("Add Property"));
    dialog->open(this, SLOT(addProperty(QString)));
}
Example #5
0
void FSTableView::mkdir()
{
    QInputDialog dialog;
    dialog.setLabelText("Nom du nouveau dossier:");
    dialog.setWindowTitle("Nouveau dossier");
    dialog.setInputMode(QInputDialog::TextInput);

    if (dialog.exec() == QDialog::Accepted) {
        fsModel()->mkdir(dialog.textValue(), rootIndex());
    }
}
Example #6
0
void FontSettingsPage::openCopyColorSchemeDialog()
{
    QInputDialog *dialog = new QInputDialog(d_ptr->m_ui->copyButton->window());
    dialog->setAttribute(Qt::WA_DeleteOnClose);
    dialog->setInputMode(QInputDialog::TextInput);
    dialog->setWindowTitle(tr("Copy Color Scheme"));
    dialog->setLabelText(tr("Color scheme name:"));
    dialog->setTextValue(tr("%1 (copy)").arg(d_ptr->m_value.colorScheme().displayName()));

    connect(dialog, &QInputDialog::textValueSelected, this, &FontSettingsPage::copyColorScheme);
    dialog->open();
}
QInputDialog *
TriggerPoint::nameInputDialog()
{
  QInputDialog *nameDialog = new QInputDialog(_scene->views().first(), Qt::Popup);
  nameDialog->setInputMode(QInputDialog::TextInput);
  nameDialog->setLabelText(QObject::tr("Enter the trigger message :"));
  nameDialog->setTextValue(QString::fromStdString(this->_abstract->message()));
  QPoint position = _scene->views().first()->parentWidget()->pos();
  int MMwidth = _scene->views().first()->parentWidget()->width();
  nameDialog->move(position.x() + MMwidth / 2, position.y());

  return nameDialog;
}
Example #8
0
void ObjectTypesEditor::renameProperty()
{
    QtBrowserItem *item = mUi->propertiesView->currentItem();
    if (!item)
        return;

    const QString oldName = item->property()->propertyName();

    QInputDialog *dialog = new QInputDialog(mUi->propertiesView);
    dialog->setInputMode(QInputDialog::TextInput);
    dialog->setLabelText(tr("Name:"));
    dialog->setTextValue(oldName);
    dialog->setWindowTitle(tr("Rename Property"));
    dialog->open(this, SLOT(renamePropertyTo(QString)));
}
Example #9
0
void PropertiesDock::renameProperty()
{
    QtBrowserItem *item = mPropertyBrowser->currentItem();
    if (!mPropertyBrowser->isCustomPropertyItem(item))
        return;

    const QString oldName = item->property()->propertyName();

    QInputDialog *dialog = new QInputDialog(mPropertyBrowser);
    dialog->setInputMode(QInputDialog::TextInput);
    dialog->setLabelText(tr("Name:"));
    dialog->setTextValue(oldName);
    dialog->setWindowTitle(tr("Rename Property"));
    dialog->open(this, SLOT(renamePropertyTo(QString)));
}
Example #10
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QString RicImportEnsembleFeature::askForEnsembleName()
{
    RimProject* project = RiaApplication::instance()->project();
    std::vector<RimSummaryCaseCollection*> groups = project->summaryGroups();
    int ensembleCount = std::count_if(groups.begin(), groups.end(), [](RimSummaryCaseCollection* group) { return group->isEnsemble(); });
    ensembleCount += 1;

    QInputDialog dialog;
    dialog.setInputMode(QInputDialog::TextInput);
    dialog.setWindowTitle("Ensemble Name");
    dialog.setLabelText("Ensemble Name");
    dialog.setTextValue(QString("Ensemble %1").arg(ensembleCount));
    dialog.resize(300, 50);
    dialog.exec();
    return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString("");
}
Example #11
0
 Widget() {
    m_layout.addWidget(&m_view, 0, 0, 1, 1);
    m_layout.addWidget(&m_button, 1, 0, 1, 1);
    connect(&m_button, SIGNAL(clicked()), &m_dialog, SLOT(open()));
    m_model.append({"Volvo", "240", "SQL8941"});
    m_model.append({"Volvo", "850", {}});
    m_model.append({"Volvo", "940", "QRZ1321"});
    m_model.append({"Volvo", "960", "QRZ1628"});
    m_proxy.setSourceModel(&m_model);
    m_proxy.setFilterKeyColumn(2);
    m_view.setModel(&m_proxy);
    m_dialog.setLabelText("Enter registration number fragment to filter on. Leave empty to clear filter.");
    m_dialog.setInputMode(QInputDialog::TextInput);
    connect(&m_dialog, SIGNAL(textValueSelected(QString)),
            &m_proxy, SLOT(setFilterFixedString(QString)));
 }
Example #12
0
void tst_QInputDialog::inputMethodHintsOfChildWidget()
{
    QInputDialog dialog;
    dialog.setInputMode(QInputDialog::TextInput);
    QList<QObject *> children = dialog.children();
    QLineEdit *editWidget = 0;
    for (int c = 0; c < children.size(); c++) {
        editWidget = qobject_cast<QLineEdit *>(children.at(c));
        if (editWidget)
            break;
    }
    QVERIFY(editWidget);
    QCOMPARE(editWidget->inputMethodHints(), dialog.inputMethodHints());
    QCOMPARE(editWidget->inputMethodHints(), Qt::ImhNone);
    dialog.setInputMethodHints(Qt::ImhDigitsOnly);
    QCOMPARE(editWidget->inputMethodHints(), dialog.inputMethodHints());
    QCOMPARE(editWidget->inputMethodHints(), Qt::ImhDigitsOnly);
}
Example #13
0
static bool execInputDialog_Int(
    const char *title, const char *label, int minVal, int maxVal, int &ret)
{
    QInputDialog dlg;
    dlg.setWindowTitle(title);
    dlg.setLabelText(label);
    dlg.setOkButtonText("确定");
    dlg.setCancelButtonText("取消");
    dlg.setInputMode(QInputDialog::IntInput);
    dlg.setIntRange(minVal, maxVal);
    dlg.setIntValue(ret);
    if (dlg.exec() == QDialog::Accepted)
    {
        ret = dlg.intValue();
        return true;
    }
    return false;
}
QString SshKeyGenerator::getPassword() const
{
    QInputDialog d;
    d.setInputMode(QInputDialog::TextInput);
    d.setTextEchoMode(QLineEdit::Password);
    d.setWindowTitle(tr("Password for Private Key"));
    d.setLabelText(tr("It is recommended that you secure your private key\n"
        "with a password, which you can enter below."));
    d.setOkButtonText(tr("Encrypt key file"));
    d.setCancelButtonText(tr("Do not encrypt key file"));
    int result = QDialog::Accepted;
    QString password;
    while (result == QDialog::Accepted && password.isEmpty()) {
        result = d.exec();
        password = d.textValue();
    }
    return result == QDialog::Accepted ? password : QString();
}
Example #15
0
static inline StackFrame inputFunctionForDisassembly()
{
    StackFrame frame;
    QInputDialog dialog;
    dialog.setInputMode(QInputDialog::TextInput);
    dialog.setLabelText(StackTreeView::tr("Function:"));
    dialog.setWindowTitle(StackTreeView::tr("Disassemble Function"));
    dialog.setWindowFlags(dialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
    if (dialog.exec() != QDialog::Accepted)
        return frame;
    const QString function = dialog.textValue();
    if (function.isEmpty())
        return frame;
    const int bangPos = function.indexOf(QLatin1Char('!'));
    if (bangPos != -1) {
        frame.module = function.left(bangPos);
        frame.function = function.mid(bangPos + 1);
    } else {
        frame.function = function;
    }
    frame.line = 42; // trick gdb into mixed mode.
    return frame;
}
Example #16
0
QInputDialog *
TriggerPoint::nameInputDialog()
{
  QInputDialog *nameDialog = new QInputDialog(_scene->views().first(), Qt::Popup);
  nameDialog->setInputMode(QInputDialog::TextInput);
  nameDialog->setLabelText(QObject::tr("Enter the trigger message :"));
  nameDialog->setTextValue(QString::fromStdString(this->_abstract->message()));
  QPoint position = _scene->views().first()->parentWidget()->pos();
  int MMwidth = _scene->views().first()->parentWidget()->width();
  nameDialog->move(position.x() + MMwidth / 2, position.y());

  nameDialog->setStyleSheet(
              "QInputDialog {"
              "font-weight: bold;"
              "border: 2px solid gray;"
              "border-width: 2px;"
              "border-color: #606060;"
              "background-color: darkgray;"
              "}"
              );

  return nameDialog;
}
void LightFader::configureClicked()
{
    switch (m_operatingMode)
    {
        case SINGLE_CHANNEL:
        {
            QInputDialog *dlg = new QInputDialog(this);
            dlg->setInputMode(QInputDialog::IntInput);
            dlg->setIntMaximum(255);
            dlg->setIntMinimum(0);
            dlg->setIntValue(m_values[0]);
            dlg->setOption(QInputDialog::NoButtons, true);
            dlg->setWindowTitle(ui.faderName->text());
            dlg->setLabelText(tr("DMX Value:"));
            connect(dlg, &QInputDialog::intValueChanged, this, &LightFader::setValueFromDialog);
            dlg->exec();
            break;
        }
        case EUROLITE_PMD_8:
            EuroLitePMD8Configuration *dlg = new EuroLitePMD8Configuration(this);
            dlg->exec();
            break;
    }
}