mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Check and attempt to fir the registry on Windows, if the text/css type is misconfigured. Fixes #2716
This commit is contained in:
parent
8f070f6095
commit
96df3147d6
@ -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()
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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!
|
||||
|
Loading…
Reference in New Issue
Block a user