#include <boost/python.hpp>
#include "Publisher.hh"
#include <QDesktopServices>
+#include <QWebHistory>
+#include "Viewer.hh"
//#include "PythonPublisher.mpp"
#define prefix_
;
}
+namespace {
+
+ bool canGoBack()
+ {
+ return pykit::Viewer::instance()->page()->history()->canGoBack();
+ }
+
+ bool canGoForward()
+ {
+ return pykit::Viewer::instance()->page()->history()->canGoForward();
+ }
+
+}
+
BOOST_PYTHON_MODULE(_pykit)
{
py::class_<pykit::Request>("Request", py::no_init)
;
py::def("openUrl", &QDesktopServices::openUrl);
+
+ py::def("canGoBack", &canGoBack);
+ py::def("canGoForward", &canGoForward);
}
PYTHON_EXTERN_MODULE(_httpapi);
///////////////////////////////////////////////////////////////////////////
// pykit::Viewer
+namespace {
+ pykit::Viewer * instance_ (0);
+}
+
prefix_ pykit::Viewer::Viewer(QUrl const & url, Publisher * publisher, QWidget * parent)
: QWebView (parent)
{
+ instance_ = this;
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
if (! QWebSettings::globalSettings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
setContextMenuPolicy(Qt::NoContextMenu);
inspector_->setPage(page());
}
+prefix_ pykit::Viewer * pykit::Viewer::instance()
+{
+ return instance_;
+}
+
prefix_ pykit::Viewer::~Viewer()
{
if (inspector_)
Viewer(QUrl const & url, Publisher * publisher, QWidget * parent = 0);
~Viewer();
+ static Viewer * instance();
+
private slots:
void printRequested();