SHA256
1
0
forked from pool/musescore
musescore/no-webview-in-startcentre.patch

177 lines
6.3 KiB
Diff
Raw Normal View History

diff -ur a/mscore/startcenter.cpp b/mscore/startcenter.cpp
--- a/mscore/startcenter.cpp 2021-02-08 13:16:37.000000000 +0100
+++ b/mscore/startcenter.cpp 2021-04-24 14:18:23.888027687 +0200
@@ -58,43 +58,6 @@
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
setStyleSheet(QString("QPushButton { background-color: %1 }").arg(openScore->palette().color(QPalette::Base).name()));
-#ifdef USE_WEBENGINE
- if (!noWebView) {
-#if defined(WIN_PORTABLE)
- QWebEngineProfile* defaultProfile = QWebEngineProfile::defaultProfile();
- defaultProfile->setCachePath(QDir::cleanPath(QString("%1/../../../Data/settings/QWebEngine").arg(QCoreApplication::applicationDirPath())));
- defaultProfile->setPersistentStoragePath(QDir::cleanPath(QString("%1/../../../Data/settings/QWebEngine").arg(QCoreApplication::applicationDirPath())));
-#endif
- _webView = new MyWebView(this);
- _webView->setMaximumWidth(200);
-
- MyWebEnginePage* page = new MyWebEnginePage(this);
- MyWebUrlRequestInterceptor* wuri = new MyWebUrlRequestInterceptor(page);
- QWebEngineProfile* profile = page->profile();
-#if defined(WIN_PORTABLE)
- profile->setCachePath(QDir::cleanPath(QString("%1/../../../Data/settings/QWebEngine").arg(QCoreApplication::applicationDirPath())));
- profile->setPersistentStoragePath(QDir::cleanPath(QString("%1/../../../Data/settings/QWebEngine").arg(QCoreApplication::applicationDirPath())));
-#endif
- profile->setRequestInterceptor(wuri);
- _webView->setPage(page);
-
- auto extendedVer = QString(VERSION) + "." + QString(BUILD_NUMBER);
- QUrl connectPageUrl = QUrl(QString("https://connect2.musescore.com/?version=%1").arg(extendedVer));
- _webView->setUrl(connectPageUrl);
-
- horizontalLayout->addWidget(_webView);
-
- //workaround for the crashes sometimes happening in Chromium on macOS with Qt 5.12
- connect(_webView, &QWebEngineView::renderProcessTerminated, this, [this, profile, connectPageUrl](QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)
- {
- qDebug() << "Login page loading terminated" << terminationStatus << " " << exitCode;
- profile->clearHttpCache();
- _webView->load(connectPageUrl);
- _webView->show();
- });
- }
-#endif
-
// if (enableExperimental)
// right now dont know how it use in WebEngine @handrok
// QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
@@ -217,62 +180,5 @@
AbstractDialog::keyReleaseEvent(event);
}
-#ifdef USE_WEBENGINE
-
-//---------------------------------------------------------
-// MyWebView
-//---------------------------------------------------------
-
-MyWebView::MyWebView(QWidget *parent):
- QWebEngineView(parent)
- {
- if (!enableExperimental)
- setContextMenuPolicy(Qt::NoContextMenu);
- }
-
-//---------------------------------------------------------
-// ~MyWebView
-//---------------------------------------------------------
-
-MyWebView::~MyWebView()
- {
- disconnect(this, SIGNAL(loadFinished(bool)), this, SLOT(stopBusy(bool)));
- }
-
-//---------------------------------------------------------
-// sizeHint
-//---------------------------------------------------------
-
-QSize MyWebView::sizeHint() const
- {
- return QSize(200 , 600);
- }
-
-
-bool MyWebEnginePage::acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame)
- {
- qDebug() << "acceptNavigationRequest(" << url << "," << type << "," << isMainFrame << ")";
-
- if (type == QWebEnginePage::NavigationTypeLinkClicked)
- {
- QString path(url.path());
- QFileInfo fi(path);
- if (fi.suffix() == "mscz" || fi.suffix() == "xml"
- || fi.suffix() == "musicxml" || fi.suffix() == "mxl") {
- mscore->loadFile(url);
- QAction* a = getAction("startcenter");
- a->setChecked(false);
- mscore->showStartcenter(false);
- }
- else
- QDesktopServices::openUrl(url);
-
- return false;
- }
- return true;
- }
-
-
-#endif //USE_WEBENGINE
}
diff -ur a/mscore/startcenter.h b/mscore/startcenter.h
--- a/mscore/startcenter.h 2021-02-08 13:16:37.000000000 +0100
+++ b/mscore/startcenter.h 2021-04-24 14:19:16.684029679 +0200
@@ -19,62 +19,12 @@
namespace Ms {
-#ifdef USE_WEBENGINE
-
-class MyWebUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor {
- Q_OBJECT
-
- public:
- MyWebUrlRequestInterceptor(QObject* p = Q_NULLPTR)
- : QWebEngineUrlRequestInterceptor(p) {}
-
- void interceptRequest(QWebEngineUrlRequestInfo& info)
- {
- info.setHttpHeader("Accept-Language",
- QString("%1;q=0.8,en-US;q=0.6,en;q=0.4").arg(mscore->getLocaleISOCode()).toUtf8());
- }
- };
-
-//---------------------------------------------------------
-// MyWebEnginePage
-//---------------------------------------------------------
-
-class MyWebEnginePage : public QWebEnginePage {
- Q_OBJECT
-
- public:
- MyWebEnginePage(QObject* parent = Q_NULLPTR)
- : QWebEnginePage(parent) {}
-
- bool acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame);
- };
-
-//---------------------------------------------------------
-// MyWebEngineView
-//---------------------------------------------------------
-
-class MyWebView : public QWebEngineView {
- Q_OBJECT
-
- public slots:
-
- public:
- MyWebView(QWidget* parent = 0);
- ~MyWebView();
- virtual QSize sizeHint() const;
- };
-
-#endif //USE_WEBENGINE
-
//---------------------------------------------------------
// Startcenter
//---------------------------------------------------------
class Startcenter : public AbstractDialog, public Ui::Startcenter {
Q_OBJECT
-#ifdef USE_WEBENGINE
- MyWebView* _webView;
-#endif
virtual void closeEvent(QCloseEvent*);
private slots: