Use QInputDialog in Classes widget

This commit is contained in:
itayc0hen 2020-06-14 11:51:43 +03:00 committed by Itay Cohen
parent 3b2abf4984
commit 9c0d5d72d1

View File

@ -4,11 +4,11 @@
#include "common/Helpers.h"
#include "common/SvgIconEngine.h"
#include "dialogs/EditMethodDialog.h"
#include "dialogs/RenameDialog.h"
#include <QList>
#include <QMenu>
#include <QMouseEvent>
#include <QInputDialog>
QVariant ClassesModel::headerData(int section, Qt::Orientation, int role) const
{
@ -740,15 +740,15 @@ void ClassesWidget::on_editMethodAction_triggered()
EditMethodDialog::editMethod(className, methName, this);
}
void ClassesWidget::on_newClassAction_triggered()
{
QString name;
if (!RenameDialog::showDialog(tr("Create new Class"), &name, tr("Class Name"), this) || name.isEmpty()) {
return;
}
bool ok;
QString name = QInputDialog::getText(this, tr("Create new Class"),
tr("Class Name:"), QLineEdit::Normal, QString(), &ok);
if (ok && !name.isEmpty()) {
Core()->createNewClass(name);
}
}
void ClassesWidget::on_deleteClassAction_triggered()
{
@ -770,9 +770,10 @@ void ClassesWidget::on_renameClassAction_triggered()
return;
}
QString oldName = index.data(ClassesModel::NameRole).toString();
QString newName = oldName;
if (!RenameDialog::showDialog(tr("Rename Class %1").arg(oldName), &newName, tr("Class Name"), this) || newName.isEmpty()) {
return;
}
bool ok;
QString newName = QInputDialog::getText(this, tr("Rename Class %1").arg(oldName),
tr("Class name:"), QLineEdit::Normal, oldName, &ok);
if (ok && !newName.isEmpty()) {
Core()->renameClass(oldName, newName);
}
}