diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2011-04-23 00:43:30 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2011-04-23 00:43:30 +0200 |
commit | b81e0d524a21f8f91155781b2a8ac511d5b938fe (patch) | |
tree | e4f395267815455a9904c74a5b7c1984d8b7b8e2 /src | |
parent | firefox-like autoscroll look (diff) | |
download | rekonq-b81e0d524a21f8f91155781b2a8ac511d5b938fe.tar.xz |
Letting rekonq URL popup behaves as Chrome's and Firefox4 ones
(i.e. moving on right on pointer sovrapposition)
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7b4e3eeb..5edea797 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1145,7 +1145,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) int margin = 4; - // setting the popup + // setting popup size QLabel *label = new QLabel(msg); m_popup->setView(label); QSize labelSize(label->fontMetrics().width(msg) + 2*margin, label->fontMetrics().height() + 2*margin); @@ -1162,35 +1162,35 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) WebTab *tab = m_view->currentWebTab(); // fix crash on window close - if (!tab) + if (!tab || !tab->page()) return; - // fix crash on window close - if (!tab->page()) - return; - - bool scrollbarIsVisible = tab->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); - int scrollbarSize = 0; - if (scrollbarIsVisible) - { - //TODO: detect QStyle size - scrollbarSize = 17; - } + bool horizontalScrollbarIsVisible = tab->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); + bool verticalScrollbarIsVisible = tab->page()->currentFrame()->scrollBarMaximum(Qt::Vertical); + //TODO: detect QStyle sizeHint, instead of fixed 17 + int hScrollbarSize = horizontalScrollbarIsVisible ? 17 : 0; + int vScrollbarSize = verticalScrollbarIsVisible ? 17 : 0; + QPoint webViewOrigin = tab->view()->mapToGlobal(QPoint(0, 0)); - int bottomLeftY = webViewOrigin.y() + tab->page()->viewportSize().height() - labelSize.height() - scrollbarSize; + QPoint mousePos = tab->mapToGlobal(tab->view()->mousePos()); // setting popup in bottom-left position int x = mapToGlobal(QPoint(0, 0)).x(); - int y = bottomLeftY; + int y = webViewOrigin.y() + tab->page()->viewportSize().height() - labelSize.height() - hScrollbarSize; - QPoint mousePos = tab->mapToGlobal(tab->view()->mousePos()); - if (QRect(webViewOrigin.x() , bottomLeftY , labelSize.width() , labelSize.height()).contains(mousePos)) + if ( QRect(x, y, labelSize.width() , labelSize.height() ).contains(mousePos) ) { - // setting popup above the mouse - y = bottomLeftY - labelSize.height(); + // settings popup on the right + x = mapToGlobal(QPoint(- labelSize.width() + tab->page()->viewportSize().width(), 0)).x() - vScrollbarSize; } + if (QRect(x , y , labelSize.width() , labelSize.height()).contains(mousePos)) + { + // setting popup above the mouse + y -= labelSize.height(); + } + m_popup->show(QPoint(x, y)); } |