2012-02-20 21:47:14 +00:00
|
|
|
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
2009-10-22 11:38:11 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __ARTICLEWEBVIEW_HH_INCLUDED__
|
|
|
|
#define __ARTICLEWEBVIEW_HH_INCLUDED__
|
|
|
|
|
2013-05-30 02:18:28 +00:00
|
|
|
#include "config.hh"
|
2021-12-05 06:50:54 +00:00
|
|
|
#include <QEvent>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QWebEngineView>
|
2022-01-14 00:19:49 +00:00
|
|
|
#include <QPointer>
|
2013-05-30 02:18:28 +00:00
|
|
|
|
2021-07-06 13:01:50 +00:00
|
|
|
/// A thin wrapper around QWebEngineView to accommodate to some ArticleView's needs.
|
2013-05-30 02:18:28 +00:00
|
|
|
/// Currently the only added features:
|
|
|
|
/// 1. Ability to know if the middle mouse button is pressed or not according
|
|
|
|
/// to the view's current state. This is used to open links in new tabs when
|
2018-07-07 09:33:15 +00:00
|
|
|
/// they are clicked with middle button. There's also an added possibility to
|
2013-05-30 02:18:28 +00:00
|
|
|
/// get double-click events after the fact with the doubleClicked() signal.
|
2021-07-06 13:01:50 +00:00
|
|
|
class ArticleWebView: public QWebEngineView
|
2009-10-22 11:38:11 +00:00
|
|
|
{
|
2010-04-08 20:37:59 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2009-10-22 11:38:11 +00:00
|
|
|
public:
|
|
|
|
|
2023-03-20 04:44:28 +00:00
|
|
|
ArticleWebView( QWidget * parent );
|
2013-05-30 02:18:28 +00:00
|
|
|
~ArticleWebView();
|
2023-03-20 04:44:28 +00:00
|
|
|
void setUp( Config::Class * cfg );
|
2009-10-22 11:38:11 +00:00
|
|
|
|
|
|
|
bool isMidButtonPressed() const
|
|
|
|
{ return midButtonPressed; }
|
2022-03-03 16:17:21 +00:00
|
|
|
void resetMidButtonPressed()
|
|
|
|
{
|
|
|
|
midButtonPressed = false;
|
|
|
|
}
|
2012-09-26 13:59:48 +00:00
|
|
|
void setSelectionBySingleClick( bool set )
|
|
|
|
{ selectionBySingleClick = set; }
|
2009-10-22 11:38:11 +00:00
|
|
|
|
2021-12-05 06:50:54 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *ev);
|
2013-05-30 02:18:28 +00:00
|
|
|
|
2021-12-05 06:50:54 +00:00
|
|
|
signals:
|
2010-04-08 20:37:59 +00:00
|
|
|
|
|
|
|
/// Signals that the user has just double-clicked. The signal is delivered
|
|
|
|
/// after the event was processed by the view -- that's the difference from
|
|
|
|
/// installing an event filter. This is used for translating the double-clicked
|
|
|
|
/// word, which gets selected by the view in response to double-click.
|
2017-03-13 14:38:27 +00:00
|
|
|
void doubleClicked( QPoint pos );
|
2010-04-08 20:37:59 +00:00
|
|
|
|
2022-05-18 14:31:47 +00:00
|
|
|
void linkClicked( const QUrl & url );
|
|
|
|
|
2009-10-22 11:38:11 +00:00
|
|
|
protected:
|
2022-03-10 16:41:35 +00:00
|
|
|
QWebEngineView *createWindow(QWebEnginePage::WebWindowType type);
|
2013-05-30 02:18:28 +00:00
|
|
|
bool event( QEvent * event );
|
2022-01-10 13:40:21 +00:00
|
|
|
void singleClickAction(QMouseEvent *event);
|
|
|
|
void sendCustomMouseEvent(QEvent::Type type);
|
2021-12-11 02:21:31 +00:00
|
|
|
void mousePressEvent(QMouseEvent *event);
|
2009-10-22 11:38:11 +00:00
|
|
|
void mouseReleaseEvent( QMouseEvent * event );
|
2021-12-09 08:02:29 +00:00
|
|
|
void doubleClickAction( QMouseEvent * event );
|
2011-09-03 14:45:43 +00:00
|
|
|
void focusInEvent( QFocusEvent * event );
|
2013-01-01 23:05:29 +00:00
|
|
|
void wheelEvent( QWheelEvent * event );
|
2009-10-22 11:38:11 +00:00
|
|
|
|
2021-12-11 16:34:37 +00:00
|
|
|
|
2009-10-22 11:38:11 +00:00
|
|
|
private:
|
|
|
|
|
2013-05-30 02:18:28 +00:00
|
|
|
Config::Class * cfg;
|
2022-01-14 00:19:49 +00:00
|
|
|
//QPointer<QOpenGLWidget> child_;
|
2013-05-30 02:18:28 +00:00
|
|
|
|
2009-10-22 11:38:11 +00:00
|
|
|
bool midButtonPressed;
|
2012-09-26 13:59:48 +00:00
|
|
|
bool selectionBySingleClick;
|
2021-12-09 08:02:29 +00:00
|
|
|
|
2021-12-11 16:34:37 +00:00
|
|
|
//MouseDbClickEvent will also emit MousePressEvent which conflict the single click event.
|
|
|
|
//this variable used to distinguish the single click and real double click.
|
2022-01-14 00:19:49 +00:00
|
|
|
bool singleClickToDbClick;
|
2022-01-10 14:13:31 +00:00
|
|
|
bool dbClicked;
|
2022-01-14 00:19:49 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2023-04-15 02:48:12 +00:00
|
|
|
//receive signal ,a link has been clicked.
|
|
|
|
void linkClickedInHtml( QUrl const & url );
|
2009-10-22 11:38:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|