Skip to content

Commit

Permalink
Merge branch 'staged' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed May 20, 2022
2 parents 1660b0d + fb32704 commit bb2f114
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 174 deletions.
7 changes: 5 additions & 2 deletions article_inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
#include <QWebEngineContextMenuRequest>
#endif
ArticleInspector::ArticleInspector( QWidget * parent ) : QDialog( parent, Qt::WindowType::Window )
ArticleInspector::ArticleInspector( QWidget * parent ) : QWidget( parent, Qt::WindowType::Window )
{
setWindowTitle(tr("Inspect"));
setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false );
QVBoxLayout * v = new QVBoxLayout( this );
v->setSpacing( 0 );
v->setContentsMargins( 0, 0, 0, 0 );
inspectView = new QWebEngineView();
inspectView = new QWebEngineView( this );
v->addWidget( inspectView );

resize(800,600);
}

void ArticleInspector::setInspectPage( QWebEngineView * view )
Expand Down
3 changes: 1 addition & 2 deletions article_inspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <QWebEnginePage>
#include <QVBoxLayout>

class ArticleInspector : public QDialog
class ArticleInspector : public QWidget
{
Q_OBJECT
QWebEngineView * inspectView = nullptr;
Expand All @@ -15,7 +15,6 @@ class ArticleInspector : public QDialog
ArticleInspector( QWidget * parent = nullptr );

void setInspectPage( QWebEngineView * view);

private:

virtual void closeEvent( QCloseEvent * );
Expand Down
15 changes: 6 additions & 9 deletions articleview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au

connect(ui.definition, SIGNAL(loadProgress(int)), this,
SLOT(loadProgress(int)));
connect( ui.definition, SIGNAL( linkClicked( QUrl ) ), this, SLOT( linkClicked( QUrl ) ) );

connect( ui.definition->page(), SIGNAL( titleChanged( QString ) ),
this, SLOT( handleTitleChanged( QString ) ) );
Expand Down Expand Up @@ -494,20 +495,16 @@ void ArticleView::showAnticipation()
ui.definition->setCursor( Qt::WaitCursor );
}

