Move notes to General tab on Group Preview Panel (#3336)

This commit is contained in:
Balazs Gyurak 2019-06-29 02:48:25 +01:00 committed by Jonathan White
parent 0e0cba653f
commit a0d1304bfc
5 changed files with 174 additions and 121 deletions

View File

@ -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)
=========================

View File

@ -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;
}

View File

@ -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)

View File

@ -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

View File

@ -463,7 +463,7 @@
<string>Notes</string>
</property>
<property name="alignment">
<set>Qt::AlignRight</set>
<set>Qt::AlignTop|Qt::AlignRight</set>
</property>
</widget>
</item>
@ -476,7 +476,7 @@
<number>4</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="QToolButton" name="toggleNotesButton">
<widget class="QToolButton" name="toggleEntryNotesButton">
<property name="text">
<string/>
</property>
@ -841,8 +841,78 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="2">
<widget class="QLabel" name="groupExpirationLabel">
<item row="0" column="0">
<spacer name="groupLeftHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="groupAutotypeTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Autotype</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="groupAutotypeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="groupSearchingTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Searching</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="groupSearchingLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -873,8 +943,18 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="groupAutotypeTitleLabel">
<item row="2" column="3">
<widget class="QLabel" name="groupExpirationLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="groupNotesTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -888,106 +968,63 @@
</font>
</property>
<property name="text">
<string>Autotype</string>
<string>Notes</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignTop|Qt::AlignRight</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="groupAutotypeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="3" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0">
<property name="spacing">
<number>6</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="groupSearchingLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="leftMargin">
<number>4</number>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="groupLeftHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="groupSearchingTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Searching</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
<item alignment="Qt::AlignTop">
<widget class="QToolButton" name="toggleGroupNotesButton">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="groupNotesLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="text">
<string notr="true">notes</string>
</property>
<property name="alignment">
<set>Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="groupNotesTab">
<attribute name="title">
<string>Notes</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QTextEdit" name="groupNotesEdit">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="groupShareTab">
<attribute name="title">
<string>Share</string>
@ -1106,7 +1143,7 @@
<tabstop>entryCloseButton</tabstop>
<tabstop>entryTotpButton</tabstop>
<tabstop>togglePasswordButton</tabstop>
<tabstop>toggleNotesButton</tabstop>
<tabstop>toggleEntryNotesButton</tabstop>
<tabstop>entryAutotypeTree</tabstop>
<tabstop>groupCloseButton</tabstop>
<tabstop>groupTabWidget</tabstop>