2017-04-23 18:27:31 +02:00
|
|
|
#ifndef SYNCTHINGWIDGETS_NO_WEBVIEW
|
2016-08-25 00:45:32 +02:00
|
|
|
#include "./webpage.h"
|
2016-09-03 20:14:52 +02:00
|
|
|
#include "./webviewdialog.h"
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2017-04-23 18:27:31 +02:00
|
|
|
#include "../settings/settings.h"
|
2016-09-30 23:55:25 +02:00
|
|
|
|
2021-01-25 19:48:11 +01:00
|
|
|
#include <syncthingconnector/syncthingconnection.h>
|
2016-08-25 00:45:32 +02:00
|
|
|
|
|
|
|
#include "resources/config.h"
|
|
|
|
|
|
|
|
#include <QAuthenticator>
|
2017-05-01 03:34:43 +02:00
|
|
|
#include <QDesktopServices>
|
2017-11-01 18:04:54 +01:00
|
|
|
#include <QFileDialog>
|
2016-08-25 00:45:32 +02:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
2017-11-01 18:04:54 +01:00
|
|
|
#include <QStringBuilder>
|
2017-04-23 18:27:31 +02:00
|
|
|
#if defined(SYNCTHINGWIDGETS_USE_WEBENGINE)
|
2017-05-01 03:34:43 +02:00
|
|
|
#include <QWebEngineCertificateError>
|
|
|
|
#include <QWebEngineSettings>
|
|
|
|
#include <QWebEngineView>
|
2017-04-23 18:27:31 +02:00
|
|
|
#elif defined(SYNCTHINGWIDGETS_USE_WEBKIT)
|
2017-05-01 03:34:43 +02:00
|
|
|
#include <QNetworkRequest>
|
|
|
|
#include <QSslError>
|
|
|
|
#include <QWebFrame>
|
|
|
|
#include <QWebSettings>
|
|
|
|
#include <QWebView>
|
2016-08-25 00:45:32 +02:00
|
|
|
#endif
|
|
|
|
|
2018-10-28 17:03:23 +01:00
|
|
|
#ifdef SYNCTHINGWIDGETS_LOG_JAVASCRIPT_CONSOLE
|
|
|
|
#include <iostream>
|
|
|
|
#endif
|
|
|
|
|
2016-09-01 16:34:30 +02:00
|
|
|
using namespace Data;
|
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
namespace QtGui {
|
|
|
|
|
2017-12-30 02:26:55 +01:00
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_WEBENGINE
|
|
|
|
WebPage::WebPage(QWebEngineProfile *profile, WebViewDialog *dlg, SYNCTHINGWIDGETS_WEB_VIEW *view)
|
|
|
|
: SYNCTHINGWIDGETS_WEB_PAGE(profile, view)
|
|
|
|
#else
|
2017-05-01 03:34:43 +02:00
|
|
|
WebPage::WebPage(WebViewDialog *dlg, SYNCTHINGWIDGETS_WEB_VIEW *view)
|
|
|
|
: SYNCTHINGWIDGETS_WEB_PAGE(view)
|
2017-12-30 02:26:55 +01:00
|
|
|
#endif
|
2017-05-01 03:34:43 +02:00
|
|
|
, m_dlg(dlg)
|
|
|
|
, m_view(view)
|
2016-08-25 00:45:32 +02:00
|
|
|
{
|
2017-04-23 18:27:31 +02:00
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_WEBENGINE
|
2016-08-25 00:45:32 +02:00
|
|
|
settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
|
2021-08-07 18:05:30 +02:00
|
|
|
#if (QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
|
|
connect(this, &WebPage::certificateError, this, &WebPage::handleCertificateError);
|
|
|
|
#endif
|
2017-05-01 03:34:43 +02:00
|
|
|
connect(
|
|
|
|
this, &WebPage::authenticationRequired, this, static_cast<void (WebPage::*)(const QUrl &, QAuthenticator *)>(&WebPage::supplyCredentials));
|
2017-11-01 18:04:54 +01:00
|
|
|
#else // SYNCTHINGWIDGETS_USE_WEBKIT
|
2016-08-25 00:45:32 +02:00
|
|
|
settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
|
|
|
|
setNetworkAccessManager(&Data::networkAccessManager());
|
2017-05-01 03:34:43 +02:00
|
|
|
connect(&Data::networkAccessManager(), &QNetworkAccessManager::authenticationRequired, this,
|
|
|
|
static_cast<void (WebPage::*)(QNetworkReply *, QAuthenticator *)>(&WebPage::supplyCredentials));
|
|
|
|
connect(&Data::networkAccessManager(), &QNetworkAccessManager::sslErrors, this,
|
|
|
|
static_cast<void (WebPage::*)(QNetworkReply *, const QList<QSslError> &errors)>(&WebPage::handleSslErrors));
|
2016-08-25 00:45:32 +02:00
|
|
|
#endif
|
2017-01-01 18:14:44 +01:00
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
if (!m_view) {
|
2018-03-24 17:06:16 +01:00
|
|
|
// initialization for new window
|
|
|
|
// -> delegate to external browser if no view is assigned
|
2017-04-23 18:27:31 +02:00
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_WEBENGINE
|
2017-01-01 18:14:44 +01:00
|
|
|
connect(this, &WebPage::urlChanged, this, &WebPage::delegateNewWindowToExternalBrowser);
|
2016-08-25 00:45:32 +02:00
|
|
|
#else
|
2017-01-01 18:14:44 +01:00
|
|
|
connect(this->mainFrame(), &QWebFrame::urlChanged, this, &WebPage::delegateNewWindowToExternalBrowser);
|
2016-08-25 00:45:32 +02:00
|
|
|
#endif
|
2017-01-01 18:14:44 +01:00
|
|
|
// -> there need to be a view, though
|
2017-04-23 18:27:31 +02:00
|
|
|
m_view = new SYNCTHINGWIDGETS_WEB_VIEW;
|
2016-08-25 00:45:32 +02:00
|
|
|
m_view->setPage(this);
|
2017-11-01 18:25:30 +01:00
|
|
|
setParent(m_view);
|
2016-08-25 00:45:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-01 19:19:16 +01:00
|
|
|
bool WebPage::isSamePage(const QUrl &url1, const QUrl &url2)
|
|
|
|
{
|
2017-05-01 03:34:43 +02:00
|
|
|
if (url1.scheme() == url2.scheme() && url1.host() == url2.host() && url1.port() == url2.port()) {
|
2017-01-01 19:19:16 +01:00
|
|
|
QString path1 = url1.path();
|
2017-05-01 03:34:43 +02:00
|
|
|
while (path1.endsWith(QChar('/'))) {
|
2017-01-01 19:19:16 +01:00
|
|
|
path1.resize(path1.size() - 1);
|
|
|
|
}
|
|
|
|
QString path2 = url2.path();
|
2017-05-01 03:34:43 +02:00
|
|
|
while (path2.endsWith(QChar('/'))) {
|
2017-01-01 19:19:16 +01:00
|
|
|
path2.resize(path2.size() - 1);
|
|
|
|
}
|
2017-05-01 03:34:43 +02:00
|
|
|
if (path1 == path2) {
|
2017-01-01 19:19:16 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Delegates creation of new windows to a new instance of WebPage which will show it in an external browser.
|
|
|
|
*/
|
2017-04-23 18:27:31 +02:00
|
|
|
SYNCTHINGWIDGETS_WEB_PAGE *WebPage::createWindow(SYNCTHINGWIDGETS_WEB_PAGE::WebWindowType type)
|
2016-08-25 00:45:32 +02:00
|
|
|
{
|
2016-09-03 20:14:52 +02:00
|
|
|
Q_UNUSED(type)
|
2016-08-25 00:45:32 +02:00
|
|
|
return new WebPage;
|
|
|
|
}
|
|
|
|
|
2017-04-23 18:27:31 +02:00
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_WEBENGINE
|
2021-08-07 19:14:15 +02:00
|
|
|
/*!
|
|
|
|
* \brief Returns whether \a certificateError can be ignored.
|
|
|
|
* \remarks Before Qt 5.14 any self-signed certificates are accepted.
|
|
|
|
*/
|
2021-08-07 18:05:30 +02:00
|
|
|
bool WebPage::canIgnoreCertificateError(const QWebEngineCertificateError &certificateError) const
|
2016-09-01 16:34:30 +02:00
|
|
|
{
|
2020-03-29 20:38:05 +02:00
|
|
|
// never ignore errors other than CertificateCommonNameInvalid and CertificateAuthorityInvalid
|
2021-08-07 18:05:30 +02:00
|
|
|
switch (certificateError
|
|
|
|
#if (QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
|
|
.type()
|
|
|
|
#else
|
|
|
|
.error()
|
|
|
|
#endif
|
|
|
|
) {
|
2016-09-01 16:34:30 +02:00
|
|
|
case QWebEngineCertificateError::CertificateCommonNameInvalid:
|
|
|
|
case QWebEngineCertificateError::CertificateAuthorityInvalid:
|
2020-03-29 20:38:05 +02:00
|
|
|
break;
|
2016-09-01 16:34:30 +02:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-29 20:38:05 +02:00
|
|
|
|
|
|
|
// don't ignore the error if there are no expected self-signed SSL certificates configured
|
|
|
|
if (!m_dlg || m_dlg->connectionSettings().expectedSslErrors.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore only certificate errors matching the expected URL of the Syncthing instance
|
|
|
|
const auto urlWithError = certificateError.url();
|
|
|
|
const auto expectedUrl = m_view->url();
|
|
|
|
if (urlWithError.scheme() != expectedUrl.scheme() || urlWithError.host() != expectedUrl.host()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
|
|
// don't ignore the error if no certificate is provided at all (possible?)
|
|
|
|
const auto certificateChain = certificateError.certificateChain();
|
|
|
|
if (certificateChain.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// don't ignore the error if the first certificate in the chain (the peer's immediate certificate) does
|
|
|
|
// not match the expected SSL certificate
|
|
|
|
// note: All the SSL errors in the settings refer to the same certificate so it is sufficient to just pick
|
|
|
|
// the first one.
|
|
|
|
if (certificateChain.first() != m_dlg->connectionSettings().expectedSslErrors.first().certificate()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// accept the self-signed certificate
|
|
|
|
return true;
|
2016-09-01 16:34:30 +02:00
|
|
|
}
|
2017-01-01 18:14:44 +01:00
|
|
|
|
2021-08-07 18:05:30 +02:00
|
|
|
/*!
|
|
|
|
* \brief Accepts self-signed certificates used by the Syncthing GUI as configured.
|
|
|
|
* \remarks
|
2021-08-07 19:14:15 +02:00
|
|
|
* Judging by https://github.com/qt/qtwebengine/blob/dev/examples/webenginewidgets/simplebrowser/webpage.cpp
|
|
|
|
* the QWebEngineCertificateError is really supposed to be a copy. One would assume that
|
|
|
|
* modifying only the copy has no effect but it actually works, e.g. when removing the
|
|
|
|
* call `certificateError.acceptCertificate()` one only gets `ERR_CERT_AUTHORITY_INVALID`
|
|
|
|
* when trying to access e.g. `https://127.0.0.1:8080` but with the call it works.
|
2021-08-07 18:05:30 +02:00
|
|
|
*/
|
|
|
|
#if (QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
2021-08-07 19:14:15 +02:00
|
|
|
void WebPage::handleCertificateError(QWebEngineCertificateError certificateError)
|
2021-08-07 18:05:30 +02:00
|
|
|
{
|
|
|
|
if (canIgnoreCertificateError(certificateError)) {
|
2021-08-07 19:14:15 +02:00
|
|
|
certificateError.acceptCertificate();
|
2021-08-07 18:05:30 +02:00
|
|
|
} else {
|
2021-08-07 19:14:15 +02:00
|
|
|
certificateError.rejectCertificate();
|
2021-08-07 18:05:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
bool WebPage::certificateError(const QWebEngineCertificateError &certificateError)
|
|
|
|
{
|
|
|
|
return canIgnoreCertificateError(certificateError);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Accepts navigation requests only on the same page.
|
|
|
|
*/
|
2017-04-23 18:27:31 +02:00
|
|
|
bool WebPage::acceptNavigationRequest(const QUrl &url, SYNCTHINGWIDGETS_WEB_PAGE::NavigationType type, bool isMainFrame)
|
2017-01-01 18:14:44 +01:00
|
|
|
{
|
|
|
|
Q_UNUSED(isMainFrame)
|
|
|
|
Q_UNUSED(type)
|
|
|
|
return handleNavigationRequest(this->url(), url);
|
|
|
|
}
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Invokes processing JavaScript messages printed via "console.log()".
|
|
|
|
*/
|
|
|
|
void WebPage::javaScriptConsoleMessage(
|
|
|
|
QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
|
|
|
|
{
|
|
|
|
Q_UNUSED(level)
|
|
|
|
Q_UNUSED(lineNumber)
|
|
|
|
Q_UNUSED(sourceID)
|
|
|
|
if (level == QWebEnginePage::InfoMessageLevel) {
|
|
|
|
processJavaScriptConsoleMessage(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-23 18:27:31 +02:00
|
|
|
#else // SYNCTHINGWIDGETS_USE_WEBKIT
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Accepts navigation requests only on the same page.
|
|
|
|
*/
|
2017-04-23 18:27:31 +02:00
|
|
|
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, SYNCTHINGWIDGETS_WEB_PAGE::NavigationType type)
|
2017-01-01 18:14:44 +01:00
|
|
|
{
|
|
|
|
Q_UNUSED(frame)
|
|
|
|
Q_UNUSED(type)
|
|
|
|
return handleNavigationRequest(mainFrame() ? mainFrame()->url() : QUrl(), request.url());
|
|
|
|
}
|
2017-11-01 18:04:54 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Invokes processing JavaScript messages printed via "console.log()".
|
|
|
|
*/
|
|
|
|
void WebPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID)
|
|
|
|
{
|
|
|
|
Q_UNUSED(lineNumber)
|
|
|
|
Q_UNUSED(sourceID)
|
|
|
|
processJavaScriptConsoleMessage(message);
|
|
|
|
}
|
2016-09-01 16:34:30 +02:00
|
|
|
#endif
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Shows the specified \a url in the default browser and deletes the page and associated view.
|
|
|
|
*/
|
2017-01-01 18:14:44 +01:00
|
|
|
void WebPage::delegateNewWindowToExternalBrowser(const QUrl &url)
|
2016-08-25 00:45:32 +02:00
|
|
|
{
|
2016-09-01 16:34:30 +02:00
|
|
|
QDesktopServices::openUrl(url);
|
2016-08-25 00:45:32 +02:00
|
|
|
// this page and the associated view are useless
|
|
|
|
m_view->deleteLater();
|
|
|
|
}
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Supplies credentials from the dialog's settings.
|
|
|
|
*/
|
2016-08-25 00:45:32 +02:00
|
|
|
void WebPage::supplyCredentials(const QUrl &requestUrl, QAuthenticator *authenticator)
|
|
|
|
{
|
|
|
|
Q_UNUSED(requestUrl)
|
|
|
|
supplyCredentials(authenticator);
|
|
|
|
}
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Supplies credentials from the dialog's settings.
|
|
|
|
*/
|
2016-08-25 00:45:32 +02:00
|
|
|
void WebPage::supplyCredentials(QNetworkReply *reply, QAuthenticator *authenticator)
|
|
|
|
{
|
|
|
|
Q_UNUSED(reply)
|
|
|
|
supplyCredentials(authenticator);
|
|
|
|
}
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Supplies credentials from the dialog's settings.
|
|
|
|
*/
|
2016-08-25 00:45:32 +02:00
|
|
|
void WebPage::supplyCredentials(QAuthenticator *authenticator)
|
|
|
|
{
|
2018-10-28 14:27:25 +01:00
|
|
|
if (m_dlg && m_dlg->connectionSettings().authEnabled) {
|
|
|
|
authenticator->setUser(m_dlg->connectionSettings().userName);
|
|
|
|
authenticator->setPassword(m_dlg->connectionSettings().password);
|
2016-08-25 00:45:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Allows initial request and navigation on the same page but opens everything else in an external browser.
|
|
|
|
*/
|
2017-01-01 18:14:44 +01:00
|
|
|
bool WebPage::handleNavigationRequest(const QUrl ¤tUrl, const QUrl &targetUrl)
|
|
|
|
{
|
2017-05-01 03:34:43 +02:00
|
|
|
if (currentUrl.isEmpty()) {
|
2017-01-01 18:14:44 +01:00
|
|
|
// allow initial request
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// only allow navigation on the same page
|
2017-05-01 03:34:43 +02:00
|
|
|
if (isSamePage(currentUrl, targetUrl)) {
|
2017-01-01 19:19:16 +01:00
|
|
|
return true;
|
2017-01-01 18:14:44 +01:00
|
|
|
}
|
|
|
|
// otherwise open URL in external browser
|
|
|
|
QDesktopServices::openUrl(targetUrl);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-23 18:27:31 +02:00
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_WEBKIT
|
2017-11-01 18:04:54 +01:00
|
|
|
/*!
|
|
|
|
* \brief Ignores SSL errors that are known exceptions to support self-signed certificates.
|
|
|
|
*/
|
2016-09-01 16:34:30 +02:00
|
|
|
void WebPage::handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
|
2016-08-25 00:45:32 +02:00
|
|
|
{
|
2016-09-03 20:14:52 +02:00
|
|
|
Q_UNUSED(errors)
|
2017-05-01 03:34:43 +02:00
|
|
|
if (m_dlg && reply->request().url().host() == m_view->url().host()) {
|
2018-10-28 16:29:11 +01:00
|
|
|
reply->ignoreSslErrors(m_dlg->connectionSettings().expectedSslErrors);
|
2016-09-01 16:34:30 +02:00
|
|
|
}
|
2016-08-25 00:45:32 +02:00
|
|
|
}
|
2016-09-01 16:34:30 +02:00
|
|
|
#endif
|
2017-11-01 18:04:54 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Injects the specified JavaScript.
|
|
|
|
*/
|
|
|
|
void WebPage::injectJavaScript(const QString &scriptSource)
|
|
|
|
{
|
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_WEBENGINE
|
|
|
|
runJavaScript(scriptSource);
|
|
|
|
#else // SYNCTHINGWIDGETS_USE_WEBKIT
|
|
|
|
mainFrame()->evaluateJavaScript(scriptSource);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Injects the JavaScript code required for additional features.
|
|
|
|
* \remarks Called when the page has been loaded.
|
|
|
|
*/
|
|
|
|
void WebPage::injectJavaScripts(bool ok)
|
|
|
|
{
|
|
|
|
Q_UNUSED(ok)
|
|
|
|
// show folder path selection when double-clicking input
|
2022-11-20 14:49:50 +01:00
|
|
|
if (!Settings::values().enableWipFeatures) {
|
|
|
|
return;
|
|
|
|
}
|
2018-10-28 17:32:31 +01:00
|
|
|
injectJavaScript(QStringLiteral("var button = jQuery('<button type=\"button\" class=\"btn btn-sm\" "
|
2022-07-26 23:57:02 +02:00
|
|
|
"style=\"float: right;\">Select directory …</button>');"
|
2018-10-28 17:32:31 +01:00
|
|
|
"button.click(function(event) {"
|
|
|
|
" if (!document.getElementById('folderPath').getAttribute('readonly')) {"
|
2017-11-01 18:04:54 +01:00
|
|
|
" console.log('nativeInterface.showFolderPathSelection: ' + event.target.value);"
|
|
|
|
" }"
|
2018-10-28 17:32:31 +01:00
|
|
|
"});"
|
|
|
|
"var help = jQuery('#folderPath + * + .help-block');"
|
|
|
|
"help.prepend(button);"));
|
2017-11-01 18:04:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Invokes native methods requested via JavaScript log.
|
|
|
|
*/
|
|
|
|
void WebPage::processJavaScriptConsoleMessage(const QString &message)
|
|
|
|
{
|
2018-10-28 17:03:23 +01:00
|
|
|
#ifdef SYNCTHINGWIDGETS_LOG_JAVASCRIPT_CONSOLE
|
|
|
|
std::cerr << "JS console: " << message.toLocal8Bit().data() << std::endl;
|
|
|
|
#endif
|
2017-11-01 18:04:54 +01:00
|
|
|
if (message.startsWith(QLatin1String("nativeInterface.showFolderPathSelection: "))) {
|
|
|
|
showFolderPathSelection(message.mid(41));
|
2018-10-28 17:04:10 +01:00
|
|
|
} else if (message == QLatin1String("UIOnline")) {
|
|
|
|
injectJavaScripts(true);
|
2017-11-01 18:04:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Shows the folder path selection and sets the selected path in the page.
|
|
|
|
*/
|
|
|
|
void WebPage::showFolderPathSelection(const QString &defaultDir)
|
|
|
|
{
|
2022-07-26 23:57:02 +02:00
|
|
|
const QString dir(QFileDialog::getExistingDirectory(m_view, tr("Select path for Syncthing directory …"), defaultDir));
|
2017-11-01 18:04:54 +01:00
|
|
|
if (!dir.isEmpty()) {
|
|
|
|
injectJavaScript(QStringLiteral("document.getElementById('folderPath').value = '") % dir % QStringLiteral("';"));
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace QtGui
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2017-04-23 18:27:31 +02:00
|
|
|
#endif // SYNCTHINGWIDGETS_NO_WEBVIEW
|