2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2011-12-15 18:34:48 +01:00
|
|
|
* Copyright (C) 2010-2011 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "tabbar.h"
|
|
|
|
#include "tabwidget.h"
|
|
|
|
#include "qupzilla.h"
|
2011-03-25 19:16:21 +01:00
|
|
|
#include "webtab.h"
|
2011-09-30 21:44:18 +02:00
|
|
|
#include "iconprovider.h"
|
2011-10-14 23:12:10 +02:00
|
|
|
#include "toolbutton.h"
|
2011-03-25 19:16:21 +01:00
|
|
|
|
2011-10-14 23:12:10 +02:00
|
|
|
#define MAXIMUM_TAB_WIDTH 250
|
|
|
|
#define MINIMUM_TAB_WIDTH 50
|
2011-12-28 13:16:04 +01:00
|
|
|
|
2011-10-14 23:12:10 +02:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
#define PINNED_TAB_WIDTH 38
|
2011-12-28 13:16:04 +01:00
|
|
|
#elif defined(KDE)
|
|
|
|
#define PINNED_TAB_WIDTH 24
|
2011-10-14 23:12:10 +02:00
|
|
|
#else
|
|
|
|
#define PINNED_TAB_WIDTH 31
|
|
|
|
#endif
|
|
|
|
|
2011-10-18 21:07:58 +02:00
|
|
|
TabBar::TabBar(QupZilla* mainClass, TabWidget* tabWidget)
|
|
|
|
: QTabBar()
|
2011-10-14 23:12:10 +02:00
|
|
|
, p_QupZilla(mainClass)
|
2011-10-18 21:07:58 +02:00
|
|
|
, m_tabWidget(tabWidget)
|
2011-10-14 23:12:10 +02:00
|
|
|
, m_clickedTab(0)
|
|
|
|
, m_pinnedTabsCount(0)
|
2011-10-23 14:44:18 +02:00
|
|
|
, m_normalTabWidth(0)
|
|
|
|
, m_lastTabWidth(0)
|
|
|
|
, m_adjustingLastTab(false)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-09-11 19:15:06 +02:00
|
|
|
setObjectName("tabbar");
|
2011-03-02 16:57:41 +01:00
|
|
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
setElideMode(Qt::ElideRight);
|
2011-03-25 19:16:21 +01:00
|
|
|
setTabsClosable(true);
|
2011-03-02 16:57:41 +01:00
|
|
|
setDocumentMode(true);
|
2011-10-24 17:46:45 +02:00
|
|
|
setFocusPolicy(Qt::NoFocus);
|
2011-03-02 16:57:41 +01:00
|
|
|
loadSettings();
|
|
|
|
|
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
2011-10-14 23:12:10 +02:00
|
|
|
connect(m_tabWidget, SIGNAL(pinnedTabClosed()), this, SLOT(pinnedTabClosed()));
|
|
|
|
connect(m_tabWidget, SIGNAL(pinnedTabAdded()), this, SLOT(pinnedTabAdded()));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabBar::loadSettings()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
QSettings settings(mApp->getActiveProfilPath() + "settings.ini", QSettings::IniFormat);
|
2011-03-02 16:57:41 +01:00
|
|
|
settings.beginGroup("Browser-Tabs-Settings");
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
setMovable(settings.value("makeTabsMovable", true).toBool());
|
|
|
|
if (settings.value("ActivateLastTabWhenClosingActual", false).toBool()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2011-10-24 17:46:45 +02:00
|
|
|
void TabBar::updateVisibilityWithFullscreen(bool visible)
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (visible) {
|
2011-10-24 17:46:45 +02:00
|
|
|
emit showButtons();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-10-24 17:46:45 +02:00
|
|
|
emit hideButtons();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
|
|
|
QTabBar::setVisible(visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabBar::setVisible(bool visible)
|
|
|
|
{
|
|
|
|
if (visible) {
|
2011-11-06 17:01:23 +01:00
|
|
|
if (p_QupZilla->isFullScreen()) {
|
2011-10-24 17:46:45 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-24 17:46:45 +02:00
|
|
|
|
|
|
|
emit showButtons();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
emit hideButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
QTabBar::setVisible(visible);
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void TabBar::contextMenuRequested(const QPoint &position)
|
|
|
|
{
|
2011-03-25 19:16:21 +01:00
|
|
|
int index = tabAt(position);
|
|
|
|
m_clickedTab = index;
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QMenu menu;
|
2011-11-06 17:01:23 +01:00
|
|
|
menu.addAction(QIcon(":/icons/menu/popup.png"), tr("&New tab"), p_QupZilla, SLOT(addTab()));
|
2011-03-02 16:57:41 +01:00
|
|
|
menu.addSeparator();
|
2011-11-06 17:01:23 +01:00
|
|
|
if (index != -1) {
|
2011-10-14 23:12:10 +02:00
|
|
|
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!webTab) {
|
2011-03-26 13:34:08 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
if (p_QupZilla->weView(m_clickedTab)->isLoading()) {
|
2011-09-30 21:44:18 +02:00
|
|
|
menu.addAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("&Stop Tab"), this, SLOT(stopTab()));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-09-30 21:44:18 +02:00
|
|
|
menu.addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload Tab"), this, SLOT(reloadTab()));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-30 21:44:18 +02:00
|
|
|
|
2011-04-09 00:22:50 +02:00
|
|
|
menu.addAction(tr("&Duplicate Tab"), this, SLOT(duplicateTab()));
|
|
|
|
menu.addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab()));
|
2011-03-25 19:16:21 +01:00
|
|
|
menu.addSeparator();
|
2011-10-14 23:12:10 +02:00
|
|
|
menu.addAction(tr("Re&load All Tabs"), m_tabWidget, SLOT(reloadAllTabs()));
|
2011-04-09 00:22:50 +02:00
|
|
|
menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab()));
|
|
|
|
menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
|
2011-03-02 16:57:41 +01:00
|
|
|
menu.addSeparator();
|
2011-05-07 12:59:53 +02:00
|
|
|
QAction* action = p_QupZilla->actionRestoreTab();
|
2011-12-12 21:14:43 +01:00
|
|
|
action->setEnabled(m_tabWidget->canRestoreTab());
|
2011-05-07 12:59:53 +02:00
|
|
|
menu.addAction(action);
|
2011-03-02 16:57:41 +01:00
|
|
|
menu.addSeparator();
|
2011-04-09 00:22:50 +02:00
|
|
|
menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent()));
|
2011-11-06 17:01:23 +01:00
|
|
|
menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab()));
|
2011-03-02 16:57:41 +01:00
|
|
|
menu.addSeparator();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-10-14 23:12:10 +02:00
|
|
|
menu.addAction(tr("Reloa&d All Tabs"), m_tabWidget, SLOT(reloadAllTabs()));
|
2011-04-09 00:22:50 +02:00
|
|
|
menu.addAction(tr("Bookmark &All Ta&bs"), p_QupZilla, SLOT(bookmarkAllTabs()));
|
2011-03-02 16:57:41 +01:00
|
|
|
menu.addSeparator();
|
2011-11-06 17:01:23 +01:00
|
|
|
QAction* action = menu.addAction(QIcon::fromTheme("user-trash"), tr("Restore &Closed Tab"), m_tabWidget, SLOT(restoreClosedTab()));
|
2011-12-12 21:14:43 +01:00
|
|
|
action->setEnabled(m_tabWidget->canRestoreTab());
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Prevent choosing first option with double rightclick
|
|
|
|
QPoint pos = QCursor::pos();
|
2011-11-06 17:01:23 +01:00
|
|
|
QPoint p(pos.x(), pos.y() + 1);
|
2011-03-02 16:57:41 +01:00
|
|
|
menu.exec(p);
|
2011-05-07 12:59:53 +02:00
|
|
|
p_QupZilla->actionRestoreTab()->setEnabled(true);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-03-25 19:16:21 +01:00
|
|
|
QSize TabBar::tabSizeHint(int index) const
|
|
|
|
{
|
|
|
|
QSize size = QTabBar::tabSizeHint(index);
|
2011-10-14 23:12:10 +02:00
|
|
|
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
|
2011-10-23 14:44:18 +02:00
|
|
|
TabBar* tabBar = const_cast <TabBar*>(this);
|
|
|
|
tabBar->m_adjustingLastTab = false;
|
2011-10-14 23:12:10 +02:00
|
|
|
|
|
|
|
if (webTab && webTab->isPinned()) {
|
|
|
|
size.setWidth(PINNED_TAB_WIDTH);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-10-23 14:44:18 +02:00
|
|
|
int availableWidth = width() - (PINNED_TAB_WIDTH * m_pinnedTabsCount) - m_tabWidget->buttonListTabs()->width() - m_tabWidget->buttonAddTab()->width();
|
2011-10-14 23:12:10 +02:00
|
|
|
int normalTabsCount = count() - m_pinnedTabsCount;
|
2011-10-23 14:44:18 +02:00
|
|
|
if (availableWidth >= MAXIMUM_TAB_WIDTH * normalTabsCount) {
|
|
|
|
tabBar->m_normalTabWidth = MAXIMUM_TAB_WIDTH;
|
|
|
|
size.setWidth(m_normalTabWidth);
|
|
|
|
}
|
|
|
|
else if (availableWidth < MINIMUM_TAB_WIDTH * normalTabsCount) {
|
|
|
|
tabBar->m_normalTabWidth = MINIMUM_TAB_WIDTH;
|
|
|
|
size.setWidth(m_normalTabWidth);
|
|
|
|
}
|
2011-10-14 23:12:10 +02:00
|
|
|
else {
|
|
|
|
int maxWidthForTab = availableWidth / normalTabsCount;
|
2011-10-23 14:44:18 +02:00
|
|
|
tabBar->m_normalTabWidth = maxWidthForTab;
|
2011-10-14 23:12:10 +02:00
|
|
|
//Fill any empty space (gotten from rounding) with last tab
|
2011-10-23 14:44:18 +02:00
|
|
|
if (index == count() - 1) {
|
|
|
|
tabBar->m_lastTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab;
|
|
|
|
tabBar->m_adjustingLastTab = true;
|
|
|
|
size.setWidth(m_lastTabWidth);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tabBar->m_lastTabWidth = maxWidthForTab;
|
|
|
|
size.setWidth(m_lastTabWidth);
|
|
|
|
}
|
2011-10-14 23:12:10 +02:00
|
|
|
}
|
2011-03-25 19:16:21 +01:00
|
|
|
}
|
2011-10-23 14:44:18 +02:00
|
|
|
|
|
|
|
if (index == count() - 1) {
|
|
|
|
int xForAddTabButton = (PINNED_TAB_WIDTH * m_pinnedTabsCount) + (count() - m_pinnedTabsCount) * (m_normalTabWidth);
|
2011-11-06 17:01:23 +01:00
|
|
|
if (m_adjustingLastTab) {
|
|
|
|
xForAddTabButton += m_lastTabWidth - m_normalTabWidth;
|
|
|
|
}
|
2011-10-23 14:44:18 +02:00
|
|
|
emit tabBar->moveAddTabButton(xForAddTabButton);
|
|
|
|
}
|
|
|
|
|
2011-03-25 19:16:21 +01:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2011-10-23 14:44:18 +02:00
|
|
|
//void TabBar::emitMoveAddTabButton(int pox)
|
|
|
|
//{
|
|
|
|
// emit moveAddTabButton(pox);
|
|
|
|
//}
|
|
|
|
|
2011-07-19 15:18:49 +02:00
|
|
|
#if 0
|
2011-03-25 19:16:21 +01:00
|
|
|
void TabBar::tabInserted(int index)
|
|
|
|
{
|
|
|
|
// CloseButton* closeButton = new CloseButton(this);
|
|
|
|
// closeButton->setAutoRaise(true);
|
|
|
|
// closeButton->setMaximumSize(17,17);
|
|
|
|
// closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
|
|
|
|
// connect(closeButton, SIGNAL(clicked()), this, SLOT(closeCurrentTab()));
|
|
|
|
// setTabButton(index, QTabBar::RightSide, closeButton);
|
|
|
|
QAbstractButton* button = (QAbstractButton*)tabButton(index, QTabBar::RightSide);
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!button) {
|
2011-03-25 19:16:21 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
button->resize(17, 17);
|
2011-03-25 19:16:21 +01:00
|
|
|
}
|
|
|
|
|
2011-07-19 15:18:49 +02:00
|
|
|
void TabBar::showCloseButton(int index)
|
|
|
|
{
|
|
|
|
|
2011-10-14 23:12:10 +02:00
|
|
|
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (webTab && webTab->isPinned()) {
|
2011-07-19 15:18:49 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-07-19 15:18:49 +02:00
|
|
|
|
|
|
|
CloseButton* button = (CloseButton*)tabButton(index, QTabBar::RightSide);
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!button) {
|
2011-07-19 15:18:49 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-07-19 15:18:49 +02:00
|
|
|
|
|
|
|
button->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabBar::hideCloseButton(int index)
|
|
|
|
{
|
|
|
|
CloseButton* button = (CloseButton*)tabButton(index, QTabBar::RightSide);
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!button) {
|
2011-07-19 15:18:49 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-07-19 15:18:49 +02:00
|
|
|
button->hide();
|
|
|
|
}
|
|
|
|
#endif
|
2011-03-25 19:16:21 +01:00
|
|
|
|
|
|
|
void TabBar::updateCloseButton(int index)
|
|
|
|
{
|
2011-10-18 21:07:58 +02:00
|
|
|
QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, QTabBar::RightSide));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!button) {
|
2011-03-25 19:16:21 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-25 19:16:21 +01:00
|
|
|
|
2011-10-14 23:12:10 +02:00
|
|
|
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (webTab && webTab->isPinned()) {
|
2011-03-25 19:16:21 +01:00
|
|
|
button->hide();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-03-25 19:16:21 +01:00
|
|
|
button->show();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-25 19:16:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabBar::closeCurrentTab()
|
|
|
|
{
|
|
|
|
int id = currentIndex();
|
2011-11-06 17:01:23 +01:00
|
|
|
if (id < 0) {
|
2011-03-25 19:16:21 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-14 23:12:10 +02:00
|
|
|
|
|
|
|
m_tabWidget->closeTab(id);
|
2011-03-25 19:16:21 +01:00
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void TabBar::bookmarkTab()
|
|
|
|
{
|
2011-07-30 17:57:14 +02:00
|
|
|
p_QupZilla->addBookmark(p_QupZilla->weView(m_clickedTab)->url(), p_QupZilla->weView(m_clickedTab)->title(), p_QupZilla->weView(m_clickedTab)->siteIcon());
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2011-03-25 19:16:21 +01:00
|
|
|
void TabBar::pinTab()
|
|
|
|
{
|
2011-10-14 23:12:10 +02:00
|
|
|
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab));
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!webTab) {
|
2011-03-25 19:16:21 +01:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-25 19:16:21 +01:00
|
|
|
|
|
|
|
webTab->pinTab(m_clickedTab);
|
2011-10-14 23:12:10 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
if (webTab->isPinned()) {
|
2011-10-14 23:12:10 +02:00
|
|
|
m_pinnedTabsCount++;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-10-14 23:12:10 +02:00
|
|
|
m_pinnedTabsCount--;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-23 14:44:18 +02:00
|
|
|
|
|
|
|
// Adjust add tab button in proper position
|
|
|
|
tabSizeHint(count() - 1);
|
2011-10-14 23:12:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabBar::pinnedTabClosed()
|
|
|
|
{
|
|
|
|
m_pinnedTabsCount--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabBar::pinnedTabAdded()
|
|
|
|
{
|
|
|
|
m_pinnedTabsCount++;
|
2011-03-25 19:16:21 +01:00
|
|
|
}
|
|
|
|
|
2011-11-05 15:04:29 +01:00
|
|
|
int TabBar::pinnedTabsCount()
|
|
|
|
{
|
|
|
|
return m_pinnedTabsCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TabBar::normalTabsCount()
|
|
|
|
{
|
|
|
|
return count() - m_pinnedTabsCount;
|
|
|
|
}
|
|
|
|
|
2011-03-17 17:03:04 +01:00
|
|
|
void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
if (event->button() == Qt::LeftButton && tabAt(event->pos()) == -1) {
|
2011-12-20 18:58:42 +01:00
|
|
|
m_tabWidget->addView(QUrl(), tr("New tab"), TabWidget::NewSelectedTab, true);
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-12-15 17:43:06 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QTabBar::mouseDoubleClickEvent(event);
|
|
|
|
}
|
2011-10-14 23:32:12 +02:00
|
|
|
|
2011-12-12 21:14:43 +01:00
|
|
|
void TabBar::mouseReleaseEvent(QMouseEvent* event)
|
2011-10-14 23:32:12 +02:00
|
|
|
{
|
2011-12-12 21:14:43 +01:00
|
|
|
if (!rect().contains(event->pos())) {
|
2011-12-15 17:03:50 +01:00
|
|
|
QTabBar::mouseReleaseEvent(event);
|
2011-12-12 21:14:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-14 23:32:12 +02:00
|
|
|
int id = tabAt(event->pos());
|
2011-12-12 21:14:43 +01:00
|
|
|
if (id != -1 && event->button() == Qt::MiddleButton) {
|
2011-10-17 23:34:57 +02:00
|
|
|
m_tabWidget->closeTab(id);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-12 21:14:43 +01:00
|
|
|
if (id == -1 && event->button() == Qt::MiddleButton) {
|
2011-10-17 23:34:57 +02:00
|
|
|
m_tabWidget->addView(QUrl(), tr("New tab"), TabWidget::NewSelectedTab, true);
|
2011-10-14 23:32:12 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-12-15 17:43:06 +01:00
|
|
|
|
2011-12-12 21:14:43 +01:00
|
|
|
QTabBar::mouseReleaseEvent(event);
|
2011-10-14 23:32:12 +02:00
|
|
|
}
|