summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainview.cpp13
-rw-r--r--src/mainwindow.cpp53
-rw-r--r--src/mainwindow.h16
-rw-r--r--src/previewimage.cpp2
-rw-r--r--src/tabbar.cpp13
-rw-r--r--src/tabbar.h1
-rw-r--r--src/webview.cpp16
-rw-r--r--src/webview.h4
8 files changed, 65 insertions, 53 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 6d282e0c..0956e3ff 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -383,8 +383,15 @@ void MainView::slotCloneTab(int index)
index = currentIndex();
if (index < 0 || index >= count())
return;
- WebView *tab = newWebView();
- tab->setUrl(webView(index)->url());
+
+ WebView *tab = newWebView();
+ KUrl url = webView(index)->url();
+
+ // workaround against bug in webkit:
+ // only set url if it is not empty
+ // otherwise the current working directory will be used
+ if (!url.isEmpty())
+ tab->setUrl(url);
updateTabBar();
}
@@ -418,7 +425,7 @@ void MainView::slotCloseTab(int index)
hasFocus = tab->hasFocus();
//store close tab except homepage
- if (!tab->url().prettyUrl().startsWith("rekonq:") && !tab->url().isEmpty())
+ if (!tab->url().prettyUrl().startsWith( QLatin1String("rekonq:") ) && !tab->url().isEmpty())
{
QString title = tab->title();
QString url = tab->url().prettyUrl();
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/previewimage.cpp b/src/previewimage.cpp
index 99969893..df3a3471 100644
--- a/src/previewimage.cpp
+++ b/src/previewimage.cpp
@@ -167,7 +167,7 @@ void PreviewImage::snapFinished()
// update url (for added thumbs)
QStringList urls = ReKonfig::previewUrls();
- // stripTrailingSlash to be sure to get the same string for same adress
+ // stripTrailingSlash to be sure to get the same string for same address
urls.replace(m_index, ws->snapUrl().toString(QUrl::StripTrailingSlash));
names.replace(m_index, ws->snapTitle());
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index bde1e63e..ac050191 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -268,6 +268,19 @@ void TabBar::leaveEvent(QEvent *event)
KTabBar::leaveEvent(event);
}
+void TabBar::mousePressEvent(QMouseEvent *event)
+{
+ // just close tab on middle mouse click
+ if (event->button() == Qt::MidButton)
+ {
+ int index = tabAt(event->pos());
+ emit closeTab(index);
+ return;
+ }
+
+ KTabBar::mousePressEvent(event);
+}
+
void TabBar::updateNewTabButton()
{
diff --git a/src/tabbar.h b/src/tabbar.h
index 580021c4..57b78628 100644
--- a/src/tabbar.h
+++ b/src/tabbar.h
@@ -79,6 +79,7 @@ protected:
virtual QSize tabSizeHint(int index) const;
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void leaveEvent(QEvent *event);
+ virtual void mousePressEvent(QMouseEvent *event);
private slots:
void cloneTab();
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