]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/windows/BrowserWindow.cpp
Add a progress bar.
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.cpp
index e2dd30109863fe8b8a4a7414aacd3a757ff5afc9..03ababcb877893de2941c9cd409d92bd4d8d45e3 100644 (file)
@@ -149,9 +149,9 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow()
     domainSettingsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("network-server-symbolic")));
 
     // Update the on-the-fly menus.
-    connect(browserViewPointer, SIGNAL(userAgentUpdated(QString)), this, SLOT(updateOnTheFlyUserAgent(QString)));
-    connect(browserViewPointer, SIGNAL(zoomFactorUpdated(double)), this, SLOT(updateOnTheFlyZoomFactor(double)));
-    connect(browserViewPointer, SIGNAL(searchEngineUpdated(QString)), this, SLOT(updateOnTheFlySearchEngine(QString)));
+    connect(browserViewPointer, SIGNAL(updateUserAgentActions(QString)), this, SLOT(updateUserAgentActions(QString)));
+    connect(browserViewPointer, SIGNAL(updateZoomFactorAction(double)), this, SLOT(updateZoomFactorAction(double)));
+    connect(browserViewPointer, SIGNAL(updateSearchEngineActions(QString)), this, SLOT(updateSearchEngineActions(QString)));
 
     // Apply the on-the-fly settings when selected.
     connect(userAgentActionGroupPointer, SIGNAL(triggered(QAction*)), browserViewPointer, SLOT(applyOnTheFlyUserAgent(QAction*)));
@@ -192,9 +192,19 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow()
     // Get a handle for the status bar.
     QStatusBar *statusBarPointer = statusBar();
 
+    // Create a progress bar.
+    progressBarPointer = new QProgressBar();
+
+    // Add the progress bar to to the status bar.
+    statusBarPointer->addPermanentWidget(progressBarPointer);
+
     // Update the status bar with the URL when a link is hovered.
     connect(browserViewPointer, SIGNAL(linkHovered(QString)), statusBarPointer, SLOT(showMessage(QString)));
 
+    // Update the progress bar.
+    connect(browserViewPointer, SIGNAL(showProgressBar(const int)), this, SLOT(showProgressBar(const int)));
+    connect(browserViewPointer, SIGNAL(hideProgressBar()), progressBarPointer, SLOT(hide()));
+
     // Get the URL line edit palettes.
     noDomainSettingsPalette = urlLineEditPointer->palette();
     domainSettingsPalette = urlLineEditPointer->palette();
@@ -253,7 +263,7 @@ void BrowserWindow::getZoomFactorFromUser()
         browserViewPointer->applyOnTheFlyZoomFactor(newZoomFactor);
 
         // Update the on-the-fly action text.
-        updateOnTheFlyZoomFactor(newZoomFactor);
+        updateZoomFactorAction(newZoomFactor);
     }
 }
 
@@ -305,6 +315,15 @@ void BrowserWindow::refresh() const
     browserViewPointer->refresh();
 }
 
+void BrowserWindow::showProgressBar(const int &progress) const
+{
+    // Set the progress bar value.
+    progressBarPointer->setValue(progress);
+
+    // Show the progress bar.
+    progressBarPointer->show();
+}
+
 void BrowserWindow::toggleJavaScript() const
 {
     // Remove the focus from the URL line edit.
@@ -409,7 +428,7 @@ void BrowserWindow::updateJavaScriptAction(const bool &isEnabled) const
     else javaScriptActionPointer->setIcon(QIcon(":/icons/privacy-mode"));
 }
 
-void BrowserWindow::updateOnTheFlySearchEngine(const QString &searchEngine) const
+void BrowserWindow::updateSearchEngineActions(const QString &searchEngine) const
 {
     // Initialize the custom search engine flag.
     bool customSearchEngine = false;
@@ -466,7 +485,7 @@ void BrowserWindow::updateOnTheFlySearchEngine(const QString &searchEngine) cons
     }
 }
 
-void BrowserWindow::updateOnTheFlyUserAgent(const QString &userAgent) const
+void BrowserWindow::updateUserAgentActions(const QString &userAgent) const
 {
     // Initialize the custom user agent flag.
     bool customUserAgent = false;
@@ -508,10 +527,10 @@ void BrowserWindow::updateOnTheFlyUserAgent(const QString &userAgent) const
     }
 }
 
-void BrowserWindow::updateOnTheFlyZoomFactor(const double &zoomFactor)
+void BrowserWindow::updateZoomFactorAction(const double &zoomFactor)
 {
     // Set the current zoom factor.
-    currentZoomFactor = Settings::zoomFactor();
+    currentZoomFactor = zoomFactor;
 
     // Update the zoom factor action text, formatting the double with 2 decimal places.
     zoomFactorActionPointer->setText(ki18nc("@action", "Zoom Factor - %1").subs(zoomFactor, 0, '0', 2).toString());