Commit e0cf386e authored by jhammen's avatar jhammen

editor tab context menu item "close others"

parent 679d7061
......@@ -253,6 +253,16 @@ void MainWindow::tabChanged(int i)
}
}
void MainWindow::closeOtherEditors()
{
if (QAction *action = qobject_cast<QAction*>(sender())) {
int index = action->data().toInt();
for(int i = ui->tabWidget->count() - 1; i >= 0; i--) {
if(i != index) { closeEditorTab(i); }
}
}
}
// ------------ auto slots
void MainWindow::on_actionAbout_triggered()
......@@ -553,6 +563,16 @@ void MainWindow::on_actionUndo_triggered()
currentEditor()->undo();
}
void MainWindow::on_tabWidget_customContextMenuRequested(const QPoint &pos)
{
QMenu menu;
QAction *action = menu.addAction(tr("Close Other Tabs"), this, SLOT(closeOtherEditors()));
action->setData(ui->tabWidget->tabBar()->tabAt(pos));
action->setEnabled(ui->tabWidget->count() > 1);
menu.exec(QCursor::pos());
}
// ------------ private methods
void MainWindow::enableFileActions(EditorWidget *editor)
......
......@@ -51,6 +51,7 @@ private slots:
void markDirty(bool unsaved);
void showTime(Position pos);
void tabChanged(int index);
void closeOtherEditors();
void on_actionAbout_triggered();
void on_actionAPIDocumentation_triggered();
void on_actionCloseFile_triggered();
......@@ -77,6 +78,7 @@ private slots:
void on_actionTransportLock_toggled(bool);
void on_actionUndo_triggered();
void on_actionWebsite_triggered();
void on_tabWidget_customContextMenuRequested(const QPoint &pos);
private:
QString *selectedFolder;
AudioEngine &audioEngine;
......
......@@ -43,6 +43,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment