diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-16 09:56:55 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-16 09:56:55 +0200 |
| commit | 9589072687726dd51776b0e952625ae1996f4721 (patch) | |
| tree | 2dbc63de0b3e5805b5dca2919d05b4356c1194a4 /qt/adapter.h | |
| parent | dc5e8188a7e29909cbdf661e9b2a80700fe0491d (diff) | |
| download | nissy-core-9589072687726dd51776b0e952625ae1996f4721.tar.gz nissy-core-9589072687726dd51776b0e952625ae1996f4721.zip | |
Added rudimentary QT UI
Diffstat (limited to 'qt/adapter.h')
| -rw-r--r-- | qt/adapter.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/qt/adapter.h b/qt/adapter.h new file mode 100644 index 0000000..856cdad --- /dev/null +++ b/qt/adapter.h | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | #ifndef ADAPTER_H | ||
| 2 | #define ADAPTER_H | ||
| 3 | |||
| 4 | #include "../cpp/nissy.h" | ||
| 5 | |||
| 6 | #include <map> | ||
| 7 | #include <string> | ||
| 8 | #include <QObject> | ||
| 9 | #include <QtQmlIntegration> | ||
| 10 | |||
| 11 | struct SolveOptions { | ||
| 12 | nissy::cube cube; | ||
| 13 | nissy::solver *solver; | ||
| 14 | unsigned minmoves; | ||
| 15 | unsigned maxmoves; | ||
| 16 | unsigned maxsolutions; | ||
| 17 | int optimal; | ||
| 18 | }; | ||
| 19 | |||
| 20 | class NissyAdapter : public QObject { | ||
| 21 | Q_OBJECT | ||
| 22 | QML_SINGLETON | ||
| 23 | QML_ELEMENT | ||
| 24 | |||
| 25 | public: | ||
| 26 | NissyAdapter(); | ||
| 27 | |||
| 28 | Q_INVOKABLE bool isValidScramble(QString); | ||
| 29 | Q_INVOKABLE void requestSolve( | ||
| 30 | QString scramble, | ||
| 31 | QString solver, | ||
| 32 | int minmoves, | ||
| 33 | int maxmoves, | ||
| 34 | int maxsolutions, | ||
| 35 | int optimal | ||
| 36 | ); | ||
| 37 | |||
| 38 | signals: | ||
| 39 | void solutionsReady(QString, QString); | ||
| 40 | void solverError(QString); | ||
| 41 | void appendLog(QString); | ||
| 42 | |||
| 43 | private: | ||
| 44 | std::vector<nissy::solver> solvers; | ||
| 45 | std::function<void(const char*)> writeLog; | ||
| 46 | |||
| 47 | void initSolver(const std::string&); | ||
| 48 | void startSolve(SolveOptions); | ||
| 49 | bool loadSolverData(nissy::solver&); | ||
| 50 | }; | ||
| 51 | |||
| 52 | #endif | ||
