mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-02 09:34:58 -05:00
Add favicon fetch button next to entry's url edit textbox (#2439)
When WITH_XC_NETWORKING is defined, create a QToolButton beside the Edit Entry -> Entry -> URL, which when pressed, acts as though the Edit Entry -> Icon -> Download Favicon button is pressed. This button is disabled (grayed-out) when the URL text is empty, and enabled when the text is present. Fixes #936 * Add favicon download button * Remove the progress dialog that appears when downloading an entry's URL's favicon since (when working correctly) it disappears before it can be read. When downloading icons from the button located next to the URL text box, display a message panel that confirms the download was a success. * Do not show successful icon download msg if icon alread exists
This commit is contained in:
parent
3c362ac822
commit
a90a577ee1
6
COPYING
6
COPYING
@ -151,6 +151,12 @@ Copyright: 2003-2004, David Vignoni <david@icon-king.com>
|
||||
License: LGPL-2.1
|
||||
Comment: based on Nuvola icon theme
|
||||
|
||||
Files: share/icons/application/*/actions/favicon-download.png
|
||||
Copyright: 2003-2004, David Vignoni <david@icon-king.com>
|
||||
2018, Kyle Kneitinger <kyle@kneit.in>
|
||||
License: LGPL-2.1
|
||||
Comment: based on Nuvola icon theme
|
||||
|
||||
Files: share/icons/application/*/actions/application-exit.png
|
||||
share/icons/application/*/actions/chronometer.png
|
||||
share/icons/application/*/actions/configure.png
|
||||
|
BIN
share/icons/application/16x16/actions/favicon-download.png
Normal file
BIN
share/icons/application/16x16/actions/favicon-download.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 755 B |
BIN
share/icons/application/22x22/actions/favicon-download.png
Normal file
BIN
share/icons/application/22x22/actions/favicon-download.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
share/icons/application/32x32/actions/favicon-download.png
Normal file
BIN
share/icons/application/32x32/actions/favicon-download.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -39,25 +39,6 @@ IconStruct::IconStruct()
|
||||
{
|
||||
}
|
||||
|
||||
UrlFetchProgressDialog::UrlFetchProgressDialog(const QUrl &url, QWidget *parent)
|
||||
: QProgressDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("Download Progress"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setLabelText(tr("Downloading %1.").arg(url.toDisplayString()));
|
||||
setMinimumDuration(0);
|
||||
setMinimumSize(QSize(400, 75));
|
||||
}
|
||||
|
||||
void UrlFetchProgressDialog::networkReplyProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
if (totalBytes > 0) {
|
||||
setValue(static_cast<int>(bytesRead / totalBytes));
|
||||
} else {
|
||||
setValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
EditWidgetIcons::EditWidgetIcons(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::EditWidgetIcons())
|
||||
@ -268,14 +249,14 @@ void EditWidgetIcons::fetchFinished()
|
||||
// No redirect, and we theoretically have some icon data now.
|
||||
image.loadFromData(m_bytesReceived);
|
||||
}
|
||||
} else {
|
||||
UrlFetchProgressDialog *progress = findChild<UrlFetchProgressDialog *>(url.toString());
|
||||
progress->close();
|
||||
}
|
||||
|
||||
if (!image.isNull()) {
|
||||
if (!addCustomIcon(image)) {
|
||||
emit messageEditEntry(tr("Custom icon already exists"), MessageWidget::Information);
|
||||
} else if (!this->isVisible()) {
|
||||
// Show confirmation message if triggered from Entry tab download button
|
||||
emit messageEditEntry(tr("Custom icon successfully downloaded"), MessageWidget::Positive);
|
||||
}
|
||||
} else if (!m_urlsToTry.empty()) {
|
||||
m_redirects = 0;
|
||||
@ -316,15 +297,6 @@ void EditWidgetIcons::startFetchFavicon(const QUrl& url)
|
||||
m_reply = m_netMgr.get(request);
|
||||
connect(m_reply, &QNetworkReply::finished, this, &EditWidgetIcons::fetchFinished);
|
||||
connect(m_reply, &QIODevice::readyRead, this, &EditWidgetIcons::fetchReadyRead);
|
||||
|
||||
UrlFetchProgressDialog *progress = new UrlFetchProgressDialog(url, this);
|
||||
progress->setObjectName(url.toString());
|
||||
progress->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(m_reply, &QNetworkReply::finished, progress, &QProgressDialog::hide);
|
||||
connect(m_reply, &QNetworkReply::downloadProgress, progress, &UrlFetchProgressDialog::networkReplyProgress);
|
||||
connect(progress, &QProgressDialog::canceled, this, &EditWidgetIcons::fetchCanceled);
|
||||
|
||||
progress->show();
|
||||
#else
|
||||
Q_UNUSED(url);
|
||||
#endif
|
||||
|
@ -20,7 +20,6 @@
|
||||
#define KEEPASSX_EDITWIDGETICONS_H
|
||||
|
||||
#include <QSet>
|
||||
#include <QProgressDialog>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
#include <QNetworkAccessManager>
|
||||
@ -50,17 +49,6 @@ struct IconStruct
|
||||
int number;
|
||||
};
|
||||
|
||||
class UrlFetchProgressDialog : public QProgressDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UrlFetchProgressDialog(const QUrl &url, QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void networkReplyProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
};
|
||||
|
||||
class EditWidgetIcons : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -121,8 +121,19 @@ void EditEntryWidget::setupMain()
|
||||
|
||||
m_mainUi->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
|
||||
m_mainUi->togglePasswordGeneratorButton->setIcon(filePath()->icon("actions", "password-generator"));
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
m_mainUi->fetchFaviconButton->setIcon(filePath()->icon("actions", "favicon-download"));
|
||||
m_mainUi->fetchFaviconButton->setDisabled(true);
|
||||
#else
|
||||
m_mainUi->fetchFaviconButton->setVisible(false);
|
||||
#endif
|
||||
|
||||
|
||||
connect(m_mainUi->togglePasswordButton, SIGNAL(toggled(bool)), m_mainUi->passwordEdit, SLOT(setShowPassword(bool)));
|
||||
connect(m_mainUi->togglePasswordGeneratorButton, SIGNAL(toggled(bool)), SLOT(togglePasswordGeneratorButton(bool)));
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
connect(m_mainUi->fetchFaviconButton, SIGNAL(clicked()), m_iconsWidget, SLOT(downloadFavicon()));
|
||||
#endif
|
||||
connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool)));
|
||||
connect(m_mainUi->notesEnabled, SIGNAL(toggled(bool)), this, SLOT(toggleHideNotes(bool)));
|
||||
m_mainUi->passwordRepeatEdit->enableVerifyMode(m_mainUi->passwordEdit);
|
||||
@ -241,6 +252,9 @@ void EditEntryWidget::setupEntryUpdate()
|
||||
connect(m_mainUi->passwordEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_mainUi->passwordRepeatEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_mainUi->urlEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges()));
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
connect(m_mainUi->urlEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateFaviconButtonEnable(const QString&)));
|
||||
#endif
|
||||
connect(m_mainUi->expireCheck, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_mainUi->notesEnabled, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_mainUi->expireDatePicker, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(setUnsavedChanges()));
|
||||
@ -995,6 +1009,13 @@ void EditEntryWidget::setGeneratedPassword(const QString& password)
|
||||
m_mainUi->togglePasswordGeneratorButton->setChecked(false);
|
||||
}
|
||||
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
void EditEntryWidget::updateFaviconButtonEnable(const QString& url)
|
||||
{
|
||||
m_mainUi->fetchFaviconButton->setDisabled(url.isEmpty());
|
||||
}
|
||||
#endif
|
||||
|
||||
void EditEntryWidget::insertAttribute()
|
||||
{
|
||||
Q_ASSERT(!m_history);
|
||||
|
@ -79,6 +79,9 @@ private slots:
|
||||
void cancel();
|
||||
void togglePasswordGeneratorButton(bool checked);
|
||||
void setGeneratedPassword(const QString& password);
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
void updateFaviconButtonEnable(const QString& url);
|
||||
#endif
|
||||
void insertAttribute();
|
||||
void editCurrentAttribute();
|
||||
void removeCurrentAttribute();
|
||||
|
@ -19,6 +19,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="urlEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="fetchFaviconButton">
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="PasswordGeneratorWidget" name="passwordGenerator" native="true"/>
|
||||
</item>
|
||||
@ -155,9 +166,6 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="usernameEdit"/>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="urlEdit"/>
|
||||
</item>
|
||||
<item row="7" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="expireCheck">
|
||||
<property name="text">
|
||||
|
Loading…
x
Reference in New Issue
Block a user