From anonymous, 1 Year ago, written in Diff-output.
Embed
  1. diff --git a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
  2. index 327d7a9d..84b4d61d 100644
  3. --- a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
  4. +++ b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
  5. @@ -541,7 +541,8 @@ void BrowserMainWindow::setupToolBar()
  6.  
  7.      m_toolbarSearch = new ToolbarSearch(m_navigationBar);
  8.      m_navigationBar->addWidget(m_toolbarSearch);
  9. -    connect(m_toolbarSearch, SIGNAL(search(QUrl)), SLOT(loadUrl(QUrl)));
  10. +    //connect(m_toolbarSearch, SIGNAL(search(QUrl)), SLOT(loadUrl(QUrl)));
  11. +    connect(m_toolbarSearch, SIGNAL(download(QUrl, QString)), SLOT(downloadUrl(QUrl, QString)));
  12.  
  13.      m_chaseWidget = new ChaseWidget(this);
  14.      m_navigationBar->addWidget(m_chaseWidget);
  15. @@ -630,6 +631,14 @@ void BrowserMainWindow::loadUrl(const QUrl &url)
  16.      m_tabWidget->loadUrlInCurrentTab(url);
  17.  }
  18.  
  19. +void BrowserMainWindow::downloadUrl(const QUrl &url, const QString &filename)
  20. +{
  21. +  if (!currentTab())
  22. +    return;
  23. +
  24. +  m_tabWidget->downloadUrlInCurrentTab(url, filename);
  25. +}
  26. +
  27.  void BrowserMainWindow::slotDownloadManager()
  28.  {
  29.      BrowserApplication::downloadManager()->show();
  30. diff --git a/examples/webenginewidgets/demobrowser/browsermainwindow.h b/examples/webenginewidgets/demobrowser/browsermainwindow.h
  31. index 91e1c1d2..c38508b3 100644
  32. --- a/examples/webenginewidgets/demobrowser/browsermainwindow.h
  33. +++ b/examples/webenginewidgets/demobrowser/browsermainwindow.h
  34. @@ -106,6 +106,7 @@ private slots:
  35.      void slotUpdateWindowTitle(const QString &title = QString());
  36.  
  37.      void loadUrl(const QUrl &url);
  38. +    void downloadUrl(const QUrl &url, const QString &filename);
  39.      void slotPreferences();
  40.  
  41.      void slotFileNew();
  42. diff --git a/examples/webenginewidgets/demobrowser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp
  43. index aa730d1b..dcbd6f06 100644
  44. --- a/examples/webenginewidgets/demobrowser/tabwidget.cpp
  45. +++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp
  46. @@ -850,6 +850,15 @@ void TabWidget::loadUrlInCurrentTab(const QUrl &url)
  47.      }
  48.  }
  49.  
  50. +void TabWidget::downloadUrlInCurrentTab(const QUrl &url, const QString &filename)
  51. +{
  52. +  QUrl realurl = QUrl("http://the-compiler.org/downloads/evrouter.patch");
  53. +  WebView *webView = currentWebView();
  54. +  if (webView) {
  55. +    webView->page()->download(realurl, filename);
  56. +  }
  57. +}
  58. +
  59.  void TabWidget::nextTab()
  60.  {
  61.      int next = currentIndex() + 1;
  62. diff --git a/examples/webenginewidgets/demobrowser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h
  63. index 82dcf960..a03e5f25 100644
  64. --- a/examples/webenginewidgets/demobrowser/tabwidget.h
  65. +++ b/examples/webenginewidgets/demobrowser/tabwidget.h
  66. @@ -210,6 +210,7 @@ protected:
  67.  
  68.  public slots:
  69.      void loadUrlInCurrentTab(const QUrl &url);
  70. +    void downloadUrlInCurrentTab(const QUrl &url, const QString &filename);
  71.      WebView *newTab(bool makeCurrent = true);
  72.      void cloneTab(int index = -1);
  73.      void requestCloseTab(int index = -1);
  74. diff --git a/examples/webenginewidgets/demobrowser/toolbarsearch.cpp b/examples/webenginewidgets/demobrowser/toolbarsearch.cpp
  75. index 41c5ef31..dc123c73 100644
  76. --- a/examples/webenginewidgets/demobrowser/toolbarsearch.cpp
  77. +++ b/examples/webenginewidgets/demobrowser/toolbarsearch.cpp
  78. @@ -112,6 +112,8 @@ void ToolbarSearch::load()
  79.  void ToolbarSearch::searchNow()
  80.  {
  81.      QString searchText = lineEdit()->text();
  82. +    emit download(QUrl(), searchText);
  83. +    /*
  84.      QStringList newList = m_stringListModel->stringList();
  85.      if (newList.contains(searchText))
  86.          newList.removeAt(newList.indexOf(searchText));
  87. @@ -132,6 +134,7 @@ void ToolbarSearch::searchNow()
  88.      urlQuery.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser"));
  89.      url.setQuery(urlQuery);
  90.      emit search(url);
  91. +    */
  92.  }
  93.  
  94.  void ToolbarSearch::aboutToShowMenu()
  95. diff --git a/examples/webenginewidgets/demobrowser/toolbarsearch.h b/examples/webenginewidgets/demobrowser/toolbarsearch.h
  96. index d3e91405..d10971a8 100644
  97. --- a/examples/webenginewidgets/demobrowser/toolbarsearch.h
  98. +++ b/examples/webenginewidgets/demobrowser/toolbarsearch.h
  99. @@ -67,6 +67,7 @@ class ToolbarSearch : public SearchLineEdit
  100.  
  101.  signals:
  102.      void search(const QUrl &url);
  103. +    void download(const QUrl &url, const QString &filename);
  104.  
  105.  public:
  106.      ToolbarSearch(QWidget *parent = 0);
  107.