From 62ea725eff3c6bb93f29165e3131062fe5778bf4 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Tue, 9 Jun 2026 16:49:32 +0300 Subject: [PATCH] feat(browser): add Tabler icons to context menu --- assets/tabler/app-window.svg | 15 ++++++++++++ assets/tabler/copy.svg | 14 +++++++++++ assets/tabler/external-link.svg | 15 ++++++++++++ assets/tabler/link.svg | 15 ++++++++++++ src/app/zeal.qrc | 4 +++ src/libs/browser/webview.cpp | 43 +++++++++++++++++++++++++++------ 6 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 assets/tabler/app-window.svg create mode 100644 assets/tabler/copy.svg create mode 100644 assets/tabler/external-link.svg create mode 100644 assets/tabler/link.svg diff --git a/assets/tabler/app-window.svg b/assets/tabler/app-window.svg new file mode 100644 index 00000000..453f30d8 --- /dev/null +++ b/assets/tabler/app-window.svg @@ -0,0 +1,15 @@ + + + + + diff --git a/assets/tabler/copy.svg b/assets/tabler/copy.svg new file mode 100644 index 00000000..db579c38 --- /dev/null +++ b/assets/tabler/copy.svg @@ -0,0 +1,14 @@ + + + + diff --git a/assets/tabler/external-link.svg b/assets/tabler/external-link.svg new file mode 100644 index 00000000..48d504ed --- /dev/null +++ b/assets/tabler/external-link.svg @@ -0,0 +1,15 @@ + + + + + diff --git a/assets/tabler/link.svg b/assets/tabler/link.svg new file mode 100644 index 00000000..27a89206 --- /dev/null +++ b/assets/tabler/link.svg @@ -0,0 +1,15 @@ + + + + + diff --git a/src/app/zeal.qrc b/src/app/zeal.qrc index 3a3bd3ea..d55e4b89 100644 --- a/src/app/zeal.qrc +++ b/src/app/zeal.qrc @@ -11,11 +11,15 @@ resources/browser/welcome.html + ../../assets/tabler/app-window.svg ../../assets/tabler/arrow-left.svg ../../assets/tabler/arrow-right.svg + ../../assets/tabler/copy.svg ../../assets/tabler/dots-vertical.svg + ../../assets/tabler/external-link.svg ../../assets/tabler/info-circle.svg ../../assets/tabler/library.svg + ../../assets/tabler/link.svg ../../assets/tabler/loader-2.svg ../../assets/tabler/logout.svg ../../assets/tabler/minus.svg diff --git a/src/libs/browser/webview.cpp b/src/libs/browser/webview.cpp index 05638056..edd12b28 100644 --- a/src/libs/browser/webview.cpp +++ b/src/libs/browser/webview.cpp @@ -9,7 +9,9 @@ #include #include +#include +#include #include #include #include @@ -120,19 +122,32 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) const QString scheme = linkUrl.scheme(); if (scheme != QLatin1String("javascript")) { - m_contextMenu->addAction(tr("Open Link in New Tab"), this, [this]() { + // Tabler has no dedicated new-tab glyph yet, so app-window stands in for the + // fallback. See https://github.com/tabler/tabler-icons/issues/1535. + m_contextMenu->addAction(WidgetUi::IconHelper::fromTheme(QStringLiteral("tab-new"), + QStringLiteral(":/icons/tabler/app-window.svg")), + tr("Open Link in New Tab"), + this, + [this]() { triggerPageAction(QWebEnginePage::WebAction::OpenLinkInNewWindow); }); } if (scheme != QLatin1String("qrc")) { if (scheme != QLatin1String("javascript")) { - m_contextMenu->addAction(tr("Open Link in Desktop Browser"), this, [linkUrl]() { + m_contextMenu->addAction(WidgetUi::IconHelper::fromResource( + QStringLiteral(":/icons/tabler/external-link.svg")), + tr("Open Link in Desktop Browser"), + this, + [linkUrl]() { QDesktopServices::openUrl(linkUrl); }); } - m_contextMenu->addAction(pageAction(QWebEnginePage::CopyLinkToClipboard)); + QAction *copyLinkAction = pageAction(QWebEnginePage::CopyLinkToClipboard); + copyLinkAction->setIcon(WidgetUi::IconHelper::fromTheme(QStringLiteral("insert-link"), + QStringLiteral(":/icons/tabler/link.svg"))); + m_contextMenu->addAction(copyLinkAction); } } @@ -142,7 +157,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) m_contextMenu->addSeparator(); } - m_contextMenu->addAction(pageAction(QWebEnginePage::Copy)); + QAction *copyAction = pageAction(QWebEnginePage::Copy); + copyAction->setIcon( + WidgetUi::IconHelper::fromTheme(QStringLiteral("edit-copy"), QStringLiteral(":/icons/tabler/copy.svg"))); + m_contextMenu->addAction(copyAction); } if (!linkUrl.isValid() && url().scheme() != QLatin1String("qrc")) { @@ -150,11 +168,22 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) m_contextMenu->addSeparator(); } - m_contextMenu->addAction(pageAction(QWebEnginePage::Back)); - m_contextMenu->addAction(pageAction(QWebEnginePage::Forward)); + QAction *backAction = pageAction(QWebEnginePage::Back); + backAction->setIcon(WidgetUi::IconHelper::fromTheme(QStringLiteral("go-previous"), + QStringLiteral(":/icons/tabler/arrow-left.svg"))); + m_contextMenu->addAction(backAction); + + QAction *forwardAction = pageAction(QWebEnginePage::Forward); + forwardAction->setIcon(WidgetUi::IconHelper::fromTheme(QStringLiteral("go-next"), + QStringLiteral(":/icons/tabler/arrow-right.svg"))); + m_contextMenu->addAction(forwardAction); + m_contextMenu->addSeparator(); - m_contextMenu->addAction(tr("Open Page in Desktop Browser"), this, [this]() { + m_contextMenu->addAction(WidgetUi::IconHelper::fromResource(QStringLiteral(":/icons/tabler/external-link.svg")), + tr("Open Page in Desktop Browser"), + this, + [this]() { QDesktopServices::openUrl(url()); }); }