Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
32
struct
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
40
signals:
41
void
modalChanged
();
42
void
titleChanged
();
43
void
urlChanged
();
44
void
homeBtnChanged
();
45
46
public
:
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
73
class
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
80
signals:
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
90
public
:
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
};
Router
Screen navigation for the UI – the QML StackView's controller.
Definition
router.h:74
Router::loadScreens
static void loadScreens()
Register the app's screen set (called at boot).
Definition
router.cpp:139
Router::manualStackPush
void manualStackPush(QString name)
StackView-internal: push name without side effects.
Definition
router.cpp:114
Router::changeScreen
void changeScreen(QString name)
Navigate to the registered screen name.
Definition
router.cpp:35
Router::stack
static QVector< Screen * > stack
The live navigation stack.
Definition
router.h:103
Router::closeScreen
void closeScreen()
Close the top screen.
Definition
router.cpp:78
Router::screens
static QHash< QString, Screen * > screens
The registry of named screens.
Definition
router.h:104
Router::title
QString title
Definition
router.h:98
Router::homeBtnShown
bool homeBtnShown
Definition
router.h:99
Screen::homeBtn
bool homeBtn
Definition
router.h:59
Screen::modalChanged
protected::void modalChanged()
< Opens as a full-window modal.
Screen::titleChanged
void titleChanged()
Screen::urlChanged
void urlChanged()
Screen::title
QString title
Definition
router.h:54
Screen::modal
bool modal
Definition
router.h:51
Screen::url
QString url
Definition
router.h:57
Screen::Screen
Screen()
Empty screen.
Definition
router.cpp:27
Screen::homeBtnChanged
void homeBtnChanged()
projects
app
src
bridge
router.h
Generated by
1.17.0