From a0d1304bfc78925b6dd5c51f6aa40bddf72b59ec Mon Sep 17 00:00:00 2001 From: Balazs Gyurak Date: Sat, 29 Jun 2019 02:48:25 +0100 Subject: [PATCH] Move notes to General tab on Group Preview Panel (#3336) --- CHANGELOG | 1 + src/cli/Analyze.cpp | 3 +- src/gui/EntryPreviewWidget.cpp | 61 +++++---- src/gui/EntryPreviewWidget.h | 5 +- src/gui/EntryPreviewWidget.ui | 225 +++++++++++++++++++-------------- 5 files changed, 174 insertions(+), 121 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3e8f21ff3..54330a63a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ - Group sorting feature [#3282] - CLI: Add 'flatten' option to the 'ls' command [#3276] - Rework the Entry Preview panel [#3306] +- Move notes to General tab on Group Preview Panel [#3336] 2.4.3 (2019-06-12) ========================= diff --git a/src/cli/Analyze.cpp b/src/cli/Analyze.cpp index 41f9910c5..b600c3c3f 100644 --- a/src/cli/Analyze.cpp +++ b/src/cli/Analyze.cpp @@ -50,7 +50,8 @@ int Analyze::executeWithDatabase(QSharedPointer database, QSharedPoint QString hibpDatabase = parser->value(Analyze::HIBPDatabaseOption); QFile hibpFile(hibpDatabase); if (!hibpFile.open(QFile::ReadOnly)) { - errorTextStream << QObject::tr("Failed to open HIBP file %1: %2").arg(hibpDatabase).arg(hibpFile.errorString()) << endl; + errorTextStream << QObject::tr("Failed to open HIBP file %1: %2").arg(hibpDatabase).arg(hibpFile.errorString()) + << endl; return EXIT_FAILURE; } diff --git a/src/gui/EntryPreviewWidget.cpp b/src/gui/EntryPreviewWidget.cpp index 1e29d2fa0..7ccd54474 100644 --- a/src/gui/EntryPreviewWidget.cpp +++ b/src/gui/EntryPreviewWidget.cpp @@ -50,7 +50,8 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent) m_ui->entryTotpButton->setIcon(filePath()->icon("actions", "chronometer")); m_ui->entryCloseButton->setIcon(filePath()->icon("actions", "dialog-close")); m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show")); - m_ui->toggleNotesButton->setIcon(filePath()->onOffIcon("actions", "password-show")); + m_ui->toggleEntryNotesButton->setIcon(filePath()->onOffIcon("actions", "password-show")); + m_ui->toggleGroupNotesButton->setIcon(filePath()->onOffIcon("actions", "password-show")); m_ui->entryAttachmentsWidget->setReadOnly(true); m_ui->entryAttachmentsWidget->setButtonsVisible(false); @@ -60,7 +61,8 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent) connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpLabel, SLOT(setVisible(bool))); connect(m_ui->entryCloseButton, SIGNAL(clicked()), SLOT(hide())); connect(m_ui->togglePasswordButton, SIGNAL(clicked(bool)), SLOT(setPasswordVisible(bool))); - connect(m_ui->toggleNotesButton, SIGNAL(clicked(bool)), SLOT(setNotesVisible(bool))); + connect(m_ui->toggleEntryNotesButton, SIGNAL(clicked(bool)), SLOT(setEntryNotesVisible(bool))); + connect(m_ui->toggleGroupNotesButton, SIGNAL(clicked(bool)), SLOT(setGroupNotesVisible(bool))); connect(m_ui->entryTabWidget, SIGNAL(tabBarClicked(int)), SLOT(updateTabIndexes()), Qt::QueuedConnection); connect(&m_totpTimer, SIGNAL(timeout()), SLOT(updateTotpLabel())); @@ -107,7 +109,6 @@ void EntryPreviewWidget::setGroup(Group* selectedGroup) m_currentGroup = selectedGroup; updateGroupHeaderLine(); updateGroupGeneralTab(); - updateGroupNotesTab(); #if defined(WITH_XC_KEESHARE) updateGroupSharingTab(); @@ -181,23 +182,31 @@ void EntryPreviewWidget::setPasswordVisible(bool state) } } -void EntryPreviewWidget::setNotesVisible(bool state) +void EntryPreviewWidget::setEntryNotesVisible(bool state) { - const QString notes = m_currentEntry->notes(); + setNotesVisible(m_ui->entryNotesLabel, m_currentEntry->notes(), state); +} - auto flags = m_ui->entryNotesLabel->textInteractionFlags(); +void EntryPreviewWidget::setGroupNotesVisible(bool state) +{ + setNotesVisible(m_ui->groupNotesLabel, m_currentGroup->notes(), state); +} + +void EntryPreviewWidget::setNotesVisible(QLabel* notesLabel, const QString notes, bool state) +{ + auto flags = notesLabel->textInteractionFlags(); if (state) { - m_ui->entryNotesLabel->setText(notes); - m_ui->entryNotesLabel->setToolTip(notes); - m_ui->entryNotesLabel->setTextInteractionFlags(flags | Qt::TextSelectableByMouse); + notesLabel->setText(notes); + notesLabel->setToolTip(notes); + notesLabel->setTextInteractionFlags(flags | Qt::TextSelectableByMouse); } else { if (notes.isEmpty()) { - m_ui->entryNotesLabel->setText(""); + notesLabel->setText(""); } else { - m_ui->entryNotesLabel->setText(QString("\u25cf").repeated(6)); + notesLabel->setText(QString("\u25cf").repeated(6)); } - m_ui->entryNotesLabel->setToolTip({}); - m_ui->entryNotesLabel->setTextInteractionFlags(flags & ~Qt::TextSelectableByMouse); + notesLabel->setToolTip({}); + notesLabel->setTextInteractionFlags(flags & ~Qt::TextSelectableByMouse); } } @@ -219,12 +228,12 @@ void EntryPreviewWidget::updateEntryGeneralTab() } if (config()->get("security/hidenotes").toBool()) { - setNotesVisible(false); - m_ui->toggleNotesButton->setVisible(!m_ui->entryNotesLabel->text().isEmpty()); - m_ui->toggleNotesButton->setChecked(false); + setEntryNotesVisible(false); + m_ui->toggleEntryNotesButton->setVisible(!m_ui->entryNotesLabel->text().isEmpty()); + m_ui->toggleEntryNotesButton->setChecked(false); } else { - setNotesVisible(true); - m_ui->toggleNotesButton->setVisible(false); + setEntryNotesVisible(true); + m_ui->toggleEntryNotesButton->setVisible(false); } m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl()); @@ -307,14 +316,18 @@ void EntryPreviewWidget::updateGroupGeneralTab() const QString expiresText = groupTime.expires() ? groupTime.expiryTime().toString(Qt::DefaultLocaleShortDate) : tr("Never"); m_ui->groupExpirationLabel->setText(expiresText); -} -void EntryPreviewWidget::updateGroupNotesTab() -{ - Q_ASSERT(m_currentGroup); const QString notes = m_currentGroup->notes(); - setTabEnabled(m_ui->groupTabWidget, m_ui->groupNotesTab, !notes.isEmpty()); - m_ui->groupNotesEdit->setText(notes); + m_ui->groupNotesLabel->setText(notes); + + if (config()->get("security/hidenotes").toBool()) { + setGroupNotesVisible(false); + m_ui->toggleGroupNotesButton->setVisible(!m_ui->groupNotesLabel->text().isEmpty()); + m_ui->toggleGroupNotesButton->setChecked(false); + } else { + setGroupNotesVisible(true); + m_ui->toggleGroupNotesButton->setVisible(false); + } } #if defined(WITH_XC_KEESHARE) diff --git a/src/gui/EntryPreviewWidget.h b/src/gui/EntryPreviewWidget.h index c38171524..205b3cbbf 100644 --- a/src/gui/EntryPreviewWidget.h +++ b/src/gui/EntryPreviewWidget.h @@ -52,11 +52,12 @@ private slots: void updateEntryAdvancedTab(); void updateEntryAutotypeTab(); void setPasswordVisible(bool state); - void setNotesVisible(bool state); + void setEntryNotesVisible(bool state); + void setGroupNotesVisible(bool state); + void setNotesVisible(QLabel* notesLabel, const QString notes, bool state); void updateGroupHeaderLine(); void updateGroupGeneralTab(); - void updateGroupNotesTab(); #if defined(WITH_XC_KEESHARE) void updateGroupSharingTab(); #endif diff --git a/src/gui/EntryPreviewWidget.ui b/src/gui/EntryPreviewWidget.ui index 3453de1f8..b2c8c28bf 100644 --- a/src/gui/EntryPreviewWidget.ui +++ b/src/gui/EntryPreviewWidget.ui @@ -463,7 +463,7 @@ Notes - Qt::AlignRight + Qt::AlignTop|Qt::AlignRight @@ -476,7 +476,7 @@ 4 - + @@ -841,8 +841,78 @@ 0 - - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Autotype + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Searching + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + 0 @@ -873,8 +943,18 @@ - - + + + + + 0 + 0 + + + + + + 0 @@ -888,106 +968,63 @@ - Autotype + Notes - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignTop|Qt::AlignRight - - - - - 0 - 0 - + + + + 6 - - - - - - - 0 - 0 - + + 4 - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Searching - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - 0 - 0 - - - + + + + + + + true + + + + + + + + 0 + 0 + + + + + 100 + 30 + + + + notes + + + Qt::AlignTop + + + true + + + + - - - Notes - - - - - - Qt::ClickFocus - - - true - - - - - Share @@ -1106,7 +1143,7 @@ entryCloseButton entryTotpButton togglePasswordButton - toggleNotesButton + toggleEntryNotesButton entryAutotypeTree groupCloseButton groupTabWidget