diff options
| -rw-r--r-- | src/mainwindow.cpp | 53 | ||||
| -rw-r--r-- | src/mainwindow.h | 16 | ||||
| -rw-r--r-- | src/webview.cpp | 16 | ||||
| -rw-r--r-- | src/webview.h | 4 | 
4 files changed, 40 insertions, 49 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; -} diff --git a/src/mainwindow.h b/src/mainwindow.h index 41687e60..7c42e58f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -69,11 +69,9 @@ public:      QAction *actionByName(const QString name);      virtual QSize sizeHint() const;      virtual KActionCollection *actionCollection () const; -     +      bool homePage(const KUrl &url = KUrl("rekonq:home")); -    void setFlickeringZone(bool b); -      private:      void setupActions();      void setupTools(); @@ -97,16 +95,16 @@ public slots:      void notifyMessage(const QString &msg, Rekonq::Notify status = Rekonq::Info);      void printRequested(QWebFrame *frame = 0); -     -     + +  signals:      // switching tabs      void ctrlTabPressed();      void shiftCtrlTabPressed(); -     +  protected:      bool queryClose(); -     +      /**      * Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed()      * to make switch tab @@ -120,7 +118,7 @@ private slots:      void slotBrowserLoading(bool);      void slotUpdateActions();      void slotUpdateWindowTitle(const QString &title = QString()); -     +      // history related      void slotOpenPrevious();      void slotOpenNext(); @@ -172,8 +170,6 @@ private:      QPointer<KPassivePopup> m_popup;      KActionCollection *m_ac; - -    bool m_flickeringZone;  };  #endif // MAINWINDOW_H diff --git a/src/webview.cpp b/src/webview.cpp index 7efded7f..edd8d9f6 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -63,6 +63,7 @@ WebView::WebView(QWidget* parent)          , m_scrollDirection(WebView::NoScroll)          , m_scrollSpeedVertical(0)          , m_scrollSpeedHorizontal(0) +        , m_mousePos(QPoint(0,0))  {      setPage(m_page); @@ -451,22 +452,19 @@ void WebView::mousePressEvent(QMouseEvent *event)  void WebView::mouseMoveEvent(QMouseEvent *event)  { -    QPoint p = event->pos(); -    QSize s = size(); -    int x = s.width() / 2; -    int y = s.height() - 30;    // quite reasonable value, without performing requests, cause of speed +    m_mousePos = event->pos(); -    if(p.x() <= x && p.y() >= y ) -        Application::instance()->mainWindow()->setFlickeringZone(true); -    else -        Application::instance()->mainWindow()->setFlickeringZone(false); -          if( url().protocol() != "rekonq" )      {          QWebView::mouseMoveEvent(event);      }  } +QPoint WebView::mousePos() +{ +    return m_mousePos; +} +  void WebView::wheelEvent(QWheelEvent *event)  { diff --git a/src/webview.h b/src/webview.h index d3f58f2e..5331d4cf 100644 --- a/src/webview.h +++ b/src/webview.h @@ -62,7 +62,8 @@ public:      KUrl url() const;      QString lastStatusBarText() const;      int progress(); - +    QPoint mousePos(); +      protected:      void contextMenuEvent(QContextMenuEvent *event);      void mousePressEvent(QMouseEvent *event); @@ -94,6 +95,7 @@ private:      int m_scrollDirection;      int m_scrollSpeedVertical;      int m_scrollSpeedHorizontal; +    QPoint m_mousePos;  };  #endif | 
