aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webviewcontextmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/webviewcontextmenu.cpp')
-rw-r--r--src/webengine/webviewcontextmenu.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/webengine/webviewcontextmenu.cpp b/src/webengine/webviewcontextmenu.cpp
index ea5e8c6..c9d809f 100644
--- a/src/webengine/webviewcontextmenu.cpp
+++ b/src/webengine/webviewcontextmenu.cpp
@@ -9,11 +9,11 @@
#include "webviewcontextmenu.h"
#include "webprofilemanager.h"
#include "webview.h"
+#include "util.h"
#include <QContextMenuEvent>
#include <QDialog>
#include <QMenu>
#include <QSlider>
-#include <QStatusBar>
#include <QStyle>
#include <QToolButton>
#include <QVBoxLayout>
@@ -21,13 +21,17 @@
#include <QWebEngineHistory>
#include <QWidgetAction>
+constexpr int min_width = 250;
+constexpr QSize button_size(32, 32);
+
inline QAction *historyAction(QWebEngineView *view, const QWebEngineHistoryItem &item)
{
- QAction *action = new QAction(view);
- if(item.title().isEmpty())
+ auto *action = new QAction(view);
+ if(item.title().isEmpty()) {
action->setText(item.url().toString());
- else
+ } else {
action->setText(QObject::tr("%1 (%2)").arg(item.title(), item.url().toString()));
+ }
QObject::connect(action, &QAction::triggered, view, [view, item]() {
view->history()->goToItem(item);
@@ -38,7 +42,7 @@ inline QAction *historyAction(QWebEngineView *view, const QWebEngineHistoryItem
WebViewContextMenu::WebViewContextMenu(WebView *view)
: QMenu(view)
{
- setMinimumWidth(250);
+ setMinimumWidth(min_width);
auto *navButtons = new QWidgetAction(this);
@@ -48,8 +52,9 @@ WebViewContextMenu::WebViewContextMenu(WebView *view)
buttonsLayout->setSpacing(2);
auto *backButton = new QToolButton(this);
+ backButton->setMinimumSize(button_size);
backButton->setEnabled(view->history()->canGoBack());
- backButton->setIcon(style()->standardIcon(QStyle::SP_ArrowBack));
+ backButton->setIcon(Util::icon<QStyle::SP_ArrowBack>());
connect(backButton, &QToolButton::clicked, view, [this, view]() {
view->back();
this->close();
@@ -57,8 +62,9 @@ WebViewContextMenu::WebViewContextMenu(WebView *view)
buttonsLayout->addWidget(backButton);
auto *forwardButton = new QToolButton(this);
+ forwardButton->setMinimumSize(button_size);
forwardButton->setEnabled(view->history()->canGoForward());
- forwardButton->setIcon(style()->standardIcon(QStyle::SP_ArrowForward));
+ forwardButton->setIcon(Util::icon<QStyle::SP_ArrowForward>());
connect(forwardButton, &QToolButton::clicked, view, [this, view]() {
view->forward();
this->close();
@@ -66,7 +72,8 @@ WebViewContextMenu::WebViewContextMenu(WebView *view)
buttonsLayout->addWidget(forwardButton);
auto *refreshButton = new QToolButton(this);
- refreshButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
+ refreshButton->setMinimumSize(button_size);
+ refreshButton->setIcon(Util::icon<QStyle::SP_BrowserReload>());
connect(refreshButton, &QToolButton::clicked, view, [view, this]() {
view->reload();
this->close();
@@ -76,12 +83,10 @@ WebViewContextMenu::WebViewContextMenu(WebView *view)
buttonsLayout->addStretch();
auto *muteButton = new QToolButton(this);
+ muteButton->setMinimumSize(button_size);
muteButton->setCheckable(true);
muteButton->setChecked(view->page()->isAudioMuted());
- QIcon muteIcon;
- muteIcon.addPixmap(style()->standardPixmap(QStyle::SP_MediaVolume), QIcon::Normal, QIcon::Off);
- muteIcon.addPixmap(style()->standardPixmap(QStyle::SP_MediaVolumeMuted), QIcon::Normal, QIcon::On);
- muteButton->setIcon(muteIcon);
+ muteButton->setIcon(Util::icon<QStyle::SP_MediaVolume>());
connect(muteButton, &QToolButton::clicked, view, [view, this](bool checked) {
view->page()->setAudioMuted(checked);
this->close();