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

Fix create menu

parent b9a72a41
......@@ -8,13 +8,13 @@
#include "remotecontentconfiguredialog.h"
#include <KLocalizedString>
#include <QAction>
#include <QDebug>
#include <QPointer>
using namespace MessageViewer;
RemoteContentMenu::RemoteContentMenu(QWidget *parent)
: QMenu(parent)
{
initialize();
setTitle(i18n("Remote Content"));
initialize();
updateMenu();
......@@ -49,12 +49,15 @@ void RemoteContentMenu::setUrls(const QStringList &urls)
void RemoteContentMenu::updateMenu()
{
clear();
for (auto act : qAsConst(mListAction)) {
removeAction(act);
}
for (const QString &url : qAsConst(mUrls)) {
QAction *act = addAction(i18n("Authorize %1", url));
connect(act, &QAction::triggered, this, [this, url]() {
authorize(url);
});
mListAction << act;
}
addSeparator();
addAction(mConfigureRemoteContentAction);
......@@ -75,4 +78,5 @@ void RemoteContentMenu::appendUrl(const QString &url)
if (!mUrls.contains(url)) {
mUrls.append(url);
}
updateMenu();
}
......@@ -32,6 +32,7 @@ private:
void slotConfigure();
QStringList mUrls;
QAction *mConfigureRemoteContentAction = nullptr;
QList<QAction *> mListAction;
};
}
#endif // REMOTECONTENTMENU_H
......@@ -936,7 +936,7 @@ void ViewerPrivate::initHtmlWidget()
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
......
Markdown is supported
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