Commit 6b5c5707 authored by jhammen's avatar jhammen

add context menu to output tabs, "close others" function

parent 5721c52f
......@@ -329,6 +329,17 @@ void MainWindow::closeOtherEditors() {
}
}
void MainWindow::closeOtherOutputs() {
if (QAction *action = qobject_cast<QAction *>(sender())) {
int index = action->data().toInt();
for (int i = ui->outputTabWidget->count() - 1; i >= 0; i--) {
if (i != index) {
closeOutputTab(i);
}
}
}
}
// ------------ auto slots
void MainWindow::on_actionAbout_triggered() {
......@@ -784,3 +795,11 @@ void MainWindow::on_actionWebsite_triggered() {
QString link = "http://www.bipscript.org";
QDesktopServices::openUrl(QUrl(link));
}
void MainWindow::on_outputTabWidget_customContextMenuRequested(const QPoint &pos) {
QMenu menu;
QAction *action = menu.addAction(tr("Close Other Tabs"), this, SLOT(closeOtherOutputs()));
action->setData(ui->outputTabWidget->tabBar()->tabAt(pos));
action->setEnabled(ui->outputTabWidget->count() > 1);
menu.exec(QCursor::pos());
}
......@@ -43,7 +43,9 @@ class MainWindow : public QMainWindow {
private slots:
void changeProject();
void closeOutputTab(int index);
void closeOtherOutputs();
void closeEditorTab(int index);
void closeOtherEditors();
void codeError(const QString &, int);
void engineDisconnect();
void folderTreeClicked(QTreeWidgetItem *item, int col);
......@@ -57,7 +59,6 @@ class MainWindow : public QMainWindow {
void clearSearch();
void showTime(Position pos);
void tabChanged(int index);
void closeOtherEditors();
void on_actionAbout_triggered();
void on_actionAPIDocumentation_triggered();
void on_actionCloseFile_triggered();
......@@ -87,6 +88,7 @@ class MainWindow : public QMainWindow {
void on_actionUndo_triggered();
void on_actionWebsite_triggered();
void on_tabWidget_customContextMenuRequested(const QPoint &pos);
void on_outputTabWidget_customContextMenuRequested(const QPoint &pos);
private:
ProjectList &projectList;
......
......@@ -31,9 +31,6 @@
<property name="columnCount">
<number>1</number>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="title">
<string>Filesystem</string>
</attribute>
......@@ -182,6 +179,9 @@
</property>
<item>
<widget class="QTabWidget" name="outputTabWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
......@@ -532,7 +532,8 @@
</action>
<action name="actionFind_in_Project">
<property name="icon">
<iconset theme="edit-find"/>
<iconset theme="edit-find">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>Find in Project</string>
......
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