Changeset 47d5dc9 in subsurface


Ignore:
Timestamp:
Dec 30, 2016, 2:27:04 PM (11 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
5e78144, 99ea47b
Parents:
b5f0a4a (diff), 529a4d49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'webengine' of https://github.com/atdotde/subsurface

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    ra842e44 r529a4d49  
    3434option(BTSUPPORT "enable support for QtBluetooth (requires Qt5.4 or newer)" ON)
    3535option(FTDISUPPORT "enable support for libftdi based serial" OFF)
     36option(USE_WEBENGINE "Use QWebEngine instead of QWebKit" OFF)
    3637
    3738# Options regarding What should we build on subsurface
  • cmake/Modules/HandleUserManual.cmake

    raaafaad r529a4d49  
    33        add_definitions(-DNO_USERMANUAL)
    44else()
    5         list(APPEND QT_EXTRA_COMPONENTS WebKitWidgets)
    6         list(APPEND QT_EXTRA_LIBRARIES Qt5::WebKitWidgets)
     5        if(USE_WEBENGINE)
     6                message(STATUS "building with QWebEngine")
     7                list(APPEND QT_EXTRA_COMPONENTS WebEngineWidgets)
     8                list(APPEND QT_EXTRA_LIBRARIES Qt5::WebEngineWidgets)
     9                add_definitions(-DUSE_WEBENGINE)
     10        else()
     11                list(APPEND QT_EXTRA_COMPONENTS WebKitWidgets)
     12                list(APPEND QT_EXTRA_LIBRARIES Qt5::WebKitWidgets)
     13        endif()
    714endif()
  • core/imagedownloader.cpp

    rc2c0cb4 r10b8bda  
    101101                // Let's try to load it locally via its hash
    102102                QString filename = fileFromHash(picture->hash);
     103                if (filename.isNull())
     104                        filename = QString(picture->filename);
    103105                if (filename.isNull()) {
    104106                        // That didn't produce a local filename.
  • core/qthelper.cpp

    r27b4ef32 r10b8bda  
    10761076void learnHash(struct picture *picture, QByteArray hash)
    10771077{
     1078        if (hash.isNull())
     1079                return;
    10781080        if (picture->hash)
    10791081                free(picture->hash);
     
    11011103QString fileFromHash(char *hash)
    11021104{
     1105        if (!hash || !*hash)
     1106                return "";
    11031107        QMutexLocker locker(&hashOfMutex);
    11041108
     
    11211125                return;
    11221126        char *oldHash = copy_string(picture->hash);
    1123         learnHash(picture, hashFile(QString(picture->filename)));
     1127        learnHash(picture, hashFile(localFilePath(picture->filename)));
    11241128        if (!same_string(picture->hash, "") && !same_string(picture->hash, oldHash))
    11251129                mark_divelist_changed((true));
  • desktop-widgets/plugins/facebook/facebookconnectwidget.cpp

    r12eccda r529a4d49  
    1717#include <QMessageBox>
    1818#include <QInputDialog>
     19#ifdef USE_WEBENGINE
     20#include <QWebEngineView>
     21#else
    1922#include <QWebView>
    20 
     23#endif
    2124#include "mainwindow.h"
    2225#include "profile-widget/profilewidget2.h"
     
    225228        ui->setupUi(this);
    226229        FacebookManager *fb = FacebookManager::instance();
     230#ifdef USE_WEBENGINE
     231        facebookWebView = new QWebEngineView(this);
     232#else
    227233        facebookWebView = new QWebView(this);
     234#endif
    228235        ui->fbWebviewContainer->layout()->addWidget(facebookWebView);
    229236        if (fb->loggedIn()) {
     
    232239                facebookDisconnect();
    233240        }
     241#ifdef USE_WEBENGINE
     242        connect(facebookWebView, &QWebEngineView::urlChanged, fb, &FacebookManager::tryLogin);
     243#else
    234244        connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin);
     245#endif
    235246        connect(fb, &FacebookManager::justLoggedIn, this, &FacebookConnectWidget::facebookLoggedIn);
    236247}
     
    251262        ui->FBLabel->setText(tr("To connect to Facebook, please log in. This enables Subsurface to publish dives to your timeline"));
    252263        if (facebookWebView) {
     264#ifdef USE_WEBENGINE
     265        //FIX ME
     266#else
    253267                facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar());
     268#endif
    254269                facebookWebView->setUrl(FacebookManager::instance()->connectUrl());
    255270        }
  • desktop-widgets/plugins/facebook/facebookconnectwidget.h

    r12eccda r529a4d49  
    33
    44#include <QDialog>
     5#ifdef USE_WEBENGINE
     6class QWebEngineView;
     7#else
    58class QWebView;
     9#endif
    610namespace Ui {
    711  class FacebookConnectWidget;
     
    4246private:
    4347        Ui::FacebookConnectWidget *ui;
     48#ifdef USE_WEBENGINE
     49        QWebEngineView *facebookWebView;
     50#else
    4451        QWebView *facebookWebView;
     52#endif
    4553};
    4654
  • desktop-widgets/printer.cpp

    rad2ac58 r529a4d49  
    55
    66#include <algorithm>
     7#include <QPainter>
     8#ifdef USE_WEBENGINE
     9#include <QtWebEngineWidgets>
     10#else
    711#include <QtWebKitWidgets>
    8 #include <QPainter>
    912#include <QWebElementCollection>
    1013#include <QWebElement>
     14#endif
    1115#include "profile-widget/profilewidget2.h"
    1216
     
    1923        dpi = 0;
    2024        done = 0;
     25#ifdef USE_WEBENGINE
     26        webView = new QWebEngineView();
     27#else
    2128        webView = new QWebView();
     29#endif
    2230}
    2331
     
    6270{
    6371        // add extra padding at the bottom to pages with height not divisible by view port
     72#ifndef USE_WEBENGINE
    6473        int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
    6574        QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
     
    116125
    117126        painter.end();
     127#else
     128        // FIX ME
     129#endif
    118130}
    119131
     
    141153
    142154        // get all refereces to diveprofile class in the Html template
     155#ifdef USE_WEBENGINE
     156        //FIX ME
     157#else
    143158        QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
    144159
     
    174189        }
    175190        painter.end();
     191#endif
    176192
    177193        // return profle settings
     
    180196        profile->setFontPrintScale(fontScale);
    181197        profile->setToolTipVisibile(true);
     198#ifdef USE_WEBENGINE
     199        //FIXME
     200#else
    182201        profile->resize(originalSize);
     202#endif
    183203        prefs.animation_speed = animationOriginal;
    184204
     
    211231        pageSize.setHeight(qCeil(printerPtr->pageRect(QPrinter::Inch).height() * dpi));
    212232        pageSize.setWidth(qCeil(printerPtr->pageRect(QPrinter::Inch).width() * dpi));
     233#ifdef USE_WEBENGINE
     234        //FIXME
     235#else
    213236        webView->page()->setViewportSize(pageSize);
    214237        webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
     238#endif
    215239        // export border width with at least 1 pixel
    216240        templateOptions->border_width = std::max(1, pageSize.width() / 1000);
     
    230254        // get number of dives per page from data-numberofdives attribute in the body of the selected template
    231255        bool ok;
     256#ifdef USE_WEBENGINE
     257        // FIX ME
     258#else
    232259        divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok);
    233260        if (!ok) {
     
    235262                //TODO: show warning
    236263        }
     264#endif
    237265        int Pages;
    238266        if (divesPerPage == 0) {
     
    251279                pageSize.setHeight(paintDevice->height());
    252280                pageSize.setWidth(paintDevice->width());
     281#ifdef USE_WEBENGINE
     282                //FIXME
     283#else
    253284                webView->page()->setViewportSize(pageSize);
     285#endif
    254286                // initialize the border settings
    255287                templateOptions->border_width = std::max(1, pageSize.width() / 1000);
     
    259291                        webView->setHtml(t.generateStatistics());
    260292                }
    261 
     293#ifdef USE_WEBENGINE
     294                // FIX ME
     295                render(1);
     296#else
    262297                bool ok;
    263298                int divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok);
     
    271306                        render(1);
    272307                }
    273         }
    274 }
     308#endif
     309        }
     310}
  • desktop-widgets/printer.h

    r1d6683f r529a4d49  
    33
    44#include <QPrinter>
     5#ifdef USE_WEBENGINE
     6#include <QWebEngineView>
     7#else
    58#include <QWebView>
     9#endif
    610#include <QRect>
    711#include <QPainter>
     
    2125private:
    2226        QPaintDevice *paintDevice;
     27#ifdef USE_WEBENGINE
     28        QWebEngineView *webView;
     29#else
    2330        QWebView *webView;
     31#endif
    2432        print_options *printOptions;
    2533        template_options *templateOptions;
  • desktop-widgets/usermanual.cpp

    r7be962b r529a4d49  
    3535}
    3636
     37#ifdef USE_WEBENGINE
     38MyQWebEnginePage::MyQWebEnginePage(QObject* parent) : QWebEnginePage(parent)
     39{
     40}
     41
     42bool MyQWebEnginePage::acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool)
     43{
     44        if (type == QWebEnginePage::NavigationTypeLinkClicked)
     45        {
     46                QDesktopServices::openUrl(url);
     47                return false;
     48        }
     49        return true;
     50}
     51
     52
     53MyQWebEngineView::MyQWebEngineView(QWidget* parent)
     54{
     55}
     56#endif
     57
    3758UserManual::UserManual(QWidget *parent) : QWidget(parent)
    3859{
     
    5576        setWindowIcon(QIcon(":/subsurface-icon"));
    5677
     78#ifdef USE_WEBENGINE
     79        userManual = new MyQWebEngineView(this);
     80        MyQWebEnginePage *page = new MyQWebEnginePage();
     81        userManual->setPage(page);
     82#else
    5783        userManual = new QWebView(this);
     84#endif
    5885        QString colorBack = palette().highlight().color().name(QColor::HexRgb);
    5986        QString colorText = palette().highlightedText().color().name(QColor::HexRgb);
    6087        userManual->setStyleSheet(QString("QWebView { selection-background-color: %1; selection-color: %2; }")
    6188                .arg(colorBack).arg(colorText));
     89#ifndef USE_WEBENGINE
    6290        userManual->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
     91#endif
    6392        QString searchPath = getSubsurfaceDataPath("Documentation");
    6493        if (searchPath.size()) {
     
    85114        connect(actionShowSearch, SIGNAL(triggered(bool)), searchBar, SLOT(show()));
    86115        connect(actionHideSearch, SIGNAL(triggered(bool)), searchBar, SLOT(hide()));
     116#ifndef USE_WEBENGINE
    87117        connect(userManual, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
     118#endif
    88119        connect(searchBar, SIGNAL(searchTextChanged(QString)), this, SLOT(searchTextChanged(QString)));
    89120        connect(searchBar, SIGNAL(searchNext()), this, SLOT(searchNext()));
     
    97128}
    98129
     130#ifdef USE_WEBENGINE
     131void UserManual::search(QString text, QWebEnginePage::FindFlags flags = 0)
     132{
     133        userManual->findText(text, flags,
     134                             [this, text](bool found) {searchBar->setStyleSheet(found || text.length() == 0 ? "" : "QLineEdit{background: red;}");});
     135}
     136#else
    99137void UserManual::search(QString text, QWebPage::FindFlags flags = 0)
    100138{
     
    105143        }
    106144}
     145#endif
    107146
    108147void UserManual::searchTextChanged(const QString& text)
     
    119158void UserManual::searchPrev()
    120159{
     160#ifdef USE_WEBENGINE
     161        search(mLastText, QWebEnginePage::FindBackward);
     162#else
    121163        search(mLastText, QWebPage::FindBackward);
     164#endif
    122165}
    123166
     167#ifndef USE_WEBENGINE
    124168void UserManual::linkClickedSlot(const QUrl& url)
    125169{
    126170        QDesktopServices::openUrl(url);
    127171}
     172#endif
    128173
    129174#ifdef Q_OS_MAC
  • desktop-widgets/usermanual.h

    re49d621 r529a4d49  
    22#define USERMANUAL_H
    33
     4#ifdef USE_WEBENGINE
     5#include <QWebEngineView>
     6#include <QWebEnginePage>
     7#else
    48#include <QWebView>
    5 
     9#endif
    610#include "ui_searchbar.h"
    711
     
    2125        Ui::SearchBar ui;
    2226};
     27
     28#ifdef USE_WEBENGINE
     29class MyQWebEnginePage : public QWebEnginePage
     30{
     31        Q_OBJECT
     32
     33public:
     34        MyQWebEnginePage(QObject* parent = 0);
     35        bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool);
     36};
     37
     38class MyQWebEngineView : public QWebEngineView
     39{
     40        Q_OBJECT
     41
     42public:
     43        MyQWebEngineView(QWidget* parent = 0);
     44        MyQWebEnginePage* page() const;
     45};
     46#endif
     47
    2348
    2449class UserManual : public QWidget {
     
    4166        void searchNext();
    4267        void searchPrev();
     68#ifndef USE_WEBENGINE
    4369        void linkClickedSlot(const QUrl& url);
     70#endif
    4471private:
    45         QWebView *userManual;
    4672        SearchBar *searchBar;
    4773        QString mLastText;
     74#ifdef USE_WEBENGINE
     75        QWebEngineView *userManual;
     76        void search(QString, QWebEnginePage::FindFlags);
     77#else
     78        QWebView *userManual;
    4879        void search(QString, QWebPage::FindFlags);
     80#endif
    4981};
    5082#endif // USERMANUAL_H
Note: See TracChangeset for help on using the changeset viewer.