Skip to content
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
mainwindow.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 <QString>
18#include <QHash>
19#include <QShortcut>
20#include <QSettings>
21#include <QQmlEngine>
22
23#include "ui_mainwindow.h"
24
25// The Q_PROPERTY(FileManagement* file) below makes MOC require the COMPLETE type
26// (not a forward decl), and FileManagement is traversed in QML via brg.file so it
27// must NOT be Q_DECLARE_OPAQUE_POINTER'd. This was previously satisfied only as a
28// side effect of the single-target unity MOC; now that the app logic is a library
29// (appcore), include it explicitly. See notes/reference/qt6-patterns.md.
31
33class QAbstractItemModel;
34class Bridge;
35class QFileSystemWatcher;
36
51class MainWindow : public QMainWindow
52{
53 Q_OBJECT
54
55 Q_PROPERTY(FileManagement* file MEMBER file NOTIFY fileChanged)
56
57public:
58 MainWindow(QWidget* parent = nullptr);
59 virtual ~MainWindow();
60
61 static MainWindow* getInstance();
62 static Bridge* bridge;
63 static QQmlEngine* engine;
64
67 bool saveShot(const QString& path);
68
72 bool debugOpenPartyDetails(int index);
73
76 QObject* qmlRootObject();
77
83 void reloadQml();
84
85 FileManagement* file = nullptr;
86
87 // MAX_RECENT_FILES
88 QShortcut* recentFileShortcuts[5];
89 QHash<QString, QShortcut*> otherShortcuts;
90
91signals:
92 void fileChanged();
93
94private slots:
95 void reUpdateRecentFiles(QList<QString> files);
96 void onRecentFileClick();
97 void onPathChanged(QString path);
98
99private:
100 Ui::MainWindow ui;
101 QSettings settings;
102 void closeEvent(QCloseEvent* event);
103
104 void saveState();
105 void loadState();
106
107 void setupShortcuts();
108 void setupProviders();
109 void injectIntoQML();
110 void setupHotReload();
111 QFileSystemWatcher* m_qmlWatcher = nullptr;
112 bool m_reloadPending = false;
113 void ssConnect();
114
115 static MainWindow* instance;
116};
The single QML<->C++ doorway – everything the UI touches hangs off here.
Definition bridge.h:71
Owns the on-disk side of a save: the current path, the recent-files list, and the live SaveFile.
bool saveShot(const QString &path)
DEBUG: render the live QML view to an image file (focus/occlusion-independent).
bool debugOpenPartyDetails(int index)
DEBUG: open the details editor for party mon index (drives the QML AppWindow.debugOpenPartyDetails).
static QQmlEngine * engine
The QML engine behind the hosted QQuickWidget.
Definition mainwindow.h:63
QShortcut * recentFileShortcuts[5]
Ctrl+1..5 open-recent shortcuts.
Definition mainwindow.h:88
QHash< QString, QShortcut * > otherShortcuts
Other global keyboard shortcuts by name.
Definition mainwindow.h:89
QObject * qmlRootObject()
DEBUG: the root QML object of the hosted view (for the debug control server's object lookups).
FileManagement * file
Definition mainwindow.h:85
MainWindow(QWidget *parent=nullptr)
< The live save controller.
protected::void fileChanged()
The live save was replaced.
static MainWindow * getInstance()
The single MainWindow instance.
virtual ~MainWindow()
static Bridge * bridge
The brg aggregate (created here, injected into QML).
Definition mainwindow.h:62
void reloadQml()
DEBUG (–hot): clear the QML cache and reload the view from the source files on disk (live QML refresh...
Recent-files list model for the start screen.