summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-09 19:38:40 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-19 14:01:47 (GMT)
commitced980e4694962af7c348e2f269f8cac2b9a134c (patch)
tree7525f784c08240ee403e7a879325b1a9b55136c3
parentac61e7597ac45a4301b3bd1b8f5eab124e3e5c9b (diff)
Port away from kinputdialog
Ideally we would want to just use a QInputDialog, but then we don't get access to the validator. REVIEW: 128414
-rw-r--r--src/manager/kwalletmanager.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/manager/kwalletmanager.cpp b/src/manager/kwalletmanager.cpp
index f978c02..b47a8fb 100644
--- a/src/manager/kwalletmanager.cpp
+++ b/src/manager/kwalletmanager.cpp
@@ -31,7 +31,6 @@
#include <qaction.h>
#include <kconfig.h>
#include <kiconloader.h>
-#include <kinputdialog.h>
#include <kmessagebox.h>
#include <kstandardaction.h>
#include <kstatusnotifieritem.h>
@@ -48,6 +47,8 @@
#include <QRegExpValidator>
#include <QTimer>
#include <QFileDialog>
+#include <QDialog>
+#include <QLineEdit>
KWalletManager::KWalletManager(QWidget *parent, const char *name, Qt::WindowFlags f)
@@ -308,8 +309,6 @@ void KWalletManager::possiblyRescan(const QString &app, const QString &oldOwner,
void KWalletManager::createWallet()
{
- QString n;
- bool ok;
QString txt = i18n("Please choose a name for the new wallet:");
QRegExpValidator validator(QRegExp(QLatin1String("^[\\w\\^\\&\\'\\@\\{\\}\\[\\]\\,\\$\\=\\!\\-\\#\\(\\)\\%\\.\\+\\_\\s]+$")), this);
@@ -318,31 +317,47 @@ void KWalletManager::createWallet()
return;
}
+ QDialog nameDialog(this);
+ nameDialog.setWindowTitle(i18n("New Wallet"));
+ nameDialog.setLayout(new QVBoxLayout);
+ nameDialog.layout()->addWidget(new QLabel(txt));
+ QLineEdit *lineEdit = new QLineEdit;
+ lineEdit->setValidator(&validator);
+ nameDialog.layout()->addWidget(lineEdit);
+
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ connect(buttonBox, &QDialogButtonBox::accepted, &nameDialog, &QDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, &nameDialog, &QDialog::reject);
+ nameDialog.layout()->addWidget(buttonBox);
+
+ QString name;
do {
- n = KInputDialog::getText(i18n("New Wallet"), txt, QString(), &ok, this,
- &validator);
+ if (!nameDialog.exec()) {
+ return;
+ }
- if (!ok) {
+ name = lineEdit->text();
+ if (name.isEmpty()) {
return;
}
- if (_managerWidget->hasWallet(n)) {
+ if (_managerWidget->hasWallet(name)) {
int rc = KMessageBox::questionYesNo(this, i18n("Sorry, that wallet already exists. Try a new name?"), QString(), KGuiItem(i18n("Try New")), KGuiItem(i18n("Do Not Try")));
if (rc == KMessageBox::No) {
return;
}
- n.clear();
+ lineEdit->clear();
} else {
break;
}
} while (true);
// Small race here - the wallet could be created on us already.
- if (!n.isEmpty()) {
+ if (!name.isEmpty()) {
// attempt open the wallet to create it, then dispose it
// as it'll appear in on the main window via the walletCreated signal
// emmitted by the kwalletd
- KWallet::Wallet::openWallet(n, effectiveWinId());
+ KWallet::Wallet::openWallet(name, effectiveWinId());
}
}