Rework the Entry Preview panel (#3306)

* Add notes to General tab
* Combine Attributes and Attachments tabs into Advanced
* Remove extra viewTotpWidget
* Shrink minimum size of preview panel
This commit is contained in:
Balazs Gyurak 2019-06-23 15:02:02 +01:00 committed by Jonathan White
parent 5492b5c4f6
commit 6dcd00b609
4 changed files with 1158 additions and 959 deletions

View File

@ -2,6 +2,7 @@
========================= =========================
- Group sorting feature [#3282] - Group sorting feature [#3282]
- CLI: Add 'flatten' option to the 'ls' command [#3276] - CLI: Add 'flatten' option to the 'ls' command [#3276]
- Rework the Entry Preview panel [#3306]
2.4.3 (2019-06-12) 2.4.3 (2019-06-12)
========================= =========================

View File

@ -50,15 +50,17 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
m_ui->entryTotpButton->setIcon(filePath()->icon("actions", "chronometer")); m_ui->entryTotpButton->setIcon(filePath()->icon("actions", "chronometer"));
m_ui->entryCloseButton->setIcon(filePath()->icon("actions", "dialog-close")); m_ui->entryCloseButton->setIcon(filePath()->icon("actions", "dialog-close"));
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show")); 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->setReadOnly(true);
m_ui->entryAttachmentsWidget->setButtonsVisible(false); m_ui->entryAttachmentsWidget->setButtonsVisible(false);
connect(m_ui->entryUrlLabel, SIGNAL(linkActivated(QString)), SLOT(openEntryUrl())); 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->entryCloseButton, SIGNAL(clicked()), SLOT(hide()));
connect(m_ui->togglePasswordButton, SIGNAL(clicked(bool)), SLOT(setPasswordVisible(bool))); 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_ui->entryTabWidget, SIGNAL(tabBarClicked(int)), SLOT(updateTabIndexes()), Qt::QueuedConnection);
connect(&m_totpTimer, SIGNAL(timeout()), SLOT(updateTotpLabel())); connect(&m_totpTimer, SIGNAL(timeout()), SLOT(updateTotpLabel()));
@ -84,9 +86,7 @@ void EntryPreviewWidget::setEntry(Entry* selectedEntry)
updateEntryHeaderLine(); updateEntryHeaderLine();
updateEntryTotp(); updateEntryTotp();
updateEntryGeneralTab(); updateEntryGeneralTab();
updateEntryNotesTab(); updateEntryAdvancedTab();
updateEntryAttributesTab();
updateEntryAttachmentsTab();
updateEntryAutotypeTab(); updateEntryAutotypeTab();
setVisible(!config()->get("GUI/HidePreviewPanel").toBool()); setVisible(!config()->get("GUI/HidePreviewPanel").toBool());
@ -150,7 +150,7 @@ void EntryPreviewWidget::updateEntryTotp()
Q_ASSERT(m_currentEntry); Q_ASSERT(m_currentEntry);
const bool hasTotp = m_currentEntry->hasTotp(); const bool hasTotp = m_currentEntry->hasTotp();
m_ui->entryTotpButton->setVisible(hasTotp); m_ui->entryTotpButton->setVisible(hasTotp);
m_ui->entryTotpWidget->hide(); m_ui->entryTotpLabel->hide();
m_ui->entryTotpButton->setChecked(false); m_ui->entryTotpButton->setChecked(false);
if (hasTotp) { 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() void EntryPreviewWidget::updateEntryGeneralTab()
{ {
Q_ASSERT(m_currentEntry); Q_ASSERT(m_currentEntry);
@ -198,6 +218,15 @@ void EntryPreviewWidget::updateEntryGeneralTab()
m_ui->togglePasswordButton->setVisible(false); 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()); m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl());
const QString url = m_currentEntry->url(); const QString url = m_currentEntry->url();
if (!url.isEmpty()) { if (!url.isEmpty()) {
@ -216,23 +245,17 @@ void EntryPreviewWidget::updateEntryGeneralTab()
m_ui->entryExpirationLabel->setText(expires); m_ui->entryExpirationLabel->setText(expires);
} }
void EntryPreviewWidget::updateEntryNotesTab() void EntryPreviewWidget::updateEntryAdvancedTab()
{
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()
{ {
Q_ASSERT(m_currentEntry); Q_ASSERT(m_currentEntry);
m_ui->entryAttributesEdit->clear(); m_ui->entryAttributesEdit->clear();
const EntryAttributes* attributes = m_currentEntry->attributes(); const EntryAttributes* attributes = m_currentEntry->attributes();
const QStringList customAttributes = attributes->customKeys(); const QStringList customAttributes = attributes->customKeys();
const bool haveAttributes = !customAttributes.isEmpty(); const bool hasAttributes = !customAttributes.isEmpty();
setTabEnabled(m_ui->entryTabWidget, m_ui->entryAttributesTab, haveAttributes); const bool hasAttachments = !m_currentEntry->attachments()->isEmpty();
if (haveAttributes) {
setTabEnabled(m_ui->entryTabWidget, m_ui->entryAdvancedTab, hasAttributes || hasAttachments);
if (hasAttributes) {
QString attributesText; QString attributesText;
for (const QString& key : customAttributes) { for (const QString& key : customAttributes) {
QString value = m_currentEntry->attributes()->value(key); QString value = m_currentEntry->attributes()->value(key);
@ -243,13 +266,7 @@ void EntryPreviewWidget::updateEntryAttributesTab()
} }
m_ui->entryAttributesEdit->setText(attributesText); 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()); 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) QString EntryPreviewWidget::hierarchy(const Group* group, const QString& title)
{ {
const QString separator(" / "); const QString separator("] > [");
QStringList hierarchy = group->hierarchy(); QStringList hierarchy = group->hierarchy();
hierarchy.removeFirst(); QString groupList = QString("[%1]").arg(hierarchy.join(separator));
hierarchy.append(title);
return QString("%1%2").arg(separator, hierarchy.join(separator)); return title.isEmpty() ? groupList : QString("%1 > %2").arg(groupList, title);
} }

View File

@ -49,11 +49,10 @@ private slots:
void updateEntryHeaderLine(); void updateEntryHeaderLine();
void updateEntryTotp(); void updateEntryTotp();
void updateEntryGeneralTab(); void updateEntryGeneralTab();
void updateEntryNotesTab(); void updateEntryAdvancedTab();
void updateEntryAttributesTab();
void updateEntryAttachmentsTab();
void updateEntryAutotypeTab(); void updateEntryAutotypeTab();
void setPasswordVisible(bool state); void setPasswordVisible(bool state);
void setNotesVisible(bool state);
void updateGroupHeaderLine(); void updateGroupHeaderLine();
void updateGroupGeneralTab(); void updateGroupGeneralTab();

File diff suppressed because it is too large Load Diff