diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-10-25 11:10:35 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-10-25 11:10:35 +0100 |
commit | e0fa463ebb64c671a92862da600df70c8b76e0cc (patch) | |
tree | 9a4a3fa4b2861768e5ce8f834978bb8ab308a69b /src/mainwindow.cpp | |
parent | Just close tab on middle mouse click (diff) | |
parent | A better popup implementation (diff) | |
download | rekonq-e0fa463ebb64c671a92862da600df70c8b76e0cc.tar.xz |
Merge commit 'refs/merge-requests/1902' of git://gitorious.org/rekonq/mainline into Lasts1
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 275f64eb..39ec18e3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -87,11 +87,11 @@ #include <QtGui/QPrinter> #include <QtGui/QPrintDialog> #include <QtGui/QPrintPreviewDialog> +#include <QtGui/QFontMetrics> #include <QtWebKit/QWebHistory> - MainWindow::MainWindow() : KMainWindow() , m_view(new MainView(this)) @@ -101,7 +101,6 @@ MainWindow::MainWindow() , m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, false, false) ) , m_bmBar( new KToolBar( QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, false) ) , m_ac( new KActionCollection(this) ) - , m_flickeringZone(false) { // enable window size "auto-save" setAutoSaveSettings(); @@ -960,39 +959,41 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) break; } - // useful values - int pageHeight = m_view->currentWebView()->page()->viewportSize().height(); - int labelHeight = KGlobalSettings::generalFont().pointSize()*2 + 7; - bool scrollbarIsVisible = m_view->currentWebView()->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); - int scrollbarSize = 0; - if (scrollbarIsVisible) - { - //TODO: detect QStyle size - scrollbarSize = 17; - } - + int margin = 4; + // setting the popup m_popup->setFrameShape(QFrame::NoFrame); QLabel *label = new QLabel(msg); - label->setMaximumWidth(width()-8); + label->setMaximumWidth(width()-2*margin); m_popup->setLineWidth(0); m_popup->setView(label); m_popup->setFixedSize(0, 0); m_popup->layout()->setAlignment(Qt::AlignTop); - m_popup->layout()->setMargin(4); + m_popup->layout()->setMargin(margin); - // setting popus in bottom-(left/right) position - int x = geometry().x(); - int y; - if(m_flickeringZone) + // useful values + QSize labelSize(label->fontMetrics().width(msg)+2*margin, label->fontMetrics().height()+2*margin); + bool scrollbarIsVisible = m_view->currentWebView()->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); + int scrollbarSize = 0; + if (scrollbarIsVisible) { - y = m_view->currentWebView()->mapToGlobal(QPoint(0,0)).y(); + //TODO: detect QStyle size + scrollbarSize = 17; } - else + QPoint webViewOrigin = m_view->currentWebView()->mapToGlobal(QPoint(0,0)); + int bottomLeftY=webViewOrigin.y() + m_view->currentWebView()->page()->viewportSize().height() - labelSize.height() - scrollbarSize; + + // setting popup in bottom-left position + int x = geometry().x(); + int y = bottomLeftY; + + QPoint mousePos = m_view->currentWebView()->mapToGlobal(m_view->currentWebView()->mousePos()); + if(QRect(webViewOrigin.x(),bottomLeftY,labelSize.width(),labelSize.height()).contains(mousePos)) { - y = m_view->currentWebView()->mapToGlobal(QPoint(0,pageHeight)).y() - labelHeight - scrollbarSize; + // setting popup above the mouse + y = bottomLeftY - labelSize.height(); } - + QPoint p(x,y); m_popup->show(p); @@ -1123,9 +1124,3 @@ bool MainWindow::homePage(const KUrl &url) } return false; } - - -void MainWindow::setFlickeringZone(bool b) -{ - m_flickeringZone = b; -} |