Added an option to prevent a browser tab being opened at startup. Fixes #5353

This commit is contained in:
Dave Page 2020-04-03 19:43:00 +05:30 committed by Akshay Joshi
parent e26a9a25d5
commit 4da327088c
7 changed files with 142 additions and 34 deletions

View File

@ -71,6 +71,12 @@ The configuration settings:
+--------------------------+--------------------+---------------------------------------------------------------+
| ConnectionTimeout | Integer | The number of seconds to wait for application server startup. |
+--------------------------+--------------------+---------------------------------------------------------------+
| FixedPort | Boolean | Use a fixed network port number rather than a random one. |
+--------------------------+--------------------+---------------------------------------------------------------+
| OpenTabAtStartup | Boolean | Open a browser tab at startup. |
+--------------------------+--------------------+---------------------------------------------------------------+
| PortNumber | Integer | The port number to use, if using a fixed port. |
+--------------------------+--------------------+---------------------------------------------------------------+
| PythonPath | String | The Python module search path |
+--------------------------+--------------------+---------------------------------------------------------------+

View File

@ -11,6 +11,7 @@ New features
| `Issue #5184 <https://redmine.postgresql.org/issues/5184>`_ - Added support for parameter toast_tuple_target and parallel_workers of the table.
| `Issue #5264 <https://redmine.postgresql.org/issues/5264>`_ - Added support of Packages, Sequences and Synonyms to the Schema Diff.
| `Issue #5353 <https://redmine.postgresql.org/issues/5353>`_ - Added an option to prevent a browser tab being opened at startup.
Housekeeping
************

View File

