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;
35
50class MainWindow : public QMainWindow
51{
52 Q_OBJECT
53
54 Q_PROPERTY(FileManagement* file MEMBER file NOTIFY fileChanged)
55
56public:
57 MainWindow(QWidget* parent = nullptr);
58 virtual ~MainWindow();
59
60 static MainWindow* getInstance();
61 static Bridge* bridge;
62 static QQmlEngine* engine;
63
64 FileManagement* file = nullptr;
65
66 // MAX_RECENT_FILES
67 QShortcut* recentFileShortcuts[5];
68 QHash<QString, QShortcut*> otherShortcuts;
69
70signals:
71 void fileChanged();
72
73private slots:
74 void reUpdateRecentFiles(QList<QString> files);
75 void onRecentFileClick();
76 void onPathChanged(QString path);
77
78private:
79 Ui::MainWindow ui;
80 QSettings settings;
81 void closeEvent(QCloseEvent* event);
82
83 void saveState();
84 void loadState();
85
86 void setupShortcuts();
87 void setupProviders();
88 void injectIntoQML();
89 void ssConnect();
90
91 static MainWindow* instance;
92};
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.
static QQmlEngine * engine
The QML engine behind the hosted QQuickWidget.
Definition mainwindow.h:62
QShortcut * recentFileShortcuts[5]
Ctrl+1..5 open-recent shortcuts.
Definition mainwindow.h:67
QHash< QString, QShortcut * > otherShortcuts
Other global keyboard shortcuts by name.
Definition mainwindow.h:68
FileManagement * file
Definition mainwindow.h:64
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:61
Recent-files list model for the start screen.