Some work on context menu.
This commit is contained in:
parent
253ae7b84f
commit
a63b55f725
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QtWebKitVersion>
|
#include <qwebkitglobal.h>
|
||||||
#else
|
#elif QT_VERSION >= 0x040600
|
||||||
#include <qwebkitversion.h>
|
#include <qwebkitversion.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define CMAKE_VERSION "@CMAKE_VERSION@"
|
#define CMAKE_VERSION "@CMAKE_VERSION@"
|
||||||
#define CMAKE_SYSTEM "@CMAKE_SYSTEM@"
|
#define CMAKE_SYSTEM "@CMAKE_SYSTEM@"
|
||||||
|
|
||||||
@ -18,7 +19,12 @@
|
|||||||
#define APP_AUTHORS "@APP_AUTHOR@"
|
#define APP_AUTHORS "@APP_AUTHOR@"
|
||||||
#define APP_URL "@APP_URL@"
|
#define APP_URL "@APP_URL@"
|
||||||
#define APP_VERSION "@APP_VERSION@"
|
#define APP_VERSION "@APP_VERSION@"
|
||||||
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@; Webkit/") + QTWEBKIT_VERSION_STR
|
|
||||||
|
#if QT_VERSION >= 0x040600
|
||||||
|
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@; Webkit/") + qWebKitVersion()
|
||||||
|
#else
|
||||||
|
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@;")
|
||||||
|
#endif
|
||||||
|
|
||||||
#define APP_CFG_PATH "data/config/config.ini"
|
#define APP_CFG_PATH "data/config/config.ini"
|
||||||
#define APP_CFG_GUI "gui"
|
#define APP_CFG_GUI "gui"
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BaseWebView::BaseWebView(QWidget *parent)
|
BaseWebView::BaseWebView(QWidget *parent)
|
||||||
: QWebView(parent), m_page(new BaseWebPage(this)) {
|
: QWebView(parent), m_page(new BaseWebPage(this)) {
|
||||||
setPage(m_page);
|
setPage(m_page);
|
||||||
setContextMenuPolicy(Qt::NoContextMenu);
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
initializeActions();
|
initializeActions();
|
||||||
createConnections();
|
createConnections();
|
||||||
}
|
}
|
||||||
@ -142,8 +142,7 @@ void BaseWebView::popupContextMenu(const QPoint &pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::mousePressEvent(QMouseEvent *event) {
|
void BaseWebView::mousePressEvent(QMouseEvent *event) {
|
||||||
if ((event->button() & Qt::MiddleButton) ||
|
if (event->button() & Qt::LeftButton && event->modifiers() & Qt::ControlModifier) {
|
||||||
(event->button() & Qt::LeftButton && event->modifiers() & Qt::ControlModifier)) {
|
|
||||||
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());
|
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());
|
||||||
|
|
||||||
// Check if user clicked with middle mouse button on some
|
// Check if user clicked with middle mouse button on some
|
||||||
@ -161,50 +160,45 @@ void BaseWebView::mousePressEvent(QMouseEvent *event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event->button() & Qt::RightButton) {
|
else if (event->button() & Qt::MiddleButton) {
|
||||||
m_gestureOrigin = event->pos();
|
m_gestureOrigin = event->pos();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWebView::mousePressEvent(event);
|
QWebView::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::mouseReleaseEvent(QMouseEvent *event) {
|
void BaseWebView::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
QWebView::mouseReleaseEvent(event);
|
if (event->button() & Qt::MiddleButton) {
|
||||||
|
|
||||||
if (event->button() & Qt::RightButton) {
|
|
||||||
bool are_gestures_enabled = Settings::getInstance()->value(APP_CFG_BROWSER,
|
bool are_gestures_enabled = Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||||
"gestures_enabled",
|
"gestures_enabled",
|
||||||
true).toBool();
|
true).toBool();
|
||||||
if (are_gestures_enabled) {
|
if (are_gestures_enabled) {
|
||||||
QPoint release_point = event->pos();
|
QPoint release_point = event->pos();
|
||||||
int left_move = m_gestureOrigin.x() - release_point.x();
|
int left_move = m_gestureOrigin.x() - release_point.x();
|
||||||
int right_move = release_point.x() - m_gestureOrigin.x();
|
int right_move = -left_move;
|
||||||
int top_move = m_gestureOrigin.y() - release_point.y();
|
int top_move = m_gestureOrigin.y() - release_point.y();
|
||||||
int bottom_move = release_point.y() - m_gestureOrigin.y();
|
int bottom_move = -top_move;
|
||||||
int total_max = qMax(qMax(qMax(left_move, right_move),
|
int total_max = qMax(qMax(qMax(left_move, right_move),
|
||||||
qMax(top_move, bottom_move)),
|
qMax(top_move, bottom_move)),
|
||||||
40);
|
40);
|
||||||
|
|
||||||
if (total_max == left_move && are_gestures_enabled) {
|
if (total_max == left_move) {
|
||||||
back();
|
back();
|
||||||
}
|
}
|
||||||
else if (total_max == right_move && are_gestures_enabled) {
|
else if (total_max == right_move) {
|
||||||
forward();
|
forward();
|
||||||
}
|
}
|
||||||
else if (total_max == top_move && are_gestures_enabled) {
|
else if (total_max == top_move) {
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
else if (total_max == bottom_move && are_gestures_enabled) {
|
else if (total_max == bottom_move) {
|
||||||
emit newTabRequested();
|
emit newTabRequested();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
emit customContextMenuRequested(event->pos());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
emit customContextMenuRequested(event->pos());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWebView::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::paintEvent(QPaintEvent *event) {
|
void BaseWebView::paintEvent(QPaintEvent *event) {
|
||||||
|
@ -337,7 +337,7 @@
|
|||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="m_lblMouseGestures">
|
<widget class="QLabel" name="m_lblMouseGestures">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Mouse gestures work with right mouse button. Possible gestures are:
|
<string>Mouse gestures work with middle mouse button. Possible gestures are:
|
||||||
<ul>
|
<ul>
|
||||||
<li>previous web page (drag mouse left)</li>
|
<li>previous web page (drag mouse left)</li>
|
||||||
<li>next web page (drag mouse right)</li>
|
<li>next web page (drag mouse right)</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user