Make the runtime configuration dialog non-modal. Fixes #5490

Major refactoring of the runtime code, Specifically:
  - Move the bulk of the core code from main() into a new Runtime class.
  - Break up the mass of code that was main() into a number of relatively simple functions.
  - Make the Configuration dialog synchronous so the Log dialog can be properly viewed.
  - Enable/disable menu options at the right time.
  - Remove support for Qt < 5.0.
  - Remove the application name constant and hardcode the name to simplify the code.
  - Improve log messages.
  - Replace the sdbm hashing with Qt's MD5 hashing.
This commit is contained in:
Dave Page
2020-07-28 16:13:05 +05:30
committed by Akshay Joshi
parent ed0dc62b69
commit 46ba0310fa
23 changed files with 881 additions and 651 deletions
+65
View File
@@ -0,0 +1,65 @@
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// Runtime.h - Core of the runtime
//
//////////////////////////////////////////////////////////////////////////
#ifndef RUNTIME_H
#define RUNTIME_H
// Include the Python header here as it needs to appear before any QT
// headers anywhere in the app.
#ifdef __MINGW32__
#include <cmath>
#endif
#include <Python.h>
#include "TrayIcon.h"
#include "MenuActions.h"
#include "FloatingWindow.h"
// QT headers
#include <QtWidgets>
class Server;
class Runtime: public QObject
{
Q_OBJECT
public:
Runtime();
bool alreadyRunning();
bool go(int argc, char *argv[]);
void delay(int milliseconds);
bool shutdownServer(QUrl url);
private:
QSettings m_settings;
QSharedMemory *m_shmem;
bool m_configDone;
void setupStyling(QApplication *app);
void configureProxy();
QSplashScreen *displaySplash(QApplication *app);
quint16 getPort();
TrayIcon *createTrayIcon(QSplashScreen *splash, MenuActions *menuActions);
FloatingWindow *createFloatingWindow(QSplashScreen *splash, MenuActions *menuActions);
Server *startServerLoop(QSplashScreen *splash, FloatingWindow *floatingWindow, TrayIcon *trayIcon, int port, QString key);
Server *startServer(QSplashScreen *splash, int port, QString key);
void checkServer(QSplashScreen *splash, QString url);
void createAddressFile(QString url);
void openBrowserTab(QString url);
QString serverRequest(QUrl url, QString path);
bool pingServer(QUrl url);
private slots:
void onConfigDone(bool accepted);
};
#endif // RUNTIME_H