diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts
index 4f11ecb83..098d5ea15 100644
--- a/share/translations/keepassxc_en.ts
+++ b/share/translations/keepassxc_en.ts
@@ -3239,10 +3239,6 @@ Supported extensions are: %1.
EditWidgetIcons
-
-
- Add custom icon
-
Download favicon
@@ -3332,6 +3328,18 @@ Supported extensions are: %1.
+
+
+
+
+
+
+
+
+
+
+
+
EditWidgetProperties
diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp
index 82af65f95..25542730c 100644
--- a/src/gui/EditWidgetIcons.cpp
+++ b/src/gui/EditWidgetIcons.cpp
@@ -32,6 +32,8 @@
#include "gui/IconDownloader.h"
#endif
+#include
+
IconStruct::IconStruct()
: uuid(QUuid())
, number(0)
@@ -78,8 +80,10 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
#endif
// clang-format on
+#ifndef WITH_XC_NETWORKING
m_ui->faviconButton->setVisible(false);
- m_ui->addButton->setEnabled(true);
+ m_ui->faviconURL->setVisible(false);
+#endif
}
EditWidgetIcons::~EditWidgetIcons()
@@ -175,22 +179,36 @@ QMenu* EditWidgetIcons::createApplyIconToMenu()
return applyIconToMenu;
}
+void EditWidgetIcons::keyPressEvent(QKeyEvent* event)
+{
+ if (m_ui->faviconURL->hasFocus() && (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)) {
+ m_ui->faviconButton->animateClick();
+ } else {
+ QWidget::keyPressEvent(event);
+ }
+}
+
void EditWidgetIcons::setUrl(const QString& url)
{
#ifdef WITH_XC_NETWORKING
- m_url = url;
- m_ui->faviconButton->setVisible(!url.isEmpty());
+ QUrl urlCheck(url);
+ if (urlCheck.scheme().startsWith("http")) {
+ m_ui->faviconURL->setText(urlCheck.url(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment));
+ m_ui->faviconURL->setCursorPosition(0);
+ } else {
+ m_ui->faviconURL->setText("");
+ }
#else
Q_UNUSED(url);
- m_ui->faviconButton->setVisible(false);
#endif
}
void EditWidgetIcons::downloadFavicon()
{
#ifdef WITH_XC_NETWORKING
- if (!m_url.isEmpty()) {
- m_downloader->setUrl(m_url);
+ auto url = m_ui->faviconURL->text();
+ if (!url.isEmpty()) {
+ m_downloader->setUrl(url);
m_downloader->download();
}
#endif
diff --git a/src/gui/EditWidgetIcons.h b/src/gui/EditWidgetIcons.h
index 6e134ced6..15e927d6c 100644
--- a/src/gui/EditWidgetIcons.h
+++ b/src/gui/EditWidgetIcons.h
@@ -72,6 +72,9 @@ public:
const QString& url = "");
void setShowApplyIconToButton(bool state);
+protected:
+ void keyPressEvent(QKeyEvent* event) override;
+
public slots:
void setUrl(const QString& url);
void abortRequests();
@@ -102,8 +105,7 @@ private:
DefaultIconModel* const m_defaultIconModel;
CustomIconModel* const m_customIconModel;
#ifdef WITH_XC_NETWORKING
- QScopedPointer m_downloader;
- QString m_url;
+ QSharedPointer m_downloader;
#endif
Q_DISABLE_COPY(EditWidgetIcons)
diff --git a/src/gui/EditWidgetIcons.ui b/src/gui/EditWidgetIcons.ui
index e9fc6fbca..eac83dbb3 100644
--- a/src/gui/EditWidgetIcons.ui
+++ b/src/gui/EditWidgetIcons.ui
@@ -104,11 +104,40 @@
-
-
+
-
- Add custom icon
+ Choose icon…
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 200
+ 0
+
+
+
+ Set the URL to use to search for a favicon
+
+
+ Favicon URL
@@ -174,6 +203,7 @@
customIconsRadio
customIconsView
addButton
+ faviconURL
faviconButton
applyIconToPushButton