2012-02-20 21:47:14 +00:00
|
|
|
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __ARTICLEVIEW_HH_INCLUDED__
|
|
|
|
#define __ARTICLEVIEW_HH_INCLUDED__
|
|
|
|
|
2021-07-06 13:01:50 +00:00
|
|
|
#include <QWebEngineView>
|
2009-05-29 19:48:50 +00:00
|
|
|
#include <QMap>
|
2013-05-31 04:20:25 +00:00
|
|
|
#include <QUrl>
|
2017-03-13 14:38:27 +00:00
|
|
|
#include <QSet>
|
2009-03-26 19:00:08 +00:00
|
|
|
#include <list>
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "article_netmgr.hh"
|
2018-03-21 17:49:34 +00:00
|
|
|
#include "audioplayerinterface.hh"
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "instances.hh"
|
2009-05-14 19:27:19 +00:00
|
|
|
#include "groupcombobox.hh"
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "ui_articleview.h"
|
2022-01-08 06:51:24 +00:00
|
|
|
#include "globalbroadcaster.h"
|
2022-03-04 15:25:11 +00:00
|
|
|
#include "article_inspect.h"
|
2022-02-27 05:17:37 +00:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
|
2022-02-27 14:42:40 +00:00
|
|
|
#include <QtCore5Compat/QRegExp>
|
2022-02-27 05:17:37 +00:00
|
|
|
#endif
|
2022-05-21 06:03:26 +00:00
|
|
|
#include "ankiconnector.h"
|
2022-07-10 02:09:58 +00:00
|
|
|
#include "webmultimediadownload.hh"
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2013-05-27 11:18:13 +00:00
|
|
|
class ResourceToSaveHandler;
|
2022-01-19 23:29:02 +00:00
|
|
|
class ArticleViewAgent ;
|
2013-05-27 11:18:13 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
/// A widget with the web view tailored to view and handle articles -- it
|
|
|
|
/// uses the appropriate netmgr, handles link clicks, rmb clicks etc
|
|
|
|
class ArticleView: public QFrame
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
ArticleNetworkAccessManager & articleNetMgr;
|
2018-03-21 17:49:34 +00:00
|
|
|
AudioPlayerPtr const & audioPlayer;
|
2009-04-12 16:22:42 +00:00
|
|
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries;
|
2009-01-28 20:55:45 +00:00
|
|
|
Instances::Groups const & groups;
|
|
|
|
bool popupView;
|
2009-04-10 21:07:03 +00:00
|
|
|
Config::Class const & cfg;
|
2022-01-04 13:01:16 +00:00
|
|
|
QWebChannel *channel;
|
2022-01-19 23:29:02 +00:00
|
|
|
ArticleViewAgent * agent;
|
2009-01-28 20:55:45 +00:00
|
|
|
Ui::ArticleView ui;
|
|
|
|
|
2022-05-21 06:03:26 +00:00
|
|
|
AnkiConnector * ankiConnector;
|
|
|
|
|
2009-05-29 22:04:43 +00:00
|
|
|
QAction pasteAction, articleUpAction, articleDownAction,
|
2014-04-16 16:18:28 +00:00
|
|
|
goBackAction, goForwardAction, selectCurrentArticleAction,
|
2013-05-30 02:18:28 +00:00
|
|
|
copyAsTextAction, inspectAction;
|
2014-04-16 16:18:28 +00:00
|
|
|
QAction & openSearchAction;
|
2009-05-16 11:14:43 +00:00
|
|
|
bool searchIsOpened;
|
2012-09-16 10:19:47 +00:00
|
|
|
bool expandOptionalParts;
|
2014-04-22 13:47:02 +00:00
|
|
|
QString rangeVarName;
|
2009-05-12 10:52:11 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
/// 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.
|
|
|
|
std::list< sptr< Dictionary::DataRequest > > resourceDownloadRequests;
|
|
|
|
/// Url of the resourceDownloadRequests
|
2013-05-31 04:20:25 +00:00
|
|
|
QUrl resourceDownloadUrl;
|
2009-03-26 19:00:08 +00:00
|
|
|
|
|
|
|
/// For resources opened via desktop services
|
2017-03-13 14:38:27 +00:00
|
|
|
QSet< QString > desktopOpenedTempFiles;
|
2009-02-08 14:40:26 +00:00
|
|
|
|
2009-09-23 18:44:38 +00:00
|
|
|
QAction * dictionaryBarToggled;
|
2022-01-08 06:51:24 +00:00
|
|
|
GroupComboBox const *groupComboBox;
|
|
|
|
|
|
|
|
/// current searching word.
|
|
|
|
QString currentWord;
|
|
|
|
|
|
|
|
/// current active dict id list;
|
|
|
|
QStringList currentActiveDictIds;
|
2009-05-14 19:27:19 +00:00
|
|
|
|
2022-11-04 13:23:42 +00:00
|
|
|
bool historyMode=false;
|
|
|
|
|
2022-01-19 12:16:45 +00:00
|
|
|
//current active dictionary id;
|
|
|
|
QString activeDictId;
|
|
|
|
|
2014-04-22 13:47:02 +00:00
|
|
|
/// Search in results of full-text search
|
|
|
|
QStringList allMatches;
|
|
|
|
QStringList uniqueMatches;
|
|
|
|
bool ftsSearchIsOpened, ftsSearchMatchCase;
|
|
|
|
int ftsPosition;
|
|
|
|
|
2022-06-01 15:11:41 +00:00
|
|
|
QString delayedHighlightText;
|
|
|
|
|
2014-04-22 13:47:02 +00:00
|
|
|
void highlightFTSResults();
|
2022-05-24 12:21:40 +00:00
|
|
|
void highlightAllFtsOccurences( QWebEnginePage::FindFlags flags );
|
2014-04-22 13:47:02 +00:00
|
|
|
void performFtsFindOperation( bool backwards );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
public:
|
|
|
|
/// The popupView flag influences contents of the context menus to be
|
|
|
|
/// appropriate to the context of the view.
|
|
|
|
/// The groups aren't copied -- rather than that, the reference is kept
|
|
|
|
ArticleView( QWidget * parent,
|
|
|
|
ArticleNetworkAccessManager &,
|
2018-03-21 17:49:34 +00:00
|
|
|
AudioPlayerPtr const &,
|
2009-04-12 16:22:42 +00:00
|
|
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries,
|
2009-01-28 20:55:45 +00:00
|
|
|
Instances::Groups const &,
|
2009-04-10 21:07:03 +00:00
|
|
|
bool popupView,
|
2009-05-14 19:27:19 +00:00
|
|
|
Config::Class const & cfg,
|
2014-04-16 16:18:28 +00:00
|
|
|
QAction & openSearchAction_,
|
2009-09-23 18:44:38 +00:00
|
|
|
QAction * dictionaryBarToggled = 0,
|
2009-05-14 19:27:19 +00:00
|
|
|
GroupComboBox const * groupComboBox = 0 );
|
|
|
|
|
|
|
|
/// Sets the currently active group combo box. When looking up selections,
|
|
|
|
/// this allows presenting a choice of looking up in the currently chosen
|
|
|
|
/// group. Setting this to 0 disables this. It is 0 by default.
|
|
|
|
void setGroupComboBox( GroupComboBox const * );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2012-12-27 20:32:16 +00:00
|
|
|
virtual QSize minimumSizeHint() const;
|
|
|
|
|
2009-02-06 15:37:37 +00:00
|
|
|
~ArticleView();
|
|
|
|
|
2009-05-29 19:48:50 +00:00
|
|
|
typedef QMap< QString, QString > Contexts;
|
|
|
|
|
2021-06-29 08:59:16 +00:00
|
|
|
/// Returns "gdfrom-" + dictionaryId.
|
|
|
|
static QString scrollToFromDictionaryId( QString const & dictionaryId );
|
|
|
|
|
2021-11-24 14:38:37 +00:00
|
|
|
void emitJavascriptFinished();
|
|
|
|
|
2009-05-11 19:14:28 +00:00
|
|
|
/// Shows the definition of the given word with the given group.
|
|
|
|
/// scrollTo can be optionally set to a "gdfrom-xxxx" identifier to position
|
|
|
|
/// the page to that article on load.
|
2009-05-29 19:48:50 +00:00
|
|
|
/// contexts is an optional map of context values to be passed for dictionaries.
|
|
|
|
/// The only values to pass here are ones obtained from showDefinitionInNewTab()
|
|
|
|
/// signal or none at all.
|
2021-06-10 16:13:11 +00:00
|
|
|
void showDefinition( Config::InputPhrase const & phrase, unsigned group,
|
|
|
|
QString const & scrollTo = QString(),
|
|
|
|
Contexts const & contexts = Contexts() );
|
|
|
|
|
2009-05-11 19:14:28 +00:00
|
|
|
void showDefinition( QString const & word, unsigned group,
|
2009-05-29 19:48:50 +00:00
|
|
|
QString const & scrollTo = QString(),
|
|
|
|
Contexts const & contexts = Contexts() );
|
2009-02-01 00:08:08 +00:00
|
|
|
|
2014-04-22 13:47:02 +00:00
|
|
|
void showDefinition( QString const & word, QStringList const & dictIDs,
|
2018-04-10 14:49:52 +00:00
|
|
|
QRegExp const & searchRegExp, unsigned group,
|
|
|
|
bool ignoreDiacritics );
|
2014-04-16 16:18:28 +00:00
|
|
|
|
2022-05-21 06:03:26 +00:00
|
|
|
void sendToAnki(QString const & word, QString const & text );
|
2009-02-08 16:50:18 +00:00
|
|
|
/// Clears the view and sets the application-global waiting cursor,
|
|
|
|
/// which will be restored when some article loads eventually.
|
|
|
|
void showAnticipation();
|
2009-04-30 19:57:25 +00:00
|
|
|
|
2009-02-08 15:49:17 +00:00
|
|
|
/// Opens the given link. Supposed to be used in response to
|
|
|
|
/// openLinkInNewTab() signal. The link scheme is therefore supposed to be
|
|
|
|
/// one of the internal ones.
|
2009-05-29 19:48:50 +00:00
|
|
|
/// contexts is an optional map of context values to be passed for dictionaries.
|
|
|
|
/// The only values to pass here are ones obtained from showDefinitionInNewTab()
|
|
|
|
/// signal or none at all.
|
2009-05-11 19:14:28 +00:00
|
|
|
void openLink( QUrl const & url, QUrl const & referrer,
|
2009-05-29 19:48:50 +00:00
|
|
|
QString const & scrollTo = QString(),
|
|
|
|
Contexts const & contexts = Contexts() );
|
2009-04-30 19:57:25 +00:00
|
|
|
|
2009-09-23 18:44:38 +00:00
|
|
|
/// Called when the state of dictionary bar changes and the view is active.
|
|
|
|
/// The function reloads content if the change affects it.
|
|
|
|
void updateMutedContents();
|
|
|
|
|
2011-06-07 11:27:19 +00:00
|
|
|
bool canGoBack();
|
|
|
|
bool canGoForward();
|
|
|
|
|
2012-09-26 13:59:48 +00:00
|
|
|
/// Called when preference changes
|
|
|
|
void setSelectionBySingleClick( bool set );
|
|
|
|
|
2022-06-01 15:11:41 +00:00
|
|
|
void setDelayedHighlightText(QString const & text);
|
|
|
|
|
2009-05-29 22:04:43 +00:00
|
|
|
public slots:
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
/// Goes back in history
|
2011-06-07 07:57:25 +00:00
|
|
|
void back();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
/// Goes forward in history
|
2011-06-07 07:57:25 +00:00
|
|
|
void forward();
|
2009-05-29 22:04:43 +00:00
|
|
|
|
2009-03-29 17:38:54 +00:00
|
|
|
/// Takes the focus to the view
|
|
|
|
void focus()
|
|
|
|
{ ui.definition->setFocus( Qt::ShortcutFocusReason ); }
|
|
|
|
|
2018-05-16 11:48:27 +00:00
|
|
|
public:
|
|
|
|
|
2009-05-11 11:03:36 +00:00
|
|
|
/// Reloads the view
|
2022-06-11 17:57:52 +00:00
|
|
|
void reload();
|
2009-05-11 11:03:36 +00:00
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
/// Returns true if there's an audio reference on the page, false otherwise.
|
2022-03-30 15:08:24 +00:00
|
|
|
void hasSound( const std::function< void( bool has ) > & callback );
|
2009-04-10 21:07:03 +00:00
|
|
|
|
|
|
|
/// Plays the first audio reference on the page, if any.
|
|
|
|
void playSound();
|
|
|
|
|
2009-04-30 19:57:25 +00:00
|
|
|
void setZoomFactor( qreal factor )
|
2022-01-15 10:23:44 +00:00
|
|
|
{
|
2022-02-17 16:39:24 +00:00
|
|
|
qreal existedFactor = ui.definition->zoomFactor();
|
|
|
|
if(!qFuzzyCompare(existedFactor,factor)){
|
|
|
|
qDebug()<<"zoom factor ,existed:"<<existedFactor<<"set:"<<factor;
|
2022-01-15 10:23:44 +00:00
|
|
|
ui.definition->setZoomFactor( factor );
|
2022-03-18 14:22:48 +00:00
|
|
|
//ui.definition->page()->setZoomFactor(factor);
|
2022-01-20 12:34:14 +00:00
|
|
|
}
|
2022-01-15 10:23:44 +00:00
|
|
|
}
|
2009-04-30 19:57:25 +00:00
|
|
|
|
2009-05-01 11:17:29 +00:00
|
|
|
/// Returns current article's text in .html format
|
2022-03-30 15:08:24 +00:00
|
|
|
void toHtml( const std::function< void( QString & ) > & callback );
|
2009-05-01 11:17:29 +00:00
|
|
|
|
2021-08-15 03:05:38 +00:00
|
|
|
void setHtml(const QString& content, const QUrl& baseUrl);
|
2021-08-21 01:41:40 +00:00
|
|
|
void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
|
2021-08-14 07:25:10 +00:00
|
|
|
|
2009-05-01 11:17:29 +00:00
|
|
|
/// Returns current article's title
|
|
|
|
QString getTitle();
|
2009-05-01 12:20:33 +00:00
|
|
|
|
2021-06-10 16:13:11 +00:00
|
|
|
/// Returns the phrase translated by the current article.
|
|
|
|
Config::InputPhrase getPhrase() const;
|
|
|
|
|
2009-05-01 12:20:33 +00:00
|
|
|
/// Prints current article
|
|
|
|
void print( QPrinter * ) const;
|
2009-05-16 11:14:43 +00:00
|
|
|
|
|
|
|
/// Closes search if it's open and returns true. Returns false if it
|
|
|
|
/// wasn't open.
|
|
|
|
bool closeSearch();
|
2011-06-05 11:49:50 +00:00
|
|
|
|
2011-06-29 19:12:46 +00:00
|
|
|
bool isSearchOpened();
|
|
|
|
|
2011-06-06 09:54:23 +00:00
|
|
|
/// Jumps to the article specified by the dictionary id,
|
2011-06-05 11:49:50 +00:00
|
|
|
/// by executing a javascript code.
|
2013-06-28 16:00:13 +00:00
|
|
|
void jumpToDictionary( QString const &, bool force );
|
2011-06-05 11:49:50 +00:00
|
|
|
|
2011-07-03 12:27:08 +00:00
|
|
|
/// Returns all articles currently present in view, as a list of dictionary
|
2011-06-05 11:49:50 +00:00
|
|
|
/// string ids.
|
|
|
|
QStringList getArticlesList();
|
|
|
|
|
2011-07-03 12:27:08 +00:00
|
|
|
/// Returns the dictionary id of the currently active article in the view.
|
|
|
|
QString getActiveArticleId();
|
2022-01-19 12:16:45 +00:00
|
|
|
void setActiveArticleId(QString const&);
|
2011-07-03 12:27:08 +00:00
|
|
|
|
2017-04-27 20:55:53 +00:00
|
|
|
ResourceToSaveHandler * saveResource( const QUrl & url, const QString & fileName );
|
|
|
|
ResourceToSaveHandler * saveResource( const QUrl & url, const QUrl & ref, const QString & fileName );
|
2013-05-27 11:18:13 +00:00
|
|
|
|
2022-06-01 15:11:41 +00:00
|
|
|
void findText( QString & text,
|
|
|
|
const QWebEnginePage::FindFlags & f,
|
|
|
|
const std::function< void( bool match ) > & callback = nullptr );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void iconChanged( ArticleView *, QIcon const & icon );
|
|
|
|
|
|
|
|
void titleChanged( ArticleView *, QString const & title );
|
|
|
|
|
2009-05-14 19:27:19 +00:00
|
|
|
void pageLoaded( ArticleView * );
|
2009-04-10 21:07:03 +00:00
|
|
|
|
2012-11-12 13:52:54 +00:00
|
|
|
/// Signals that the following link was requested to be opened in new tab
|
2009-05-11 19:14:28 +00:00
|
|
|
void openLinkInNewTab( QUrl const &, QUrl const & referrer,
|
2009-05-29 19:48:50 +00:00
|
|
|
QString const & fromArticle,
|
|
|
|
ArticleView::Contexts const & contexts );
|
2012-11-12 13:52:54 +00:00
|
|
|
/// Signals that the following definition was requested to be showed in new tab
|
2009-05-11 19:14:28 +00:00
|
|
|
void showDefinitionInNewTab( QString const & word, unsigned group,
|
2009-05-29 19:48:50 +00:00
|
|
|
QString const & fromArticle,
|
|
|
|
ArticleView::Contexts const & contexts );
|
2009-02-08 15:49:17 +00:00
|
|
|
|
2012-11-12 13:52:54 +00:00
|
|
|
/// Put translated word into history
|
|
|
|
void sendWordToHistory( QString const & word );
|
|
|
|
|
2009-05-12 13:25:18 +00:00
|
|
|
/// Emitted when user types a text key. This should typically be used to
|
|
|
|
/// switch focus to word input.
|
|
|
|
void typingEvent( QString const & text );
|
|
|
|
|
2011-07-14 20:11:57 +00:00
|
|
|
void statusBarMessage( QString const & message, int timeout = 0, QPixmap const & pixmap = QPixmap());
|
2011-07-02 13:04:49 +00:00
|
|
|
|
2011-07-31 00:11:07 +00:00
|
|
|
/// Signals that the dictionaries pane was requested to be showed
|
|
|
|
void showDictsPane( );
|
2022-01-09 04:54:50 +00:00
|
|
|
/// Signals that the founded dictionaries ready to be showed
|
|
|
|
void updateFoundInDictsList( );
|
2011-07-31 00:11:07 +00:00
|
|
|
|
2011-07-03 12:27:08 +00:00
|
|
|
/// Emitted when an article becomes active,
|
|
|
|
/// typically in response to user actions
|
2011-07-30 20:28:24 +00:00
|
|
|
/// (clicking on the article or using shortcuts).
|
2011-07-03 12:27:08 +00:00
|
|
|
/// id - the dictionary id of the active article.
|
2014-02-09 15:00:48 +00:00
|
|
|
void activeArticleChanged ( ArticleView const *, QString const & id );
|
2011-07-03 12:27:08 +00:00
|
|
|
|
2012-09-12 14:11:30 +00:00
|
|
|
/// Signal to add word to history even if history is disabled
|
|
|
|
void forceAddWordToHistory( const QString & word);
|
|
|
|
|
2012-09-12 14:18:16 +00:00
|
|
|
/// Signal to close popup menu
|
|
|
|
void closePopupMenu();
|
|
|
|
|
2012-09-16 10:19:47 +00:00
|
|
|
/// Signal to set optional parts expand mode
|
|
|
|
void setExpandMode ( bool expand );
|
|
|
|
|
2012-11-26 13:13:13 +00:00
|
|
|
void sendWordToInputLine( QString const & word );
|
|
|
|
|
2013-02-22 12:44:23 +00:00
|
|
|
void storeResourceSavePath(QString const & );
|
|
|
|
|
2014-02-04 13:35:42 +00:00
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
|
|
|
|
2021-11-24 14:38:37 +00:00
|
|
|
/// signal finished javascript;
|
|
|
|
void notifyJavascriptFinished();
|
|
|
|
|
2022-08-08 12:48:46 +00:00
|
|
|
void inspectSignal(QWebEnginePage * page);
|
2022-05-20 09:18:38 +00:00
|
|
|
|
2022-06-01 15:11:41 +00:00
|
|
|
void saveBookmarkSignal( const QString & bookmark );
|
|
|
|
|
2011-06-29 19:12:46 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void on_searchPrevious_clicked();
|
|
|
|
void on_searchNext_clicked();
|
2013-01-23 18:36:45 +00:00
|
|
|
|
2011-07-03 12:27:08 +00:00
|
|
|
void onJsActiveArticleChanged(QString const & id);
|
2011-06-29 19:12:46 +00:00
|
|
|
|
2013-01-23 18:36:45 +00:00
|
|
|
/// Handles F3 and Shift+F3 for search navigation
|
|
|
|
bool handleF3( QObject * obj, QEvent * ev );
|
|
|
|
|
2012-09-16 10:19:47 +00:00
|
|
|
/// Control optional parts expanding
|
|
|
|
void receiveExpandOptionalParts( bool expand );
|
|
|
|
void switchExpandOptionalParts();
|
|
|
|
|
2013-01-18 14:37:24 +00:00
|
|
|
/// Selects an entire text of the current article
|
|
|
|
void selectCurrentArticle();
|
2022-01-14 00:19:49 +00:00
|
|
|
//receive signal from weburlinterceptor.
|
2021-12-28 13:49:32 +00:00
|
|
|
void linkClicked( QUrl const & );
|
2022-01-14 00:19:49 +00:00
|
|
|
//aim to receive signal from html. the fragment url click to navigation through page wil not be intecepted by weburlinteceptor
|
|
|
|
Q_INVOKABLE void linkClickedInHtml( QUrl const & );
|
2009-01-28 20:55:45 +00:00
|
|
|
private slots:
|
2022-02-17 17:13:01 +00:00
|
|
|
void inspectElement();
|
2009-02-08 16:50:18 +00:00
|
|
|
void loadFinished( bool ok );
|
2022-01-20 12:34:14 +00:00
|
|
|
void loadProgress(int);
|
2009-01-28 20:55:45 +00:00
|
|
|
void handleTitleChanged( QString const & title );
|
|
|
|
void handleUrlChanged( QUrl const & url );
|
2022-01-19 23:29:02 +00:00
|
|
|
void attachWebChannelToHtml();
|
2021-12-28 13:49:32 +00:00
|
|
|
|
2021-07-06 13:01:50 +00:00
|
|
|
void linkHovered( const QString & link);
|
2009-01-28 20:55:45 +00:00
|
|
|
void contextMenuRequested( QPoint const & );
|
|
|
|
|
2022-07-10 02:09:58 +00:00
|
|
|
bool isAudioLink( QUrl & targetUrl )
|
|
|
|
{
|
|
|
|
return ( targetUrl.scheme() == "gdau" || Dictionary::WebMultimediaDownload::isAudioUrl( targetUrl ) );
|
|
|
|
}
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
void resourceDownloadFinished();
|
|
|
|
|
2009-05-12 10:52:11 +00:00
|
|
|
/// We handle pasting by attempting to define the word in clipboard.
|
|
|
|
void pasteTriggered();
|
|
|
|
|
2009-05-15 14:11:54 +00:00
|
|
|
/// Nagivates to the previous article relative to the active one.
|
|
|
|
void moveOneArticleUp();
|
|
|
|
|
|
|
|
/// Nagivates to the next article relative to the active one.
|
|
|
|
void moveOneArticleDown();
|
|
|
|
|
2009-05-16 11:14:43 +00:00
|
|
|
/// Opens the search area
|
|
|
|
void openSearch();
|
|
|
|
|
|
|
|
void on_searchText_textEdited();
|
|
|
|
void on_searchText_returnPressed();
|
|
|
|
void on_searchCloseButton_clicked();
|
2011-06-12 23:59:35 +00:00
|
|
|
void on_searchCaseSensitive_clicked();
|
|
|
|
void on_highlightAllButton_clicked();
|
2009-05-16 11:14:43 +00:00
|
|
|
|
2014-04-22 13:47:02 +00:00
|
|
|
void on_ftsSearchPrevious_clicked();
|
|
|
|
void on_ftsSearchNext_clicked();
|
|
|
|
|
2010-04-08 20:37:59 +00:00
|
|
|
/// Handles the double-click from the definition.
|
2017-03-13 14:38:27 +00:00
|
|
|
void doubleClicked( QPoint pos );
|
2010-04-08 20:37:59 +00:00
|
|
|
|
2013-05-05 10:22:12 +00:00
|
|
|
/// Handles audio player error message
|
|
|
|
void audioPlayerError( QString const & message );
|
|
|
|
|
2013-05-15 13:52:47 +00:00
|
|
|
/// Copy current selection as plain text
|
|
|
|
void copyAsText();
|
|
|
|
|
2022-01-08 06:51:24 +00:00
|
|
|
void setActiveDictIds(ActiveDictIds);
|
|
|
|
|
2022-07-16 22:54:53 +00:00
|
|
|
void dictionaryClear( ActiveDictIds ad );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
/// Deduces group from the url. If there doesn't seem to be any group,
|
2009-04-10 12:48:40 +00:00
|
|
|
/// returns 0.
|
|
|
|
unsigned getGroup( QUrl const & );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-05-11 22:25:22 +00:00
|
|
|
/// Returns current article in the view, in the form of "gdfrom-xxx" id.
|
2009-05-11 19:14:28 +00:00
|
|
|
QString getCurrentArticle();
|
|
|
|
|
2009-05-11 22:25:22 +00:00
|
|
|
/// Sets the current article by executing a javascript code.
|
2009-05-15 14:11:54 +00:00
|
|
|
/// If moveToIt is true, it moves the focus to it as well.
|
2022-05-24 11:47:15 +00:00
|
|
|
/// Returns true in case of success, false otherwise.
|
|
|
|
bool setCurrentArticle( QString const &, bool moveToIt = false );
|
2009-05-11 22:25:22 +00:00
|
|
|
|
2009-05-29 19:48:50 +00:00
|
|
|
/// Checks if the given article in form of "gdfrom-xxx" is inside a "website"
|
|
|
|
/// frame.
|
2022-03-30 15:08:24 +00:00
|
|
|
void isFramedArticle( QString const & article, const std::function< void( bool framed ) > & callback );
|
2009-05-29 19:48:50 +00:00
|
|
|
|
|
|
|
/// Checks if the given link is to be opened externally, as opposed to opening
|
|
|
|
/// it in-place.
|
|
|
|
bool isExternalLink( QUrl const & url );
|
|
|
|
|
|
|
|
/// Sees if the last clicked link is from a website frame. If so, changes url
|
|
|
|
/// to point to url text translation instead, and saves the original
|
|
|
|
/// url to the appropriate "contexts" entry.
|
|
|
|
void tryMangleWebsiteClickedUrl( QUrl & url, Contexts & contexts );
|
|
|
|
|
2009-05-29 22:04:43 +00:00
|
|
|
/// Saves current article and scroll position for the current history item.
|
|
|
|
/// Should be used when leaving the page.
|
|
|
|
void saveHistoryUserData();
|
|
|
|
|
2022-06-12 11:26:15 +00:00
|
|
|
/// Loads a page at @p url into view.
|
|
|
|
void load( QUrl const & url );
|
|
|
|
|
2009-02-08 21:54:19 +00:00
|
|
|
/// Attempts removing last temporary file created.
|
|
|
|
void cleanupTemp();
|
2009-04-30 19:57:25 +00:00
|
|
|
|
2009-05-12 13:25:18 +00:00
|
|
|
bool eventFilter( QObject * obj, QEvent * ev );
|
|
|
|
|
2011-06-12 23:59:35 +00:00
|
|
|
void performFindOperation( bool restart, bool backwards, bool checkHighlight = false );
|
2009-05-16 11:14:43 +00:00
|
|
|
|
2021-07-06 13:01:50 +00:00
|
|
|
|
2010-11-15 15:22:35 +00:00
|
|
|
void reloadStyleSheet();
|
|
|
|
|
2009-09-23 18:44:38 +00:00
|
|
|
/// Returns the comma-separated list of dictionary ids which should be muted
|
|
|
|
/// for the given group. If there are none, returns empty string.
|
|
|
|
QString getMutedForGroup( unsigned group );
|
|
|
|
|
2021-10-05 01:23:30 +00:00
|
|
|
QStringList getMutedDictionaries(unsigned group);
|
|
|
|
|
2022-01-08 06:51:24 +00:00
|
|
|
|
2021-12-12 05:35:32 +00:00
|
|
|
protected:
|
2009-01-28 20:55:45 +00:00
|
|
|
// We need this to hide the search bar when we're showed
|
|
|
|
void showEvent( QShowEvent * );
|
2012-09-18 23:01:31 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
2013-05-27 11:18:13 +00:00
|
|
|
class ResourceToSaveHandler: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-04-27 20:55:53 +00:00
|
|
|
explicit ResourceToSaveHandler( ArticleView * view, QString const & fileName );
|
|
|
|
void addRequest( sptr< Dictionary::DataRequest > req );
|
|
|
|
bool isEmpty()
|
|
|
|
{ return downloadRequests.empty(); }
|
2013-05-27 11:18:13 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void done();
|
|
|
|
void statusBarMessage( QString const & message, int timeout = 0, QPixmap const & pixmap = QPixmap() );
|
|
|
|
|
2017-04-27 20:55:53 +00:00
|
|
|
public slots:
|
2013-05-27 11:18:13 +00:00
|
|
|
void downloadFinished();
|
|
|
|
|
|
|
|
private:
|
2017-04-27 20:55:53 +00:00
|
|
|
std::list< sptr< Dictionary::DataRequest > > downloadRequests;
|
2013-05-27 11:18:13 +00:00
|
|
|
QString fileName;
|
2017-04-27 20:55:53 +00:00
|
|
|
bool alreadyDone;
|
2013-05-27 11:18:13 +00:00
|
|
|
};
|
|
|
|
|
2022-01-19 23:29:02 +00:00
|
|
|
class ArticleViewAgent : public QObject
|
|
|
|
{
|
2022-05-19 12:37:11 +00:00
|
|
|
Q_OBJECT
|
|
|
|
ArticleView * articleView;
|
2022-01-19 23:29:02 +00:00
|
|
|
|
2022-05-19 12:37:11 +00:00
|
|
|
public:
|
|
|
|
ArticleViewAgent( ArticleView * articleView );
|
2022-01-19 23:29:02 +00:00
|
|
|
|
2022-05-19 12:37:11 +00:00
|
|
|
signals:
|
2022-01-19 23:29:02 +00:00
|
|
|
|
2022-05-19 12:37:11 +00:00
|
|
|
public slots:
|
|
|
|
Q_INVOKABLE void onJsActiveArticleChanged( QString const & id );
|
|
|
|
Q_INVOKABLE void linkClickedInHtml( QUrl const & );
|
2022-01-19 23:29:02 +00:00
|
|
|
};
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
#endif
|