@ -57,6 +57,11 @@ int ConfigWindow::getPortNumber()
return ui->spinPortNumber->value();
}
bool ConfigWindow::getOpenTabAtStartup()
{
return ui->chkOpenTabAtStartup->isChecked();
}
QString ConfigWindow::getPythonPath()
{
return ui->pythonPathLineEdit->text();
@ -92,6 +97,18 @@ void ConfigWindow::setPortNumber(int port)
ui->spinPortNumber->setValue(port);
}
void ConfigWindow::setOpenTabAtStartup(bool openTabAtStartup)
{
if (openTabAtStartup)
{
ui->chkOpenTabAtStartup->setCheckState(Qt::Checked);
}
else
{
ui->chkOpenTabAtStartup->setCheckState(Qt::Unchecked);
}
}
void ConfigWindow::setPythonPath(QString path)
{
ui->pythonPathLineEdit->setText(path);

View File

@ -29,12 +29,14 @@ public:
QString getBrowserCommand();
bool getFixedPort();
int getPortNumber();
bool getOpenTabAtStartup();
QString getPythonPath();
QString getApplicationPath();
void setBrowserCommand(QString command);
void setFixedPort(bool fixedPort);
void setPortNumber(int port);
void setOpenTabAtStartup(bool openTabAtStartup);
void setPythonPath(QString path);
void setApplicationPath(QString path);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>731</width>
<height>300</height>
<height>398</height>
</rect>
</property>
<property name="sizePolicy">
@ -228,6 +228,66 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>By default, when the pgAdmin server is started a browser tab will be automatically opened to display the user interface. Un-check this option to run the server without automatically opening the browser.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Open a Browser Window/Tab at Startup?</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkOpenTabAtStartup">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
@ -267,17 +327,26 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="1">
<widget class="QLineEdit" name="applicationPathLineEdit">
<property name="placeholderText">
<string>/usr/pgadmin4/web</string>
<item row="3" column="1">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>60</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="pythonPathLineEdit">
<property name="placeholderText">
<string>/usr/pgadmin4/lib/python2.7;/usr/pgadmin4/lib/python2.7/site-packages</string>
<item row="0" column="0">
<widget class="QLabel" name="pythonPathLabel">
<property name="text">
<string>Python Path</string>
</property>
</widget>
</item>
@ -288,10 +357,17 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="pythonPathLabel">
<property name="text">
<string>Python Path</string>
<item row="0" column="1">
<widget class="QLineEdit" name="pythonPathLineEdit">
<property name="placeholderText">
<string>/usr/pgadmin4/lib/python2.7;/usr/pgadmin4/lib/python2.7/site-packages</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="applicationPathLineEdit">
<property name="placeholderText">
<string>/usr/pgadmin4/web</string>
</property>
</widget>
</item>
@ -312,18 +388,15 @@
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_5">
<item row="7" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>60</height>
<height>40</height>
</size>
</property>
</spacer>

View File

@ -79,6 +79,7 @@ void MenuActions::onConfig()
dlg->setBrowserCommand(settings.value("BrowserCommand").toString());
dlg->setFixedPort(settings.value("FixedPort").toBool());
dlg->setPortNumber(settings.value("PortNumber").toInt());
dlg->setOpenTabAtStartup(settings.value("OpenTabAtStartup", true).toBool());
dlg->setPythonPath(settings.value("PythonPath").toString());
dlg->setApplicationPath(settings.value("ApplicationPath").toString());
dlg->setModal(true);
@ -87,6 +88,7 @@ void MenuActions::onConfig()
QString browsercommand = dlg->getBrowserCommand();
bool fixedport = dlg->getFixedPort();
int portnumber = dlg->getPortNumber();
bool opentabatstartup = dlg->getOpenTabAtStartup();
QString pythonpath = dlg->getPythonPath();
QString applicationpath = dlg->getApplicationPath();
@ -100,6 +102,7 @@ void MenuActions::onConfig()
settings.setValue("BrowserCommand", browsercommand);
settings.setValue("FixedPort", fixedport);
settings.setValue("PortNumber", portnumber);
settings.setValue("OpenTabAtStartup", opentabatstartup);
settings.setValue("PythonPath", pythonpath);
settings.setValue("ApplicationPath", applicationpath);

View File

@ -313,6 +313,7 @@ int main(int argc, char * argv[])
dlg->setBrowserCommand(settings.value("BrowserCommand").toString());
dlg->setFixedPort(settings.value("FixedPort").toBool());
dlg->setPortNumber(settings.value("PortNumber").toInt());
dlg->setOpenTabAtStartup(settings.value("OpenTabAtStartup", true).toBool());
dlg->setPythonPath(settings.value("PythonPath").toString());
dlg->setApplicationPath(settings.value("ApplicationPath").toString());
dlg->setModal(true);
@ -321,6 +322,7 @@ int main(int argc, char * argv[])
QString browsercommand = dlg->getBrowserCommand();
bool fixedport = dlg->getFixedPort();
int portnumber = dlg->getPortNumber();
bool opentabatstartup = dlg->getOpenTabAtStartup();
QString pythonpath = dlg->getPythonPath();
QString applicationpath = dlg->getApplicationPath();
@ -329,6 +331,7 @@ int main(int argc, char * argv[])
settings.setValue("BrowserCommand", browsercommand);
settings.setValue("FixedPort", fixedport);
settings.setValue("PortNumber", portnumber);
settings.setValue("OpenTabAtStartup", opentabatstartup);
settings.setValue("PythonPath", pythonpath);
settings.setValue("ApplicationPath", applicationpath);
settings.sync();
@ -416,23 +419,26 @@ int main(int argc, char * argv[])
if (floatingWindow != Q_NULLPTR)
floatingWindow->enableShutdownMenu();
QString cmd = settings.value("BrowserCommand").toString();
if (settings.value("OpenTabAtStartup", true).toBool())
{
QString cmd = settings.value("BrowserCommand").toString();
if (!cmd.isEmpty())
{
cmd.replace("%URL%", appServerUrl);
QProcess::startDetached(cmd);
}
else
{
if (!QDesktopServices::openUrl(appServerUrl))
if (!cmd.isEmpty())
{
QString error(QWidget::tr("Failed to open the system default web browser. Is one installed?."));
QMessageBox::critical(Q_NULLPTR, QString(QWidget::tr("Fatal Error")), error);
cmd.replace("%URL%", appServerUrl);
QProcess::startDetached(cmd);
}
else
{
if (!QDesktopServices::openUrl(appServerUrl))
{
QString error(QWidget::tr("Failed to open the system default web browser. Is one installed?."));
QMessageBox::critical(Q_NULLPTR, QString(QWidget::tr("Fatal Error")), error);
Logger::GetLogger()->Log(error);
Logger::ReleaseLogger();
exit(1);
Logger::GetLogger()->Log(error);
Logger::ReleaseLogger();
exit(1);
}
}
}