summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2015-07-10 01:03:55 +0200
committerAnne Jan Brouwer <brouwer@annejan.com>2015-07-10 01:03:55 +0200
commitc00520ec2238f6ce26a2ff6c1010b49c33a82ac4 (patch)
tree6df14aff3b01514e4acf3de54e13046e78b084c7
parent4cda1ec9cceb5e4119b4d6d9f22b834e791416ed (diff)
Basic PasswordDialog implemented . . don't clipboard empty passwords
-rw-r--r--mainwindow.cpp30
-rw-r--r--passworddialog.cpp42
-rw-r--r--passworddialog.h28
-rw-r--r--passworddialog.ui95
-rw-r--r--qtpass.pro15
5 files changed, 189 insertions, 21 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 970cd653..78f4779d 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -3,6 +3,7 @@
#include "dialog.h"
#include "usersdialog.h"
#include "keygendialog.h"
+#include "passworddialog.h"
#include "util.h"
#include <QClipboard>
#include <QDebug>
@@ -519,7 +520,7 @@ void MainWindow::readyRead(bool finished = false) {
output = process->readAllStandardOutput();
if (finished && currentAction == GPG) {
lastDecrypt = output;
- if (useClipboard) {
+ if (useClipboard && !output.isEmpty()) {
QClipboard *clip = QApplication::clipboard();
QStringList tokens = output.split("\n");
clip->setText(tokens[0]);
@@ -666,7 +667,12 @@ void MainWindow::setGitExecutable(QString path) {
}
/**
- * @brief MainWindow::setGpgExecutable
+ * @briefUsersDialog d(this);
+ d.setUsers(&users);
+ if (!d.exec()) {
+ d.setUsers(NULL);
+ return;
+ } MainWindow::setGpgExecutable
* @param path
*/
void MainWindow::setGpgExecutable(QString path) {
@@ -819,19 +825,17 @@ void MainWindow::setPassword(QString file, bool overwrite, bool isNew = false)
// warn?
return;
}
- bool ok;
-#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
- QString newValue = QInputDialog::getMultiLineText(this, tr("New Value"),
- tr("New password value:"),
- lastDecrypt, &ok);
-#else
- QString newValue = QInputDialog::getText(this, tr("New Value"),
- tr("New password value:"), QLineEdit::Normal,
- lastDecrypt, &ok);
-#endif
- if (!ok || newValue.isEmpty()) {
+ PasswordDialog d(this);
+ d.setPassword(lastDecrypt);
+ if (!d.exec()) {
+ d.setPassword(NULL);
return;
}
+ QString newValue = d.getPassword();
+ if (newValue.isEmpty()) {
+ return;
+ }
+
currentAction = EDIT;
if (usePass) {
QString force(overwrite ? " -f " : " ");
diff --git a/passworddialog.cpp b/passworddialog.cpp
new file mode 100644
index 00000000..a105c824
--- /dev/null
+++ b/passworddialog.cpp
@@ -0,0 +1,42 @@
+#include "passworddialog.h"
+#include "ui_passworddialog.h"
+
+PasswordDialog::PasswordDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::PasswordDialog)
+{
+ ui->setupUi(this);
+}
+
+PasswordDialog::~PasswordDialog()
+{
+ delete ui;
+}
+
+void PasswordDialog::on_checkBoxShow_stateChanged(int arg1)
+{
+ if (arg1) {
+ ui->lineEditPassword->setEchoMode(QLineEdit::Normal);
+ } else {
+ ui->lineEditPassword->setEchoMode(QLineEdit::Password);
+ }
+}
+
+void PasswordDialog::on_createPasswordButton_clicked()
+{
+ // TODO
+ ui->lineEditPassword->setText("generated");
+}
+
+void PasswordDialog::setPassword(QString password)
+{
+ QStringList tokens = password.split("\n");
+ ui->lineEditPassword->setText(tokens[0]);
+ tokens.pop_front();
+ ui->plainTextEdit->insertPlainText(tokens.join("\n"));
+}
+
+QString PasswordDialog::getPassword()
+{
+ return ui->lineEditPassword->text() + "\n" + ui->plainTextEdit->toPlainText();
+}
diff --git a/passworddialog.h b/passworddialog.h
new file mode 100644
index 00000000..07ef2c7a
--- /dev/null
+++ b/passworddialog.h
@@ -0,0 +1,28 @@
+#ifndef PASSWORDDIALOG_H
+#define PASSWORDDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class PasswordDialog;
+}
+
+class PasswordDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit PasswordDialog(QWidget *parent = 0);
+ ~PasswordDialog();
+ void setPassword(QString);
+ QString getPassword();
+
+private slots:
+ void on_checkBoxShow_stateChanged(int arg1);
+ void on_createPasswordButton_clicked();
+
+private:
+ Ui::PasswordDialog *ui;
+};
+
+#endif // PASSWORDDIALOG_H
diff --git a/passworddialog.ui b/passworddialog.ui
new file mode 100644
index 00000000..db0b0dc6
--- /dev/null
+++ b/passworddialog.ui
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PasswordDialog</class>
+ <widget class="QDialog" name="PasswordDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>266</width>
+ <height>235</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Password</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLineEdit" name="lineEditPassword">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="createPasswordButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Generate</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxShow">
+ <property name="text">
+ <string>Show password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPlainTextEdit" name="plainTextEdit"/>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>PasswordDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>PasswordDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/qtpass.pro b/qtpass.pro
index f9383a0f..eb904d32 100644
--- a/qtpass.pro
+++ b/qtpass.pro
@@ -18,7 +18,7 @@ macx {
}
TEMPLATE = app
-VERSION = 0.8.5
+VERSION = 0.8.6
SOURCES += main.cpp\
mainwindow.cpp \
@@ -28,7 +28,8 @@ SOURCES += main.cpp\
usersdialog.cpp \
keygendialog.cpp \
progressindicator.cpp \
- trayicon.cpp
+ trayicon.cpp \
+ passworddialog.cpp
HEADERS += mainwindow.h \
dialog.h \
@@ -37,19 +38,17 @@ HEADERS += mainwindow.h \
usersdialog.h \
keygendialog.h \
progressindicator.h \
- trayicon.h
+ trayicon.h \
+ passworddialog.h
FORMS += mainwindow.ui \
dialog.ui \
usersdialog.ui \
- keygendialog.ui
+ keygendialog.ui \
+ passworddialog.ui
QMAKE_CXXFLAGS_WARN_ON += -Wno-unknown-pragmas
-*-g++* {
- QMAKE_CXXFLAGS += -std=c++11
-}
-
nosingleapp {
QMAKE_CXXFLAGS += -DSINGLE_APP=0
} else {