diff --git a/runtime/BrowserWindow.cpp b/runtime/BrowserWindow.cpp index 8007664d5..b4e475f15 100644 --- a/runtime/BrowserWindow.cpp +++ b/runtime/BrowserWindow.cpp @@ -63,6 +63,10 @@ BrowserWindow::BrowserWindow(QString url) m_appServerUrl = url; +#ifdef _WIN32 + m_regMessage = ""; +#endif + // Setup the shortcuts createActions(); @@ -137,6 +141,9 @@ BrowserWindow::BrowserWindow(QString url) m_mainWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); #endif + // Register the signal when base URL loading is finished. + connect(m_mainWebView, SIGNAL(loadFinished(bool )),this, SLOT(urlLoadingFinished(bool ))); + // Restore the geometry, or set a nice default QSettings settings; @@ -188,6 +195,33 @@ void BrowserWindow::closeEvent(QCloseEvent *event) } } +#ifdef _WIN32 +// Set the message when change in registry value. +void BrowserWindow::setRegistryMessage(const QString &msg) +{ + m_regMessage = msg; +} + +QString BrowserWindow::getRegistryMessage() +{ + return m_regMessage; +} +#endif + +void BrowserWindow::urlLoadingFinished(bool res) +{ + if (res) + { +#ifdef _WIN32 + // Check if registry value is set by application then display information message to user. + // If message is empty string means no value set by application in registry. + QString message = getRegistryMessage(); + if (message != QString("")) + QMessageBox::information(this, tr("Registry change"), message); +#endif + } +} + // Create the actions for the window void BrowserWindow::createActions() { diff --git a/runtime/BrowserWindow.h b/runtime/BrowserWindow.h index 998c503e5..d6e9b67a0 100644 --- a/runtime/BrowserWindow.h +++ b/runtime/BrowserWindow.h @@ -57,6 +57,10 @@ public: BrowserWindow(QString url); ~BrowserWindow(); +#ifdef _WIN32 + void setRegistryMessage(const QString &msg); +#endif + protected: void closeEvent(QCloseEvent *event); @@ -79,6 +83,7 @@ private slots: #ifdef PGADMIN4_USE_WEBENGINE void downloadRequested(QWebEngineDownloadItem *download); #endif + void urlLoadingFinished(bool); public slots: void download(const QNetworkRequest &request); @@ -133,6 +138,10 @@ private: QString m_dir; QNetworkReply *m_reply; +#ifdef _WIN32 + QString m_regMessage; +#endif + #ifdef PGADMIN4_USE_WEBENGINE QWebEngineDownloadItem *m_download; #else @@ -144,6 +153,9 @@ private: void pause(int seconds = 1); int findURLTab(const QUrl &name); void enableDisableToolButtons(WebViewWindow *webViewPtr); +#ifdef _WIN32 + QString getRegistryMessage(); +#endif #ifdef __APPLE__ #ifdef PGADMIN4_USE_WEBENGINE diff --git a/runtime/pgAdmin4.cpp b/runtime/pgAdmin4.cpp index cf78eb081..58d309cbd 100644 --- a/runtime/pgAdmin4.cpp +++ b/runtime/pgAdmin4.cpp @@ -197,6 +197,27 @@ int main(int argc, char * argv[]) QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif +#ifdef _WIN32 + // Set registry "HKEY_CLASSES_ROOT\.css\Content Type" to value "text/css" to avoid rendering issue in windows OS. + QString infoMsgStr(""); + QSettings css_keys("HKEY_CLASSES_ROOT", QSettings::NativeFormat); + + // If key already exists then check for existing value and it differs then only change it. + if (css_keys.childGroups().contains(".css", Qt::CaseInsensitive)) + { + QSettings set("HKEY_CLASSES_ROOT\\.css", QSettings::NativeFormat); + if (set.value("Content Type").toString() != "text/css") + { + set.setValue("Content Type", "text/css"); + // If error while setting registry then it should be issue with permissions. + if (set.status() == QSettings::NoError) + infoMsgStr = "pgAdmin 4 application has reset the registry key 'HKEY_CLASSES_ROOT\\css\\Content Type' to 'text/css' to fix a system misconfiguration that can lead to rendering problems."; + else + infoMsgStr = "Failed to reset the registry key 'HKEY_CLASSES_ROOT\\css\\Content Type' to 'text/css'. Try to run with Administrator privileges."; + } + } +#endif + /* In windows and linux, it is required to set application level proxy * becuase socket bind logic to find free port gives socket creation error * when system proxy is configured. We are also setting @@ -385,6 +406,9 @@ int main(int argc, char * argv[]) BrowserWindow browserWindow(appServerUrl); browserWindow.setWindowTitle(PGA_APP_NAME); browserWindow.setWindowIcon(QIcon(":/pgAdmin4.ico")); +#ifdef _WIN32 + browserWindow.setRegistryMessage(infoMsgStr); +#endif browserWindow.show(); // Go!