diff --git a/COPYING b/COPYING index b91037658..b3eddd766 100644 --- a/COPYING +++ b/COPYING @@ -151,6 +151,12 @@ Copyright: 2003-2004, David Vignoni License: LGPL-2.1 Comment: based on Nuvola icon theme +Files: share/icons/application/*/actions/favicon-download.png +Copyright: 2003-2004, David Vignoni + 2018, Kyle Kneitinger +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 diff --git a/share/icons/application/16x16/actions/favicon-download.png b/share/icons/application/16x16/actions/favicon-download.png new file mode 100644 index 000000000..80bc4a65d Binary files /dev/null and b/share/icons/application/16x16/actions/favicon-download.png differ diff --git a/share/icons/application/22x22/actions/favicon-download.png b/share/icons/application/22x22/actions/favicon-download.png new file mode 100644 index 000000000..96596c4bd Binary files /dev/null and b/share/icons/application/22x22/actions/favicon-download.png differ diff --git a/share/icons/application/32x32/actions/favicon-download.png b/share/icons/application/32x32/actions/favicon-download.png new file mode 100644 index 000000000..2f838d9d7 Binary files /dev/null and b/share/icons/application/32x32/actions/favicon-download.png differ diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index 61bffe701..09aafbf11 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -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(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(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 diff --git a/src/gui/EditWidgetIcons.h b/src/gui/EditWidgetIcons.h index d00e064af..677cbebef 100644 --- a/src/gui/EditWidgetIcons.h +++ b/src/gui/EditWidgetIcons.h @@ -20,7 +20,6 @@ #define KEEPASSX_EDITWIDGETICONS_H #include -#include #include #include #include @@ -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 diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index a19a89332..72d09c9ff 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -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); diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h index d45b29726..b0f5d8c94 100644 --- a/src/gui/entry/EditEntryWidget.h +++ b/src/gui/entry/EditEntryWidget.h @@ -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(); diff --git a/src/gui/entry/EditEntryWidgetMain.ui b/src/gui/entry/EditEntryWidgetMain.ui index dc07603aa..3e759fec7 100644 --- a/src/gui/entry/EditEntryWidgetMain.ui +++ b/src/gui/entry/EditEntryWidgetMain.ui @@ -19,6 +19,17 @@ + + + + + + + + + + + @@ -155,9 +166,6 @@ - - -