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__
|
|
|
|
|
|
|
|
#include <QWebView>
|
|
|
|
|
|
|
|
/// A thin wrapper around QWebView to accomodate to some ArticleView's needs.
|
|
|
|
/// Currently the only added feature is an 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 they are clicked with middle button.
|
2010-04-08 20:37:59 +00:00
|
|
|
/// There's also an added posibility to get double-click events after the fact
|
|
|
|
/// with the doubleClicked() signal.
|
2009-10-22 11:38:11 +00:00
|
|
|
class ArticleWebView: public QWebView
|
|
|
|
{
|
2010-04-08 20:37:59 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2009-10-22 11:38:11 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
ArticleWebView( QWidget * parent ): QWebView( parent ),
|
|
|
|
midButtonPressed( false )
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool isMidButtonPressed() const
|
|
|
|
{ return midButtonPressed; }
|
|
|
|
|
2010-04-08 20:37:59 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
void doubleClicked();
|
|
|
|
|
2009-10-22 11:38:11 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void mousePressEvent( QMouseEvent * event );
|
|
|
|
void mouseReleaseEvent( QMouseEvent * event );
|
2010-04-08 20:37:59 +00:00
|
|
|
void mouseDoubleClickEvent( QMouseEvent * event );
|
2011-09-03 14:45:43 +00:00
|
|
|
void focusInEvent( QFocusEvent * event );
|
2009-10-22 11:38:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
bool midButtonPressed;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|