add QWebInspector and debug config option
Stefan Bund [Tue, 25 Jan 2011 14:01:35 +0000 (15:01 +0100)]
Viewer.cc
Viewer.hh
main.cc
pykit.ini

index 56708ee..46b8419 100644 (file)
--- a/Viewer.cc
+++ b/Viewer.cc
@@ -18,6 +18,7 @@
 #endif
 #include <QPrinter>
 #include <QPrintDialog>
+#include <QWebInspector>
 
 //#include "Viewer.mpp"
 #define prefix_
@@ -104,6 +105,14 @@ prefix_ pykit::Viewer::Viewer(QUrl const & url, Publisher * publisher, QWidget *
 #endif
     connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SLOT(printRequested()));
     load(url);
+    inspector_ = new QWebInspector();
+    inspector_->setPage(page());
+}
+
+prefix_ pykit::Viewer::~Viewer()
+{
+    if (inspector_)
+        delete inspector_;
 }
 
 prefix_ void pykit::Viewer::printRequested()
index 3634e25..e7bed7a 100644 (file)
--- a/Viewer.hh
+++ b/Viewer.hh
@@ -16,6 +16,8 @@
 //#include "Viewer.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
 
+class QWebInspector;
+
 namespace pykit {
 
     class Publisher;
@@ -26,9 +28,13 @@ namespace pykit {
         Q_OBJECT;
     public:
         Viewer(QUrl const & url, Publisher * publisher, QWidget * parent = 0);
+        ~Viewer();
 
     private slots:
         void printRequested();
+
+    private:
+        QWebInspector * inspector_;
     };
 
 }
diff --git a/main.cc b/main.cc
index e6c4f27..c4d4910 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -18,6 +18,7 @@
 #include <QDir>
 #include <QFileInfo>
 #include <QFontDatabase>
+#include <QWebSettings>
 #include <boost/scoped_ptr.hpp>
 #include "MainWindow.hh"
 #include "PythonPublisher.hh"
@@ -90,6 +91,10 @@ int main(int argc, char *argv[])
         QString url (settings.value("home").toString());
         if (arguments.size()>1)
             url = arguments.at(1);
+
+        if (settings.value("debug").toBool())
+            QWebSettings::globalSettings()->setAttribute(
+                QWebSettings::DeveloperExtrasEnabled, true);
         pykit::MainWindow window (QUrl(url), &publisher);
         window.setWindowTitle(app.applicationName());
         if (!iconPath.isEmpty())
index ef666df..5d20f62 100644 (file)
--- a/pykit.ini
+++ b/pykit.ini
@@ -4,5 +4,5 @@ version=0.1
 organization=g0dil.de
 
 [Viewer]
-init=init.py
 home=http://pykit/
+debug=true
\ No newline at end of file