- enhancement: close editor when middle button clicked on it's title tab

This commit is contained in:
Roy Qu 2022-03-15 12:29:56 +08:00
parent 0d4b7d0d4d
commit b56f549cf4
4 changed files with 23 additions and 0 deletions

View File

@ -19,6 +19,7 @@ Red Panda C++ Version 1.0.0
- fix: when no selection, copy/cut should auto select whole line with the line break
- fix: redo cut with no selection while make whole line selected
- fix: correctly reset caret when redo cut with no selection
- enhancement: close editor when middle button clicked on it's title tab
Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong

View File

@ -335,6 +335,12 @@ MainWindow::MainWindow(QWidget *parent)
ui->actionEGE_Manual->setVisible(pSettings->environment().language()=="zh_CN");
connect(ui->EditorTabsLeft, &EditorsTabWidget::middleButtonClicked,
this, &MainWindow::on_EditorTabsLeft_tabCloseRequested);
connect(ui->EditorTabsRight, &EditorsTabWidget::middleButtonClicked,
this, &MainWindow::on_EditorTabsRight_tabCloseRequested);
//git menu
connect(ui->menuGit, &QMenu::aboutToShow,
this, &MainWindow::updateVCSActions);

View File

@ -55,3 +55,13 @@ void EditorsTabWidget::dragEnterEvent(QDragEnterEvent *event)
event->acceptProposedAction();
}
}
void EditorsTabWidget::mousePressEvent(QMouseEvent *event)
{
if (event->buttons() == Qt::MiddleButton) {
int idx = this->tabBar()->tabAt(event->pos());
if (idx>=0)
emit middleButtonClicked(idx);
}
QTabWidget::mousePressEvent(event);
}

View File

@ -28,10 +28,16 @@ class EditorsTabWidget : public QTabWidget
public:
explicit EditorsTabWidget(QWidget* parent=nullptr);
signals:
void middleButtonClicked(int index);
// QWidget interface
protected:
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
// QWidget interface
protected:
void mousePressEvent(QMouseEvent *event) override;
};
#endif // EDITORSTABWIDGET_H