mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
refactor: convert articleview into plain code
This commit is contained in:
parent
fb6d4f9ccd
commit
a75867f82b
|
@ -48,6 +48,7 @@ ExperimentalAutoDetectBinPacking: true
|
||||||
FixNamespaceComments: false
|
FixNamespaceComments: false
|
||||||
IncludeBlocks: Regroup
|
IncludeBlocks: Regroup
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
|
IndentAccessModifiers: false
|
||||||
IndentPPDirectives: BeforeHash
|
IndentPPDirectives: BeforeHash
|
||||||
MaxEmptyLinesToKeep: 2
|
MaxEmptyLinesToKeep: 2
|
||||||
NamespaceIndentation: Inner
|
NamespaceIndentation: Inner
|
||||||
|
|
|
@ -16,6 +16,7 @@ Checks: >
|
||||||
-bugprone-easily-swappable-parameters,
|
-bugprone-easily-swappable-parameters,
|
||||||
-bugprone-reserved-identifier,
|
-bugprone-reserved-identifier,
|
||||||
-cppcoreguidelines-owning-memory,
|
-cppcoreguidelines-owning-memory,
|
||||||
|
-cppcoreguidelines-prefer-member-initializer,
|
||||||
-google-default-arguments,
|
-google-default-arguments,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
-misc-const-correctness,
|
-misc-const-correctness,
|
||||||
|
|
|
@ -133,7 +133,6 @@ set(QRC_RESOURCES
|
||||||
|
|
||||||
set(UI_SRC
|
set(UI_SRC
|
||||||
about.ui
|
about.ui
|
||||||
articleview.ui
|
|
||||||
authentication.ui
|
authentication.ui
|
||||||
chineseconversion.ui
|
chineseconversion.ui
|
||||||
dictgroupwidget.ui
|
dictgroupwidget.ui
|
||||||
|
|
632
articleview.cc
632
articleview.cc
File diff suppressed because it is too large
Load diff
|
@ -1,34 +1,39 @@
|
||||||
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
||||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||||
|
|
||||||
#ifndef __ARTICLEVIEW_HH_INCLUDED__
|
#ifndef GOLDENDICT_ARTICLEVIEW_HH
|
||||||
#define __ARTICLEVIEW_HH_INCLUDED__
|
#define GOLDENDICT_ARTICLEVIEW_HH
|
||||||
|
|
||||||
#include <QWebEngineView>
|
#include <QAction>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QUrl>
|
#include <QPushButton>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QWebEngineView>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "article_netmgr.hh"
|
#include "article_netmgr.hh"
|
||||||
#include "audioplayerinterface.hh"
|
#include "audioplayerinterface.hh"
|
||||||
#include "instances.hh"
|
#include "instances.hh"
|
||||||
#include "groupcombobox.hh"
|
#include "groupcombobox.hh"
|
||||||
#include "ui_articleview.h"
|
|
||||||
#include "globalbroadcaster.h"
|
#include "globalbroadcaster.h"
|
||||||
#include "article_inspect.h"
|
#include "article_inspect.h"
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
|
#if( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
||||||
#include <QtCore5Compat/QRegExp>
|
#include <QtCore5Compat/QRegExp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#include "ankiconnector.h"
|
#include "ankiconnector.h"
|
||||||
#include "webmultimediadownload.hh"
|
#include "webmultimediadownload.hh"
|
||||||
#include "base_type.h"
|
#include "base_type.h"
|
||||||
|
#include "articlewebview.hh"
|
||||||
|
|
||||||
class ResourceToSaveHandler;
|
class ResourceToSaveHandler;
|
||||||
class ArticleViewAgent ;
|
class ArticleViewAgent ;
|
||||||
|
|
||||||
/// A widget with the web view tailored to view and handle articles -- it
|
/// A widget with the web view tailored to view and handle articles -- it
|
||||||
/// uses the appropriate netmgr, handles link clicks, rmb clicks etc
|
/// uses the appropriate netmgr, handles link clicks, rmb clicks etc
|
||||||
class ArticleView: public QFrame
|
class ArticleView: public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -38,9 +43,8 @@ class ArticleView: public QFrame
|
||||||
Instances::Groups const & groups;
|
Instances::Groups const & groups;
|
||||||
bool popupView;
|
bool popupView;
|
||||||
Config::Class const & cfg;
|
Config::Class const & cfg;
|
||||||
QWebChannel *channel;
|
QWebChannel * channel;
|
||||||
ArticleViewAgent * agent;
|
ArticleViewAgent * agent;
|
||||||
Ui::ArticleView ui;
|
|
||||||
|
|
||||||
AnkiConnector * ankiConnector;
|
AnkiConnector * ankiConnector;
|
||||||
|
|
||||||
|
@ -167,7 +171,25 @@ public:
|
||||||
|
|
||||||
void setDelayedHighlightText(QString const & text);
|
void setDelayedHighlightText(QString const & text);
|
||||||
|
|
||||||
public slots:
|
private:
|
||||||
|
// widgets
|
||||||
|
ArticleWebView * webview;
|
||||||
|
|
||||||
|
QWidget * searchPanel;
|
||||||
|
QLineEdit * searchText;
|
||||||
|
QPushButton * searchCloseButton;
|
||||||
|
QPushButton * searchPrevious;
|
||||||
|
QPushButton * searchNext;
|
||||||
|
QCheckBox * highlightAllButton;
|
||||||
|
QCheckBox * searchCaseSensitive;
|
||||||
|
|
||||||
|
QWidget * ftsSearchPanel;
|
||||||
|
QLabel * ftsSearchStatusLabel;
|
||||||
|
QPushButton * ftsSearchPrevious;
|
||||||
|
QPushButton * ftsSearchNext;
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
/// Goes back in history
|
/// Goes back in history
|
||||||
void back();
|
void back();
|
||||||
|
@ -176,8 +198,7 @@ public slots:
|
||||||
void forward();
|
void forward();
|
||||||
|
|
||||||
/// Takes the focus to the view
|
/// Takes the focus to the view
|
||||||
void focus()
|
void focus() { webview->setFocus( Qt::ShortcutFocusReason ); }
|
||||||
{ ui.definition->setFocus( Qt::ShortcutFocusReason ); }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -192,11 +213,11 @@ public:
|
||||||
|
|
||||||
void setZoomFactor( qreal factor )
|
void setZoomFactor( qreal factor )
|
||||||
{
|
{
|
||||||
qreal existedFactor = ui.definition->zoomFactor();
|
qreal existedFactor = webview->zoomFactor();
|
||||||
if(!qFuzzyCompare(existedFactor,factor)){
|
if( !qFuzzyCompare( existedFactor, factor ) ) {
|
||||||
qDebug()<<"zoom factor ,existed:"<<existedFactor<<"set:"<<factor;
|
qDebug() << "zoom factor ,existed:" << existedFactor << "set:" << factor;
|
||||||
ui.definition->setZoomFactor( factor );
|
webview->setZoomFactor( factor );
|
||||||
//ui.definition->page()->setZoomFactor(factor);
|
//webview->page()->setZoomFactor(factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +296,7 @@ signals:
|
||||||
/// typically in response to user actions
|
/// typically in response to user actions
|
||||||
/// (clicking on the article or using shortcuts).
|
/// (clicking on the article or using shortcuts).
|
||||||
/// id - the dictionary id of the active article.
|
/// id - the dictionary id of the active article.
|
||||||
void activeArticleChanged ( ArticleView const *, QString const & id );
|
void activeArticleChanged( ArticleView const *, QString const & id );
|
||||||
|
|
||||||
/// Signal to add word to history even if history is disabled
|
/// Signal to add word to history even if history is disabled
|
||||||
void forceAddWordToHistory( const QString & word);
|
void forceAddWordToHistory( const QString & word);
|
||||||
|
@ -418,7 +439,6 @@ private:
|
||||||
|
|
||||||
QStringList getMutedDictionaries(unsigned group);
|
QStringList getMutedDictionaries(unsigned group);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// We need this to hide the search bar when we're showed
|
// We need this to hide the search bar when we're showed
|
||||||
void showEvent( QShowEvent * );
|
void showEvent( QShowEvent * );
|
||||||
|
|
258
articleview.ui
258
articleview.ui
|
@ -1,258 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ArticleView</class>
|
|
||||||
<widget class="QWidget" name="ArticleView">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>833</width>
|
|
||||||
<height>634</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1000,0,0">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="frame">
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="ArticleWebView" name="definition" native="true">
|
|
||||||
<property name="url" stdset="0">
|
|
||||||
<url>
|
|
||||||
<string>about:blank</string>
|
|
||||||
</url>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="ftsSearchFrame">
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="ftsSearchPrevious">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Previous</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/icons/previous.svg</normaloff>:/icons/previous.svg</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="toolButtonStyle">
|
|
||||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="ftsSearchNext">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Next</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/icons/next.svg</normaloff>:/icons/next.svg</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="toolButtonStyle">
|
|
||||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="ftsSearchStatusLabel"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="searchFrame">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Find:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="searchText"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="searchCloseButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>x</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/icons/closetab.svg</normaloff>:/icons/closetab.svg</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="autoRaise">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="searchPrevious">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Previous</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/icons/previous.svg</normaloff>:/icons/previous.svg</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="toolButtonStyle">
|
|
||||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
|
||||||
</property>
|
|
||||||
<property name="autoRaise">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="searchNext">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Next</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/icons/next.svg</normaloff>:/icons/next.svg</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Ctrl+G</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolButtonStyle">
|
|
||||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
|
||||||
</property>
|
|
||||||
<property name="autoRaise">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="highlightAllButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Highlight &all</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/icons/highlighter.png</normaloff>:/icons/highlighter.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolButtonStyle">
|
|
||||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
|
||||||
</property>
|
|
||||||
<property name="autoRaise">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="searchCaseSensitive">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Case Sensitive</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>782</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>ArticleWebView</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>articlewebview.hh</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources>
|
|
||||||
<include location="resources.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -412,7 +412,6 @@ FORMS += groups.ui \
|
||||||
sources.ui \
|
sources.ui \
|
||||||
initializing.ui \
|
initializing.ui \
|
||||||
scanpopup.ui \
|
scanpopup.ui \
|
||||||
articleview.ui \
|
|
||||||
preferences.ui \
|
preferences.ui \
|
||||||
about.ui \
|
about.ui \
|
||||||
editdictionaries.ui \
|
editdictionaries.ui \
|
||||||
|
|
Loading…
Reference in a new issue