Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move notes to General tab on Group Preview Panel #3336

Merged
merged 2 commits into from
Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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)
=========================
Expand Down
3 changes: 2 additions & 1 deletion src/cli/Analyze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ int Analyze::executeWithDatabase(QSharedPointer<Database> 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;
}

Expand Down
61 changes: 37 additions & 24 deletions src/gui/EntryPreviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()));

Expand Down Expand Up @@ -107,7 +109,6 @@ void EntryPreviewWidget::setGroup(Group* selectedGroup)
m_currentGroup = selectedGroup;
updateGroupHeaderLine();
updateGroupGeneralTab();
updateGroupNotesTab();

#if defined(WITH_XC_KEESHARE)
updateGroupSharingTab();
Expand Down Expand Up @@ -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);
}

void EntryPreviewWidget::setGroupNotesVisible(bool state)
{
setNotesVisible(m_ui->groupNotesLabel, m_currentGroup->notes(), state);
}

auto flags = m_ui->entryNotesLabel->textInteractionFlags();
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);
}
}

Expand All @@ -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());
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/gui/EntryPreviewWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading