KStandardAction::print(tabWidgetPointer, SLOT(print()), actionCollectionPointer);
QAction *printPreviewActionPointer = KStandardAction::printPreview(tabWidgetPointer, SLOT(printPreview()), actionCollectionPointer);
KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
+ KStandardAction::zoomIn(this, SLOT(incrementZoom()), actionCollectionPointer);
+ KStandardAction::zoomOut(this, SLOT(decrementZoom()), actionCollectionPointer);
KStandardAction::redisplay(this, SLOT(refresh()), actionCollectionPointer);
fullScreenActionPointer = KStandardAction::fullScreen(this, SLOT(toggleFullScreen()), this, actionCollectionPointer);
QAction *backActionPointer = KStandardAction::back(this, SLOT(back()), actionCollectionPointer);
QAction *newWindowActionPointer = actionCollectionPointer->addAction(QLatin1String("new_window"));
QAction *reloadAndBypassCacheActionPointer = actionCollectionPointer->addAction(QLatin1String("reload_and_bypass_cache"));
viewSourceActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source"));
- QAction *viewSourceInNewTabActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source_in_new_tab"));
+ viewSourceInNewTabActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source_in_new_tab"));
userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_privacy_browser"));
userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_webengine_default"));
userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_firefox_linux"));
// Get a handle for the status bar.
QStatusBar *statusBarPointer = statusBar();
- // Create a progress bar.
+ // Create the status bar widgets.
progressBarPointer = new QProgressBar();
+ QPushButton *zoomMinusButtonPointer = new QPushButton();
+ currentZoomButtonPointer = new QPushButton();
+ QPushButton *zoomPlusButtonPointer = new QPushButton();
- // Add the progress bar to to the status bar.
+ // Set the button icons.
+ zoomMinusButtonPointer->setIcon(QIcon::fromTheme(QStringLiteral("list-remove-symbolic")));
+ zoomPlusButtonPointer->setIcon(QIcon::fromTheme(QStringLiteral("list-add-symbolic")));
+
+ // Set the button icons to be flat (no borders).
+ zoomMinusButtonPointer->setFlat(true);
+ currentZoomButtonPointer->setFlat(true);
+ zoomPlusButtonPointer->setFlat(true);
+
+ // Handle clicks on the zoom buttons.
+ connect(zoomMinusButtonPointer, SIGNAL(clicked()), this, SLOT(decrementZoom()));
+ connect(currentZoomButtonPointer, SIGNAL(clicked()), this, SLOT(getZoomFactorFromUser()));
+ connect(zoomPlusButtonPointer, SIGNAL(clicked()), this, SLOT(incrementZoom()));
+
+ // Remove the padding around the current zoom button text.
+ currentZoomButtonPointer->setStyleSheet("padding: 0px;");
+
+ // Add the widgets to the far right of the status bar.
statusBarPointer->addPermanentWidget(progressBarPointer);
+ statusBarPointer->addPermanentWidget(zoomMinusButtonPointer);
+ statusBarPointer->addPermanentWidget(currentZoomButtonPointer);
+ statusBarPointer->addPermanentWidget(zoomPlusButtonPointer);
// Update the status bar with the URL when a link is hovered.
connect(tabWidgetPointer, SIGNAL(linkHovered(QString)), statusBarPointer, SLOT(showMessage(QString)));
urlLineEditPointer->clearFocus();
}
+void BrowserWindow::decrementZoom()
+{
+ // Update the current zoom factor.
+ currentZoomFactor = currentZoomFactor - 0.25;
+
+ // Check to make sure the zoom factor is in the valid range (0.25 to 5.00).
+ if (currentZoomFactor < 0.25)
+ currentZoomFactor = 0.25;
+
+ // Set the new zoom factor.
+ tabWidgetPointer->applyOnTheFlyZoomFactor(currentZoomFactor);
+
+ // Update the on-the-fly action text.
+ updateZoomFactorAction(currentZoomFactor);
+}
+
void BrowserWindow::escape() const
{
// Process the escape according to the status of the browser.
// Update the zoom factor if the user clicked OK.
if (okClicked)
{
- // Update the current zoom factor.
- currentZoomFactor = newZoomFactor;
-
// Set the new zoom factor.
tabWidgetPointer->applyOnTheFlyZoomFactor(newZoomFactor);
tabWidgetPointer->home();
}
+void BrowserWindow::incrementZoom()
+{
+ // Update the current zoom factor.
+ currentZoomFactor = currentZoomFactor + 0.25;
+
+ // Check to make sure the zoom factor is in the valid range (0.25 to 5.00).
+ if (currentZoomFactor > 5.0)
+ currentZoomFactor = 5.0;
+
+ // Set the new zoom factor.
+ tabWidgetPointer->applyOnTheFlyZoomFactor(currentZoomFactor);
+
+ // Update the on-the-fly action text.
+ updateZoomFactorAction(currentZoomFactor);
+}
+
void BrowserWindow::loadUrlFromLineEdit(const QString &url) const
{
// Remove the focus from the URL line edit.
// Set the current zoom factor.
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());
+ // Update the zoom factor action text, formatting the double with 2 decimal places. `0` specifies no extra field width. `'0'` sets the format to not use scientific notation.
+ zoomFactorActionPointer->setText(ki18nc("The zoom factor action", "Zoom Factor - %1").subs(zoomFactor, 0, '0', 2).toString());
+
+ // Update the status bar zoom factor label.
+ currentZoomButtonPointer->setText(ki18nc("The status bar zoom, which is just the formatted zoom factor", "%1").subs(zoomFactor, 0, '0', 2).toString());
}
void BrowserWindow::updateSearchEngineLabel(const QString &searchEngineString) const
// Get the new URL string.
QString newUrlString = newUrl.toString();
- // Update the view source checkbox.
- viewSourceActionPointer->setChecked(newUrlString.startsWith(QLatin1String("view-source:")));
+ // Update the view source actions.
+ if (newUrlString.startsWith(QLatin1String("view-source:"))) // The source is currently being viewed.
+ {
+ // Mark the view source checkbox.
+ viewSourceActionPointer->setChecked(true);
+
+ // Update the view in new tab action text.
+ viewSourceInNewTabActionPointer->setText(i18nc("View rendered website in new tab action", "View Rendered Website in New Tab"));
+ }
+ else // The source is not currently being viewed.
+ {
+ // Unmark the view source checkbox.
+ viewSourceActionPointer->setChecked(false);
+
+ // Update the view in new tab action text.
+ viewSourceInNewTabActionPointer->setText(i18nc("View source in new tab action", "View Source in New Tab"));
+ }
// Update the URL line edit if it does not have focus.
if (!urlLineEditPointer->hasFocus())