Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
router.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17#include <QObject>
18#include <QString>
19#include <QUrl>
20#include <QHash>
21#include <QVector>
22
31// An individual screen
32struct Screen : public QObject {
33 Q_OBJECT
34
35 Q_PROPERTY(bool modal MEMBER modal NOTIFY modalChanged)
36 Q_PROPERTY(QString title MEMBER title NOTIFY titleChanged)
37 Q_PROPERTY(QString url MEMBER url NOTIFY urlChanged)
38 Q_PROPERTY(bool homeBtn MEMBER homeBtn NOTIFY homeBtnChanged)
39
40signals:
43 void urlChanged();
45
46public:
47 Screen();
48 Screen(bool modal, QString title, QString url, bool homeBtn = true);
49
50 // Open this screen as a modal, taking up the entire window
51 bool modal = false;
52
53 // Name of this screen
54 QString title = "";
55
56 // URL of the screen to the QML file
57 QString url = "";
58
59 bool homeBtn = true;
60};
61
72// Router for screens
73class Router : public QObject
74{
75 Q_OBJECT
76
77 Q_PROPERTY(QString title MEMBER title NOTIFY titleChanged)
78 Q_PROPERTY(bool homeBtnShown MEMBER homeBtnShown NOTIFY homeBtnShownChanged)
79
80signals:
81 void goHome();
82 void openModal(QString url);
83 void openNonModal(QString url);
84 void closeModal();
85 void closeNonModal();
86
87 void titleChanged();
88 void homeBtnShownChanged();
89
90public:
91 Q_INVOKABLE void changeScreen(QString name);
92 Q_INVOKABLE void closeScreen();
93
94 // For internal use only by StackView
95 // Silently adds a screen onto the stack
96 Q_INVOKABLE void manualStackPush(QString name);
97
98 QString title = "";
99 bool homeBtnShown = true;
100
101 static void loadScreens();
102
103 static QVector<Screen*> stack;
104 static QHash<QString, Screen*> screens;
105};
Screen navigation for the UI – the QML StackView's controller.
Definition router.h:74
static void loadScreens()
Register the app's screen set (called at boot).
Definition router.cpp:139
void manualStackPush(QString name)
StackView-internal: push name without side effects.
Definition router.cpp:114
void changeScreen(QString name)
Navigate to the registered screen name.
Definition router.cpp:35
static QVector< Screen * > stack
The live navigation stack.
Definition router.h:103
void closeScreen()
Close the top screen.
Definition router.cpp:78
static QHash< QString, Screen * > screens
The registry of named screens.
Definition router.h:104
QString title
Definition router.h:98
bool homeBtnShown
Definition router.h:99
bool homeBtn
Definition router.h:59
protected::void modalChanged()
< Opens as a full-window modal.
void titleChanged()
void urlChanged()
QString title
Definition router.h:54
bool modal
Definition router.h:51
QString url
Definition router.h:57
Screen()
Empty screen.
Definition router.cpp:27
void homeBtnChanged()