diff --git a/articleview.cc b/articleview.cc index b3cd0b1b..e6cb45b0 100644 --- a/articleview.cc +++ b/articleview.cc @@ -2697,148 +2697,6 @@ void ArticleView::on_ftsSearchNext_clicked() performFtsFindOperation( false ); } -#ifdef Q_OS_WIN32 - -void ArticleView::readTag( const QString & from, QString & to, int & count ) -{ - QChar ch, prev_ch; - bool inQuote = false, inDoublequote = false; - - to.append( ch = prev_ch = from[ count++ ] ); - while( count < from.size() ) - { - ch = from[ count ]; - if( ch == '>' && !( inQuote || inDoublequote ) ) - { - to.append( ch ); - break; - } - if( ch == '\'' ) - inQuote = !inQuote; - if( ch == '\"' ) - inDoublequote = !inDoublequote; - to.append( prev_ch = ch ); - count++; - } -} - -QString ArticleView::insertSpans( QString const & html ) -{ - QChar ch; - QString newContent; - bool inSpan = false, escaped = false; - - /// Enclose every word in string (exclude tags) with - - for( int i = 0; i < html.size(); i++ ) - { - ch = html[ i ]; - if( ch == '&' ) - { - escaped = true; - if( inSpan ) - { - newContent.append( "" ); - inSpan = false; - } - newContent.append( ch ); - continue; - } - - if( ch == '<' ) // Skip tag - { - escaped = false; - if( inSpan ) - { - newContent.append( "" ); - inSpan = false; - } - readTag( html, newContent, i ); - continue; - } - - if( escaped ) - { - if( ch == ';' ) - escaped = false; - newContent.append( ch ); - continue; - } - - if( !inSpan && ( ch.isLetterOrNumber() || ch.isLowSurrogate() ) ) - { - newContent.append( ""); - inSpan = true; - } - - if( inSpan && !( ch.isLetterOrNumber() || ch.isLowSurrogate() ) ) - { - newContent.append( ""); - inSpan = false; - } - - if( ch.isLowSurrogate() ) - { - newContent.append( ch ); - ch = html[ ++i ]; - } - - newContent.append( ch ); - if( ch == '-' && !( html[ i + 1 ] == ' ' || ( i > 0 && html[ i - 1 ] == ' ' ) ) ) - newContent.append( " " ); - } - if( inSpan ) - newContent.append( "" ); - return newContent; -} - -QString ArticleView::checkElement( QWebEnginePage & page, QPoint const & pt ) -{ - return runJavaScriptSync(&page, QString( - " var a= document.elementFromPoint(%1,%2);" - "var nodename=a.nodeName.toLowerCase();" - "if(nodename==\"body\"||nodename==\"html\"||nodename==\"head\")" - "{" - " return '';" - "}" - "return a.textContent;") - .arg(pt.x()) - .arg(pt.y())); -} - -QString ArticleView::wordAtPoint( int x, int y ) -{ - QString word; - - if( popupView ) - return word; - - QPoint pos = mapFromGlobal( QPoint( x, y ) ); - //todo - QWebEnginePage *frame = ui.definition->page(); - if( !frame ) - return word; - - QPointF scrollPoint=frame->scrollPosition(); - - QPoint posWithScroll = pos + QPoint((int)scrollPoint.x(),(int)scrollPoint.y()); - - /// Find target HTML element - QString nodeValue = runJavaScriptSync(frame, QString( - "var a= document.elementFromPoint(%1,%2);" - "var nodename=a.nodeName.toLowerCase();" - "if(nodename==\"body\"||nodename==\"html\"||nodename==\"head\")" - "{" - " return '';" - "}" - "return a.textContent;") - .arg(posWithScroll.x()) - .arg(posWithScroll.y())); - return nodeValue; -} - -#endif - ResourceToSaveHandler::ResourceToSaveHandler(ArticleView * view, QString const & fileName ) : QObject( view ), fileName( fileName ), diff --git a/articleview.hh b/articleview.hh index 0062aaa8..c9b46556 100644 --- a/articleview.hh +++ b/articleview.hh @@ -190,7 +190,7 @@ public: if(!qFuzzyCompare(existedFactor,factor)){ qDebug()<<"zoom factor ,existed:"<setZoomFactor( factor ); - ui.definition->page()->setZoomFactor(factor); + //ui.definition->page()->setZoomFactor(factor); } } @@ -410,18 +410,6 @@ private: // We need this to hide the search bar when we're showed void showEvent( QShowEvent * ); -#ifdef Q_OS_WIN32 - - /// Search inside web page for word under cursor - -private: - QString insertSpans( QString const & html ); - void readTag( QString const & from, QString & to, int & count ); - QString checkElement( QWebEnginePage & elem, const QPoint & pt ); -public: - QString wordAtPoint( int x, int y ); -#endif - }; class ResourceToSaveHandler: public QObject diff --git a/articlewebview.cc b/articlewebview.cc index 7fbad610..ad697013 100644 --- a/articlewebview.cc +++ b/articlewebview.cc @@ -16,8 +16,7 @@ ArticleWebView::ArticleWebView( QWidget *parent ): QWebEngineView( parent ), midButtonPressed( false ), - selectionBySingleClick( false ), - showInspectorDirectly( true ) + selectionBySingleClick( false ) { } diff --git a/articlewebview.hh b/articlewebview.hh index d5a6efb0..ac954bfc 100644 --- a/articlewebview.hh +++ b/articlewebview.hh @@ -66,7 +66,6 @@ private: bool midButtonPressed; bool selectionBySingleClick; - bool showInspectorDirectly; //MouseDbClickEvent will also emit MousePressEvent which conflict the single click event. //this variable used to distinguish the single click and real double click.