summaryrefslogtreecommitdiffstats
path: root/webview.cpp
diff options
context:
space:
mode:
authorRoopesh Chander <roop@forwardbias.in>2009-10-21 18:59:01 +0530
committerRoopesh Chander <roop@forwardbias.in>2009-10-21 18:59:01 +0530
commitb48e0dfc854d9ecca4f2c3fdc33b617f6889829b (patch)
tree91aa241b0db095af601751859d60d7f60a5a0f42 /webview.cpp
parentf12646679f58dc9d59c5180f0c8d64b862506df9 (diff)
allow enabling disabling of the selection ui
Diffstat (limited to 'webview.cpp')
-rw-r--r--webview.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/webview.cpp b/webview.cpp
index 4e3783d..2c3eed9 100644
--- a/webview.cpp
+++ b/webview.cpp
@@ -8,15 +8,24 @@
WebView::WebView(QGraphicsItem * parent)
: QGraphicsWebView(parent)
+ , m_scrapSelectionEnabled(false)
, m_scrapRect(QRect())
, m_scrapSelected(false)
{
setAcceptHoverEvents(true);
}
+void WebView::setScrapSelectionEnabled(bool enabled) {
+ m_scrapSelectionEnabled = enabled;
+}
+
+bool WebView::scrapSelectionEnabled() const {
+ return m_scrapSelectionEnabled;
+}
+
void WebView::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
{
- if (m_scrapSelected) {
+ if (!m_scrapSelectionEnabled || m_scrapSelected) {
QGraphicsWebView::hoverMoveEvent(event);
return;
}
@@ -50,6 +59,10 @@ void WebView::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
+ if (!m_scrapSelectionEnabled) {
+ QGraphicsWebView::mousePressEvent(event);
+ return;
+ }
if (page()->mainFrame()->scrollBarGeometry(Qt::Horizontal).contains(event->pos().toPoint()) ||
page()->mainFrame()->scrollBarGeometry(Qt::Vertical).contains(event->pos().toPoint())) {
QGraphicsWebView::mousePressEvent(event);
@@ -68,16 +81,19 @@ void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
void WebView::keyPressEvent(QKeyEvent *event) {
- if (event->key() == Qt::Key_Escape) {
+ if (!m_scrapSelectionEnabled && event->key() == Qt::Key_Escape) {
m_scrapSelected = false;
update();
+ return;
}
+ QGraphicsWebView::keyPressEvent(event);
}
void WebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* options, QWidget* widget)
{
QGraphicsWebView::paint(painter, options, widget);
-
+ if (!m_scrapSelectionEnabled)
+ return;
QPainterPath pageAreaPath, greyedoutPath;
QPainterPath scrollbars;
if (page() && page()->mainFrame()) {