mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Use a custom configuration dialogue and allow the user to specify
the application path as well as the Python path.
This commit is contained in:
parent
2acba32c86
commit
7c9347873f
@ -26,6 +26,7 @@
|
||||
|
||||
// App headers
|
||||
#include "BrowserWindow.h"
|
||||
#include "ConfigWindow.h"
|
||||
|
||||
// Constructor
|
||||
BrowserWindow::BrowserWindow(QString url)
|
||||
@ -71,7 +72,7 @@ BrowserWindow::BrowserWindow(QString url)
|
||||
connect(m_mainWebView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
|
||||
|
||||
// Register the slot when click on the URL link form main menu bar
|
||||
connect(m_mainWebView,SIGNAL(linkClicked(const QUrl &)),SLOT(urlLinkClicked(const QUrl &)));
|
||||
connect(m_mainWebView, SIGNAL(linkClicked(const QUrl &)),SLOT(urlLinkClicked(const QUrl &)));
|
||||
|
||||
// Register the slot on tab index change
|
||||
connect(m_tabWidget,SIGNAL(currentChanged(int )),this,SLOT(tabIndexChanged(int )));
|
||||
@ -109,9 +110,9 @@ void BrowserWindow::createActions()
|
||||
connect(openUrlAction, SIGNAL(triggered()), this, SLOT(openUrl()));
|
||||
|
||||
// Set the Python Path
|
||||
pythonPathAction = new QAction(tr("&Python Path..."), this);
|
||||
pythonPathAction->setStatusTip(tr("Set the Python search path"));
|
||||
connect(pythonPathAction, SIGNAL(triggered()), this, SLOT(pythonPath()));
|
||||
configurationAction = new QAction(tr("&Configuration..."), this);
|
||||
configurationAction->setStatusTip(tr("Configure the application paths"));
|
||||
connect(configurationAction, SIGNAL(triggered()), this, SLOT(configuration()));
|
||||
|
||||
// Exit the app
|
||||
exitAction = new QAction(tr("E&xit"), this);
|
||||
@ -133,7 +134,7 @@ void BrowserWindow::createMenus()
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(openUrlAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(pythonPathAction);
|
||||
fileMenu->addAction(configurationAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAction);
|
||||
|
||||
@ -429,29 +430,43 @@ void BrowserWindow::about()
|
||||
void BrowserWindow::openUrl()
|
||||
{
|
||||
bool ok;
|
||||
QString url = QInputDialog::getText(this, tr("Open URL"), tr("Enter a URL"), QLineEdit::Normal, "http://", &ok);
|
||||
|
||||
QInputDialog *dlg = new QInputDialog();
|
||||
dlg->setInputMode(QInputDialog::TextInput);
|
||||
dlg->setWindowTitle(QWidget::tr("Open URL"));
|
||||
dlg->setLabelText(QWidget::tr("Enter a URL"));
|
||||
dlg->setTextValue("http://");
|
||||
dlg->resize(600,100);
|
||||
|
||||
ok = dlg->exec();
|
||||
|
||||
QString url = dlg->textValue();
|
||||
|
||||
if (ok && !url.isEmpty())
|
||||
m_mainWebView->setUrl(url);
|
||||
urlLinkClicked(QUrl(url));
|
||||
}
|
||||
|
||||
// Open an arbitrary URL
|
||||
void BrowserWindow::pythonPath()
|
||||
void BrowserWindow::configuration()
|
||||
{
|
||||
QSettings settings;
|
||||
bool ok;
|
||||
|
||||
QInputDialog *dlg = new QInputDialog();
|
||||
dlg->setInputMode(QInputDialog::TextInput);
|
||||
dlg->setWindowTitle(QWidget::tr("Python Path"));
|
||||
dlg->setLabelText(QWidget::tr("Set the Python search path (separate entries with a semicolon):"));
|
||||
dlg->setTextValue(settings.value("PythonPath").toString());
|
||||
dlg->resize(600,100);
|
||||
ConfigWindow *dlg = new ConfigWindow();
|
||||
dlg->setWindowTitle(QWidget::tr("Configuration"));
|
||||
dlg->setPythonPath(settings.value("PythonPath").toString());
|
||||
dlg->setApplicationPath(settings.value("ApplicationPath").toString());
|
||||
dlg->setModal(true);
|
||||
ok = dlg->exec();
|
||||
QString path = dlg->textValue();
|
||||
|
||||
QString pythonpath = dlg->getPythonPath();
|
||||
QString applicationpath = dlg->getApplicationPath();
|
||||
|
||||
if (ok)
|
||||
settings.setValue("PythonPath", path);
|
||||
{
|
||||
settings.setValue("PythonPath", pythonpath);
|
||||
settings.setValue("ApplicationPath", applicationpath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ protected slots:
|
||||
|
||||
private slots:
|
||||
void openUrl();
|
||||
void pythonPath();
|
||||
void configuration();
|
||||
void about();
|
||||
|
||||
public slots:
|
||||
@ -61,7 +61,7 @@ private:
|
||||
QMenu *fileMenu;
|
||||
QMenu *helpMenu;
|
||||
QAction *openUrlAction;
|
||||
QAction *pythonPathAction;
|
||||
QAction *configurationAction;
|
||||
QAction *exitAction;
|
||||
QAction *aboutAction;
|
||||
|
||||
|
57
runtime/ConfigWindow.cpp
Normal file
57
runtime/ConfigWindow.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
// ConfigWindow.h - Configuration window
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ConfigWindow.h"
|
||||
#include "ui_ConfigWindow.h"
|
||||
|
||||
ConfigWindow::ConfigWindow(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ConfigWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
ConfigWindow::~ConfigWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ConfigWindow::on_buttonBox_accepted()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void ConfigWindow::on_buttonBox_rejected()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
QString ConfigWindow::getPythonPath()
|
||||
{
|
||||
return ui->pythonPathLineEdit->text();
|
||||
}
|
||||
|
||||
QString ConfigWindow::getApplicationPath()
|
||||
{
|
||||
return ui->applicationPathLineEdit->text();
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::setPythonPath(QString path)
|
||||
{
|
||||
ui->pythonPathLineEdit->setText(path);
|
||||
}
|
||||
|
||||
void ConfigWindow::setApplicationPath(QString path)
|
||||
{
|
||||
ui->applicationPathLineEdit->setText(path);
|
||||
}
|
||||
|
44
runtime/ConfigWindow.h
Normal file
44
runtime/ConfigWindow.h
Normal file
@ -0,0 +1,44 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
// ConfigWindow.h - Configuration window
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CONFIGWINDOW_H
|
||||
#define CONFIGWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class ConfigWindow;
|
||||
}
|
||||
|
||||
class ConfigWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigWindow(QWidget *parent = 0);
|
||||
~ConfigWindow();
|
||||
|
||||
QString getPythonPath();
|
||||
QString getApplicationPath();
|
||||
|
||||
void setPythonPath(QString path);
|
||||
void setApplicationPath(QString path);
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
private:
|
||||
Ui::ConfigWindow *ui;
|
||||
QString m_pythonpath, m_applicationpath;
|
||||
};
|
||||
|
||||
#endif // CONFIGWINDOW_H
|
100
runtime/ConfigWindow.ui
Normal file
100
runtime/ConfigWindow.ui
Normal file
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QDialog" name="ConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>608</width>
|
||||
<height>118</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="pythonPathLabel">
|
||||
<property name="text">
|
||||
<string>Python Path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="pythonPathLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="applicationPathLabel">
|
||||
<property name="text">
|
||||
<string>Application Path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="applicationPathLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ConfigWindow</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ConfigWindow</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -79,10 +79,13 @@ Server::~Server()
|
||||
|
||||
bool Server::Init()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
// Find the webapp
|
||||
QStringList paths;
|
||||
paths.append("../web/"); // Windows/Linux source tree
|
||||
paths.append("../../../../web/"); // Mac source tree (in the app bundle)
|
||||
paths.append(settings.value("ApplicationPath").toString()); // System configured value
|
||||
paths.append(""); // Should be last!
|
||||
|
||||
for (int i = 0; i < paths.size(); ++i)
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
// App headers
|
||||
#include "BrowserWindow.h"
|
||||
#include "ConfigWindow.h"
|
||||
#include "Server.h"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
@ -82,17 +83,21 @@ int main(int argc, char * argv[])
|
||||
QSettings settings;
|
||||
bool ok;
|
||||
|
||||
QInputDialog *dlg = new QInputDialog();
|
||||
dlg->setInputMode(QInputDialog::TextInput);
|
||||
dlg->setWindowTitle(QWidget::tr("Python Path"));
|
||||
dlg->setLabelText(QWidget::tr("Set the Python search path (separate entries with a semicolon):"));
|
||||
dlg->setTextValue(settings.value("PythonPath").toString());
|
||||
dlg->resize(600,100);
|
||||
ConfigWindow *dlg = new ConfigWindow();
|
||||
dlg->setWindowTitle(QWidget::tr("Configuration"));
|
||||
dlg->setPythonPath(settings.value("PythonPath").toString());
|
||||
dlg->setApplicationPath(settings.value("ApplicationPath").toString());
|
||||
dlg->setModal(true);
|
||||
ok = dlg->exec();
|
||||
QString path = dlg->textValue();
|
||||
|
||||
QString pythonpath = dlg->getPythonPath();
|
||||
QString applicationpath = dlg->getApplicationPath();
|
||||
|
||||
if (ok)
|
||||
settings.setValue("PythonPath", path);
|
||||
{
|
||||
settings.setValue("PythonPath", pythonpath);
|
||||
settings.setValue("ApplicationPath", applicationpath);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
@ -27,13 +27,16 @@ HEADERS = BrowserWindow.h \
|
||||
Server.h \
|
||||
pgAdmin4.h \
|
||||
TabWindow.h \
|
||||
WebViewWindow.h
|
||||
WebViewWindow.h \
|
||||
ConfigWindow.h
|
||||
SOURCES = pgAdmin4.cpp \
|
||||
BrowserWindow.cpp \
|
||||
Server.cpp \
|
||||
TabWindow.cpp \
|
||||
WebViewWindow.cpp
|
||||
FORMS = BrowserWindow.ui
|
||||
WebViewWindow.cpp \
|
||||
ConfigWindow.cpp
|
||||
FORMS = BrowserWindow.ui \
|
||||
ConfigWindow.ui
|
||||
ICON = pgAdmin4.icns
|
||||
QMAKE_INFO_PLIST = Info.plist
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user