void TabBar::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("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.exec(QCursor::pos()); }
void FooTabWidget::closeOtherTabs(int index) { if (-1 == index) { return; } for (int i = count() - 1; i > index; --i) { closeTab(i); } for (int i = index - 1; i >= 0; --i) { closeTab(i); } }
void WorkAreaTabWidget::ui_closeOtherTabsRequested(int index) { tabBar()->moveTab(index, 0); while (count() > 1) { closeTab(1); // close second tab } }
void TabBar::closeTab() { if (QAction *action = qobject_cast<QAction*>(sender())) { int index = action->data().toInt(); emit closeTab(index); } }
void TabBar::slotCloseTab() { int index = indexClickedTab_; if (index == -1) index = currentIndex(); emit closeTab(index); }
/** * @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); }
void Manitou::createActions() { QAction *action = new QAction(tr("New Window"), this); action->setShortcut(QKeySequence::New); actionsMap.insert(Manitou::ActionNewWindow, action); connect(action, SIGNAL(triggered()), SLOT(onOpenWindow())); action = new QAction(tr("New Tab"), this); action->setShortcut(QKeySequence::AddTab/*(Qt::CTRL + Qt::Key_T)*/); actionsMap.insert(Manitou::ActionNewTab, action); connect(action, SIGNAL(triggered()), SLOT(onOpenTab())); action = new QAction(tr("Close Window"), this); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); actionsMap.insert(Manitou::ActionCloseWindow, action); connect(action, SIGNAL(triggered()), SLOT(closeWindow())); action = new QAction(tr("Close Tab"), this); actionsMap.insert(Manitou::ActionCloseTab, action); connect(action, SIGNAL(triggered()), SLOT(closeTab())); #ifdef Q_WS_MAC // initialize dock menu (specific for Mac OS X) dockMenu = new QMenu(); dockMenu->addAction(getAction(Manitou::ActionNewWindow)); qt_mac_set_dock_menu(dockMenu); #endif }
void WebBrowser::initGui() { // setup the tool bar _back = new QPushButton( "|<< Back" ); _stop = new QPushButton( "stop" ); _reload = new QPushButton( "reload" ); _forward = new QPushButton( "Forward >>|" ); _newTab = new QPushButton( "nTab" ); _closeTab = new QPushButton( "cTab" ); _address = new QLineEdit(); _go = new QPushButton( "Go" ); QToolBar* toolBar = new QToolBar(); toolBar->addWidget( _back ); toolBar->addWidget( _stop ); toolBar->addWidget( _reload ); toolBar->addWidget( _forward ); toolBar->addSeparator(); toolBar->addWidget( _newTab ); toolBar->addWidget( _closeTab ); toolBar->addWidget( _address ); toolBar->addWidget( _go ); connect( _newTab, SIGNAL(released()), this, SLOT(newTab()) ); connect( _closeTab, SIGNAL(released()), this, SLOT(closeTab()) ); connect( _go, SIGNAL(released()), this, SLOT(goToAddress()) ); this->addToolBar( toolBar ); // setup the tab area _tabWidget = new QTabWidget(); connect( _tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabActivated(int)) ); setCentralWidget( _tabWidget ); }
QMenuBar * Menu::createMenuBar(MainEngine *w) { QMenuBar *menuBar = new QMenuBar(); QMenu *fileMenu = menuBar->addMenu(tr("&File")); fileMenu->addAction(tr("Load team"), this, SLOT(loadTeam()), tr("Ctrl+L", "Load team")); fileMenu->addAction(tr("Close tab"), w, SLOT(closeTab()), tr("Ctrl+W", "Close tab")); fileMenu->addAction(tr("Open &replay"),w,SLOT(loadReplayDialog()), Qt::CTRL+Qt::Key_R); fileMenu->addAction(tr("&Quit"),qApp,SLOT(quit()),Qt::CTRL+Qt::Key_Q); w->addThemeMenu(menuBar); w->addStyleMenu(menuBar); QMenu *langMenu = menuBar->addMenu(tr("&Language")); QFile in ("languages.txt"); in.open(QIODevice::ReadOnly); QSettings s; QStringList langs = QString::fromUtf8(in.readAll()).trimmed().split('\n'); QActionGroup *ag = new QActionGroup(langMenu); foreach(QString a, langs) { QAction *act = langMenu->addAction(a,w, SLOT(changeLanguage())); act->setCheckable(true); act->setChecked(s.value("language").toString() == a.section("(", 1).section(")", 0, 0)); ag->addAction(act); }
/* Handles closing all of the open editor windows when the window is closed */ void MainWindow::closeEvent(QCloseEvent *e) { int widgetCount = ui_tabWidget->count(); while(ui_tabWidget->count() > 0) { ui_tabWidget->setCurrentIndex(0); closeTab(); if(ui_tabWidget->count() == widgetCount) { qWarning() << "Ignoring close event."; e->ignore(); return; } --widgetCount; } //Close all other windows hide(); QListIterator<QWidget *> i(qApp->topLevelWidgets()); while(i.hasNext()) { QWidget *w = i.next(); if(w->isVisible()) w->close(); } QMainWindow::closeEvent(e); }
ShapePalette::ShapePalette( QWidget* parent) : ScDockPalette( parent, "Shap", 0) { setMinimumSize( QSize( 220, 240 ) ); setObjectName(QString::fromLocal8Bit("Shap")); setSizePolicy( QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); containerWidget = new QWidget(this); vLayout = new QVBoxLayout( containerWidget ); vLayout->setSpacing( 0 ); vLayout->setMargin( 0 ); buttonLayout = new QHBoxLayout; buttonLayout->setSpacing( 5 ); buttonLayout->setMargin( 0 ); importButton = new QToolButton(this); importButton->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); importButton->setIcon(IconManager::instance()->loadIcon("16/document-open.png")); importButton->setIconSize(QSize(16, 16)); buttonLayout->addWidget( importButton ); QSpacerItem* spacer = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum ); buttonLayout->addItem( spacer ); closeButton = new QToolButton(this); closeButton->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); closeButton->setIcon(IconManager::instance()->loadIcon("16/close.png")); closeButton->setIconSize(QSize(16, 16)); buttonLayout->addWidget( closeButton ); vLayout->addLayout( buttonLayout ); Frame3 = new QToolBox( this ); vLayout->addWidget(Frame3); setWidget(containerWidget); unsetDoc(); m_scMW = NULL; languageChange(); connect(importButton, SIGNAL(clicked()), this, SLOT(Import())); connect(closeButton, SIGNAL(clicked()), this, SLOT(closeTab())); }
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 EditorTab::closeThis(void) { if (currentIndex() < 0) { return; } closeTab(currentIndex()); }
void FractalImagesFrame::OnCloseFractal(wxCommandEvent& WXUNUSED(event)) { int pos = m_tabs->GetSelection(); closeTab(pos); updateMenu(); }
void MainWindow::loadErrorHandler(const QString& fullpath) { QMessageBox::information(this, tr("Error!"), tr("Cannot load %1.").arg(fullpath)); TabPage* page = qobject_cast<TabPage*>(sender()); auto idx = ui.tabWidget->indexOf(page); closeTab(idx); }
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 PlaylistWindow::on_tabWidget_customContextMenuRequested(const QPoint &pos) { QMenu *m = new QMenu(this); m->addAction(tr("&New Playlist"), this, SLOT(newTab())); m->addAction(tr("&Remove Playlist"), this, SLOT(closeTab())); m->addAction(tr("&Duplicate Playlist"), this, SLOT(duplicateTab())); m->addAction(tr("&Import Playlist"), this, SLOT(importTab())); m->addAction(tr("&Export Playlist"), this, SLOT(exportTab())); m->exec(ui->tabWidget->mapToGlobal(pos)); }
void TabBar::slotCloseAllTab() { closingTabState_ = CloseTabOtherIndex; for (int i = count()-1; i > 0; i--) { if (i == 1) closingTabState_ = CloseTabCurrentIndex; emit closeTab(i); } closingTabState_ = CloseTabIdle; }
void BrowserWindow::setupMenu() { #ifdef Q_OS_MAC static MainMenu* macMainMenu = 0; if (!macMainMenu) { macMainMenu = new MainMenu(this, 0); macMainMenu->initMenuBar(new QMenuBar(0)); } else { macMainMenu->setWindow(this); } m_mainMenu = macMainMenu; m_mainMenu->initSuperMenu(m_superMenu); #else setMenuBar(new MenuBar(this)); m_mainMenu = new MainMenu(this, this); m_mainMenu->initMenuBar(menuBar()); m_mainMenu->initSuperMenu(m_superMenu); #endif // Setup other shortcuts QShortcut* reloadBypassCacheAction = new QShortcut(QKeySequence(QSL("Ctrl+F5")), this); QShortcut* reloadBypassCacheAction2 = new QShortcut(QKeySequence(QSL("Ctrl+Shift+R")), this); connect(reloadBypassCacheAction, SIGNAL(activated()), this, SLOT(reloadBypassCache())); connect(reloadBypassCacheAction2, SIGNAL(activated()), this, SLOT(reloadBypassCache())); QShortcut* closeTabAction = new QShortcut(QKeySequence(QSL("Ctrl+W")), this); QShortcut* closeTabAction2 = new QShortcut(QKeySequence(QSL("Ctrl+F4")), this); connect(closeTabAction, SIGNAL(activated()), this, SLOT(closeTab())); connect(closeTabAction2, SIGNAL(activated()), this, SLOT(closeTab())); QShortcut* reloadAction = new QShortcut(QKeySequence("Ctrl+R"), this); connect(reloadAction, SIGNAL(activated()), this, SLOT(reload())); QShortcut* openLocationAction = new QShortcut(QKeySequence("Alt+D"), this); connect(openLocationAction, SIGNAL(activated()), this, SLOT(openLocation())); QShortcut* inspectorAction = new QShortcut(QKeySequence(QSL("F12")), this); connect(inspectorAction, SIGNAL(activated()), this, SLOT(toggleWebInspector())); }
void MainTab::mousePressEvent(QMouseEvent* event) { if(event->buttons() == Qt::MidButton) { QTabBar* bar = tabBar(); m_index = bar->tabAt(bar->mapFrom(this, event->pos())); closeTab(); } QTabWidget::mousePressEvent(event); }
void MainWindow::closeTabTriggered() { int index = currentTabIndex(); if (index == -1) { close(); } else { closeTab(index); } }
void FractalImagesFrame::close() { while(m_tabs->GetPageCount() != 0) { m_tabs->ChangeSelection(0); closeTab(0); } Destroy(); }
DTabWidget *DMainWindow::createTab() { DTabWidget *tab = new DTabWidget(m_central); m_tabs.append(tab); if (tab->closeButton()) connect(tab->closeButton(), SIGNAL(clicked()), this, SLOT(closeTab())); connect(tab, SIGNAL(closeRequest(QWidget*)), this, SLOT(closeTab(QWidget*))); connect(tab, SIGNAL(contextMenu(QWidget*,const QPoint &)), this, SLOT(tabContext(QWidget*,const QPoint &))); return tab; }
void PhpWebView::contextMenuEvent(QContextMenuEvent * ev) { QMenu *menu = this->page()->createStandardContextMenu(); rightClick = ev->pos(); menu->addSeparator(); menu->addAction("Get XPath", this, SLOT(showXPath())); if (browser) menu->addAction("Close tab", this, SLOT(closeTab())); menu->exec(ev->globalPos()); delete menu; }
void MultizoneIndividualTabForm::on_cancelButton_clicked() { if (_needToSave) { ShowMessageHelper _warningMsg; bool _saveResults = _warningMsg.showWarningMessage("Unsaved Changes!","You need to save your modifications. Do you want to save?"); if (_saveResults) _parentWindow->saveMultizoneData(_configFile, _meshFile, _configVal,_virtualMRFList); } closeTab(); }
/** * @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; } QTabWidget::keyPressEvent(keyEvent); }
void TabWidget::closeEvent(QCloseEvent *e) { // do not block window closing when session is about to close if (m_application->isSavingSession()) { QTabWidget::closeEvent(e); return; } //w zaleznosci od opcji w konfiguracji zamykamy wszystkie karty, lub tylko aktywna if (config_oldStyleClosing) closeTab(static_cast<ChatWidget *>(currentWidget())); else for (int i = count() - 1; i >= 0; i--) closeTab(static_cast<ChatWidget *>(widget(i))); if (count() > 0) e->ignore(); else e->accept(); }
void FAR PASCAL _EXPORT freeTabs(HWND hwnd, LPTabData lpTabData) { if (lpTabData) { if (lpTabData->lpTabList) { closeTab(hwnd, lpTabData); gfree(lpTabData->lpTabList); lpTabData->lpTabList = NULL; } gfree(lpTabData); lpTabData = NULL; } }
void SeparateTerminal::exitHandler(Console *console) { const int tabCount = mTabWidget->count(); for (int i=0; i<tabCount; ++i) { Console *consoleTab = qobject_cast<Console*>(mTabWidget->widget(i)); if (console==consoleTab) { closeTab(i); return; } } }
void MainTabsWidget::closeCurrentTabWithValue() { int currIndex = currentIndex(); if (currIndex == -1) return; QWidget * w = widget(currIndex); if (w->objectName() == "valueTabReady") { closeTab(currIndex); } }