void TabBar::contextMenuEvent(QContextMenuEvent* event) { int index = tabAt(event->pos()); m_clickedTab = index; QMenu menu; menu.addAction(IconProvider::newTabIcon(), tr("&New tab"), m_window, SLOT(addTab())); menu.addSeparator(); if (index != -1) { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab)); if (!webTab) { return; } if (m_window->weView(m_clickedTab)->isLoading()) { menu.addAction(QIcon::fromTheme(QSL("process-stop")), tr("&Stop Tab"), this, SLOT(stopTab())); } else { menu.addAction(QIcon::fromTheme(QSL("view-refresh")), tr("&Reload Tab"), this, SLOT(reloadTab())); } menu.addAction(QIcon::fromTheme("tab-duplicate"), tr("&Duplicate Tab"), this, SLOT(duplicateTab())); if (count() > 1 && !webTab->isPinned()) { menu.addAction(QIcon::fromTheme("tab-detach"), tr("D&etach Tab"), this, SLOT(detachTab())); } menu.addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab())); #if QT_VERSION >= QT_VERSION_CHECK(5,7,0) menu.addAction(webTab->isMuted() ? tr("Un&mute Tab") : tr("&Mute Tab"), this, SLOT(muteTab())); #endif menu.addSeparator(); menu.addAction(tr("Re&load All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab())); menu.addAction(tr("Bookmark &All Tabs"), m_window, SLOT(bookmarkAllTabs())); menu.addSeparator(); menu.addAction(m_window->action(QSL("Other/RestoreClosedTab"))); menu.addSeparator(); menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent())); menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab())); menu.addSeparator(); } else { menu.addAction(tr("Reloa&d All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("Bookmark &All Tabs"), m_window, SLOT(bookmarkAllTabs())); menu.addSeparator(); menu.addAction(m_window->action(QSL("Other/RestoreClosedTab"))); } m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(m_tabWidget->canRestoreTab()); // Prevent choosing first option with double rightclick const QPoint pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); menu.exec(p); m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(true); }
void TabBar::contextMenuRequested(const QPoint &position) { int index = tabAt(position); m_clickedTab = index; QMenu menu; menu.addAction(QIcon(":/icons/menu/new-tab.png"), tr("&New tab"), p_QupZilla, SLOT(addTab())); menu.addSeparator(); if (index != -1) { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab)); if (!webTab) { return; } if (p_QupZilla->weView(m_clickedTab)->isLoading()) { menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop Tab"), this, SLOT(stopTab())); } else { menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload Tab"), this, SLOT(reloadTab())); } menu.addAction(tr("&Duplicate Tab"), this, SLOT(duplicateTab())); menu.addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab())); menu.addSeparator(); menu.addAction(tr("Re&load All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab())); menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addSeparator(); QAction* action = p_QupZilla->actionRestoreTab(); action->setEnabled(m_tabWidget->canRestoreTab()); menu.addAction(action); menu.addSeparator(); menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent())); menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab())); menu.addSeparator(); } else { menu.addAction(tr("Reloa&d All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("Bookmark &All Ta&bs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addSeparator(); QAction* action = menu.addAction(QIcon::fromTheme("user-trash"), tr("Restore &Closed Tab"), m_tabWidget, SLOT(restoreClosedTab())); action->setEnabled(m_tabWidget->canRestoreTab()); } // Prevent choosing first option with double rightclick const QPoint &pos = mapToGlobal(position); QPoint p(pos.x(), pos.y() + 1); menu.exec(p); p_QupZilla->actionRestoreTab()->setEnabled(true); }
void WBTabBar::contextMenuRequested(const QPoint &position) { QMenu menu; menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); if (-1 != index) { QAction *action = menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); action->setData(index); action = menu.addAction(tr("Close &Other Tabs"), this, SLOT(closeOtherTabs())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); } else { menu.addSeparator(); } menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); menu.exec(QCursor::pos()); }
WBTabWidget::WBTabWidget(QWidget *parent) : QTabWidget(parent) , mRecentlyClosedTabsMenu(0) , mLineEditCompleter(0) , mLineEdits(0) , mTabBar(new WBTabBar(this)) { setObjectName("ubWebBrowserTabWidget"); mAddTabIcon = QPixmap(":/images/toolbar/plusBlack.png"); setElideMode(Qt::ElideRight); connect(mTabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(mTabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(mTabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(mTabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); connect(mTabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); connect(mTabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); connect(mTabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int))); setTabBar(mTabBar); setDocumentMode(false); mRecentlyClosedTabsMenu = new QMenu(this); connect(mRecentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(mRecentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); mRecentlyClosedTabsAction = new QAction(tr("Recently Closed Tabs"), this); mRecentlyClosedTabsAction->setMenu(mRecentlyClosedTabsMenu); mRecentlyClosedTabsAction->setEnabled(false); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); mLineEdits = new QStackedWidget(this); mLineEdits->setMinimumWidth(200); QSizePolicy spolicy = mLineEdits->sizePolicy(); mLineEdits->setSizePolicy(QSizePolicy::Maximum, spolicy.verticalPolicy()); }
void TabBar::contextMenuRequested(const QPoint &position) { QMenu menu; TabWidget *tabWidget = qobject_cast<TabWidget *>(parentWidget()); if (!tabWidget) return; menu.addAction(tabWidget->newTabAction()); int index = tabAt(position); if (-1 != index) { QAction *action = menu.addAction(tr("Duplicate Tab"), this, SLOT(cloneTab())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); action->setData(index); action = menu.addAction(tr("Close &Other Tabs"), this, SLOT(closeOtherTabs())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); } else { menu.addSeparator(); } menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); menu.addSeparator(); menu.addAction(tabWidget->bookmarkTabsAction()); menu.exec(QCursor::pos()); }
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) , m_newTabAction(0) , m_closeTabAction(0) , m_nextTabAction(0) , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) , m_lineEdits(0) , m_tabBar(new TabBar(this)) { setElideMode(Qt::ElideRight); 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())); connect(m_tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int))); setTabBar(m_tabBar); setDocumentMode(true); // Actions m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this); m_newTabAction->setShortcuts(QKeySequence::AddTab); m_newTabAction->setIconVisibleInMenu(false); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this); m_closeTabAction->setShortcuts(QKeySequence::Close); m_closeTabAction->setIconVisibleInMenu(false); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_nextTabAction = new QAction(tr("Show Next Tab"), this); QList<QKeySequence> shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Less)); m_nextTabAction->setShortcuts(shortcuts); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new QAction(tr("Show Previous Tab"), this); shortcuts.clear(); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Greater)); m_previousTabAction->setShortcuts(shortcuts); 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(tr("Recently Closed Tabs"), this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); }
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) , m_newTabAction(0) , m_closeTabAction(0) , m_nextTabAction(0) , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , 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::Tab)), this, SLOT(loadUrl(const QUrl&, TabWidget::Tab))); 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(tr("New &Tab"), this); m_newTabAction->setShortcuts(QKeySequence::AddTab); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new QAction(tr("&Close Tab"), this); m_closeTabAction->setShortcuts(QKeySequence::Close); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); #if QT_VERSION < 0x040500 m_newTabAction->setIcon(QIcon(QLatin1String(":addtab.png"))); m_newTabAction->setIconVisibleInMenu(false); m_closeTabAction->setIcon(QIcon(QLatin1String(":closetab.png"))); m_closeTabAction->setIconVisibleInMenu(false); #endif m_nextTabAction = new QAction(tr("Show Next Tab"), this); QList<QKeySequence> shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Less)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Tab)); m_nextTabAction->setShortcuts(shortcuts); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new QAction(tr("Show Previous Tab"), this); shortcuts.clear(); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Greater)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab)); m_previousTabAction->setShortcuts(shortcuts); 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(tr("Recently Closed Tabs"), this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); #if QT_VERSION >= 0x040500 m_tabBar->setTabsClosable(true); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); m_tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); #else // corner buttons QToolButton *addTabButton = new QToolButton(this); addTabButton->setDefaultAction(m_newTabAction); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(addTabButton, Qt::TopLeftCorner); QToolButton *closeTabButton = new QToolButton(this); closeTabButton->setDefaultAction(m_closeTabAction); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(closeTabButton, Qt::TopRightCorner); #endif connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); connect(BrowserApplication::historyManager(), SIGNAL(historyCleared()), this, SLOT(historyCleared())); }
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_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_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); #if QT_VERSION < 0x040500 QToolButton *addTabButton = new QToolButton(this); addTabButton->setDefaultAction(m_newTabAction); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(addTabButton, Qt::TopLeftCorner); #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::TopRightCorner); #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(); }