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

Several UI/UX Fixes #9647

Merged
merged 4 commits into from
Aug 6, 2023
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
4 changes: 4 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3931,6 +3931,10 @@ Error: %1</source>
<source>Disabled</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Double click to copy to clipboard</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EntryURLModel</name>
Expand Down
7 changes: 4 additions & 3 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "gui/group/GroupView.h"
#include "gui/reports/ReportsDialog.h"
#include "gui/tag/TagView.h"
#include "gui/widgets/ElidedLabel.h"
#include "keeshare/KeeShare.h"

#ifdef WITH_XC_NETWORKING
Expand All @@ -73,7 +74,7 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
, m_previewView(new EntryPreviewWidget(this))
, m_previewSplitter(new QSplitter(m_mainWidget))
, m_searchingLabel(new QLabel(this))
, m_shareLabel(new QLabel(this))
, m_shareLabel(new ElidedLabel(this))
, m_csvImportWizard(new CsvImportWizard(this))
, m_editEntryWidget(new EditEntryWidget(this))
, m_editGroupWidget(new EditGroupWidget(this))
Expand Down Expand Up @@ -159,7 +160,7 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)

#ifdef WITH_XC_KEESHARE
m_shareLabel->setObjectName("KeeShareBanner");
m_shareLabel->setText(tr("Shared group…"));
m_shareLabel->setRawText(tr("Shared group…"));
m_shareLabel->setAlignment(Qt::AlignCenter);
m_shareLabel->setVisible(false);
#endif
Expand Down Expand Up @@ -1520,7 +1521,7 @@ void DatabaseWidget::onGroupChanged()
#ifdef WITH_XC_KEESHARE
auto shareLabel = KeeShare::sharingLabel(group);
if (!shareLabel.isEmpty()) {
m_shareLabel->setText(shareLabel);
m_shareLabel->setRawText(shareLabel);
m_shareLabel->setVisible(true);
} else {
m_shareLabel->setVisible(false);
Expand Down
3 changes: 2 additions & 1 deletion src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class QLabel;
class MessageWidget;
class EntryPreviewWidget;
class TagView;
class ElidedLabel;

namespace Ui
{
Expand Down Expand Up @@ -279,7 +280,7 @@ private slots:
QPointer<EntryPreviewWidget> m_previewView;
QPointer<QSplitter> m_previewSplitter;
QPointer<QLabel> m_searchingLabel;
QPointer<QLabel> m_shareLabel;
QPointer<ElidedLabel> m_shareLabel;
QPointer<CsvImportWizard> m_csvImportWizard;
QPointer<EditEntryWidget> m_editEntryWidget;
QPointer<EditGroupWidget> m_editGroupWidget;
Expand Down
27 changes: 23 additions & 4 deletions src/gui/EntryPreviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "keeshare/KeeShareSettings.h"
#endif

#include <QScrollBar>

namespace
{
constexpr int GeneralTabIndex = 0;
Expand Down Expand Up @@ -66,6 +68,8 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
m_ui->entryNotesTextEdit->document()->setDocumentMargin(0);
m_ui->groupNotesTextEdit->document()->setDocumentMargin(0);

m_ui->entryTotpLabel->installEventFilter(this);

connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpLabel, SLOT(setVisible(bool)));
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpProgress, SLOT(setVisible(bool)));
connect(m_ui->entryCloseButton, SIGNAL(clicked()), SLOT(hide()));
Expand Down Expand Up @@ -109,6 +113,18 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)

EntryPreviewWidget::~EntryPreviewWidget() = default;

bool EntryPreviewWidget::eventFilter(QObject* object, QEvent* event)
{
if (object == m_ui->entryTotpLabel && event->type() == QEvent::MouseButtonDblClick) {
if (m_currentEntry && m_currentEntry->hasTotp()) {
clipboard()->setText(m_currentEntry->totp());
m_ui->entryTotpLabel->clearFocus();
return true;
}
}
return QWidget::eventFilter(object, event);
}

void EntryPreviewWidget::clear()
{
hide();
Expand Down Expand Up @@ -286,17 +302,20 @@ void EntryPreviewWidget::setPasswordVisible(bool state)
html += "<span style=\"color: " + QString(color) + ";\">" + QString(c).toHtmlEscaped() + "</span>";
}
// clang-format on
m_ui->entryPasswordLabel->setHtml(html);
m_ui->entryPasswordLabel->setText(html);
} else {
// No color
m_ui->entryPasswordLabel->setPlainText(password);
m_ui->entryPasswordLabel->setText(password);
}
} else if (password.isEmpty() && !config()->get(Config::Security_PasswordEmptyPlaceholder).toBool()) {
m_ui->entryPasswordLabel->setPlainText("");
m_ui->entryPasswordLabel->setText("");
} else {
m_ui->entryPasswordLabel->setPlainText(QString("\u25cf").repeated(6));
m_ui->entryPasswordLabel->setText(QString("\u25cf").repeated(6));
}

m_ui->passwordScrollArea->setMaximumHeight(m_ui->entryPasswordLabel->sizeHint().height()
+ m_ui->passwordScrollArea->horizontalScrollBar()->sizeHint().height());

m_ui->togglePasswordButton->setIcon(icons()->onOffIcon("password-show", state));
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/EntryPreviewWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public slots:
signals:
void entryUrlActivated(Entry* entry);

protected:
bool eventFilter(QObject* object, QEvent* event) override;

private slots:
void updateEntryHeaderLine();
void updateEntryTotp();
Expand Down
Loading