void EditAreaTabWidget::initSignalsAndSlots() { //--------- TabBar Signals and Slots ----------------------------- connect(tabBar, SIGNAL(closeTab(int)), this, SLOT(closeOneTab(int))); connect(tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); connect(tabBar, SIGNAL(closeAllTabs()), this, SLOT(closeAllTabs())); connect(tabBar, SIGNAL(cloneToOtherView(int)), this, SIGNAL(cloneToOtherView(int))); connect(tabBar, SIGNAL(moveToOtherView(int)), this, SIGNAL(moveToOtherView(int))); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeOneTab(int))); }
MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) { ui.setupUi(this); setTabActionsEnabled(false); connect(ui.actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQT())); connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui.action_Open, SIGNAL(triggered()), this, SLOT(chooseFiles())); connect(ui.action_Resize, SIGNAL(triggered()), this, SLOT(resizeDialog())); connect(ui.actionZoom_In, SIGNAL(triggered()), this, SLOT(zoomIn())); connect(ui.actionZoom_Out, SIGNAL(triggered()), this, SLOT(zoomOut())); connect(ui.action_Close, SIGNAL(triggered()), this, SLOT(closeCurrentTab())); connect(ui.actionClose_All, SIGNAL(triggered()), this, SLOT(closeAllTabs())); connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(displayCurrentTab())); }
/** * A context menu event for the tab widget itself * @param event :: The context menu event */ void MultiTabScriptInterpreter::contextMenuEvent(QContextMenuEvent *event) { QMenu context(this); m_cursor_pos = event->pos(); //in widget coordinates if( count() > 0 ) { if( tabBar()->tabAt(m_cursor_pos) >= 0 ) { QAction *close = new QAction(tr("&Close Tab"), this); connect(close, SIGNAL(triggered()), this, SLOT(closeClickedTab())); context.addAction(close); } // Close all tabs QAction *closeall = new QAction(tr("&Close All Tabs"), this); connect(closeall, SIGNAL(triggered()), this, SLOT(closeAllTabs())); context.addAction(closeall); context.insertSeparator(); } QAction *newtab = new QAction(tr("&New Tab"), this); connect(newtab, SIGNAL(triggered()), this, SLOT(newTab())); context.addAction(newtab); context.exec(QCursor::pos()); }
void MainWindow::closeEvent(QCloseEvent* event) { if (closeAllTabs()) { writeSettings(); event->accept(); } else { event->ignore(); } }
void GLShaderDev::initializeActions() { QSettings settings; QMenu* recent; QMenu* fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(QIcon(":/document-new.png"), tr("&New..."), _newFileDialog, SLOT(exec()), QKeySequence::New); connect(_newFileDialog, SIGNAL(accepted()), this, SLOT(newFile())); fileMenu->addAction(QIcon(":/document-open.png"), tr("&Open..."), this, SLOT(openFileDialog()), QKeySequence::Open); recent = fileMenu->addMenu(QIcon(":/document-open-recent.png"), tr("Open &Recent")); for (int i = 0; i < MaxRecentFiles; ++i) (_recentFileActions[i] = recent->addAction(tr("<Empty>"), this, SLOT(openRecentFile())))->setVisible(true); (_recentFileActions[MaxRecentFiles] = recent->addSeparator())->setVisible(true); (_recentFileActions[MaxRecentFiles + 1] = recent->addAction(tr("&Clear List"), this, SLOT(clearFileRecent())))->setEnabled(false); updateRecentFiles(); fileMenu->addSeparator(); fileMenu->addAction(QIcon(":/document-save-all.png"), tr("Save Al&l"), _editor, SLOT(saveAll())); fileMenu->addAction(QIcon(":/document-save.png"), tr("&Save"), _editor, SLOT(save()), QKeySequence::Save); fileMenu->addAction(QIcon(":/document-save-as.png"), tr("Save &As..."), this, SLOT(saveFileAs()), QKeySequence::SaveAs); fileMenu->addSeparator(); fileMenu->addAction(QIcon(":/dialog-close.png"), tr("&Close"), _editor, SLOT(closeCurrentTab()), tr("Ctrl+W")); fileMenu->addAction(QIcon(":/dialog-close.png"), tr("Cl&ose All"), _editor, SLOT(closeAllTabs()), tr("Ctrl+Shift+W")); fileMenu->addSeparator(); fileMenu->addAction(QIcon(":/application-exit.png"), tr("&Quit"), this, SLOT(close()), QKeySequence::Quit); QMenu* projectMenu = menuBar()->addMenu(tr("&Project")); projectMenu->addAction(QIcon(":/project-development-new-template.png"), tr("&New Project"), this, SLOT(newProject())); projectMenu->addAction(QIcon(":/project-open.png"), tr("&Open Project..."), this, SLOT(openProjectDialog())); recent = projectMenu->addMenu(QIcon(":/document-open-recent.png"), tr("Open &Recent")); for (int i = 0; i < MaxRecentProjects; ++i) (_recentProjectActions[i] = recent->addAction(tr("<Empty>"), this, SLOT(openRecentProject())))->setVisible(true); (_recentProjectActions[MaxRecentProjects] = recent->addSeparator())->setVisible(true); (_recentProjectActions[MaxRecentProjects + 1] = recent->addAction(tr("&Clear List"), this, SLOT(clearProjectRecent())))->setEnabled(false); updateRecentProjects(); projectMenu->addSeparator(); projectMenu->addAction(QIcon(":/configure.png"), tr("Open &Configuration..."), this, SLOT(openProjectConfiguration())); projectMenu->addAction(QIcon(":/run-build.png"), tr("&Build Current"), this, SLOT(buildCurrentProject()), tr("F8")); projectMenu->addSeparator(); projectMenu->addAction(QIcon(":/project-development-close.png"), tr("&Close Project"), this, SLOT(closeProject())); menuBar()->addMenu("|")->setEnabled(false); QMenu* toolsMenu = menuBar()->addMenu(tr("&Tools")); toolsMenu->addAction(QIcon(":/preferences-other.png"), tr("&OpenGL Info..."), this, SLOT(showGLInfo())); QMenu* settingsMenu = menuBar()->addMenu(tr("&Settings")); settingsMenu->addAction(QIcon(":/preferences-other.png"), tr("&Preferences..."), this, SLOT(showPreferences())); QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(QIcon(":/glsd-icon.png"), tr("&About GLShaderDev"), this, SLOT(about())); helpMenu->addAction(QIcon(":/qt-icon.png"), tr("About &Qt"), qApp, SLOT(aboutQt())); }
pTabbedWorkspace::~pTabbedWorkspace() { // close all document closeAllTabs( true ); // delete all unclose document, if user click cancel qDeleteAll( mDocuments ); // delete containers delete mStackedWidget; delete mWorkspaceWidget; }
SourceViewerManager::SourceViewerManager(QWidget* parent) : QTabWidget(parent) { setMovable(true); setTabsClosable(true); //Close All Tabs mCloseAllTabs = new QPushButton(this); mCloseAllTabs->setIcon(QIcon(":/icons/images/close-all-tabs.png")); mCloseAllTabs->setToolTip("Close All Tabs"); connect(mCloseAllTabs, SIGNAL(clicked()), this, SLOT(closeAllTabs())); setCornerWidget(mCloseAllTabs, Qt::TopLeftCorner); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(Bridge::getBridge(), SIGNAL(loadSourceFile(QString, int, int)), this, SLOT(loadSourceFile(QString, int, int))); }
ReferenceManager::ReferenceManager(QWidget* parent) : QTabWidget(parent) { setMovable(true); setTabsClosable(true); mCurrentReferenceView = 0; //Close All Tabs mCloseAllTabs = new QPushButton(this); mCloseAllTabs->setIcon(DIcon("close-all-tabs.png")); mCloseAllTabs->setToolTip(tr("Close All Tabs")); connect(mCloseAllTabs, SIGNAL(clicked()), this, SLOT(closeAllTabs())); setCornerWidget(mCloseAllTabs, Qt::TopLeftCorner); setContextMenuPolicy(Qt::CustomContextMenu); connect(Bridge::getBridge(), SIGNAL(referenceInitialize(QString)), this, SLOT(newReferenceView(QString))); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); }
void MainTab::contextMenuEvent(QContextMenuEvent* event) { QTabBar* bar = tabBar(); m_index = bar->tabAt(bar->mapFrom(this, event->pos())); if(m_index < 0) return; QAction* action; QMenu menu(this); if(m_index > 3) { action = menu.addAction(tr("Close tab")); connect(action, SIGNAL(triggered()), this, SLOT(closeTab())); } action = menu.addAction(tr("Close all tabs")); connect(action, SIGNAL(triggered()), this, SLOT(closeAllTabs())); menu.exec(mapToGlobal(event->pos())); }
void EditAreaTabBar::closeAllActionSlot() { emit closeAllTabs(); }
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())); }