Преглед на файлове

Fix action QWebInspector

Kandrashin Denis преди 13 години
родител
ревизия
77e8c48976
променени са 4 файла, в които са добавени 22 реда и са изтрити 11 реда
  1. 2 10
      source/fb2main.cpp
  2. 0 1
      source/fb2main.hpp
  3. 14 0
      source/fb2view.cpp
  4. 6 0
      source/fb2view.hpp

+ 2 - 10
source/fb2main.cpp

@@ -1,7 +1,6 @@
 #include <QtGui>
 #include <QtDebug>
 #include <QTreeView>
-#include <QWebInspector>
 #include <QWebFrame>
 
 #include "fb2main.hpp"
@@ -402,8 +401,7 @@ void Fb2MainWindow::createActions()
     connect(act, SIGNAL(triggered()), this, SLOT(viewTree()));
     menu->addAction(act);
 
-    act = new QAction(tr("&Web inspector"), this);
-    connect(act, SIGNAL(triggered()), this, SLOT(showInspector()));
+    actionInspect = act = new QAction(tr("&Web inspector"), this);
     menu->addAction(act);
 
     menuBar()->addSeparator();
@@ -678,6 +676,7 @@ void Fb2MainWindow::viewText()
     connect(actionZoomIn, SIGNAL(triggered()), textEdit, SLOT(zoomIn()));
     connect(actionZoomOut, SIGNAL(triggered()), textEdit, SLOT(zoomOut()));
     connect(actionZoomOrig, SIGNAL(triggered()), textEdit, SLOT(zoomOrig()));
+    connect(actionInspect, SIGNAL(triggered()), textEdit, SLOT(showInspector()));
 
     if (!xml.isEmpty()) textEdit->load(curFile, xml);
 
@@ -771,11 +770,4 @@ void Fb2MainWindow::clipboardDataChanged()
     }
 }
 
-void Fb2MainWindow::showInspector()
-{
-    if (!textEdit) return;
-    QWebInspector * inspector = new QWebInspector();
-    inspector->setPage(textEdit->page());
-    inspector->show();
-}
 

+ 0 - 1
source/fb2main.hpp

@@ -55,7 +55,6 @@ private slots:
     void selectionChanged();
     void undoChanged();
     void redoChanged();
-    void showInspector();
     void zoomOrig();
     void openSettings();
 

+ 14 - 0
source/fb2view.cpp

@@ -11,6 +11,7 @@
 #include <QNetworkRequest>
 #include <QToolTip>
 #include <QWebElement>
+#include <QWebInspector>
 #include <QWebFrame>
 #include <QWebPage>
 
@@ -84,6 +85,7 @@ bool Fb2WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest
 
 Fb2WebView::Fb2WebView(QWidget *parent)
     : Fb2BaseWebView(parent)
+    , m_inspector(0)
     , m_noteView(0)
     , m_thread(0)
 {
@@ -96,6 +98,7 @@ Fb2WebView::Fb2WebView(QWidget *parent)
 
 Fb2WebView::~Fb2WebView()
 {
+    FB2DELETE(m_inspector);
     FB2DELETE(m_noteView);
 }
 
@@ -322,3 +325,14 @@ QString Fb2WebView::status()
     return page()->mainFrame()->evaluateJavaScript(javascript).toString();
     return QString();
 }
+
+void Fb2WebView::showInspector()
+{
+    if (!m_inspector) {
+        m_inspector = new QWebInspector();
+        m_inspector->setAttribute(Qt::WA_DeleteOnClose, false);
+        m_inspector->setPage(page());
+    }
+    m_inspector->show();
+}
+

+ 6 - 0
source/fb2view.hpp

@@ -9,6 +9,10 @@
 
 #include "fb2temp.hpp"
 
+QT_BEGIN_NAMESPACE
+class QWebInspector;
+QT_END_NAMESPACE
+
 class Fb2NoteView;
 
 class Fb2BaseWebView : public QWebView
@@ -88,6 +92,7 @@ public slots:
     void data(QString name, QByteArray data);
     void html(QString name, QString html);
     void linkHovered(const QString &link, const QString &title, const QString &textContent);
+    void showInspector();
     void insertImage();
     void insertNote();
     void insertLink();
@@ -105,6 +110,7 @@ private:
     QWebElement doc();
 
 private:
+    QWebInspector * m_inspector;
     Fb2TemporaryList m_files;
     Fb2NoteView *m_noteView;
     QThread *m_thread;