mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-23 13:11:12 -05:00
Add url field to download favicon
This commit is contained in:
parent
12d16f67ae
commit
456726556d
@ -3239,10 +3239,6 @@ Supported extensions are: %1.</source>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditWidgetIcons</name>
|
||||
<message>
|
||||
<source>Add custom icon</source>
|
||||
<translation>Add custom icon</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download favicon</source>
|
||||
<translation>Download favicon</translation>
|
||||
@ -3332,6 +3328,18 @@ Supported extensions are: %1.</source>
|
||||
<source>Apply icon to…</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose icon…</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Set the URL to use to search for a favicon</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Favicon URL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditWidgetProperties</name>
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "gui/IconDownloader.h"
|
||||
#endif
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
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
|
||||
|
@ -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<IconDownloader> m_downloader;
|
||||
QString m_url;
|
||||
QSharedPointer<IconDownloader> m_downloader;
|
||||
#endif
|
||||
|
||||
Q_DISABLE_COPY(EditWidgetIcons)
|
||||
|
@ -104,11 +104,40 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="customIconButtonsHorizontalLayout">
|
||||
<layout class="QHBoxLayout" name="customIconButtonsHorizontalLayout" stretch="0,0,0,0">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
<string>Add custom icon</string>
|
||||
<string>Choose icon…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="faviconURL">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set the URL to use to search for a favicon</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Favicon URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -174,6 +203,7 @@
|
||||
<tabstop>customIconsRadio</tabstop>
|
||||
<tabstop>customIconsView</tabstop>
|
||||
<tabstop>addButton</tabstop>
|
||||
<tabstop>faviconURL</tabstop>
|
||||
<tabstop>faviconButton</tabstop>
|
||||
<tabstop>applyIconToPushButton</tabstop>
|
||||
</tabstops>
|
||||
|
Loading…
Reference in New Issue
Block a user