test QtFiber demo

This commit is contained in:
郑树新 2024-09-23 22:03:00 +08:00
parent baa76b07d9
commit c29d1bd199
3 changed files with 20 additions and 10 deletions

View File

@ -1,6 +1,8 @@
#include "stdafx.h"
#include "inputdialog.h"
InputDialog::InputDialog(QWidget *parent) : QDialog(parent)
InputDialog::InputDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle("Http Options: ");
setGeometry(200, 200, 600, 400);

View File

@ -11,7 +11,7 @@ class InputDialog : public QDialog
Q_OBJECT
public:
explicit InputDialog(QWidget *parent = nullptr);
explicit InputDialog(QWidget *parentr);
signals:
void dialogAccepted(const QString &text);

View File

@ -237,14 +237,22 @@ void MainWindow::onStopSchedule()
void MainWindow::onHttpOptions()
{
InputDialog dialog(this);
QRect mainWindowGeometry = this->frameGeometry();
QPoint mainWindowPos = this->pos();
int x = mainWindowPos.x() + (mainWindowGeometry.width() - dialog.width()) / 2;
int y = mainWindowPos.y() + (mainWindowGeometry.height() - dialog.height()) / 2;
dialog.move(x, y);
connect(&dialog, &InputDialog::dialogAccepted, this, &MainWindow::onDialogAccepted);
dialog.exec();
go[this] {
qDebug() << "Sleep 5 seconds before starting http options dialog";
acl::fiber::delay(5000);
InputDialog dialog(this);
QRect mainWindowGeometry = this->frameGeometry();
QPoint mainWindowPos = this->pos();
int x = mainWindowPos.x() + (mainWindowGeometry.width() - dialog.width()) / 2;
int y = mainWindowPos.y() + (mainWindowGeometry.height() - dialog.height()) / 2;
dialog.move(x, y);
connect(&dialog, &InputDialog::dialogAccepted, this, &MainWindow::onDialogAccepted);
qDebug() << "Start the http options dialog!";
dialog.exec();
qDebug() << "Http options dialog stopped!";
};
qDebug() << "Waiting for the results of http options";
}
void MainWindow::onDialogAccepted(const QString &text)