- 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: 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: redo cut with no selection while make whole line selected
- fix: correctly reset caret when redo cut with no selection - 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 Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong - 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"); 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 //git menu
connect(ui->menuGit, &QMenu::aboutToShow, connect(ui->menuGit, &QMenu::aboutToShow,
this, &MainWindow::updateVCSActions); this, &MainWindow::updateVCSActions);

View File

@ -55,3 +55,13 @@ void EditorsTabWidget::dragEnterEvent(QDragEnterEvent *event)
event->acceptProposedAction(); 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: public:
explicit EditorsTabWidget(QWidget* parent=nullptr); explicit EditorsTabWidget(QWidget* parent=nullptr);
signals:
void middleButtonClicked(int index);
// QWidget interface // QWidget interface
protected: protected:
void dropEvent(QDropEvent *event) override; void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) override;
// QWidget interface
protected:
void mousePressEvent(QMouseEvent *event) override;
}; };
#endif // EDITORSTABWIDGET_H #endif // EDITORSTABWIDGET_H