Hi,

Please find the attached patch to reset the zoom level in the desktop
runtime.

Added the new shortcut CTRL + 0 to reset the zoom level.

Thanks,
Khushboo
diff --git a/runtime/BrowserWindow.cpp b/runtime/BrowserWindow.cpp
index 516b868..5845b7e 100644
--- a/runtime/BrowserWindow.cpp
+++ b/runtime/BrowserWindow.cpp
@@ -154,6 +154,7 @@ BrowserWindow::BrowserWindow(QString url)
     // Set the initial zoom
     qreal zoom = settings.value("Browser/Zoom", m_mainWebView->zoomFactor()).toReal();
     m_mainWebView->setZoomFactor(zoom);
+    settings.setValue("Browser/OrigZoomValue", zoom);
 
     // The last save location
     m_last_open_folder_path = settings.value("Browser/LastSaveLocation", QDir::homePath()).toString();
@@ -212,6 +213,11 @@ void BrowserWindow::createActions()
     zoomOutShortcut->setContext(Qt::ApplicationShortcut);
     connect(zoomOutShortcut, SIGNAL(activated()), this, SLOT(zoomOut()));
 
+    // Reset the zoom
+    zoomResetShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_0), this);
+    zoomResetShortcut->setContext(Qt::ApplicationShortcut);
+    connect(zoomResetShortcut, SIGNAL(activated()), this, SLOT(zoomReset()));
+
 #ifdef __APPLE__
   #ifdef PGADMIN4_USE_WEBENGINE
     QShortcut *cut_shortcut = new QShortcut(QKeySequence("Ctrl+X"), this);
@@ -1258,6 +1264,44 @@ void BrowserWindow::zoomOut()
 }
 
 
+// Reset Zoom
+void BrowserWindow::zoomReset()
+{
+
+    int tabCount = 0;
+    WebViewWindow *webviewPtr = NULL;
+    QSettings settings;
+
+    // Loop through all the tabs
+    for (tabCount = 0; tabCount < m_tabWidget->count(); tabCount++)
+    {
+        QWidget *tab = m_tabWidget->widget(tabCount);
+        if (tab != NULL)
+        {
+            // Find and loop through any child controls
+            QList<QWidget*> widgetList = tab->findChildren<QWidget*>();
+            foreach( QWidget* widgetPtr, widgetList )
+            {
+                if (widgetPtr != NULL)
+                {
+                    // If it's a web view control, set the zoom level based on the main view
+                    webviewPtr = dynamic_cast<WebViewWindow*>(widgetPtr);
+
+                    if (webviewPtr != NULL)
+                    {
+                        webviewPtr->setZoomFactor(settings.value("Browser/OrigZoomValue").toReal());
+                    }
+                }
+            }
+        }
+    }
+
+    // Save the original value
+    settings.setValue("Browser/Zoom", settings.value("Browser/OrigZoomValue").toReal());
+
+}
+
+
 // Open an arbitrary URL
 void BrowserWindow::openUrl()
 {
diff --git a/runtime/BrowserWindow.h b/runtime/BrowserWindow.h
index 1465a48..db26c4a 100644
--- a/runtime/BrowserWindow.h
+++ b/runtime/BrowserWindow.h
@@ -72,6 +72,7 @@ private slots:
     void about();
     void zoomIn();
     void zoomOut();
+    void zoomReset();
 #ifdef PGADMIN4_USE_WEBENGINE
     void downloadRequested(QWebEngineDownloadItem *download);
 #endif
@@ -104,6 +105,7 @@ private:
     QShortcut *aboutShortcut;
     QShortcut *zoomInShortcut;
     QShortcut *zoomOutShortcut;
+    QShortcut *zoomResetShortcut;
 
     QGridLayout  *m_tabGridLayout;
     QGridLayout  *m_mainGridLayout;
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to