Esempio n. 1
0
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();
}
Esempio n. 2
0
File: gui.cpp Progetto: 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:"));
    }
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // Get the port we will listen on
    QInputDialog options;
    options.setLabelText("Enter port for listening:");
    options.setTextValue("12349");
    options.exec();

    MainWindow window;
    Server server(options.textValue());
    Client client;

    window.connect(&server, SIGNAL(messageRecieved(QString,QString)),
                    &window, SLOT(displayNewMessage(QString,QString)));

    window.connect(&window, SIGNAL(connectToChanged(QString,QString)),
                   &client, SLOT(connectTo(QString,QString)));

    window.connect(&window, SIGNAL(sendMessage(QString)),
                   &client, SLOT(startTransfer(QString)));

    window.show();
    window.resize(480,320);
    window.setWindowTitle(window.windowTitle() + " (listen port: " + options.textValue() + ")");
    
    return a.exec();
}
/// Open an input dialog to enter a tie expression.
QString LocalParameterEditor::setTieDialog(QString tie) {
  QInputDialog input;
  input.setWindowTitle("Set a tie.");
  input.setTextValue(tie);
  if (input.exec() == QDialog::Accepted) {
    return input.textValue();
  }
  return "";
}
/// Send a signal to tie a parameter.
void LocalParameterEditor::setTie()
{
  QInputDialog input;
  input.setWindowTitle("Set a tie.");
  input.setTextValue(m_tie);
  if (input.exec() == QDialog::Accepted) {
    auto tie = input.textValue();
    emit setTie(m_index, tie);
  }
}
Esempio n. 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();
}
Esempio n. 7
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());

  return nameDialog;
}
Esempio n. 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)));
}
/**
 * Dialog: Change your Nickname in the ChatLobby
 */
void ChatLobbyDialog::changeNickname()
{
	QInputDialog dialog;
	dialog.setWindowTitle(tr("Change nick name"));
	dialog.setLabelText(tr("Please enter your new nick name"));
	dialog.setWindowIcon(QIcon(":/images/rstray3.png"));

	std::string nickName;
	rsMsgs->getNickNameForChatLobby(lobbyId, nickName);
	dialog.setTextValue(QString::fromUtf8(nickName.c_str()));

	if (dialog.exec() == QDialog::Accepted && !dialog.textValue().isEmpty()) {
		setNickname(dialog.textValue());
	}
}
Esempio n. 10
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)));
}
Esempio n. 11
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("");
}
Esempio n. 12
0
void FolderWizardTargetPage::slotAddRemoteFolder()
{
    QTreeWidgetItem *current = _ui.folderTreeWidget->currentItem();

    QString parent('/');
    if (current) {
        parent = current->data(0, Qt::UserRole).toString();
    }

    QInputDialog *dlg = new QInputDialog(this);

    dlg->setWindowTitle(tr("Add Remote Folder"));
    dlg->setLabelText(tr("Enter the name of the new folder:"));
    dlg->setTextValue(parent);
    dlg->open(this, SLOT(slotCreateRemoteFolder(QString)));
    dlg->setAttribute(Qt::WA_DeleteOnClose);
}
Esempio n. 13
0
void HttpCredentialsGui::showDialog()
{
    QString msg = tr("Please enter %1 password:<br>"
                     "<br>"
                     "User: %2<br>"
                     "Account: %3<br>")
                      .arg(Utility::escape(Theme::instance()->appNameGUI()),
                          Utility::escape(_user),
                          Utility::escape(_account->displayName()));

    QString reqTxt = requestAppPasswordText(_account);
    if (!reqTxt.isEmpty()) {
        msg += QLatin1String("<br>") + reqTxt + QLatin1String("<br>");
    }
    if (!_fetchErrorString.isEmpty()) {
        msg += QLatin1String("<br>")
            + tr("Reading from keychain failed with error: '%1'")
                  .arg(Utility::escape(_fetchErrorString))
            + QLatin1String("<br>");
    }

    QInputDialog dialog;
    dialog.setWindowTitle(tr("Enter Password"));
    dialog.setLabelText(msg);
    dialog.setTextValue(_previousPassword);
    dialog.setTextEchoMode(QLineEdit::Password);
    if (QLabel *dialogLabel = dialog.findChild<QLabel *>()) {
        dialogLabel->setOpenExternalLinks(true);
        dialogLabel->setTextFormat(Qt::RichText);
    }

    bool ok = dialog.exec();
    if (ok) {
        _password = dialog.textValue();
        _refreshToken.clear();
        _ready = true;
        persist();
    }
    emit asked();
}
Esempio n. 14
0
void PlaylistWindow::on_tabWidget_tabBarDoubleClicked(int index)
{
    auto widget = reinterpret_cast<QDrawnPlaylist *>(ui->tabWidget->widget(index));
    QUuid tabUuid = widget->uuid();
    if (tabUuid.isNull())
        return;
    QInputDialog *qid = new QInputDialog(this);
    qid->setAttribute(Qt::WA_DeleteOnClose);
    qid->setWindowModality(Qt::ApplicationModal);
    qid->setWindowTitle(tr("Enter playlist name"));
    qid->setTextValue(ui->tabWidget->tabText(index));
    connect(qid, &QInputDialog::accepted, [=]() {
        int tabIndex = ui->tabWidget->indexOf(widget);
        if (tabIndex < 0)
            return;
        auto pl = PlaylistCollection::getSingleton()->playlistOf(tabUuid);
        if (!pl)
            return;
        pl->setTitle(qid->textValue());
        ui->tabWidget->setTabText(tabIndex, qid->textValue());
    });
    qid->show();
}
Esempio n. 15
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;
}