mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-09-03 20:52:57 -05:00
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:
@@ -9,16 +9,20 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "pgAdmin4.h"
|
||||
#include "FloatingWindow.h"
|
||||
#include "ui_FloatingWindow.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
|
||||
|
||||
FloatingWindow::FloatingWindow(QWidget *parent) :
|
||||
QMainWindow(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool FloatingWindow::Init()
|
||||
{
|
||||
ui = new Ui::FloatingWindow;
|
||||
@@ -41,12 +45,13 @@ bool FloatingWindow::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Create the menu
|
||||
void FloatingWindow::createMenu()
|
||||
{
|
||||
createActions();
|
||||
|
||||
m_floatingWindowMenu = menuBar()->addMenu(QString(tr("&%1")).arg(PGA_APP_NAME));
|
||||
m_floatingWindowMenu = menuBar()->addMenu(tr("&pgAdmin 4"));
|
||||
m_floatingWindowMenu->addAction(m_newAction);
|
||||
m_floatingWindowMenu->addAction(m_copyUrlAction);
|
||||
m_floatingWindowMenu->addSeparator();
|
||||
@@ -56,19 +61,24 @@ void FloatingWindow::createMenu()
|
||||
m_floatingWindowMenu->addAction(m_quitAction);
|
||||
}
|
||||
|
||||
|
||||
// Create the menu actions
|
||||
void FloatingWindow::createActions()
|
||||
{
|
||||
m_newAction = new QAction(QString(tr("&New %1 window...")).arg(PGA_APP_NAME), this);
|
||||
m_newAction = new QAction(tr("&New pgAdmin 4 window..."), this);
|
||||
m_newAction->setEnabled(false);
|
||||
connect(m_newAction, SIGNAL(triggered()), m_menuActions, SLOT(onNew()));
|
||||
|
||||
m_copyUrlAction = new QAction(tr("&Copy server URL"), this);
|
||||
m_copyUrlAction->setEnabled(false);
|
||||
connect(m_copyUrlAction, SIGNAL(triggered()), m_menuActions, SLOT(onCopyUrl()));
|
||||
|
||||
m_configAction = new QAction(tr("C&onfigure..."), this);
|
||||
m_configAction->setEnabled(true);
|
||||
connect(m_configAction, SIGNAL(triggered()), m_menuActions, SLOT(onConfig()));
|
||||
|
||||
m_logAction = new QAction(tr("&View log..."), this);
|
||||
m_logAction->setEnabled(true);
|
||||
connect(m_logAction, SIGNAL(triggered()), m_menuActions, SLOT(onLog()));
|
||||
|
||||
m_quitAction = new QAction(tr("&Shut down server"), this);
|
||||
@@ -76,12 +86,23 @@ void FloatingWindow::createActions()
|
||||
connect(m_quitAction, SIGNAL(triggered()), m_menuActions, SLOT(onQuit()));
|
||||
}
|
||||
|
||||
void FloatingWindow::enableShutdownMenu()
|
||||
|
||||
void FloatingWindow::enablePostStartOptions()
|
||||
{
|
||||
if (m_newAction != Q_NULLPTR)
|
||||
m_newAction->setEnabled(true);
|
||||
|
||||
if (m_copyUrlAction != Q_NULLPTR)
|
||||
m_copyUrlAction->setEnabled(true);
|
||||
|
||||
if (m_configAction != Q_NULLPTR)
|
||||
m_configAction->setEnabled(true);
|
||||
|
||||
if (m_logAction != Q_NULLPTR)
|
||||
m_logAction->setEnabled(true);
|
||||
|
||||
if (m_quitAction != Q_NULLPTR)
|
||||
{
|
||||
m_quitAction->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void FloatingWindow::setMenuActions(MenuActions * menuActions)
|
||||
@@ -89,6 +110,7 @@ void FloatingWindow::setMenuActions(MenuActions * menuActions)
|
||||
m_menuActions = menuActions;
|
||||
}
|
||||
|
||||
|
||||
void FloatingWindow::closeEvent(QCloseEvent * event)
|
||||
{
|
||||
// Emit the signal to shut down the python server.
|
||||
|
||||
Reference in New Issue
Block a user