Коммит 7cf6a773 создал по автору Коул Милена Ричардовна's avatar Коул Милена Ричардовна
Просмотр файлов

open links in browser

владелец b456b774
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#include <QMenu> #include <QMenu>
#include <QTabBar> #include <QTabBar>
#include <QWebEngineProfile> #include <QWebEngineProfile>
#include <QTimer>
#include <QDesktopServices>
TabWidget::TabWidget(QWebEngineProfile *profile, QWidget *parent) TabWidget::TabWidget(QWebEngineProfile *profile, QWidget *parent)
: QTabWidget(parent) : QTabWidget(parent)
...@@ -97,6 +99,15 @@ WebView *TabWidget::createLinkTab() ...@@ -97,6 +99,15 @@ WebView *TabWidget::createLinkTab()
WebView *webView = new WebView; WebView *webView = new WebView;
WebPage *webPage = new WebPage(m_profile, webView); WebPage *webPage = new WebPage(m_profile, webView);
webView->setPage(webPage); webView->setPage(webPage);
m_webView = webView;
QTimer::singleShot(500, this, [this] () {
QString new_url = m_webView->url().toDisplayString();
if (new_url.startsWith("https://"))
{
QDesktopServices::openUrl(QUrl(new_url, QUrl::TolerantMode));
}
qWarning() << m_webView->url().toDisplayString();
});
return webView; return webView;
} }
......
...@@ -77,6 +77,7 @@ public slots: ...@@ -77,6 +77,7 @@ public slots:
private: private:
WebView *webView(int index) const; WebView *webView(int index) const;
WebView *m_webView;
QWebEngineProfile *m_profile; QWebEngineProfile *m_profile;
}; };
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать