summaryrefslogtreecommitdiff
path: root/src/tabbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabbar.cpp')
-rw-r--r--src/tabbar.cpp72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index b43bf4d0..65a65f7e 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -75,8 +75,8 @@ TabBar::TabBar(MainView *parent)
setContextMenuPolicy(Qt::CustomContextMenu);
- connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this,
- SLOT(contextMenuRequested(const QPoint &)));
+ connect(this, SIGNAL(contextMenu(int, const QPoint &)), this, SLOT(slotContextMenuRequested(int, const QPoint &)));
+ connect(this, SIGNAL(emptyAreaContextMenu(const QPoint &)), this, SLOT(slotEmptyAreaContextMenu(const QPoint &)));
QTimer::singleShot(0, this, SLOT(postLaunch()));
}
@@ -136,33 +136,6 @@ QSize TabBar::tabSizeHint(int index) const
}
-void TabBar::contextMenuRequested(const QPoint &position)
-{
- KMenu menu;
- MainWindow *mainWindow = Application::instance()->mainWindow();
-
- menu.addAction(mainWindow->actionByName(QLatin1String("new_tab")));
- int index = tabAt(position);
- if (-1 != index)
- {
- m_actualIndex = index;
-
- menu.addAction( mainWindow->actionByName("clone_tab") );
- menu.addSeparator();
- menu.addAction( mainWindow->actionByName("close_tab") );
- menu.addAction( mainWindow->actionByName("close_other_tabs") );
- menu.addSeparator();
- menu.addAction( mainWindow->actionByName("reload_tab") );
- }
- else
- {
- menu.addSeparator();
- }
- menu.addAction( mainWindow->actionByName("reload_all_tabs") );
- menu.exec(QCursor::pos());
-}
-
-
void TabBar::cloneTab()
{
emit cloneTab(m_actualIndex);
@@ -190,21 +163,23 @@ void TabBar::reloadTab()
void TabBar::showTabPreview(int tab)
{
WebView *view = m_parent->webView(tab);
-
+ WebView *currentView = m_parent->webView(currentIndex());
+
int w = tabSizeHint(tab).width();
- int h = w*((0.0 + view->height())/view->width());
+ int h = w*((0.0 + currentView->height())/currentView->width());
//delete previous tab preview
if (m_previewPopup)
{
delete m_previewPopup;
}
-
+
m_previewPopup = new KPassivePopup(this);
m_previewPopup->setFrameShape(QFrame::StyledPanel);
m_previewPopup->setFrameShadow(QFrame::Plain);
m_previewPopup->setFixedSize(w, h);
QLabel *l = new QLabel();
+ view->page()->setViewportSize(currentView->page()->viewportSize());
l->setPixmap(WebSnap::renderPreview(*(view->page()), w, h));
m_previewPopup->setView(l);
m_previewPopup->layout()->setAlignment(Qt::AlignTop);
@@ -310,3 +285,36 @@ void TabBar::updateNewTabButton()
m_addTabButton->move(newPosX, newPosY);
}
}
+
+
+void TabBar::slotContextMenuRequested(int tab, const QPoint &pos)
+{
+ m_actualIndex = tab;
+
+ KMenu menu;
+ MainWindow *mainWindow = Application::instance()->mainWindow();
+
+ menu.addAction(mainWindow->actionByName(QLatin1String("new_tab")));
+ menu.addAction( mainWindow->actionByName("clone_tab") );
+ menu.addSeparator();
+ menu.addAction( mainWindow->actionByName("close_tab") );
+ menu.addAction( mainWindow->actionByName("close_other_tabs") );
+ menu.addSeparator();
+ menu.addAction( mainWindow->actionByName("reload_tab") );
+ menu.addAction( mainWindow->actionByName("reload_all_tabs") );
+
+ menu.exec(pos);
+}
+
+
+void TabBar::slotEmptyAreaContextMenu(const QPoint &pos)
+{
+ KMenu menu;
+ MainWindow *mainWindow = Application::instance()->mainWindow();
+
+ menu.addAction(mainWindow->actionByName(QLatin1String("new_tab")));
+ menu.addSeparator();
+ menu.addAction( mainWindow->actionByName("reload_all_tabs") );
+
+ menu.exec(pos);
+}