TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) , m_newTabAction(0) , m_closeTabAction(0) , m_bookmarkTabsAction(0) , m_nextTabAction(0) , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) , m_locationBars(0) , m_tabBar(new TabBar(this)) , addTabButton(0) , closeTabButton(0) { setElideMode(Qt::ElideRight); new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T), this, SLOT(openLastTab())); new QShortcut(QKeySequence::Undo, this, SLOT(openLastTab())); connect(m_tabBar, SIGNAL(loadUrl(const QUrl&, TabWidget::OpenUrlIn)), this, SLOT(loadUrl(const QUrl&, TabWidget::OpenUrlIn))); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); setTabBar(m_tabBar); setDocumentMode(true); connect(m_tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int))); // Actions m_newTabAction = new QAction(this); m_newTabAction->setShortcuts(QKeySequence::AddTab); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new QAction(this); m_closeTabAction->setShortcuts(QKeySequence::Close); m_closeTabAction->setIcon(QIcon(QLatin1String(":graphics/closetab.png"))); m_closeTabAction->setIconVisibleInMenu(true); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_bookmarkTabsAction = new QAction(this); connect(m_bookmarkTabsAction, SIGNAL(triggered()), this, SLOT(bookmarkTabs())); m_newTabAction->setIcon(QIcon(QLatin1String(":graphics/addtab.png"))); m_newTabAction->setIconVisibleInMenu(true); m_nextTabAction = new QAction(this); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new QAction(this); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); #if QT_VERSION >= 0x040600 && defined(Q_WS_X11) m_previousTabAction->setIcon(QIcon::fromTheme(QLatin1String("go-previous"))); m_nextTabAction->setIcon(QIcon::fromTheme(QLatin1String("go-next"))); #endif m_recentlyClosedTabsMenu = new QMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); m_recentlyClosedTabsAction = new QAction(this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(true); #ifndef Q_WS_MAC // can't seem to figure out the background color :( addTabButton = new QToolButton(this); addTabButton->setDefaultAction(m_newTabAction); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); #endif connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_locationBars = new QStackedWidget(this); connect(BrowserApplication::historyManager(), SIGNAL(historyCleared()), this, SLOT(historyCleared())); // Initialize Actions' labels retranslate(); loadSettings(); }
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) , m_newTabAction(0) , m_closeTabAction(0) , m_bookmarkTabsAction(0) , m_nextTabAction(0) , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_swappedDelayedWidget(false) , m_lineEditCompleter(0) , m_lineEdits(0) , m_tabBar(new TabBar(this)) { setElideMode(Qt::ElideRight); new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T), this, SLOT(openLastTab())); connect(m_tabBar, SIGNAL(loadUrl(const QUrl&, TabWidget::OpenUrlIn)), this, SLOT(loadUrl(const QUrl&, TabWidget::OpenUrlIn))); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); #if QT_VERSION < 0x040500 connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); #endif setTabBar(m_tabBar); #if QT_VERSION >= 0x040500 setDocumentMode(true); connect(m_tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int))); #endif // Actions m_newTabAction = new QAction(this); m_newTabAction->setShortcuts(QKeySequence::AddTab); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new QAction(this); m_closeTabAction->setShortcuts(QKeySequence::Close); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_bookmarkTabsAction = new QAction(this); connect(m_bookmarkTabsAction, SIGNAL(triggered()), this, SLOT(bookmarkTabs())); m_newTabAction->setIcon(QIcon(QLatin1String(":addtab.png"))); m_newTabAction->setIconVisibleInMenu(false); #if QT_VERSION >= 0x040500 QSettings settings; settings.beginGroup(QLatin1String("tabs")); bool oneCloseButton = settings.value(QLatin1String("oneCloseButton"), false).toBool(); if (oneCloseButton) { #endif // With Qt < 4.5 do this always, with >=4.5 only if enabled. m_closeTabAction->setIcon(QIcon(QLatin1String(":closetab.png"))); m_closeTabAction->setIconVisibleInMenu(false); #if QT_VERSION >= 0x040500 } #endif m_nextTabAction = new QAction(this); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new QAction(this); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); m_recentlyClosedTabsMenu = new QMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); m_recentlyClosedTabsAction = new QAction(this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); #ifndef Q_WS_MAC // can't seem to figure out the background color :( QToolButton *addTabButton = new QToolButton(this); addTabButton->setDefaultAction(m_newTabAction); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(addTabButton, Qt::TopRightCorner); #endif #if QT_VERSION >= 0x040500 if (oneCloseButton) { #endif // corner buttons // With Qt < 4.5 do this always, with >=4.5 only if enabled. QToolButton *closeTabButton = new QToolButton(this); closeTabButton->setDefaultAction(m_closeTabAction); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(closeTabButton, Qt::TopLeftCorner); #if QT_VERSION >= 0x040500 } else { m_tabBar->setTabsClosable(true); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); } #endif connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); connect(BrowserApplication::historyManager(), SIGNAL(historyCleared()), this, SLOT(historyCleared())); // Initialize Actions' labels retranslate(); }