summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Wolff <[email protected]>2017-08-02 14:13:04 +0200
committerJulian Wolff <[email protected]>2017-08-02 16:16:19 +0200
commit60c6600a388d4c44fd18a84d9cda69212e971a88 (patch)
tree5ba0d4a00fdf52186c0234c78d8c028fdb705949
parentfd50a04df49bac3ce3e95f3eef5e5aa38b4021e0 (diff)
add --newpassword option
Summary: Adds an option to create a "new password"-dialog. Closes Bug 340397 Reviewers: cfeck Reviewed By: cfeck Subscribers: #kde_applications Differential Revision: https://phabricator.kde.org/D7072
-rw-r--r--src/kdialog.cpp10
-rw-r--r--src/widgets.cpp15
-rw-r--r--src/widgets.h1
3 files changed, 26 insertions, 0 deletions
diff --git a/src/kdialog.cpp b/src/kdialog.cpp
index 71274c6..c77ecaa 100644
--- a/src/kdialog.cpp
+++ b/src/kdialog.cpp
@@ -300,6 +300,7 @@ int main(int argc, char *argv[])
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("msgbox"), i18n("Message Box dialog"), QLatin1String("text")));
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("inputbox"), i18n("Input Box dialog"), QLatin1String("text> <init")));
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("password"), i18n("Password dialog"), QLatin1String("text")));
+ parser.addOption(QCommandLineOption(QStringList() << QLatin1String("newpassword"), i18n("New Password dialog"), QLatin1String("text")));
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("textbox"), i18n("Text Box dialog"), QLatin1String("file")));
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("textinputbox"), i18n("Text Input Box dialog"), QLatin1String("text> <init")));
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("combobox"), i18n("ComboBox dialog"), QLatin1String("text")));
@@ -503,6 +504,15 @@ int main(int argc, char *argv[])
cout << qPrintable(result) << endl;
return retcode ? 0 : 1;
}
+
+ // --newpassword text
+ if (parser.isSet("newpassword"))
+ {
+ QString result;
+ const bool retcode = Widgets::newPasswordBox(0, title, parser.value("newpassword"), result);
+ cout << qPrintable(result) << endl;
+ return retcode ? 0 : 1;
+ }
// --passivepopup
if (parser.isSet("passivepopup"))
diff --git a/src/widgets.cpp b/src/widgets.cpp
index 54a6e64..ed78266 100644
--- a/src/widgets.cpp
+++ b/src/widgets.cpp
@@ -36,6 +36,7 @@
// KDE
#include <kpassworddialog.h>
+#include <knewpassworddialog.h>
#include <ktextedit.h>
#include <kdatepicker.h>
#include <klocalizedstring.h>
@@ -76,6 +77,20 @@ bool Widgets::passwordBox(QWidget *parent, const QString& title, const QString&
return retcode;
}
+bool Widgets::newPasswordBox(QWidget *parent, const QString& title, const QString& text, QString &result)
+{
+ KNewPasswordDialog dlg( parent );
+ dlg.setWindowTitle(title);
+ dlg.setPrompt(text);
+
+ Utils::handleXGeometry(&dlg);
+
+ bool retcode = (dlg.exec() == QDialog::Accepted);
+ if ( retcode )
+ result = dlg.password();
+ return retcode;
+}
+
int Widgets::textBox(QWidget *parent, int width, int height, const QString& title, const QString& file)
{
QDialog dlg(parent);
diff --git a/src/widgets.h b/src/widgets.h
index f90e0fb..68087b3 100644
--- a/src/widgets.h
+++ b/src/widgets.h
@@ -29,6 +29,7 @@ namespace Widgets
{
bool inputBox(QWidget *parent, const QString& title, const QString& text, const QString& init, QString &result);
bool passwordBox(QWidget *parent, const QString& title, const QString& text, QString &result);
+ bool newPasswordBox(QWidget *parent, const QString& title, const QString& text, QString &result);
int textBox(QWidget *parent, int width, int height, const QString& title, const QString& file);
int textInputBox(QWidget *parent, int width, int height, const QString& title, const QString& text, const QString& init, QString &result);
bool listBox(QWidget *parent, const QString& title, const QString& text, const QStringList& args, const QString &defaultEntry, QString &result);