Ensure replay loop is cancelled before window is hidden

* See also f56a989e4f - we don't want to make the replay loop always on
  top though
This commit is contained in:
baldurk
2025-02-21 14:38:54 +00:00
parent 31d29fcea1
commit 46f83c15a4
3 changed files with 33 additions and 2 deletions
+12
View File
@@ -2533,6 +2533,18 @@ QString RDDialog::getSaveFileName(QWidget *parent, const QString &caption, const
return QString();
}
void RDDialog::closeEvent(QCloseEvent *e)
{
emit(aboutToClose(e));
QDialog::closeEvent(e);
}
void RDDialog::keyPressEvent(QKeyEvent *e)
{
emit(keyPress(e));
QDialog::keyPressEvent(e);
}
bool QFileFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
+13 -1
View File
@@ -917,8 +917,12 @@ public:
class QMenu;
// helper for doing a manual blocking invoke of a dialog
struct RDDialog
class RDDialog : public QDialog
{
private:
Q_OBJECT
public:
static const QMessageBox::StandardButtons YesNoCancel;
static QString DefaultBrowsePath;
@@ -995,6 +999,14 @@ struct RDDialog
const QString &dir = QString(), const QString &filter = QString(),
QString *selectedFilter = NULL,
QFileDialog::Options options = QFileDialog::Options());
signals:
void aboutToClose(QCloseEvent *);
void keyPress(QKeyEvent *e);
private:
void closeEvent(QCloseEvent *) override;
void keyPressEvent(QKeyEvent *e) override;
};
class QGridLayout;
+8 -1
View File
@@ -2588,7 +2588,7 @@ void MainWindow::on_action_Start_Replay_Loop_triggered()
if(!m_Ctx.IsCaptureLoaded())
return;
QDialog popup;
RDDialog popup;
popup.setWindowFlags(popup.windowFlags() & ~Qt::WindowContextHelpButtonHint);
popup.setWindowIcon(windowIcon());
@@ -2651,6 +2651,13 @@ void MainWindow::on_action_Start_Replay_Loop_triggered()
m_Ctx.Replay().AsyncInvoke([winData, id](IReplayController *r) { r->ReplayLoop(winData, id); });
QObject::connect(&popup, &RDDialog::aboutToClose,
[this](QCloseEvent *) { m_Ctx.Replay().CancelReplayLoop(); });
QObject::connect(&popup, &RDDialog::keyPress, [this](QKeyEvent *e) {
if(e->matches(QKeySequence::Cancel))
m_Ctx.Replay().CancelReplayLoop();
});
RDDialog::show(&popup);
m_Ctx.Replay().CancelReplayLoop();