/** * Constructs a TabDlg * * \param tabManager The tabManager that will manage this TabDlg * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that * will manage some aspects of the TabDlg behavior. Ownership is not * passed. */ TabDlg::TabDlg(TabManager* tabManager, const QString& geometryOption, TabDlgDelegate *delegate) : AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0) , delegate_(delegate) , tabWidget_(0) , detachButton_(0) , closeButton_(0) , closeCross_(0) , tabMenu_(new QMenu(this)) , act_close_(0) , act_next_(0) , act_prev_(0) , tabManager_(tabManager) , userManagement_(true) , tabBarSingles_(true) , simplifiedCaption_(false) , activateTabMapper_(0) { if (delegate_) { delegate_->create(this); } // FIXME qRegisterMetaType<TabDlg*>("TabDlg*"); qRegisterMetaType<TabbableWidget*>("TabbableWidget*"); tabWidget_ = new PsiTabWidget(this); tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon()); connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(mouseMiddleClickTab(QWidget*)), SLOT(mouseMiddleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*))); connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*))); connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab())); connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*))); if(delegate_) delegate_->tabWidgetCreated(this, tabWidget_); QVBoxLayout *vert1 = new QVBoxLayout(this); vert1->setMargin(1); vert1->addWidget(tabWidget_); setAcceptDrops(true); X11WM_CLASS("tabs"); setLooks(); act_close_ = new QAction(this); addAction(act_close_); connect(act_close_,SIGNAL(triggered()), SLOT(closeCurrentTab())); act_prev_ = new QAction(this); addAction(act_prev_); connect(act_prev_,SIGNAL(triggered()), SLOT(previousTab())); act_next_ = new QAction(this); addAction(act_next_); connect(act_next_,SIGNAL(triggered()), SLOT(nextTab())); setShortcuts(); setGeometryOptionPath(geometryOption); }
/** * @brief Overrides QTabWidget::keyPressEvent() in order to intercept * tab close key shortcuts (Ctrl+F4 and Ctrl+W) */ void WorkAreaTabWidget::keyPressEvent(QKeyEvent *keyEvent) { if ((keyEvent->modifiers() & Qt::ControlModifier) && (keyEvent->key()==Qt::Key_F4 || keyEvent->key()==Qt::Key_W)) { int index = currentIndex(); closeTab(index); return; } if (KeyboardManager::isPreviousTabShortcut(keyEvent)) { previousTab(); return; } else if (KeyboardManager::isNextTabShortcut(keyEvent)) { nextTab(); return; } else if (KeyboardManager::isNewTabShortcut(keyEvent)) { currentQueryWidget()->openNewTab(); return; } else if (KeyboardManager::isSetFocusOnQueryLineShortcut(keyEvent)) { currentQueryWidget()->setScriptFocus(); return; } else if (KeyboardManager::isExecuteScriptShortcut(keyEvent)) { currentQueryWidget()->execute(); return; } else if (KeyboardManager::isAutoCompleteShortcut(keyEvent)) { currentQueryWidget()->showAutocompletion(); return; } else if (KeyboardManager::isHideAutoCompleteShortcut(keyEvent)) { currentQueryWidget()->hideAutocompletion(); return; } QTabWidget::keyPressEvent(keyEvent); }
TabWidget::TabWidget(QWidget *parent) : QWidget(parent) , m_toolBar(new QToolBar(this)) , m_toolBarTree(new QToolBar(this)) , m_tabBar(NULL) , m_tabTree(NULL) , m_stackedWidget(NULL) , m_hideTabBar(false) { // Set object name for tool bars so they can be saved with QMainWindow::saveState(). m_toolBar->setObjectName("toolBarTabBar"); m_toolBarTree->setObjectName("toolBarTabTree"); m_toolBar->setContextMenuPolicy(Qt::NoContextMenu); m_toolBarTree->setContextMenuPolicy(Qt::NoContextMenu); m_toolBar->installEventFilter(this); connect( m_toolBar, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(onToolBarOrientationChanged(Qt::Orientation)) ); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this); setLayout(layout); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); m_stackedWidget = new QStackedWidget(this); layout->addWidget(m_stackedWidget); createTabBar(); addTabAction(this, QKeySequence::PreviousChild, this, SLOT(previousTab())); addTabAction(this, QKeySequence::NextChild, this, SLOT(nextTab())); }
void MainWindow::setupActions() { buildActions = new QActionGroup(this); buildActions->addAction(ui.action_Build); buildActions->addAction(ui.action_Upload); connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabHasChanged())); connect(ui.action_New, SIGNAL(triggered()), this, SLOT(newProject())); connect(ui.action_Open, SIGNAL(triggered()), this, SLOT(open())); connect(ui.action_Save, SIGNAL(triggered()), this, SLOT(save())); connect(ui.action_Saveas, SIGNAL(triggered()), this, SLOT(save_as())); connect(ui.action_Close, SIGNAL(triggered()), this, SLOT(closeTab())); connect(ui.actionUpPastebin, SIGNAL(triggered()), this, SLOT(uploadToPastebin())); connect(ui.actionUndo, SIGNAL(triggered()), this, SLOT(undo())); connect(ui.actionRedo, SIGNAL(triggered()), this, SLOT(redo())); connect(ui.action_Copy, SIGNAL(triggered()), this, SLOT(copy())); connect(ui.action_Cut, SIGNAL(triggered()), this, SLOT(cut())); connect(ui.action_Find, SIGNAL(triggered(bool)), this, SLOT(showFindBox(bool))); connect(ui.action_Paste, SIGNAL(triggered()), this, SLOT(paste())); connect(ui.action_Build, SIGNAL(triggered()), this, SLOT(build())); connect(ui.action_Upload, SIGNAL(triggered()), this, SLOT(upload())); connect(ui.action_Utilities, SIGNAL(triggered()), this, SLOT(toggleDock())); connect(ui.actionGo_to_the_next_tab, SIGNAL(triggered()), this, SLOT(nextTab())); connect(ui.actionGo_to_the_previous_tab, SIGNAL(triggered()), this, SLOT(previousTab())); connect(ui.action_Configure_the_IDE, SIGNAL(triggered()), this, SLOT(configure())); connect(ui.action_Contextual_help, SIGNAL(triggered()), this, SLOT(contextualHelp())); connect(ui.actionCommunityArduinoCC, SIGNAL(triggered()), this, SLOT(openCommunityArduinoCC())); connect(ui.actionCommunityArduinoForums, SIGNAL(triggered()), this, SLOT(openCommunityArduinoForums())); connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui.actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(ui.lineFind, SIGNAL(returnPressed()), this, SLOT(find())); connect(ui.lineReplace, SIGNAL(returnPressed()), this, SLOT(find())); connect(ui.pushFind, SIGNAL(clicked()), this, SLOT(find())); connect(ui.pushReplace, SIGNAL(clicked()), this, SLOT(replace())); connect(ui.pushReplaceAll, SIGNAL(clicked()), this, SLOT(replaceAll())); connect(this, SIGNAL(tabChanged(bool)), ui.pushReplace, SLOT(setEnabled(bool))); connect(this, SIGNAL(tabChanged(bool)), ui.pushReplaceAll, SLOT(setEnabled(bool))); connect(this, SIGNAL(tabChanged(bool)), ui.checkRegExp, SLOT(setEnabled(bool))); connect(this, SIGNAL(tabChanged(bool)), ui.checkWordOnly, SLOT(setEnabled(bool))); connect(this, SIGNAL(tabChanged(bool)), ui.menu_Libraries, SLOT(setEnabled(bool))); connect(ui.action_Lib_Refresh, SIGNAL(triggered()), this, SLOT(refreshLibrariesMenu())); connect(browser, SIGNAL(newProjectRequested()), this, SLOT(newProject())); connect(browser, SIGNAL(newProjectRequested(const QString &, const QString &)), this, SLOT(newProject(const QString &, const QString &))); connect(browser, SIGNAL(openProjectRequested()), this, SLOT(open())); connect(browser, SIGNAL(openProjectRequested(const QString &)), this, SLOT(open(const QString &))); connect(browser, SIGNAL(newPageLoaded(QUrl)), this, SLOT(tabContentHasChanged())); connect(ui.action_Prev, SIGNAL(triggered()), browser, SLOT(back())); connect(ui.action_Next, SIGNAL(triggered()), browser, SLOT(forward())); connect(ideApp->projectHistory(), SIGNAL(historyUpdated(QString)), browser, SLOT(refresh())); connect(ideApp->settings(), SIGNAL(fontChanged(const QFont &)), this, SLOT(setFont(const QFont &))); connect(&pastebin, SIGNAL(finished(QNetworkReply*)), this, SLOT(pastebinUploadDone(QNetworkReply*))); }
void MainWindow::setupConnections() { /* * Actions */ connect(actionAbout, SIGNAL(triggered()), aboutDial, SLOT(exec())); connect(actionAddDb, SIGNAL(triggered()), this, SLOT(createDatabase())); connect(actionClearRecent, SIGNAL(triggered()), this, SLOT(clearRecent())); connect(actionCloseTab, SIGNAL(triggered()), this, SLOT(closeCurrentTab())); connect(actionCopy, SIGNAL(triggered()), this, SLOT(copy())); connect(actionCut, SIGNAL(triggered()), this, SLOT(cut())); connect(actionDbManager, SIGNAL(triggered()), dbDialog, SLOT(exec())); connect(actionLogs, SIGNAL(triggered()), logDial, SLOT(exec())); connect(actionNewQuery, SIGNAL(triggered()), this, SLOT(newQuery())); connect(actionNextTab, SIGNAL(triggered()), this, SLOT(nextTab())); connect(actionOpenQuery, SIGNAL(triggered()), this, SLOT(openQuery())); connect(actionPaste, SIGNAL(triggered()), this, SLOT(paste())); connect(actionPlugins, SIGNAL(triggered()), pluginDialog, SLOT(exec())); connect(actionPreferences, SIGNAL(triggered()), confDial, SLOT(exec())); connect(actionPreviousTab, SIGNAL(triggered()), this, SLOT(previousTab())); connect(actionPrint, SIGNAL(triggered()), this, SLOT(print())); connect(actionRedo, SIGNAL(triggered()), this, SLOT(redo())); connect(actionSaveQuery, SIGNAL(triggered()), this, SLOT(saveQuery())); connect(actionSaveQueryAs, SIGNAL(triggered()), this, SLOT(saveQueryAs())); connect(actionSearch, SIGNAL(triggered()), this, SLOT(search())); connect(actionSelect_all, SIGNAL(triggered()), this, SLOT(selectAll())); connect(actionUndo, SIGNAL(triggered()), this, SLOT(undo())); /* * DbTreeView */ connect(dbTreeView, SIGNAL(tableSelected(QSqlDatabase*,QString)), this, SLOT(openTable(QSqlDatabase*,QString))); /* * DbManager */ connect(DbManager::instance(), SIGNAL(statusChanged(QSqlDatabase*)), this, SLOT(checkDb(QSqlDatabase*))); connect(DbManager::model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(reloadDbList())); /* * Dialogs */ connect(dbWizard, SIGNAL(accepted()), this, SLOT(reloadDbList())); connect(logDial, SIGNAL(event(QString)), QMainWindow::statusBar(), SLOT(showMessage(QString))); connect(QueryScheduler::instance(), SIGNAL(countChanged(int)), this, SLOT(setQueryCount(int))); /* * Tab widget */ connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(refreshTab())); connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); }
void MainWindow::postLaunch() { setupBookmarksAndToolsShortcuts(); // setting popup notification m_popup->setAutoDelete(false); connect(Application::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), m_popup, SLOT(hide())); m_popup->setFrameShape(QFrame::NoFrame); m_popup->setLineWidth(0); connect(m_hidePopup, SIGNAL(timeout()), m_popup, SLOT(hide())); // notification system connect(m_view, SIGNAL(showStatusBarMessage(const QString&, Rekonq::Notify)), this, SLOT(notifyMessage(const QString&, Rekonq::Notify))); connect(m_view, SIGNAL(linkHovered(const QString&)), this, SLOT(notifyMessage(const QString&))); // --------- connect signals and slots connect(m_view, SIGNAL(currentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &))); connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); // (shift +) ctrl + tab switching connect(this, SIGNAL(ctrlTabPressed()), m_view, SLOT(nextTab())); connect(this, SIGNAL(shiftCtrlTabPressed()), m_view, SLOT(previousTab())); // wheel history navigation connect(m_view, SIGNAL(openPreviousInHistory()), this, SLOT(openPrevious())); connect(m_view, SIGNAL(openNextInHistory()), this, SLOT(openNext())); // update toolbar actions signals connect(m_view, SIGNAL(tabsChanged()), this, SLOT(updateActions())); connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(updateActions())); // launch it manually. Just the first time... updateActions(); // Find Bar signal connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(find(const QString &))); // Zoom Bar signal connect(m_view, SIGNAL(currentChanged(int)), m_zoomBar, SLOT(updateSlider(int))); // Ctrl + wheel handling connect(this->currentTab()->view(), SIGNAL(zoomChanged(int)), m_zoomBar, SLOT(setValue(int))); // setting up toolbars to NOT have context menu enabled setContextMenuPolicy(Qt::DefaultContextMenu); // accept d'n'd setAcceptDrops(true); // Bookmark ToolBar (needs to be setup after the call to setupGUI()) initBookmarkBar(); }
DkPreferenceWidget::DkPreferenceWidget(QWidget* parent) : DkWidget(parent) { createLayout(); QAction* nextAction = new QAction(tr("next"), this); nextAction->setShortcut(Qt::Key_Down); connect(nextAction, SIGNAL(triggered()), this, SLOT(nextTab())); addAction(nextAction); QAction* previousAction = new QAction(tr("previous"), this); previousAction->setShortcut(Qt::Key_Up); previousAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(previousAction, SIGNAL(triggered()), this, SLOT(previousTab())); addAction(previousAction); }
FooTabWidget::FooTabWidget (QWidget *parent) : QTabWidget (parent), m_newTabAction(0), m_closeTabAction(0), m_nextTabAction(0), m_previousTabAction(0), m_tabBar(new FooTabBar (this)) { setElideMode(Qt::ElideRight); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); setTabBar(m_tabBar); setDocumentMode(true); // Actions m_newTabAction = new QAction(tr("New &Tab"), this); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new QAction(tr("&Close Tab"), this); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_nextTabAction = new QAction(tr("Show Next Tab"), this); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new QAction(tr("Show Previous Tab"), this); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); m_tabBar->setTabsClosable(false); m_tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); connect(FooPlaylistManager::instance(), SIGNAL(playlistAdded(FooTrackList*)), this, SLOT(playlistAdded(FooTrackList*))); connect(FooPlaylistManager::instance(), SIGNAL(playlistRemoved(FooTrackList*)), this, SLOT(playlistRemoved(FooTrackList*))); connect(FooPlaylistManager::instance(), SIGNAL(currentPlaylistChanged(FooTrackList*)), this, SLOT(currentPlaylistChanged(FooTrackList*))); connect(this, SIGNAL(currentChanged(int)), FooPlaylistManager::instance(), SLOT(currentTabChanged(int))); }
void TabWidget::createTabTree() { m_tabTree = new TabTree(this); m_toolBarTree->addWidget(m_tabTree); m_tabTree->setObjectName("tab_tree"); connect( m_tabTree, SIGNAL(tabMenuRequested(QPoint,QString)), this, SIGNAL(tabMenuRequested(QPoint,QString)) ); connect( m_tabTree, SIGNAL(tabMoved(QString,QString,QString)), this, SIGNAL(tabMoved(QString,QString,QString)) ); connect( m_tabTree, SIGNAL(dropItems(QString,QMimeData)), this, SIGNAL(dropItems(QString,QMimeData)) ); connect( m_tabTree, SIGNAL(currentTabChanged(int)), this, SLOT(setCurrentIndex(int)) ); updateToolBar(); // Override left and right keys of tab tree. addTabAction(m_tabTree, Qt::Key_Left, this, SLOT(previousTab()), Qt::WidgetShortcut); addTabAction(m_tabTree, Qt::Key_Right, this, SLOT(nextTab()), Qt::WidgetShortcut); }
VerticalTabWidget::VerticalTabWidget(QWidget * parent) : QWidget(parent) { QHBoxLayout * mainLayout = new QHBoxLayout(); mainLayout->setSpacing(0); mainLayout->setContentsMargins(5,0,0,0); setLayout(mainLayout); m_tabBar = new QWidget(this); m_tabBar->setMinimumWidth(39); m_tabBar->setMaximumWidth(39); m_tabBar->setContentsMargins(0,0,0,0); layout()->addWidget(m_tabBar); m_pageStack = new QStackedWidget(); m_pageStack->setContentsMargins(0,0,0,0); layout()->addWidget(m_pageStack); currentIndex = -1; QShortcut* nextTabShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab), this); bool isConnected = connect(nextTabShortcut, SIGNAL(activated()), this, SLOT(nextTab())); Q_ASSERT(isConnected); QShortcut* previousTabShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab), this); isConnected = connect(previousTabShortcut, SIGNAL(activated()), this, SLOT(previousTab())); Q_ASSERT(isConnected); }
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(); }
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())); }
/** * Constructs a TabDlg * * \param tabManager The tabManager that will manage this TabDlg * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that * will manage some aspects of the TabDlg behavior. Ownership is not * passed. */ TabDlg::TabDlg(TabManager* tabManager, QSize size, TabDlgDelegate *delegate) : AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0) , delegate_(delegate) , tabWidget_(0) , detachButton_(0) , closeButton_(0) , closeCross_(0) , tabMenu_(new QMenu(this)) , act_close_(0) , act_next_(0) , act_prev_(0) , tabManager_(tabManager) , userManagement_(true) , tabBarSingles_(true) , simplifiedCaption_(false) { if (delegate_) { delegate_->create(this); } if (PsiOptions::instance()->getOption("options.ui.mac.use-brushed-metal-windows").toBool()) { setAttribute(Qt::WA_MacMetalStyle); } // FIXME qRegisterMetaType<TabDlg*>("TabDlg*"); qRegisterMetaType<TabbableWidget*>("TabbableWidget*"); tabWidget_ = new PsiTabWidget(this); tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon()); connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*))); connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*))); connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab())); connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*))); if(delegate_) delegate_->tabWidgetCreated(this, tabWidget_); QVBoxLayout *vert1 = new QVBoxLayout( this, 1); vert1->addWidget(tabWidget_); setAcceptDrops(TRUE); X11WM_CLASS("tabs"); setLooks(); act_close_ = new QAction(this); addAction(act_close_); connect(act_close_,SIGNAL(activated()), SLOT(closeCurrentTab())); act_prev_ = new QAction(this); addAction(act_prev_); connect(act_prev_,SIGNAL(activated()), SLOT(previousTab())); act_next_ = new QAction(this); addAction(act_next_); connect(act_next_,SIGNAL(activated()), SLOT(nextTab())); setShortcuts(); if (size.isValid()) { resize(size); } else { resize(ChatDlg::defaultSize()); //TODO: no! } }
void MainWindow::setup() { if(setupCompleted) return; qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); statusBar()->showMessage(tr("Initializing Qt Assistant...")); setupCompleted = true; helpDock->initialize(); connect(ui.actionGoPrevious, SIGNAL(triggered()), tabs, SLOT(backward())); connect(ui.actionGoNext, SIGNAL(triggered()), tabs, SLOT(forward())); connect(ui.actionEditCopy, SIGNAL(triggered()), tabs, SLOT(copy())); connect(ui.actionFileExit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(ui.actionAddBookmark, SIGNAL(triggered()), helpDock, SLOT(addBookmark())); connect(helpDock, SIGNAL(showLink(QString)), this, SLOT(showLink(QString))); connect(helpDock, SIGNAL(showSearchLink(QString,QStringList)), this, SLOT(showSearchLink(QString,QStringList))); connect(ui.bookmarkMenu, SIGNAL(triggered(QAction*)), this, SLOT(showBookmark(QAction*))); connect(ui.actionZoomIn, SIGNAL(triggered()), tabs, SLOT(zoomIn())); connect(ui.actionZoomOut, SIGNAL(triggered()), tabs, SLOT(zoomOut())); connect(ui.actionOpenPage, SIGNAL(triggered()), tabs, SLOT(newTab())); connect(ui.actionClosePage, SIGNAL(triggered()), tabs, SLOT(closeTab())); connect(ui.actionNextPage, SIGNAL(triggered()), tabs, SLOT(nextTab())); connect(ui.actionPrevPage, SIGNAL(triggered()), tabs, SLOT(previousTab())); #if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) QShortcut *acc = new QShortcut(tr("SHIFT+CTRL+="), this); connect(acc, SIGNAL(activated()), ui.actionZoomIn, SIGNAL(triggered())); #endif connect(new QShortcut(tr("Ctrl+T"), this), SIGNAL(activated()), helpDock, SLOT(toggleContents())); connect(new QShortcut(tr("Ctrl+I"), this), SIGNAL(activated()), helpDock, SLOT(toggleIndex())); connect(new QShortcut(tr("Ctrl+B"), this), SIGNAL(activated()), helpDock, SLOT(toggleBookmarks())); connect(new QShortcut(tr("Ctrl+S"), this), SIGNAL(activated()), helpDock, SLOT(toggleSearch())); connect(new QShortcut(tr("Ctrl+]"), this), SIGNAL(activated()), tabs, SLOT(nextTab())); connect(new QShortcut(tr("Ctrl+["), this), SIGNAL(activated()), tabs, SLOT(previousTab())); Config *config = Config::configuration(); setupBookmarkMenu(); QAction *viewsAction = createPopupMenu()->menuAction(); viewsAction->setText(tr("Views")); ui.viewMenu->addAction(viewsAction); const int tabIndex = config->sideBarPage(); helpDock->tabWidget()->setCurrentIndex(tabIndex); // The tab index is 0 by default, so we need to force an upate // to poulate the contents in this case. if (tabIndex == 0) helpDock->currentTabChanged(tabIndex); ui.actionEditFind->setShortcut(QKeySequence::Find); ui.actionEditFindNext->setShortcut(QKeySequence::FindNext); ui.actionEditFindPrev->setShortcut(QKeySequence::FindPrevious); QObject::connect(ui.actionEditFind, SIGNAL(triggered()), tabs, SLOT(find())); QObject::connect(ui.actionEditFindNext, SIGNAL(triggered()), tabs, SLOT(findNext())); QObject::connect(ui.actionEditFindPrev, SIGNAL(triggered()), tabs, SLOT(findPrevious())); connect(ui.actionEditFont_Settings, SIGNAL(triggered()), this, SLOT(showFontSettingsDialog())); qApp->restoreOverrideCursor(); ui.actionGoPrevious->setEnabled(false); ui.actionGoNext->setEnabled(false); ui.actionEditCopy->setEnabled(false); connect(tabs->currentBrowser(), SIGNAL(copyAvailable(bool)), this, SLOT(copyAvailable(bool))); // set the current selected item in the treeview helpDialog()->locateContents(tabs->currentBrowser()->source().toString()); connect(tabs, SIGNAL(browserUrlChanged(QString)), helpDock, SLOT(locateContents(QString))); }
void MainWindow::createActions() { openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing file")); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); saveAct->setShortcuts(QKeySequence::Save); saveAct->setStatusTip(tr("Save the document to disk")); saveAct->setEnabled(false); connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); closeAct = new QAction(QIcon(":/images/close.png"), tr("Cl&ose"), this); closeAct->setShortcut(QKeySequence::Close); closeAct->setStatusTip(tr("Close the active tab")); connect(closeAct, SIGNAL(triggered()), this, SLOT(closeActiveTab())); closeAllAct = new QAction(tr("Close &All"), this); closeAllAct->setShortcut(tr("Ctrl+Shift+W")); closeAllAct->setStatusTip(tr("Close all the tabs")); connect(closeAllAct, SIGNAL(triggered()), this, SLOT(closeAllTabs())); separatorAct = new QAction(this); separatorAct->setSeparator(true); exitAct = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this); exitAct->setShortcut(tr("Ctrl+Q")); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); boldAct = new QAction(QIcon(":/images/textbold.png"), tr("&Bold"), this); boldAct->setShortcut(QKeySequence::Bold); boldAct->setCheckable(true); connect(boldAct, SIGNAL(triggered(bool)), this, SLOT(bold(bool))); italicAct = new QAction(QIcon(":/images/textitalic.png"), tr("&Italic"), this); italicAct->setShortcut(QKeySequence::Italic); italicAct->setCheckable(true); connect(italicAct, SIGNAL(triggered(bool)), this, SLOT(italic(bool))); underlineAct = new QAction(QIcon(":/images/textunder.png"), tr("&Underine"), this); underlineAct->setShortcut(QKeySequence::Underline); underlineAct->setCheckable(true); connect(underlineAct, SIGNAL(triggered(bool)), this, SLOT(underline(bool))); zoomInAct = new QAction(QIcon(":/images/zoomin.png"), tr("Zoom &in"), this); zoomInAct->setShortcut(QKeySequence::ZoomIn); connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn())); zoomOutAct = new QAction(QIcon(":/images/zoomout.png"), tr("Zoom &out"), this); zoomOutAct->setShortcut(QKeySequence::ZoomOut); connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut())); nextAct = new QAction(QIcon(":/images/next.png"), tr("Ne&xt"), this); nextAct->setShortcuts(QKeySequence::NextChild); nextAct->setStatusTip(tr("Move the focus to the next window")); connect(nextAct, SIGNAL(triggered()), this, SLOT(nextTab())); previousAct = new QAction(QIcon(":/images/previous.png"), tr("Pre&vious"), this); previousAct->setShortcuts(QKeySequence::PreviousChild); previousAct->setStatusTip(tr("Move the focus to the previous window")); connect(previousAct, SIGNAL(triggered()), this, SLOT(previousTab())); splitAct = new QAction(tr("&Split symbol"), this); splitAct->setShortcut(tr("Ctrl+2")); connect(splitAct, SIGNAL(triggered()), this, SLOT(splitSymbol())); joinAct = new QAction(tr("&Join with Next Symbol"), this); joinAct->setShortcut(tr("Ctrl+1")); connect(joinAct, SIGNAL(triggered()), this, SLOT(joinSymbol())); deleteAct = new QAction(tr("&Delete symbol"), this); deleteAct->setShortcut(QKeySequence::Delete); connect(deleteAct, SIGNAL(triggered()), this, SLOT(deleteSymbol())); aboutAct = new QAction(QIcon(":/images/about.png"), tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); }
/** * Constructs a TabDlg * * \param tabManager The tabManager that will manage this TabDlg * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that * will manage some aspects of the TabDlg behavior. Ownership is not * passed. */ TabDlg::TabDlg(TabManager* tabManager, QSize size, TabDlgDelegate *delegate) : AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0) , delegate_(delegate) , tabWidget_(0) , detachButton_(0) , closeButton_(0) , closeCross_(0) , tabMenu_(new QMenu(this)) , act_close_(0) , act_next_(0) , act_prev_(0) , tabManager_(tabManager) , userManagement_(true) , tabBarSingles_(true) , simplifiedCaption_(false) { if (delegate_) { delegate_->create(this); } // FIXME qRegisterMetaType<TabDlg*>("TabDlg*"); qRegisterMetaType<TabbableWidget*>("TabbableWidget*"); tabWidget_ = new PsiTabWidget(this); tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon()); connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(mouseMiddleClickTab(QWidget*)), SLOT(mouseMiddleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*))); connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*))); connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab())); connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*))); if(delegate_) delegate_->tabWidgetCreated(this, tabWidget_); QVBoxLayout *vert1 = new QVBoxLayout(this); vert1->setMargin(1); vert1->addWidget(tabWidget_); setAcceptDrops(true); X11WM_CLASS("tabs"); setLooks(); act_close_ = new QAction(this); addAction(act_close_); connect(act_close_,SIGNAL(triggered()), SLOT(closeCurrentTab())); act_prev_ = new QAction(this); addAction(act_prev_); connect(act_prev_,SIGNAL(triggered()), SLOT(previousTab())); act_next_ = new QAction(this); addAction(act_next_); connect(act_next_,SIGNAL(triggered()), SLOT(nextTab())); setShortcuts(); QSignalMapper* activateTabMapper_ = new QSignalMapper(this); connect(activateTabMapper_, SIGNAL(mapped(int)), tabWidget_, SLOT(setCurrentPage(int))); for (int i = 0; i < 10; ++i) { QAction* action = new QAction(this); connect(action, SIGNAL(triggered()), activateTabMapper_, SLOT(map())); action->setShortcuts(QList<QKeySequence>() << QKeySequence(QString("Ctrl+%1").arg(i)) << QKeySequence(QString("Alt+%1").arg(i))); activateTabMapper_->setMapping(action, (i > 0 ? i : 10) - 1); addAction(action); } if (size.isValid()) { resize(size); } else { resize(ChatDlg::defaultSize()); //TODO: no! } }
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(); }
TabActions::TabActions(QObject *parent, FileManagerWindow *mainWindow) : ActionsBase(parent, mainWindow) { actNewTab = action(i18n("New Tab"), "tab-new", QKeySequence::keyBindings(QKeySequence::AddTab), this, SLOT(newTab()), "new tab"); actDupTab = action(i18n("Duplicate Current Tab"), "tab-duplicate", Qt::ALT + Qt::CTRL + Qt::SHIFT + Qt::Key_N, SLOT(duplicateTab()), "duplicate tab"); actMoveTabToOtherSide = action(i18n("Move Current Tab to Other Side"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_O, SLOT(moveTabToOtherSide()), "move_tab_to_other_side"); actCloseTab = action(i18n("Close Current Tab"), "tab-close", KStandardShortcut::close(), this, SLOT(closeTab()), "close tab"); actNextTab = action(i18n("Next Tab"), QString(), KStandardShortcut::tabNext(), this, SLOT(nextTab()), "next tab"); actPreviousTab = action(i18n("Previous Tab"), QString(), KStandardShortcut::tabPrev(), this, SLOT(previousTab()), "previous tab"); actCloseInactiveTabs = action(i18n("Close Inactive Tabs"), 0, 0, SLOT(closeInactiveTabs()), "close inactive tabs"); actCloseDuplicatedTabs = action(i18n("Close Duplicated Tabs"), 0, 0, SLOT(closeDuplicatedTabs()), "close duplicated tabs"); actLockTab = action(i18n("Lock Tab"), 0, 0, SLOT(lockTab()), "lock tab"); }