From 0e6fedc056f2f03400a3048c71c2faefd278f2df Mon Sep 17 00:00:00 2001 From: thez3ro Date: Thu, 31 Aug 2017 00:52:05 +0200 Subject: [PATCH] fix group parent, add details update by keyboard --- src/core/Group.cpp | 10 +++++--- src/gui/DatabaseWidget.cpp | 4 +-- src/gui/DetailsWidget.cpp | 52 ++++++++++++++++++++++---------------- src/gui/DetailsWidget.h | 2 +- src/gui/DetailsWidget.ui | 38 +++------------------------- 5 files changed, 43 insertions(+), 63 deletions(-) diff --git a/src/core/Group.cpp b/src/core/Group.cpp index fa48d8ce..1fee54a4 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -439,10 +439,14 @@ QStringList Group::hierarchy() { QStringList hierarchy; Group* group = this; - while (group->parentGroup()) { - hierarchy << group->name(); - + Group* parent = m_parent; + hierarchy << group->name(); + + while (parent) { group = group->parentGroup(); + parent = group->parentGroup(); + + hierarchy << group->name(); } return hierarchy; } diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 0b83002e..6571668c 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -193,9 +193,9 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged())); connect(m_groupView, SIGNAL(groupPressed(Group*)), SLOT(emitPressedGroup(Group*))); - //connect(m_groupView, SIGNAL(groupChanged(Group*)), SLOT(emitPressedGroup(Group*))); + connect(m_groupView, SIGNAL(groupChanged(Group*)), SLOT(emitPressedGroup(Group*))); connect(m_entryView, SIGNAL(entryPressed(Entry*)), SLOT(emitPressedEntry(Entry*))); - //connect(m_entryView, SIGNAL(entrySelectionChanged()), SLOT(emitPressedEntry())); + connect(m_entryView, SIGNAL(entrySelectionChanged()), SLOT(emitPressedEntry())); connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(emitPressedEntry())); m_databaseModified = false; diff --git a/src/gui/DetailsWidget.cpp b/src/gui/DetailsWidget.cpp index d506d551..ee051e9c 100644 --- a/src/gui/DetailsWidget.cpp +++ b/src/gui/DetailsWidget.cpp @@ -24,6 +24,7 @@ #include "core/Config.h" #include "core/FilePath.h" #include "core/TimeInfo.h" +#include "gui/Clipboard.h" DetailsWidget::DetailsWidget(QWidget* parent) : QWidget(parent) @@ -38,11 +39,9 @@ DetailsWidget::DetailsWidget(QWidget* parent) m_ui->totpButton->setIcon(filePath()->icon("actions", "chronometer")); m_ui->closeButton->setIcon(filePath()->icon("actions", "dialog-close")); - m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show")); connect(m_ui->totpButton, SIGNAL(toggled(bool)), SLOT(showTotp(bool))); connect(m_ui->closeButton, SIGNAL(toggled(bool)), SLOT(hideDetails())); - connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePasswordShown(bool))); this->hide(); } @@ -67,25 +66,31 @@ void DetailsWidget::getSelectedEntry(Entry* selectedEntry) m_ui->entryIcon->setPixmap(m_currentEntry->iconPixmap()); - QStringList hierarchy = m_currentEntry->group()->hierarchy(); QString title = " / "; - for (QString parent : hierarchy) { - title.append(parent); - title.append(" / "); + + Group* entry_group = m_currentEntry->group(); + if (entry_group) { + QStringList hierarchy = entry_group->hierarchy(); + + for (QString parent : hierarchy) { + title.append(parent); + title.append(" / "); + } } - title.append(m_currentEntry->title()); + title.append(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->title())); m_ui->titleLabel->setText(title); - m_ui->usernameLabel->setText(m_currentEntry->username()); - m_ui->groupLabel->setText(m_currentEntry->group()->name()); - m_ui->notesEdit->setText(m_currentEntry->notes()); + m_ui->usernameLabel->setText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->username())); + if (entry_group) { + m_ui->groupLabel->setText(entry_group->name()); + } + m_ui->notesEdit->setText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->notes())); if (!config()->get("security/hidepassworddetails").toBool()) { - m_ui->passwordEdit->setText(m_currentEntry->password()); - m_ui->togglePasswordButton->show(); + m_ui->passwordLabel->setText(shortPassword(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->password()))); + m_ui->passwordLabel->setToolTip(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->password())); } else { - m_ui->passwordEdit->setText("****"); - m_ui->togglePasswordButton->hide(); + m_ui->passwordLabel->setText("****"); } QString url = m_currentEntry->webUrl(); @@ -199,15 +204,18 @@ QString DetailsWidget::shortUrl(QString url) return url; } +QString DetailsWidget::shortPassword(QString password) +{ + QString newpassword = ""; + if (password.length() > 60) { + newpassword.append(password.left(50)); + newpassword.append("..."); + return newpassword; + } + return password; +} + void DetailsWidget::hideDetails() { this->hide(); } - -void DetailsWidget::togglePasswordShown(bool showing) -{ - m_ui->passwordEdit->setShowPassword(showing); - bool blockSignals = m_ui->togglePasswordButton->blockSignals(true); - m_ui->togglePasswordButton->setChecked(showing); - m_ui->togglePasswordButton->blockSignals(blockSignals); -} \ No newline at end of file diff --git a/src/gui/DetailsWidget.h b/src/gui/DetailsWidget.h index 89e6cf62..d4accf08 100644 --- a/src/gui/DetailsWidget.h +++ b/src/gui/DetailsWidget.h @@ -46,7 +46,6 @@ private slots: void showTotp(bool visible); void updateTotp(); void hideDetails(); - void togglePasswordShown(bool showing); private: const QScopedPointer m_ui; @@ -55,6 +54,7 @@ private: quint8 m_step; QTimer* m_timer; QString shortUrl(QString url); + QString shortPassword(QString password); }; #endif // KEEPASSX_DETAILSWIDGET_H diff --git a/src/gui/DetailsWidget.ui b/src/gui/DetailsWidget.ui index fb6b7fb2..b4c3150f 100644 --- a/src/gui/DetailsWidget.ui +++ b/src/gui/DetailsWidget.ui @@ -235,33 +235,6 @@ - - - - - - - 0 - 0 - - - - 999 - - - true - - - - - - - true - - - - - @@ -275,6 +248,9 @@ + + + @@ -539,14 +515,6 @@ - - - PasswordEdit - QLineEdit -
gui/PasswordEdit.h
- 1 -
-