Browse Source

fix initialization

Sonnix 6 years ago
parent
commit
ab3c943532
4 changed files with 24 additions and 5 deletions
  1. 11 1
      mainwindow.cpp
  2. 1 1
      qspexecwebengineurlschemehandler.cpp
  3. 11 2
      qspwebbox.cpp
  4. 1 1
      qspwebbox_webkit.cpp

+ 11 - 1
mainwindow.cpp

@@ -679,6 +679,11 @@ void MainWindow::CreateDockWindows()
     _mainDescTextBox = new QspWebBox(this);
     connect(_mainDescTextBox, SIGNAL(qspLinkClicked(QUrl)), this, SLOT(OnLinkClicked(QUrl)));
     _mainDescTextBox->page()->load(QUrl("qsp:/"));
+    {
+        QEventLoop loop;
+        connect(_mainDescTextBox->page(), SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));
+        loop.exec();
+    }
 #endif
 #ifdef _WEBBOX_WEBKIT
     _mainDescTextBox = new QspWebBox(this);
@@ -732,7 +737,12 @@ void MainWindow::CreateDockWindows()
 #ifdef _WEBBOX
     _descTextBox = new QspWebBox(this);
     connect(_descTextBox, SIGNAL(qspLinkClicked(QUrl)), this, SLOT(OnLinkClicked(QUrl)));
-    _mainDescTextBox->page()->load(QUrl("qsp:/"));
+    _descTextBox->page()->load(QUrl("qsp:/"));
+    {
+        QEventLoop loop;
+        connect(_descTextBox->page(), SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));
+        loop.exec();
+    }
 #endif
 #ifdef _WEBBOX_WEBKIT
     _descTextBox = new QspWebBox(this);

+ 1 - 1
qspexecwebengineurlschemehandler.cpp

@@ -53,5 +53,5 @@ void QspExecWebEngineUrlSchemeHandler::legacyLinkClicked(QWebEngineUrlRequestJob
         dialog.exec();
         QSPCallBacks::RefreshInt(QSP_FALSE);
     }
-    request->redirect(QUrl("qsp:/"));
+    //request->redirect(QUrl("qsp:/"));
 }

+ 11 - 2
qspwebbox.cpp

@@ -8,7 +8,7 @@
 #include <QWebEngineProfile>
 #include <QWebEngineSettings>
 //#include <QTimer>
-//#include <QEventLoop>
+#include <QEventLoop>
 
 #include "comtools.h"
 
@@ -117,7 +117,16 @@ void QspWebBox::RefreshUI(bool isScroll)
         qweush->SetPlainText(text);
     else
         qweush->SetHtml(text);
-    page()->load(QUrl("qsp:/"));
+
+    QString url_str = QByteArray::fromPercentEncoding(url().toString().toUtf8());
+    if(url_str.compare("qsp:" , Qt::CaseInsensitive) != 0 && url_str.compare("qsp:/" , Qt::CaseInsensitive) != 0)
+    {
+        QEventLoop loop;
+        connect(page(), SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));
+        page()->load(QUrl("qsp:/"));
+        loop.exec();
+    }
+    page()->triggerAction(QWebEnginePage::ReloadAndBypassCache);
 
     //QTimer wtimer;
     //wtimer.setSingleShot(true);

+ 1 - 1
qspwebbox_webkit.cpp

@@ -108,7 +108,7 @@ void QspWebBox::RefreshUI(bool isScroll)
     else
         qspManager->SetHtml(text);
     QString url_str = QByteArray::fromPercentEncoding(url().toString().toUtf8());
-    if(url_str.compare("qsp:" , Qt::CaseInsensitive) != 0 || url_str.compare("qsp:/" , Qt::CaseInsensitive) != 0)
+    if(url_str.compare("qsp:" , Qt::CaseInsensitive) != 0 && url_str.compare("qsp:/" , Qt::CaseInsensitive) != 0)
     {
         QEventLoop loop;
         connect(this, SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));