diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-25 16:18:26 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-25 16:19:02 +0200 |
| commit | 97b5778172572504c8dfbe173b18281e786270c0 (patch) | |
| tree | e775099577e9ef61465717ae453d71d8ff44559f /qt-widgets/nissywindow.cpp | |
| download | qt-experiments-97b5778172572504c8dfbe173b18281e786270c0.tar.gz qt-experiments-97b5778172572504c8dfbe173b18281e786270c0.zip | |
Initial commit
Diffstat (limited to 'qt-widgets/nissywindow.cpp')
| -rw-r--r-- | qt-widgets/nissywindow.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/qt-widgets/nissywindow.cpp b/qt-widgets/nissywindow.cpp new file mode 100644 index 0000000..98cfc86 --- /dev/null +++ b/qt-widgets/nissywindow.cpp | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #include "nissywindow.h" | ||
| 2 | #include "./ui_nissywindow.h" | ||
| 3 | #include "nissy/cpp/nissy.h" | ||
| 4 | |||
| 5 | #include <QtConcurrent> | ||
| 6 | |||
| 7 | NissyWindow::NissyWindow(QWidget *parent) | ||
| 8 | : QMainWindow(parent), ui(new Ui::NissyWindow) | ||
| 9 | { | ||
| 10 | ui->setupUi(this); | ||
| 11 | |||
| 12 | QObject::connect(ui->solverCfgWidget, | ||
| 13 | SIGNAL(solveRequest(const SolverConfiguration&)), this, | ||
| 14 | SLOT(startSolve(const SolverConfiguration&))); | ||
| 15 | QObject::connect(&adapter, SIGNAL(solveDone(QString)), this, | ||
| 16 | SLOT(showSolutions(QString))); | ||
| 17 | } | ||
| 18 | |||
| 19 | NissyWindow::~NissyWindow() | ||
| 20 | { | ||
| 21 | delete ui; | ||
| 22 | } | ||
| 23 | |||
| 24 | void NissyWindow::startSolve(const SolverConfiguration& config) | ||
| 25 | { | ||
| 26 | ui->solverCfgWidget->lockSubmit(); | ||
| 27 | ui->solutionsLabel->setText("Loading solutions..."); | ||
| 28 | auto _ = QtConcurrent::run(&NissyAdapter::solve, &adapter, config); | ||
| 29 | } | ||
| 30 | |||
| 31 | void NissyWindow::showSolutions(QString solutions) { | ||
| 32 | QString header = QString("Solution(s) found:\n"); | ||
| 33 | ui->solutionsLabel->setText(header + solutions); | ||
| 34 | ui->solverCfgWidget->unlockSubmit(); | ||
| 35 | } | ||
