feat(browser): add Tabler icons to context menu

This commit is contained in:
Oleg Shparber
2026-06-09 16:49:32 +03:00
parent 139ee001bb
commit 62ea725eff
6 changed files with 99 additions and 7 deletions
+15
View File
@@ -0,0 +1,15 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10" />
<path d="M6 8h.01" />
<path d="M9 8h.01" />
</svg>

After

Width:  |  Height:  |  Size: 350 B

+14
View File
@@ -0,0 +1,14 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666" />
<path d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" />
</svg>

After

Width:  |  Height:  |  Size: 493 B

+15
View File
@@ -0,0 +1,15 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6" />
<path d="M11 13l9 -9" />
<path d="M15 4h5v5" />
</svg>

After

Width:  |  Height:  |  Size: 337 B

+15
View File
@@ -0,0 +1,15 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M9 15l6 -6" />
<path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
<path d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" />
</svg>

After

Width:  |  Height:  |  Size: 397 B

+4
View File
@@ -11,11 +11,15 @@
<file alias="welcome.html">resources/browser/welcome.html</file>
</qresource>
<qresource prefix="/icons/tabler">
<file alias="app-window.svg">../../assets/tabler/app-window.svg</file>
<file alias="arrow-left.svg">../../assets/tabler/arrow-left.svg</file>
<file alias="arrow-right.svg">../../assets/tabler/arrow-right.svg</file>
<file alias="copy.svg">../../assets/tabler/copy.svg</file>
<file alias="dots-vertical.svg">../../assets/tabler/dots-vertical.svg</file>
<file alias="external-link.svg">../../assets/tabler/external-link.svg</file>
<file alias="info-circle.svg">../../assets/tabler/info-circle.svg</file>
<file alias="library.svg">../../assets/tabler/library.svg</file>
<file alias="link.svg">../../assets/tabler/link.svg</file>
<file alias="loader-2.svg">../../assets/tabler/loader-2.svg</file>
<file alias="logout.svg">../../assets/tabler/logout.svg</file>
<file alias="minus.svg">../../assets/tabler/minus.svg</file>
+36 -7
View File
@@ -9,7 +9,9 @@
#include <ui/browsertab.h>
#include <ui/mainwindow.h>
#include <ui/widgets/iconhelper.h>
#include <QAction>
#include <QApplication>
#include <QCheckBox>
#include <QDesktopServices>
@@ -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());
});
}