]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Colorize the requests counter background. https://redmine.stoutner.com/issues/1232
authorSoren Stoutner <soren@stoutner.com>
Tue, 22 Oct 2024 21:31:39 +0000 (14:31 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 22 Oct 2024 21:31:39 +0000 (14:31 -0700)
src/windows/BrowserWindow.cpp

index d948104c5cd5593e5a4f740e4f77725249f4bd8b..bde4ccb5b8995225776286826c3c9dfd853fc79b 100644 (file)
@@ -466,6 +466,9 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     urlToolBarPointer = toolBar(QLatin1String("url_toolbar"));
     bookmarksToolBarPointer = toolBar(QLatin1String("bookmarks_toolbar"));
 
+    // Set the blocked requests action pointer widget object name (required to change the background color with a style sheet).
+    urlToolBarPointer->widgetForAction(blockedRequestsActionPointer)->setObjectName("blocked_requests");
+
     // Populate the view bookmarks toolbar checkbox.
     connect(bookmarksToolBarPointer, SIGNAL(visibilityChanged(bool)), this, SLOT(updateViewBookmarksToolBarCheckbox(bool)));
 
@@ -1850,6 +1853,12 @@ void BrowserWindow::updateRequestsAction(const QVector<int> blockedRequestsVecto
 
     // Update the tool tips.
     blockedRequestsActionPointer->setToolTip(i18nc("Blocked requests action tool tip", "%1 Blocked Requests (Ctrl+R)", blockedRequestsVector[PrivacyWebEngineView::TOTAL]));
+
+    // Update the blocked requests action background color.
+    if (blockedRequestsVector[PrivacyWebEngineView::TOTAL] > 0)
+        urlToolBarPointer->setStyleSheet(QLatin1String("QToolButton#blocked_requests { background-color: tomato; }"));
+    else
+        urlToolBarPointer->setStyleSheet(QLatin1String("QToolButton#blocked_requests { background-color: transparent; }"));
 }
 
 void BrowserWindow::updateCookiesAction(const int numberOfCookies) const