#include <KConfigDialog>
// Qt framework headers.
+#include <QInputDialog>
#include <QStatusBar>
BrowserWindow::BrowserWindow() : KXmlGuiWindow()
userAgentEdgeWindowsActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_edge_windows"));
userAgentSafariMacosActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_safari_macos"));
userAgentCustomActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_custom"));
+ zoomFactorActionPointer = actionCollectionPointer->addAction(QStringLiteral("zoom_factor"));
searchEngineMojeekActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_mojeek"));
searchEngineMonoclesActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_monocles"));
searchEngineMetagerActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_metager"));
searchEngineYahooActionPointer->setCheckable(true);
searchEngineCustomActionPointer->setCheckable(true);
- // Set the action names. The custom action text will be set later in the on-the-fly update slots.
+ // Set the non-mutable action names.
userAgentPrivacyBrowserActionPointer->setText(i18nc("@action", "Privacy Browser"));
userAgentFirefoxLinuxActionPointer->setText(i18nc("@action", "Firefox Linux"));
userAgentChromiumLinuxActionPointer->setText(i18nc("@action", "Chromium Linux"));
// Update the on-the-fly menus.
connect(mainViewPointer, SIGNAL(userAgentUpdated(QString)), this, SLOT(updateOnTheFlyUserAgent(QString)));
+ connect(mainViewPointer, SIGNAL(zoomFactorUpdated(double)), this, SLOT(updateOnTheFlyZoomFactor(double)));
connect(mainViewPointer, SIGNAL(searchEngineUpdated(QString)), this, SLOT(updateOnTheFlySearchEngine(QString)));
// Apply the on-the-fly settings when selected.
connect(userAgentActionGroupPointer, SIGNAL(triggered(QAction*)), mainViewPointer, SLOT(applyOnTheFlyUserAgent(QAction*)));
connect(searchEngineActionGroupPointer, SIGNAL(triggered(QAction*)), mainViewPointer, SLOT(applyOnTheFlySearchEngine(QAction*)));
- // Initialize the on-the-fly search engine menu, as the slot connection had not been created when MainView was constructed.
- updateOnTheFlySearchEngine(Settings::searchEngine());
+ // Display dialogs.
+ connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser()));
// Update the status bar with the URL when a link is hovered.
connect(mainViewPointer, SIGNAL(linkHovered(QString)), this, SLOT(updateStatusBar(QString)));
// Setup the GUI based on the privacybrowserui.rc file.
setupGUI();
+
+ // Load the initial webstie.
+ mainViewPointer->loadInitialWebsite();
}
void BrowserWindow::fileNew() const
(new BrowserWindow)->show();
}
+void BrowserWindow::getZoomFactorFromUser()
+{
+ // Create an OK flag.
+ bool okClicked;
+
+ // Display a dialog to get the new zoom factor from the user. Format the double to display two decimals and have a 0.25 step.
+ double newZoomFactor = QInputDialog::getDouble(this, i18nc("The tile of the on-the-fly zoom factor dialog", "On-The-Fly Zoom Factor"),
+ i18nc("The instruction text of the on-the-fly zoom factor dialog", "Enter a zoom factor between 0.25 and 5.00"),
+ currentZoomFactor, .025, 5.00, 2, &okClicked, Qt::WindowFlags(), 0.25);
+
+ if (okClicked)
+ {
+ // Update the current zoom factor.
+ currentZoomFactor = newZoomFactor;
+
+ // Set the new zoom factor.
+ mainViewPointer->applyOnTheFlyZoomFactor(newZoomFactor);
+
+ // Update the on-the-fly action text.
+ updateOnTheFlyZoomFactor(newZoomFactor);
+ }
+}
+
void BrowserWindow::settingsConfigure()
{
// Check to make sure the dialog box isn't already displayed.
}
}
+void BrowserWindow::updateOnTheFlyZoomFactor(const double &zoomFactor)
+{
+ // Set the current zoom factor.
+ currentZoomFactor = Settings::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());
+}
void BrowserWindow::updateSearchEngineLabel(const QString &searchEngineString) const
{