From 398201f592e971bc248fb5b8406ef9274da1617f Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Sun, 28 May 2017 20:47:33 +0300 Subject: [PATCH] Add copy button to password generator (#595) --- src/gui/PasswordGeneratorWidget.cpp | 7 +++++++ src/gui/PasswordGeneratorWidget.h | 1 + src/gui/PasswordGeneratorWidget.ui | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index e585b6f58..64aa22da5 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -24,6 +24,7 @@ #include "core/Config.h" #include "core/PasswordGenerator.h" #include "core/FilePath.h" +#include "gui/Clipboard.h" PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent) : QWidget(parent) @@ -40,6 +41,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent) connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updatePasswordStrength(QString))); connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePasswordShown(bool))); connect(m_ui->buttonApply, SIGNAL(clicked()), SLOT(applyPassword())); + connect(m_ui->buttonCopy, SIGNAL(clicked()), SLOT(copyPassword())); connect(m_ui->buttonGenerate, SIGNAL(clicked()), SLOT(regeneratePassword())); connect(m_ui->sliderLength, SIGNAL(valueChanged(int)), SLOT(passwordSliderMoved())); @@ -193,6 +195,11 @@ void PasswordGeneratorWidget::applyPassword() emit dialogTerminated(); } +void PasswordGeneratorWidget::copyPassword() +{ + clipboard()->setText(m_ui->editNewPassword->text()); +} + void PasswordGeneratorWidget::passwordSliderMoved() { if (m_updatingSpinBox) { diff --git a/src/gui/PasswordGeneratorWidget.h b/src/gui/PasswordGeneratorWidget.h index 519f75f54..9fbcdbeb1 100644 --- a/src/gui/PasswordGeneratorWidget.h +++ b/src/gui/PasswordGeneratorWidget.h @@ -57,6 +57,7 @@ signals: private slots: void applyPassword(); + void copyPassword(); void updateApplyEnabled(const QString& password); void updatePasswordStrength(const QString& password); void togglePasswordShown(bool hidden); diff --git a/src/gui/PasswordGeneratorWidget.ui b/src/gui/PasswordGeneratorWidget.ui index a7af3d7f0..0b143b89e 100644 --- a/src/gui/PasswordGeneratorWidget.ui +++ b/src/gui/PasswordGeneratorWidget.ui @@ -612,6 +612,13 @@ QProgressBar::chunk { + + + + Copy + + +