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>
|
||||||
<context>
|
<context>
|
||||||
<name>EditWidgetIcons</name>
|
<name>EditWidgetIcons</name>
|
||||||
<message>
|
|
||||||
<source>Add custom icon</source>
|
|
||||||
<translation>Add custom icon</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Download favicon</source>
|
<source>Download favicon</source>
|
||||||
<translation>Download favicon</translation>
|
<translation>Download favicon</translation>
|
||||||
@ -3332,6 +3328,18 @@ Supported extensions are: %1.</source>
|
|||||||
<source>Apply icon to…</source>
|
<source>Apply icon to…</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</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>
|
||||||
<context>
|
<context>
|
||||||
<name>EditWidgetProperties</name>
|
<name>EditWidgetProperties</name>
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include "gui/IconDownloader.h"
|
#include "gui/IconDownloader.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
IconStruct::IconStruct()
|
IconStruct::IconStruct()
|
||||||
: uuid(QUuid())
|
: uuid(QUuid())
|
||||||
, number(0)
|
, number(0)
|
||||||
@ -78,8 +80,10 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
|
|||||||
#endif
|
#endif
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
#ifndef WITH_XC_NETWORKING
|
||||||
m_ui->faviconButton->setVisible(false);
|
m_ui->faviconButton->setVisible(false);
|
||||||
m_ui->addButton->setEnabled(true);
|
m_ui->faviconURL->setVisible(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EditWidgetIcons::~EditWidgetIcons()
|
EditWidgetIcons::~EditWidgetIcons()
|
||||||
@ -175,22 +179,36 @@ QMenu* EditWidgetIcons::createApplyIconToMenu()
|
|||||||
return applyIconToMenu;
|
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)
|
void EditWidgetIcons::setUrl(const QString& url)
|
||||||
{
|
{
|
||||||
#ifdef WITH_XC_NETWORKING
|
#ifdef WITH_XC_NETWORKING
|
||||||
m_url = url;
|
QUrl urlCheck(url);
|
||||||
m_ui->faviconButton->setVisible(!url.isEmpty());
|
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
|
#else
|
||||||
Q_UNUSED(url);
|
Q_UNUSED(url);
|
||||||
m_ui->faviconButton->setVisible(false);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditWidgetIcons::downloadFavicon()
|
void EditWidgetIcons::downloadFavicon()
|
||||||
{
|
{
|
||||||
#ifdef WITH_XC_NETWORKING
|
#ifdef WITH_XC_NETWORKING
|
||||||
if (!m_url.isEmpty()) {
|
auto url = m_ui->faviconURL->text();
|
||||||
m_downloader->setUrl(m_url);
|
if (!url.isEmpty()) {
|
||||||
|
m_downloader->setUrl(url);
|
||||||
m_downloader->download();
|
m_downloader->download();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -72,6 +72,9 @@ public:
|
|||||||
const QString& url = "");
|
const QString& url = "");
|
||||||
void setShowApplyIconToButton(bool state);
|
void setShowApplyIconToButton(bool state);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setUrl(const QString& url);
|
void setUrl(const QString& url);
|
||||||
void abortRequests();
|
void abortRequests();
|
||||||
@ -102,8 +105,7 @@ private:
|
|||||||
DefaultIconModel* const m_defaultIconModel;
|
DefaultIconModel* const m_defaultIconModel;
|
||||||
CustomIconModel* const m_customIconModel;
|
CustomIconModel* const m_customIconModel;
|
||||||
#ifdef WITH_XC_NETWORKING
|
#ifdef WITH_XC_NETWORKING
|
||||||
QScopedPointer<IconDownloader> m_downloader;
|
QSharedPointer<IconDownloader> m_downloader;
|
||||||
QString m_url;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Q_DISABLE_COPY(EditWidgetIcons)
|
Q_DISABLE_COPY(EditWidgetIcons)
|
||||||
|
@ -104,11 +104,40 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="customIconButtonsHorizontalLayout">
|
<layout class="QHBoxLayout" name="customIconButtonsHorizontalLayout" stretch="0,0,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addButton">
|
<widget class="QPushButton" name="addButton">
|
||||||
<property name="text">
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -174,6 +203,7 @@
|
|||||||
<tabstop>customIconsRadio</tabstop>
|
<tabstop>customIconsRadio</tabstop>
|
||||||
<tabstop>customIconsView</tabstop>
|
<tabstop>customIconsView</tabstop>
|
||||||
<tabstop>addButton</tabstop>
|
<tabstop>addButton</tabstop>
|
||||||
|
<tabstop>faviconURL</tabstop>
|
||||||
<tabstop>faviconButton</tabstop>
|
<tabstop>faviconButton</tabstop>
|
||||||
<tabstop>applyIconToPushButton</tabstop>
|
<tabstop>applyIconToPushButton</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
|
Loading…
Reference in New Issue
Block a user