diff --git a/CHANGELOG b/CHANGELOG index 043fe67c5..3e8f21ff3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ ========================= - Group sorting feature [#3282] - CLI: Add 'flatten' option to the 'ls' command [#3276] +- Rework the Entry Preview panel [#3306] 2.4.3 (2019-06-12) ========================= diff --git a/src/gui/EntryPreviewWidget.cpp b/src/gui/EntryPreviewWidget.cpp index 42f164fba..1e29d2fa0 100644 --- a/src/gui/EntryPreviewWidget.cpp +++ b/src/gui/EntryPreviewWidget.cpp @@ -50,15 +50,17 @@ 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->entryAttachmentsWidget->setReadOnly(true); m_ui->entryAttachmentsWidget->setButtonsVisible(false); connect(m_ui->entryUrlLabel, SIGNAL(linkActivated(QString)), SLOT(openEntryUrl())); - connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpWidget, SLOT(setVisible(bool))); + 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->entryTabWidget, SIGNAL(tabBarClicked(int)), SLOT(updateTabIndexes()), Qt::QueuedConnection); connect(&m_totpTimer, SIGNAL(timeout()), SLOT(updateTotpLabel())); @@ -84,9 +86,7 @@ void EntryPreviewWidget::setEntry(Entry* selectedEntry) updateEntryHeaderLine(); updateEntryTotp(); updateEntryGeneralTab(); - updateEntryNotesTab(); - updateEntryAttributesTab(); - updateEntryAttachmentsTab(); + updateEntryAdvancedTab(); updateEntryAutotypeTab(); setVisible(!config()->get("GUI/HidePreviewPanel").toBool()); @@ -150,7 +150,7 @@ void EntryPreviewWidget::updateEntryTotp() Q_ASSERT(m_currentEntry); const bool hasTotp = m_currentEntry->hasTotp(); m_ui->entryTotpButton->setVisible(hasTotp); - m_ui->entryTotpWidget->hide(); + m_ui->entryTotpLabel->hide(); m_ui->entryTotpButton->setChecked(false); if (hasTotp) { @@ -181,6 +181,26 @@ void EntryPreviewWidget::setPasswordVisible(bool state) } } +void EntryPreviewWidget::setNotesVisible(bool state) +{ + const QString notes = m_currentEntry->notes(); + + auto flags = m_ui->entryNotesLabel->textInteractionFlags(); + if (state) { + m_ui->entryNotesLabel->setText(notes); + m_ui->entryNotesLabel->setToolTip(notes); + m_ui->entryNotesLabel->setTextInteractionFlags(flags | Qt::TextSelectableByMouse); + } else { + if (notes.isEmpty()) { + m_ui->entryNotesLabel->setText(""); + } else { + m_ui->entryNotesLabel->setText(QString("\u25cf").repeated(6)); + } + m_ui->entryNotesLabel->setToolTip({}); + m_ui->entryNotesLabel->setTextInteractionFlags(flags & ~Qt::TextSelectableByMouse); + } +} + void EntryPreviewWidget::updateEntryGeneralTab() { Q_ASSERT(m_currentEntry); @@ -198,6 +218,15 @@ void EntryPreviewWidget::updateEntryGeneralTab() m_ui->togglePasswordButton->setVisible(false); } + if (config()->get("security/hidenotes").toBool()) { + setNotesVisible(false); + m_ui->toggleNotesButton->setVisible(!m_ui->entryNotesLabel->text().isEmpty()); + m_ui->toggleNotesButton->setChecked(false); + } else { + setNotesVisible(true); + m_ui->toggleNotesButton->setVisible(false); + } + m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl()); const QString url = m_currentEntry->url(); if (!url.isEmpty()) { @@ -216,23 +245,17 @@ void EntryPreviewWidget::updateEntryGeneralTab() m_ui->entryExpirationLabel->setText(expires); } -void EntryPreviewWidget::updateEntryNotesTab() -{ - Q_ASSERT(m_currentEntry); - const QString notes = m_currentEntry->notes(); - setTabEnabled(m_ui->entryTabWidget, m_ui->entryNotesTab, !notes.isEmpty()); - m_ui->entryNotesEdit->setText(notes); -} - -void EntryPreviewWidget::updateEntryAttributesTab() +void EntryPreviewWidget::updateEntryAdvancedTab() { Q_ASSERT(m_currentEntry); m_ui->entryAttributesEdit->clear(); const EntryAttributes* attributes = m_currentEntry->attributes(); const QStringList customAttributes = attributes->customKeys(); - const bool haveAttributes = !customAttributes.isEmpty(); - setTabEnabled(m_ui->entryTabWidget, m_ui->entryAttributesTab, haveAttributes); - if (haveAttributes) { + const bool hasAttributes = !customAttributes.isEmpty(); + const bool hasAttachments = !m_currentEntry->attachments()->isEmpty(); + + setTabEnabled(m_ui->entryTabWidget, m_ui->entryAdvancedTab, hasAttributes || hasAttachments); + if (hasAttributes) { QString attributesText; for (const QString& key : customAttributes) { QString value = m_currentEntry->attributes()->value(key); @@ -243,13 +266,7 @@ void EntryPreviewWidget::updateEntryAttributesTab() } m_ui->entryAttributesEdit->setText(attributesText); } -} -void EntryPreviewWidget::updateEntryAttachmentsTab() -{ - Q_ASSERT(m_currentEntry); - const bool hasAttachments = !m_currentEntry->attachments()->isEmpty(); - setTabEnabled(m_ui->entryTabWidget, m_ui->entryAttachmentsTab, hasAttachments); m_ui->entryAttachmentsWidget->setEntryAttachments(m_currentEntry->attachments()); } @@ -354,9 +371,9 @@ QPixmap EntryPreviewWidget::preparePixmap(const QPixmap& pixmap, int size) QString EntryPreviewWidget::hierarchy(const Group* group, const QString& title) { - const QString separator(" / "); + const QString separator("] > ["); QStringList hierarchy = group->hierarchy(); - hierarchy.removeFirst(); - hierarchy.append(title); - return QString("%1%2").arg(separator, hierarchy.join(separator)); + QString groupList = QString("[%1]").arg(hierarchy.join(separator)); + + return title.isEmpty() ? groupList : QString("%1 > %2").arg(groupList, title); } diff --git a/src/gui/EntryPreviewWidget.h b/src/gui/EntryPreviewWidget.h index 6a50c0feb..c38171524 100644 --- a/src/gui/EntryPreviewWidget.h +++ b/src/gui/EntryPreviewWidget.h @@ -49,11 +49,10 @@ private slots: void updateEntryHeaderLine(); void updateEntryTotp(); void updateEntryGeneralTab(); - void updateEntryNotesTab(); - void updateEntryAttributesTab(); - void updateEntryAttachmentsTab(); + void updateEntryAdvancedTab(); void updateEntryAutotypeTab(); void setPasswordVisible(bool state); + void setNotesVisible(bool state); void updateGroupHeaderLine(); void updateGroupGeneralTab(); diff --git a/src/gui/EntryPreviewWidget.ui b/src/gui/EntryPreviewWidget.ui index 8322946bb..3453de1f8 100644 --- a/src/gui/EntryPreviewWidget.ui +++ b/src/gui/EntryPreviewWidget.ui @@ -1,934 +1,1116 @@ - EntryPreviewWidget - - - - 0 - 0 - 573 - 330 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QLayout::SetDefaultConstraint - - - 9 - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - 12 - - - - Qt::AutoText - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - - - 0 - - - 0 - - - - - - 10 - 75 - true - - - - - - - - - - - - - - Qt::ClickFocus - - - Generate TOTP Token - - - - - - true - - - - - - - Qt::ClickFocus - - - Close - - - - - - - - - - - - Qt::ClickFocus - - - 0 - - - false - - - false - - - false - - - - General - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Qt::LeftToRight - - - Username - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - username - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Password - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Expiration - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - PointingHandCursor - - - https://example.com - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse - - - - - - - - 0 - 0 - - - - expired - - - - - - - - 0 - 0 - - - - - 75 - true - - - - URL - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 6 - - - 4 - - - - - - - - true - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - password - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - - - - Attributes - - - - - - Qt::ClickFocus - - - true - - - - - - - - Attachments - - - - - - - - - - Notes - - - - - - Qt::ClickFocus - - - true - - - - - - - - Autotype - - - - - - QFrame::Sunken - - - true - - - true - - - false - - - 2 - - - false - - - 250 - - - 50 - - - true - - - - Window - - - - - Sequence - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QLayout::SetDefaultConstraint - - - 9 - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - 12 - - - - Qt::AutoText - - - - - - - Close - - - - - - - - - - - - 0 - - - false - - - false - - - false - - - - General - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Expiration - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Autotype - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Searching - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - - - - - Notes - - - - - - Qt::ClickFocus - - - true - - - - - - - - Share - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - <path> - - - - - - - - 75 - true - - - - <type> - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - 20 - 147 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - - - - - - - + EntryPreviewWidget + + + + 0 + 0 + 566 + 169 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QLayout::SetDefaultConstraint + + + 9 + + + + + + 0 + 0 + + + + + 16 + 0 + + + + + + + + + + + + 0 + 0 + + + + + 12 + + + + Qt::AutoText + + + + + + + + 10 + 75 + true + + + + 1234567 + + + + + + + Qt::TabFocus + + + Display current TOTP value + + + + + + true + + + + + + + Qt::TabFocus + + + Close + + + + + + - - - Search - - - - - Clear - - + + + + + Qt::ClickFocus + + + 0 + + + false + + + false + + + false + + + + General + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Qt::LeftToRight + + + Username + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + username + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + URL + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + PointingHandCursor + + + Qt::ClickFocus + + + https://example.com + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 30 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Password + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 6 + + + 4 + + + + + + + + true + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + password + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Expiration + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + expired + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Notes + + + Qt::AlignRight + + + + + + + 6 + + + 4 + + + + + + + + true + + + + + + + + 0 + 0 + + + + + 100 + 30 + + + + notes + + + Qt::AlignTop + + + true + + + + + + + + + + + + + Advanced + + + + 0 + + + 5 + + + 0 + + + 5 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Attributes + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Attachments + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + Qt::ClickFocus + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + Qt::ClickFocus + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + + Autotype + + + + + + Qt::ClickFocus + + + QFrame::Sunken + + + true + + + true + + + false + + + 2 + + + false + + + 50 + + + 250 + + + true + + + + Window + + + + + Sequence + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QLayout::SetDefaultConstraint + + + 9 + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + + 12 + + + + Qt::AutoText + + + + + + + Close + + + + + + + + + + + + 0 + + + false + + + false + + + false + + + + General + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Expiration + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Autotype + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Searching + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + + + + Notes + + + + + + Qt::ClickFocus + + + true + + + + + + + + Share + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + <path> + + + + + + + + 75 + true + + + + <type> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + 20 + 147 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + + - - - EntryAttachmentsWidget - QWidget -
gui/entry/EntryAttachmentsWidget.h
- 1 -
- - ElidedLabel - QLabel -
gui/widgets/ElidedLabel.h
-
-
- - entryTotpButton - entryAutotypeTree - entryTabWidget - groupCloseButton - groupTabWidget - - - +
+
+ + + Search + + + + + Clear + + +
+ + + EntryAttachmentsWidget + QWidget +
gui/entry/EntryAttachmentsWidget.h
+ 1 +
+ + ElidedLabel + QLabel +
gui/widgets/ElidedLabel.h
+
+
+ + entryCloseButton + entryTotpButton + togglePasswordButton + toggleNotesButton + entryAutotypeTree + groupCloseButton + groupTabWidget + + +