diff --git a/src/gui/EntryPreviewWidget.cpp b/src/gui/EntryPreviewWidget.cpp
index af8c1cd2..e46e3a66 100644
--- a/src/gui/EntryPreviewWidget.cpp
+++ b/src/gui/EntryPreviewWidget.cpp
@@ -58,6 +58,15 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
m_ui->entryAttachmentsWidget->setReadOnly(true);
m_ui->entryAttachmentsWidget->setButtonsVisible(false);
+ // Match background of read-only text edit fields with the window
+ m_ui->entryPasswordLabel->setBackgroundRole(QPalette::Window);
+ m_ui->entryUsernameLabel->setBackgroundRole(QPalette::Window);
+ m_ui->entryNotesTextEdit->setBackgroundRole(QPalette::Window);
+ m_ui->groupNotesTextEdit->setBackgroundRole(QPalette::Window);
+ // Align notes text with label text
+ m_ui->entryNotesTextEdit->document()->setDocumentMargin(0);
+ m_ui->groupNotesTextEdit->document()->setDocumentMargin(0);
+
connect(m_ui->entryUrlLabel, SIGNAL(linkActivated(QString)), SLOT(openEntryUrl()));
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpLabel, SLOT(setVisible(bool)));
@@ -173,44 +182,35 @@ void EntryPreviewWidget::setPasswordVisible(bool state)
{
const QString password = m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->password());
if (state) {
- m_ui->entryPasswordLabel->setRawText(password);
- m_ui->entryPasswordLabel->setToolTip(password);
- m_ui->entryPasswordLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ m_ui->entryPasswordLabel->setText(password);
+ m_ui->entryPasswordLabel->setCursorPosition(0);
+ } else if (password.isEmpty() && config()->get("security/passwordemptynodots").toBool()) {
+ m_ui->entryPasswordLabel->setText("");
} else {
- m_ui->entryPasswordLabel->setTextInteractionFlags(Qt::NoTextInteraction);
- m_ui->entryPasswordLabel->setToolTip({});
- if (password.isEmpty() && config()->get("security/passwordemptynodots").toBool()) {
- m_ui->entryPasswordLabel->setRawText("");
- } else {
- m_ui->entryPasswordLabel->setRawText(QString("\u25cf").repeated(6));
- }
+ m_ui->entryPasswordLabel->setText(QString("\u25cf").repeated(6));
}
}
void EntryPreviewWidget::setEntryNotesVisible(bool state)
{
- setNotesVisible(m_ui->entryNotesLabel, m_currentEntry->notes(), state);
+ setNotesVisible(m_ui->entryNotesTextEdit, m_currentEntry->notes(), state);
}
void EntryPreviewWidget::setGroupNotesVisible(bool state)
{
- setNotesVisible(m_ui->groupNotesLabel, m_currentGroup->notes(), state);
+ setNotesVisible(m_ui->groupNotesTextEdit, m_currentGroup->notes(), state);
}
-void EntryPreviewWidget::setNotesVisible(QLabel* notesLabel, const QString& notes, bool state)
+void EntryPreviewWidget::setNotesVisible(QTextEdit* notesWidget, const QString& notes, bool state)
{
if (state) {
- // Add html hyperlinks to notes that start with XXXX://
- QString hyperlinkNotes = notes;
- notesLabel->setText(hyperlinkNotes.replace(QRegExp("(\\w+:\\/\\/\\S+)"), "\\1"));
- notesLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ notesWidget->setPlainText(notes);
+ notesWidget->moveCursor(QTextCursor::Start);
+ notesWidget->ensureCursorVisible();
} else {
- if (notes.isEmpty()) {
- notesLabel->setText("");
- } else {
- notesLabel->setText(QString("\u25cf").repeated(6));
+ if (!notes.isEmpty()) {
+ notesWidget->setPlainText(QString("\u25cf").repeated(6));
}
- notesLabel->setTextInteractionFlags(Qt::NoTextInteraction);
}
}
@@ -218,12 +218,13 @@ void EntryPreviewWidget::updateEntryGeneralTab()
{
Q_ASSERT(m_currentEntry);
m_ui->entryUsernameLabel->setText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->username()));
+ m_ui->entryUsernameLabel->setCursorPosition(0);
if (config()->get("security/HidePasswordPreviewPanel").toBool()) {
// Hide password
setPasswordVisible(false);
// Show the password toggle button if there are dots in the label
- m_ui->togglePasswordButton->setVisible(!m_ui->entryPasswordLabel->rawText().isEmpty());
+ m_ui->togglePasswordButton->setVisible(!m_ui->entryPasswordLabel->text().isEmpty());
m_ui->togglePasswordButton->setChecked(false);
} else {
// Show password
@@ -233,7 +234,7 @@ void EntryPreviewWidget::updateEntryGeneralTab()
if (config()->get("security/hidenotes").toBool()) {
setEntryNotesVisible(false);
- m_ui->toggleEntryNotesButton->setVisible(!m_ui->entryNotesLabel->text().isEmpty());
+ m_ui->toggleEntryNotesButton->setVisible(!m_ui->entryNotesTextEdit->toPlainText().isEmpty());
m_ui->toggleEntryNotesButton->setChecked(false);
} else {
setEntryNotesVisible(true);
@@ -241,9 +242,9 @@ void EntryPreviewWidget::updateEntryGeneralTab()
}
if (config()->get("GUI/MonospaceNotes", false).toBool()) {
- m_ui->entryNotesLabel->setFont(Font::fixedFont());
+ m_ui->entryNotesTextEdit->setFont(Font::fixedFont());
} else {
- m_ui->entryNotesLabel->setFont(Font::defaultFont());
+ m_ui->entryNotesTextEdit->setFont(Font::defaultFont());
}
m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl());
@@ -329,7 +330,7 @@ void EntryPreviewWidget::updateGroupGeneralTab()
if (config()->get("security/hidenotes").toBool()) {
setGroupNotesVisible(false);
- m_ui->toggleGroupNotesButton->setVisible(!m_ui->groupNotesLabel->text().isEmpty());
+ m_ui->toggleGroupNotesButton->setVisible(!m_ui->groupNotesTextEdit->toPlainText().isEmpty());
m_ui->toggleGroupNotesButton->setChecked(false);
} else {
setGroupNotesVisible(true);
@@ -337,9 +338,9 @@ void EntryPreviewWidget::updateGroupGeneralTab()
}
if (config()->get("GUI/MonospaceNotes", false).toBool()) {
- m_ui->groupNotesLabel->setFont(Font::fixedFont());
+ m_ui->groupNotesTextEdit->setFont(Font::fixedFont());
} else {
- m_ui->groupNotesLabel->setFont(Font::defaultFont());
+ m_ui->groupNotesTextEdit->setFont(Font::defaultFont());
}
}
diff --git a/src/gui/EntryPreviewWidget.h b/src/gui/EntryPreviewWidget.h
index 0887c49d..e8e7d217 100644
--- a/src/gui/EntryPreviewWidget.h
+++ b/src/gui/EntryPreviewWidget.h
@@ -28,6 +28,8 @@ namespace Ui
class EntryPreviewWidget;
}
+class QTextEdit;
+
class EntryPreviewWidget : public QWidget
{
Q_OBJECT
@@ -54,7 +56,7 @@ private slots:
void setPasswordVisible(bool state);
void setEntryNotesVisible(bool state);
void setGroupNotesVisible(bool state);
- void setNotesVisible(QLabel* notesLabel, const QString& notes, bool state);
+ void setNotesVisible(QTextEdit* notesWidget, const QString& notes, bool state);
void updateGroupHeaderLine();
void updateGroupGeneralTab();
diff --git a/src/gui/EntryPreviewWidget.ui b/src/gui/EntryPreviewWidget.ui
index 124923a7..4ac3702d 100644
--- a/src/gui/EntryPreviewWidget.ui
+++ b/src/gui/EntryPreviewWidget.ui
@@ -159,7 +159,7 @@
-
-
+
0
@@ -172,151 +172,6 @@
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
-
-
-
-
-
@@ -339,6 +194,22 @@
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 20
+ 20
+
+
+
+
-
@@ -358,28 +229,34 @@
-
-
-
-
- 0
- 0
-
-
+
- 100
+ 150
0
+
+ Qt::ClickFocus
+
password
+
+ false
+
+
+ true
+
+
+ true
+
- -
-
+
-
+
Qt::Horizontal
@@ -394,6 +271,56 @@
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 150
+ 0
+
+
+
+ PointingHandCursor
+
+
+ Qt::ClickFocus
+
+
+ https://example.com
+
+
+ Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 75
+ true
+
+
+
+ Notes
+
+
+ Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing
+
+
+
-
@@ -445,27 +372,21 @@
- -
-
-
-
- 0
- 0
-
+
-
+
+
+ Qt::Horizontal
-
-
- 75
- true
-
+
+ QSizePolicy::Fixed
-
- Notes
+
+
+ 20
+ 30
+
-
- Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing
-
-
+
-
@@ -486,41 +407,120 @@
-
-
-
-
- 0
- 0
-
+
+
+ Qt::ClickFocus
-
-
- 100
- 30
-
+
+ QFrame::NoFrame
-
- notes
+
+ QFrame::Plain
-
- Qt::RichText
+
+ 0
-
- Qt::AlignTop
-
-
+
true
-
+
true
-
- Qt::NoTextInteraction
-
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 75
+ true
+
+
+
+ Qt::LeftToRight
+
+
+ Username
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 10
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 75
+ true
+
+
+
+ URL
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 150
+ 0
+
+
+
+ Qt::ClickFocus
+
+
+ username
+
+
+ false
+
+
+ 8
+
+
+ true
+
+
+ true
+
+
+
@@ -1003,26 +1003,23 @@
-
-
-
-
- 0
- 0
-
+
+
+ Qt::ClickFocus
-
-
- 100
- 30
-
+
+ QFrame::NoFrame
-
- notes
+
+ QFrame::Plain
-
- Qt::AlignTop
+
+ 0
-
+
+ true
+
+
true