Commit 7e6ee4c0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix create menu

parent b9a72a41
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
#include "remotecontentconfiguredialog.h" #include "remotecontentconfiguredialog.h"
#include <KLocalizedString> #include <KLocalizedString>
#include <QAction> #include <QAction>
#include <QDebug>
#include <QPointer> #include <QPointer>
using namespace MessageViewer; using namespace MessageViewer;
RemoteContentMenu::RemoteContentMenu(QWidget *parent) RemoteContentMenu::RemoteContentMenu(QWidget *parent)
: QMenu(parent) : QMenu(parent)
{ {
initialize();
setTitle(i18n("Remote Content")); setTitle(i18n("Remote Content"));
initialize(); initialize();
updateMenu(); updateMenu();
...@@ -49,12 +49,15 @@ void RemoteContentMenu::setUrls(const QStringList &urls) ...@@ -49,12 +49,15 @@ void RemoteContentMenu::setUrls(const QStringList &urls)
void RemoteContentMenu::updateMenu() void RemoteContentMenu::updateMenu()
{ {
clear(); for (auto act : qAsConst(mListAction)) {
removeAction(act);
}
for (const QString &url : qAsConst(mUrls)) { for (const QString &url : qAsConst(mUrls)) {
QAction *act = addAction(i18n("Authorize %1", url)); QAction *act = addAction(i18n("Authorize %1", url));
connect(act, &QAction::triggered, this, [this, url]() { connect(act, &QAction::triggered, this, [this, url]() {
authorize(url); authorize(url);
}); });
mListAction << act;
} }
addSeparator(); addSeparator();
addAction(mConfigureRemoteContentAction); addAction(mConfigureRemoteContentAction);
...@@ -75,4 +78,5 @@ void RemoteContentMenu::appendUrl(const QString &url) ...@@ -75,4 +78,5 @@ void RemoteContentMenu::appendUrl(const QString &url)
if (!mUrls.contains(url)) { if (!mUrls.contains(url)) {
mUrls.append(url); mUrls.append(url);
} }
updateMenu();
} }
...@@ -32,6 +32,7 @@ private: ...@@ -32,6 +32,7 @@ private:
void slotConfigure(); void slotConfigure();
QStringList mUrls; QStringList mUrls;
QAction *mConfigureRemoteContentAction = nullptr; QAction *mConfigureRemoteContentAction = nullptr;
QList<QAction *> mListAction;
}; };
} }
#endif // REMOTECONTENTMENU_H #endif // REMOTECONTENTMENU_H
...@@ -936,7 +936,7 @@ void ViewerPrivate::initHtmlWidget() ...@@ -936,7 +936,7 @@ void ViewerPrivate::initHtmlWidget()
void ViewerPrivate::slotUrlBlocked(const QUrl &url) void ViewerPrivate::slotUrlBlocked(const QUrl &url)
{ {
mRemoteContentMenu->appendUrl(url.toString()); mRemoteContentMenu->appendUrl(url.adjusted(QUrl::RemovePath | QUrl::RemovePort | QUrl::RemoveQuery).toString());
} }
RemoteContentMenu *ViewerPrivate::remoteContentMenu() const RemoteContentMenu *ViewerPrivate::remoteContentMenu() const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment