diff --git a/README b/README new file mode 100644 index 000000000..7adf5ddcd --- /dev/null +++ b/README @@ -0,0 +1,71 @@ +pgAdmin 4 +========= + +pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the +PostgreSQL (http://www.postgresql.org) database. + +At present, it is an experimental/proof of concept project. Use at your own +risk, and don't blame us if it breaks anything! + +Architecture +------------ + +pgAdmin 4 is being written as a web application in Python, using jQuery for the +client side processing and UI. On the server side, CherryPy and Backbone are +being considered. + +Although developed using web technologies, we intend for pgAdmin 4 to be usable +either on a web server using a browser, or standalone on a workstation. The +runtime/ subdirectory contains a QT based runtime application intended to allow +this - it is essentially a browser and Python interpretor in one package which +will be capable of hosting the Python application and presenting it to the user +as a desktop application. + +Building +-------- + +To build the runtime, the following packages must be installed: + +- QT 4.6 or above (older versions may work, but haven't been tested). +- Python 2.6 or above. + +Assuming both qmake and python-config are in the path: + +$ cd $PGADMIN4_SRC/runtime +$ qmake +Project MESSAGE: Building for QT5+... +$ make +... + +On Linux, an executable called 'pgAdmin4' will be built, and on Mac OS X, an +app bundle called pgAdmin4.app will be created. + +At the time of writing, no attempt has been made to build the runtime on a +Windows system, though in theory it should work. + +Support +------- + +pgAdmin 4 is completely experiemental and unsupported! + +Project info +------------ + +The source code repository can be found here: + +http://git.postgresql.org/gitweb/?p=pgadmin4.git;a=summary + +A Redmine project for pgAdmin 4 can be found at the address below. A PostgreSQL +community account is required to access this site. Please note that at present +only project developers can log bug and feature requests: + +https://redmine.postgresql.org/projects/pgadmin4 + +If you wish to discuss pgAdmin 4, or contribute to the project, please use the +pgAdmin Hackers mailing list: + +pgadmin-hackers@postgresql.org + +-- +Dave Page +pgAdmin Project Lead diff --git a/runtime/BrowserWindow.cpp b/runtime/BrowserWindow.cpp new file mode 100644 index 000000000..cc5e77e0d --- /dev/null +++ b/runtime/BrowserWindow.cpp @@ -0,0 +1,131 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin 4 - PostgreSQL Tools +// +// Copyright (C) 2013, The pgAdmin Development Team +// This software is released under the PostgreSQL Licence +// +// BrowserWindow.cpp - Implementation of the main window class +// +////////////////////////////////////////////////////////////////////////// + +// Must be before QT +#include + +#include + +#if QT_VERSION >= 0x050000 +#include +#include +#else +#include +#include +#include +#include +#include +#include +#include +#endif + +#include "BrowserWindow.h" + +// Constructor +BrowserWindow::BrowserWindow() +{ + createActions(); + createMenus(); + + // Create the WebKit control + webView = new QWebView(this); + setCentralWidget(webView); + + // Execute some python and set the web text + QString data = execPython(tr("from time import time,ctime\n" + "print 'Today is %s
This is python-generated HTML.' % ctime(time())\n")); + + webView->setHtml(data); +} + +// Create the actions for the window +void BrowserWindow::createActions() +{ + // Open an arbitrary URL + openUrlAction = new QAction(tr("&Open URL..."), this); + openUrlAction->setShortcut(tr("Ctrl+U")); + openUrlAction->setStatusTip(tr("Open a URL")); + connect(openUrlAction, SIGNAL(triggered()), this, SLOT(openUrl())); + + // Exit the app + exitAction = new QAction(tr("E&xit"), this); + exitAction->setStatusTip(tr("Exit the application")); + exitAction->setShortcuts(QKeySequence::Quit); + connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); + + // About box + aboutAction = new QAction(tr("&About"), this); + aboutAction->setStatusTip(tr("Show the application's About box")); + connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); +} + +// Create the application menus +void BrowserWindow::createMenus() +{ + // File + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(openUrlAction); + fileMenu->addSeparator(); + fileMenu->addAction(exitAction); + + menuBar()->addSeparator(); + + // Help + helpMenu = menuBar()->addMenu(tr("&Help")); + helpMenu->addAction(aboutAction); +} + +// Display the about box +void BrowserWindow::about() +{ + QMessageBox::about(this, tr("About pgAdmin 4"), tr("pgAdmin 4 - PostgreSQL Tools")); +} + +// Open an arbitrary URL +void BrowserWindow::openUrl() +{ + bool ok; + QString url = QInputDialog::getText(this, tr("Enter a URL"), tr("URL:"), QLineEdit::Normal, "http://", &ok); + + if (ok && !url.isEmpty()) + webView->setUrl(url); +} + +QString BrowserWindow::execPython(QString script) +{ + // This python script allows us to capture stdout/stderr + QString stdOutErr = +tr("import sys\n\ +class CatchStdoutStderr:\n\ + def __init__(self):\n\ + self.op = ''\n\ + def write(self, txt):\n\ + self.op += txt\n\ +catchStdoutStderr = CatchStdoutStderr()\n\ +sys.stdout = catchStdoutStderr\n\ +sys.stderr = catchStdoutStderr\n\ +"); + + // Create the main module, and call the redirect code. + PyObject *pModule = PyImport_AddModule("__main__"); + PyRun_SimpleString(stdOutErr.toUtf8().constData()); + + // Now execute the actual script + PyRun_SimpleString(script.toUtf8().constData()); + + // Get the catcher object + PyObject *catcher = PyObject_GetAttrString(pModule,"catchStdoutStderr"); + PyErr_Print(); + + PyObject *output = PyObject_GetAttrString(catcher,"op"); + + return QString(PyString_AsString(output)); +} diff --git a/runtime/BrowserWindow.h b/runtime/BrowserWindow.h new file mode 100644 index 000000000..58ad96280 --- /dev/null +++ b/runtime/BrowserWindow.h @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin 4 - PostgreSQL Tools +// +// Copyright (C) 2013, The pgAdmin Development Team +// This software is released under the PostgreSQL Licence +// +// BrowserWindow.h - Declaration of the main window class +// +////////////////////////////////////////////////////////////////////////// + +#ifndef BROWSERWINDOW_H +#define BROWSERWINDOW_H + +#include + +#if QT_VERSION >= 0x050000 +#include +#include +#else +#include +#include +#endif + +QT_BEGIN_NAMESPACE +class QAction; +class QMenu; +QT_END_NAMESPACE + +class BrowserWindow : public QMainWindow +{ + Q_OBJECT + +public: + BrowserWindow(); + +private slots: + void openUrl(); + void about(); + +private: + QWebView *webView; + QMenu *fileMenu; + QMenu *helpMenu; + QAction *openUrlAction; + QAction *exitAction; + QAction *aboutAction; + + void createActions(); + void createMenus(); + QString execPython(QString script); +}; + +#endif diff --git a/runtime/BrowserWindow.ui b/runtime/BrowserWindow.ui new file mode 100644 index 000000000..65172f18a --- /dev/null +++ b/runtime/BrowserWindow.ui @@ -0,0 +1,37 @@ + + + Form + + + + 0 + 0 + 911 + 688 + + + + Form + + + + + + + about:blank + + + + + + + + + QWebView + QWidget +
QtWebKitWidgets/QWebView
+
+
+ + +
diff --git a/runtime/Info.plist b/runtime/Info.plist new file mode 100644 index 000000000..7d9702fbb --- /dev/null +++ b/runtime/Info.plist @@ -0,0 +1,19 @@ + + + + + + CFBundleIconFile + @ICON@ + CFBundlePackageType + APPL + CFBundleGetInfoString + pgAdmin 4 - PostgreSQL Tools + CFBundleSignature + @TYPEINFO@ + CFBundleExecutable + @EXECUTABLE@ + CFBundleIdentifier + org.pgadmin.@EXECUTABLE@ + + diff --git a/runtime/pgAdmin4.cpp b/runtime/pgAdmin4.cpp new file mode 100644 index 000000000..e64f4e77b --- /dev/null +++ b/runtime/pgAdmin4.cpp @@ -0,0 +1,45 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin 4 - PostgreSQL Tools +// +// Copyright (C) 2013, The pgAdmin Development Team +// This software is released under the PostgreSQL Licence +// +// pgAdmin4.cpp - Main application entry point +// +////////////////////////////////////////////////////////////////////////// + +// Must be before QT +#include + +#include + +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif + +#include "BrowserWindow.h" + +int main(int argc, char * argv[]) +{ + // Create the QT application + QApplication app(argc, argv); + + // Initialise Python + Py_SetProgramName(argv[0]); + Py_Initialize(); + + // Create & show the main window + BrowserWindow browserWindow; + browserWindow.show(); + + // Go! + return app.exec(); + + // Shutdown Python + Py_Finalize(); +} + + diff --git a/runtime/pgAdmin4.icns b/runtime/pgAdmin4.icns new file mode 100644 index 000000000..39cfb440c Binary files /dev/null and b/runtime/pgAdmin4.icns differ diff --git a/runtime/pgAdmin4.pro b/runtime/pgAdmin4.pro new file mode 100644 index 000000000..7319d2dfe --- /dev/null +++ b/runtime/pgAdmin4.pro @@ -0,0 +1,24 @@ +# Configure QT modules for the appropriate version of QT +greaterThan(QT_MAJOR_VERSION, 4) { + message(Building for QT5+...) + QT += webkitwidgets network widgets +} else { + message(Building for QT4...) + QT += webkit network +} + +# Find and configure Python +!system(which python-config > /dev/null 2>&1) { + error(The python-config executable could not be found. Ensure Python is installed and in the system path.) +} +QMAKE_CXXFLAGS += $$system(python-config --includes) +QMAKE_LFLAGS += $$system(python-config --ldflags) + +# Source code +HEADERS = BrowserWindow.h +SOURCES = pgAdmin4.cpp \ + BrowserWindow.cpp +FORMS = BrowserWindow.ui +ICON = pgAdmin4.icns +QMAKE_INFO_PLIST = Info.plist +