Commit e0cf386e authored by jhammen's avatar jhammen
Browse files

editor tab context menu item "close others"

parent 679d7061
...@@ -253,6 +253,16 @@ void MainWindow::tabChanged(int i) ...@@ -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 // ------------ auto slots
void MainWindow::on_actionAbout_triggered() void MainWindow::on_actionAbout_triggered()
...@@ -553,6 +563,16 @@ void MainWindow::on_actionUndo_triggered() ...@@ -553,6 +563,16 @@ void MainWindow::on_actionUndo_triggered()
currentEditor()->undo(); 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 // ------------ private methods
void MainWindow::enableFileActions(EditorWidget *editor) void MainWindow::enableFileActions(EditorWidget *editor)
......
...@@ -51,6 +51,7 @@ private slots: ...@@ -51,6 +51,7 @@ private slots:
void markDirty(bool unsaved); void markDirty(bool unsaved);
void showTime(Position pos); void showTime(Position pos);
void tabChanged(int index); void tabChanged(int index);
void closeOtherEditors();
void on_actionAbout_triggered(); void on_actionAbout_triggered();
void on_actionAPIDocumentation_triggered(); void on_actionAPIDocumentation_triggered();
void on_actionCloseFile_triggered(); void on_actionCloseFile_triggered();
...@@ -77,6 +78,7 @@ private slots: ...@@ -77,6 +78,7 @@ private slots:
void on_actionTransportLock_toggled(bool); void on_actionTransportLock_toggled(bool);
void on_actionUndo_triggered(); void on_actionUndo_triggered();
void on_actionWebsite_triggered(); void on_actionWebsite_triggered();
void on_tabWidget_customContextMenuRequested(const QPoint &pos);
private: private:
QString *selectedFolder; QString *selectedFolder;
AudioEngine &audioEngine; AudioEngine &audioEngine;
......
...@@ -43,6 +43,9 @@ ...@@ -43,6 +43,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="tabsClosable"> <property name="tabsClosable">
<bool>true</bool> <bool>true</bool>
</property> </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