void ArticleView::inspectElement(){
if( inspector == nullptr )
{
inspector = new ArticleInspector( this );
inspector->setWindowTitle( tr( "Inspect" ) );
}
inspector->setInspectPage( ui.definition );
void ArticleView::inspectElement()
{
emit inspectSignal( ui.definition );
}

void ArticleView::loadFinished( bool result )
{
setZoomFactor(cfg.preferences.zoomFactor);
setZoomFactor( cfg.preferences.zoomFactor );
QUrl url = ui.definition->url();
qDebug() << "article view loaded url:" << url.url ().left (200);
qDebug() << "article view loaded url:" << url.url().left( 200 );

if( cfg.preferences.autoScrollToTargetArticle )
{
Expand Down
5 changes: 2 additions & 3 deletions articleview.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class ArticleView: public QFrame
QString articleToJump;
QString rangeVarName;

//used to hold the F12 inspect source view.
ArticleInspector * inspector = nullptr;

/// Any resource we've decided to download off the dictionary gets stored here.
/// Full vector capacity is used for search requests, where we have to make
/// a multitude of requests.
Expand Down Expand Up @@ -282,6 +279,8 @@ signals:
/// signal finished javascript;
void notifyJavascriptFinished();

void inspectSignal(QWebEngineView * view);

public slots:

void on_searchPrevious_clicked();
Expand Down
15 changes: 15 additions & 0 deletions articlewebpage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "articlewebpage.h"

ArticleWebPage::ArticleWebPage(QObject *parent)
: QWebEnginePage{parent}
{
}
bool ArticleWebPage::acceptNavigationRequest( const QUrl & url, NavigationType type, bool isMainFrame )
{
if( type == QWebEnginePage::NavigationTypeLinkClicked )
{
emit linkClicked( url );
return true;
}
return QWebEnginePage::acceptNavigationRequest( url, type, isMainFrame );
}
17 changes: 17 additions & 0 deletions articlewebpage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef ARTICLEWEBPAGE_H
#define ARTICLEWEBPAGE_H

#include <QWebEnginePage>

class ArticleWebPage : public QWebEnginePage
{
Q_OBJECT
public:
explicit ArticleWebPage( QObject * parent = nullptr );
signals:
void linkClicked( const QUrl & url );
protected:
virtual bool acceptNavigationRequest( const QUrl & url, NavigationType type, bool isMainFrame );
};

#endif // ARTICLEWEBPAGE_H
4 changes: 4 additions & 0 deletions articlewebview.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#include "articlewebpage.h"
#include "articlewebview.hh"
#include <QMouseEvent>
#include <QWebEngineView>
Expand All @@ -18,6 +19,9 @@ ArticleWebView::ArticleWebView( QWidget *parent ):
midButtonPressed( false ),
selectionBySingleClick( false )
{
auto page = new ArticleWebPage( this );
connect( page, &ArticleWebPage::linkClicked, this, &ArticleWebView::linkClicked );
this->setPage( page );
}

ArticleWebView::~ArticleWebView()
Expand Down
2 changes: 2 additions & 0 deletions articlewebview.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public:
/// word, which gets selected by the view in response to double-click.
void doubleClicked( QPoint pos );

void linkClicked( const QUrl & url );

protected:
QWebEngineView *createWindow(QWebEnginePage::WebWindowType type);
bool event( QEvent * event );
Expand Down
34 changes: 0 additions & 34 deletions broken_xrecord.cc

This file was deleted.

13 changes: 0 additions & 13 deletions broken_xrecord.hh

This file was deleted.

29 changes: 0 additions & 29 deletions fulltextsearch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "initializing.hh"
#include <qt_windows.h>
#include <uxtheme.h>
#include <QOperatingSystemVersion>

#endif
Expand Down Expand Up @@ -242,27 +241,6 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
if( delegate )
ui.headwordsView->setItemDelegate( delegate );

#if defined( Q_OS_WIN32 )

// Style "windowsvista" in Qt5 turn off progress bar animation for classic appearance
// We use simply "windows" style instead for this case

oldBarStyle = 0;

if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7
&& !IsThemeActive() )
{
QStyle * barStyle = WindowsStyle::instance().getStyle();

if( barStyle )
{
oldBarStyle = ui.searchProgressBar->style();
ui.searchProgressBar->setStyle( barStyle );
}
}

#endif

ui.searchLine->setText( static_cast< MainWindow * >( parent )->getTranslateLineText() );
ui.searchLine->selectAll();
}
Expand All @@ -271,13 +249,6 @@ FullTextSearchDialog::~FullTextSearchDialog()
{
if( delegate )
delegate->deleteLater();

#if defined( Q_OS_WIN32 )

if( oldBarStyle )
ui.searchProgressBar->setStyle( oldBarStyle );

#endif
}

void FullTextSearchDialog::stopSearch()
Expand Down
4 changes: 0 additions & 4 deletions fulltextsearch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ class FullTextSearchDialog : public QDialog

QRegExp searchRegExp;

#if defined( Q_OS_WIN32 )
QStyle * oldBarStyle;
#endif

public:
FullTextSearchDialog( QWidget * parent,
Config::Class & cfg_,
Expand Down
6 changes: 2 additions & 4 deletions goldendict.pro
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ win32 {
!CONFIG( no_chinese_conversion_support ) {
CONFIG += chinese_conversion_support
}

LIBS += -luxtheme
}

unix:!mac {
Expand Down Expand Up @@ -225,6 +223,7 @@ DEFINES += PROGRAM_VERSION=\\\"$$VERSION\\\"
# Input
HEADERS += folding.hh \
article_inspect.h \
articlewebpage.h \
globalbroadcaster.h \
iframeschemehandler.h \
inc_case_folding.hh \
Expand Down Expand Up @@ -295,7 +294,6 @@ HEADERS += folding.hh \
orderandprops.hh \
language.hh \
dictionarybar.hh \
broken_xrecord.hh \
history.hh \
atomic_rename.hh \
articlewebview.hh \
Expand Down Expand Up @@ -366,6 +364,7 @@ FORMS += groups.ui \

SOURCES += folding.cc \
article_inspect.cpp \
articlewebpage.cpp \
globalbroadcaster.cpp \
iframeschemehandler.cpp \
main.cc \
Expand Down Expand Up @@ -429,7 +428,6 @@ SOURCES += folding.cc \
orderandprops.cc \
language.cc \
dictionarybar.cc \
broken_xrecord.cc \
history.cc \
atomic_rename.cc \
articlewebview.cc \
Expand Down
24 changes: 0 additions & 24 deletions initializing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#if defined( Q_OS_WIN32 )
#include <qt_windows.h>
#include <uxtheme.h>
#include <QOperatingSystemVersion>

WindowsStyle::WindowsStyle()
Expand Down Expand Up @@ -35,27 +34,6 @@ Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( par
setWindowIcon( QIcon( ":/icons/macicon.png" ) );
#endif

#if defined( Q_OS_WIN32 )

// Style "windowsvista" in Qt5 turn off progress bar animation for classic appearance
// We use simply "windows" style instead for this case

oldBarStyle = 0;

if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7
&& !IsThemeActive() )
{
QStyle * barStyle = WindowsStyle::instance().getStyle();

if( barStyle )
{
oldBarStyle = ui.progressBar->style();
ui.progressBar->setStyle( barStyle );
}
}

#endif

if ( showOnStartup )
{
ui.operation->setText( tr( "Please wait..." ) );
Expand Down Expand Up @@ -88,8 +66,6 @@ void Initializing::reject()

Initializing::~Initializing()
{
if( oldBarStyle )
ui.progressBar->setStyle( oldBarStyle );
}

#endif
3 changes: 0 additions & 3 deletions initializing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ private:

virtual void closeEvent( QCloseEvent * );
virtual void reject();
#if defined( Q_OS_WIN32 )
QStyle * oldBarStyle;
#endif

Ui::Initializing ui;
};
Expand Down
8 changes: 8 additions & 0 deletions locale/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
<translation>(c) 2008-2013 Konstantin Isakov (ikm@goldendict.org)</translation>
</message>
</context>
<context>
<name>ArticleInspector</name>
<message>
<location filename="../article_inspect.cpp" line="8"/>
<source>Inspect</source>
<translation>审查元素</translation>
</message>
</context>
<context>
<name>ArticleMaker</name>
<message>
Expand Down
Loading

0 comments on commit bb2f114

Please sign in to comment.