From 870417d9c421837ee5c77c27602381d764483fff Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Sun, 10 Mar 2013 22:23:10 +0100 Subject: [PATCH] Add dummy PasswordGeneratorWidget. Refs #52 --- src/CMakeLists.txt | 3 ++ src/gui/PasswordGeneratorWidget.cpp | 31 ++++++++++++++++++ src/gui/PasswordGeneratorWidget.h | 42 ++++++++++++++++++++++++ src/gui/PasswordGeneratorWidget.ui | 28 ++++++++++++++++ src/gui/entry/EditEntryWidget.cpp | 9 +++++ src/gui/entry/EditEntryWidget.h | 2 ++ src/gui/entry/EditEntryWidgetMain.ui | 49 +++++++++++++++++++++------- 7 files changed, 153 insertions(+), 11 deletions(-) create mode 100644 src/gui/PasswordGeneratorWidget.cpp create mode 100644 src/gui/PasswordGeneratorWidget.h create mode 100644 src/gui/PasswordGeneratorWidget.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 122d9a8b..1ba380ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,7 @@ set(keepassx_SOURCES gui/KeePass1OpenWidget.cpp gui/LineEdit.cpp gui/MainWindow.cpp + gui/PasswordGeneratorWidget.cpp gui/SettingsWidget.cpp gui/SortFilterHideProxyModel.cpp gui/UnlockDatabaseWidget.cpp @@ -142,6 +143,7 @@ set(keepassx_MOC gui/KeePass1OpenWidget.h gui/LineEdit.h gui/MainWindow.h + gui/PasswordGeneratorWidget.h gui/SettingsWidget.h gui/SortFilterHideProxyModel.h gui/UnlockDatabaseWidget.h @@ -173,6 +175,7 @@ set(keepassx_FORMS gui/EditWidgetIcons.ui gui/EditWidgetProperties.ui gui/MainWindow.ui + gui/PasswordGeneratorWidget.ui gui/SearchWidget.ui gui/SettingsWidgetGeneral.ui gui/SettingsWidgetSecurity.ui diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp new file mode 100644 index 00000000..a917ca91 --- /dev/null +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2013 Felix Geyer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "PasswordGeneratorWidget.h" +#include "ui_PasswordGeneratorWidget.h" + +PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent) + : QWidget(parent) + , m_ui(new Ui::PasswordGeneratorWidget()) +{ + m_ui->setupUi(this); +} + +PasswordGeneratorWidget::~PasswordGeneratorWidget() +{ + ; +} diff --git a/src/gui/PasswordGeneratorWidget.h b/src/gui/PasswordGeneratorWidget.h new file mode 100644 index 00000000..ad0f7540 --- /dev/null +++ b/src/gui/PasswordGeneratorWidget.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2013 Felix Geyer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KEEPASSX_PASSWORDGENERATORWIDGET_H +#define KEEPASSX_PASSWORDGENERATORWIDGET_H + +#include + +#include "core/Global.h" + +namespace Ui { + class PasswordGeneratorWidget; +} + +class PasswordGeneratorWidget : public QWidget +{ + Q_OBJECT + +public: + explicit PasswordGeneratorWidget(QWidget* parent = Q_NULLPTR); + ~PasswordGeneratorWidget(); + +private: + const QScopedPointer m_ui; + +}; + +#endif // KEEPASSX_PASSWORDGENERATORWIDGET_H diff --git a/src/gui/PasswordGeneratorWidget.ui b/src/gui/PasswordGeneratorWidget.ui new file mode 100644 index 00000000..e3cd6d9d --- /dev/null +++ b/src/gui/PasswordGeneratorWidget.ui @@ -0,0 +1,28 @@ + + + PasswordGeneratorWidget + + + + 0 + 0 + 383 + 181 + + + + + + + + + + Password Generator + + + + + + + + diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 7e3d6829..338500a8 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -89,12 +89,15 @@ void EditEntryWidget::setupMain() add(tr("Entry"), m_mainWidget); connect(m_mainUi->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePassword(bool))); + connect(m_mainUi->tooglePasswordGeneratorButton, SIGNAL(toggled(bool)), SLOT(togglePasswordGeneratorButton(bool))); connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool))); connect(m_mainUi->passwordEdit, SIGNAL(textEdited(QString)), SLOT(setPasswordCheckColors())); connect(m_mainUi->passwordRepeatEdit, SIGNAL(textEdited(QString)), SLOT(setPasswordCheckColors())); m_mainUi->expirePresets->setMenu(createPresetsMenu()); connect(m_mainUi->expirePresets->menu(), SIGNAL(triggered(QAction*)), this, SLOT(useExpiryPreset(QAction*))); + + m_mainUi->passwordGenerator->hide(); } void EditEntryWidget::setupAdvanced() @@ -276,6 +279,7 @@ void EditEntryWidget::setForms(const Entry* entry, bool restore) m_mainUi->expireCheck->setEnabled(!m_history); m_mainUi->expireDatePicker->setReadOnly(m_history); m_mainUi->notesEdit->setReadOnly(m_history); + m_mainUi->tooglePasswordGeneratorButton->setChecked(false); m_advancedUi->addAttachmentButton->setEnabled(!m_history); m_advancedUi->removeAttachmentButton->setEnabled(!m_history); m_advancedUi->addAttributeButton->setEnabled(!m_history); @@ -478,6 +482,11 @@ void EditEntryWidget::togglePassword(bool checked) m_mainUi->passwordRepeatEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal); } +void EditEntryWidget::togglePasswordGeneratorButton(bool checked) +{ + m_mainUi->passwordGenerator->setVisible(checked); +} + bool EditEntryWidget::passwordsEqual() { return m_mainUi->passwordEdit->text() == m_mainUi->passwordRepeatEdit->text(); diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h index 07c62467..c4123a16 100644 --- a/src/gui/entry/EditEntryWidget.h +++ b/src/gui/entry/EditEntryWidget.h @@ -63,6 +63,7 @@ public: void createPresetsMenu(QMenu* expirePresetsMenu); QString entryTitle() const; + Q_SIGNALS: void editFinished(bool accepted); void historyEntryActivated(Entry* entry); @@ -71,6 +72,7 @@ private Q_SLOTS: void saveEntry(); void cancel(); void togglePassword(bool checked); + void togglePasswordGeneratorButton(bool checked); void setPasswordCheckColors(); void insertAttribute(); void editCurrentAttribute(); diff --git a/src/gui/entry/EditEntryWidgetMain.ui b/src/gui/entry/EditEntryWidgetMain.ui index bf564038..d61de074 100644 --- a/src/gui/entry/EditEntryWidgetMain.ui +++ b/src/gui/entry/EditEntryWidgetMain.ui @@ -75,28 +75,45 @@ - + Repeat: - - - - QLineEdit::Password - - + + + + + + QLineEdit::Password + + + + + + + Gen. + + + true + + + + - + + + + Expires - + @@ -117,14 +134,14 @@ - + Notes: - + @@ -136,6 +153,14 @@ + + + PasswordGeneratorWidget + QWidget +
gui/PasswordGeneratorWidget.h
+ 1 +
+
titleEdit usernameEdit @@ -143,9 +168,11 @@ passwordEdit passwordRepeatEdit togglePasswordButton + tooglePasswordGeneratorButton expireCheck expireDatePicker expirePresets + notesEdit