X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fwindows%2FBrowserWindow.cpp;h=03ababcb877893de2941c9cd409d92bd4d8d45e3;hb=9514cabb5648123b68264e595e9ffef6261bd215;hp=d83dd69b5e515b12a2baf6fa9cd3e8689ac93d7a;hpb=f199b82941d34514783e4a4b85905d12999701d6;p=PrivacyBrowserPC.git diff --git a/src/windows/BrowserWindow.cpp b/src/windows/BrowserWindow.cpp index d83dd69..03ababc 100644 --- a/src/windows/BrowserWindow.cpp +++ b/src/windows/BrowserWindow.cpp @@ -46,9 +46,13 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() KActionCollection *actionCollectionPointer = this->actionCollection(); // Add the standard actions. + QAction *backActionPointer = KStandardAction::back(this, SLOT(back()), actionCollectionPointer); + QAction *forwardActionPointer = KStandardAction::forward(this, SLOT(forward()), actionCollectionPointer); + KStandardAction::home(this, SLOT(home()), actionCollectionPointer); KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer); KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer); KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer); + KStandardAction::redisplay(this, SLOT(refresh()), actionCollectionPointer); // Add the custom actions. userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_privacy_browser")); @@ -67,10 +71,6 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() searchEngineBingActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_bing")); searchEngineYahooActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_yahoo")); searchEngineCustomActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_custom")); - backActionPointer = actionCollectionPointer->addAction(QStringLiteral("back")); - forwardActionPointer = actionCollectionPointer->addAction(QStringLiteral("forward")); - refreshActionPointer = actionCollectionPointer->addAction(QStringLiteral("refresh")); - homeActionPointer = actionCollectionPointer->addAction(QStringLiteral("home")); javaScriptActionPointer = actionCollectionPointer->addAction(QStringLiteral("javascript")); domainSettingsActionPointer = actionCollectionPointer->addAction(QStringLiteral("domain_settings")); @@ -126,24 +126,32 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() searchEngineGoogleActionPointer->setText(i18nc("Search engine", "Google")); searchEngineBingActionPointer->setText(i18nc("Search engine", "Bing")); searchEngineYahooActionPointer->setText(i18nc("Search engine", "Yahoo")); - backActionPointer->setText(i18nc("Back button", "Back")); - forwardActionPointer->setText(i18nc("Forward button", "Forward")); - refreshActionPointer->setText(i18nc("Refresh button", "Refresh")); - homeActionPointer->setText(i18nc("Home button", "Home")); javaScriptActionPointer->setText(i18nc("JavaScript button", "JavaScript")); domainSettingsActionPointer->setText(i18nc("Domain Settings button", "Domain Settings")); // Set the action icons. - backActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("arrow-left"))); - forwardActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("arrow-right"))); - refreshActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); - homeActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("home"))); + userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode")); + userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr"))); + userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium"))); + userAgentFirefoxWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr"))); + userAgentChromeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium"))); + userAgentEdgeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties"))); + userAgentSafariMacosActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties"))); + userAgentCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties"))); + searchEngineMojeekActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search"))); + searchEngineMonoclesActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search"))); + searchEngineMetagerActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search"))); + searchEngineGoogleActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-google"))); + searchEngineBingActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search"))); + searchEngineYahooActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-yahoo"))); + searchEngineCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search"))); + zoomFactorActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("zoom"))); 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*))); @@ -153,10 +161,6 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser())); // Connect the URL toolbar actions. - connect(backActionPointer, SIGNAL(triggered()), this, SLOT(back())); - connect(forwardActionPointer, SIGNAL(triggered()), this, SLOT(forward())); - connect(refreshActionPointer, SIGNAL(triggered()), this, SLOT(refresh())); - connect(homeActionPointer, SIGNAL(triggered()), this, SLOT(home())); connect(javaScriptActionPointer, SIGNAL(triggered()), this, SLOT(toggleJavaScript())); connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(openDomainSettings())); @@ -188,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(); @@ -249,7 +263,7 @@ void BrowserWindow::getZoomFactorFromUser() browserViewPointer->applyOnTheFlyZoomFactor(newZoomFactor); // Update the on-the-fly action text. - updateOnTheFlyZoomFactor(newZoomFactor); + updateZoomFactorAction(newZoomFactor); } } @@ -301,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. @@ -310,6 +333,12 @@ void BrowserWindow::toggleJavaScript() const browserViewPointer->toggleJavaScript(); } +QSize BrowserWindow::sizeHint() const +{ + // Return the default window size. + return QSize(1500, 1200); +} + void BrowserWindow::settingsConfigure() { // Check to make sure the dialog box isn't already displayed. @@ -399,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; @@ -456,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; @@ -498,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());