qtk/src/app/qtkmainwindow.h

93 lines
2.9 KiB
C
Raw Normal View History

2022-11-26 18:24:38 +00:00
/*##############################################################################
## Author: Shaun Reed ##
2023-01-02 03:26:58 +00:00
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
## About: MainWindow for Qtk application ##
2022-11-26 18:24:38 +00:00
## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <unordered_map>
#include <QMainWindow>
#include <QPlainTextEdit>
#include "debugconsole.h"
#include "qtkwidget.h"
namespace Ui {
class MainWindow;
}
2022-11-26 18:24:38 +00:00
/**
* MainWindow class to provide an example of using a QtkWidget within a Qt
* window application.
*/
class MainWindow : public QMainWindow {
2022-11-24 22:26:53 +00:00
Q_OBJECT
2022-11-24 22:26:53 +00:00
public:
2022-11-26 18:24:38 +00:00
/***************************************************************************
* Contructors / Destructors
**************************************************************************/
/**
* This ctor also initializes the Scene for each QtkWidget in the window.
* To load a different scene this would need to be updated.
*
* @param parent The parent for this QMainWindow
*/
2022-11-24 22:26:53 +00:00
explicit MainWindow(QWidget * parent = nullptr);
2023-01-02 03:26:58 +00:00
2022-11-24 22:26:53 +00:00
~MainWindow() override;
/***************************************************************************
2023-01-02 03:26:58 +00:00
* Public Methods
**************************************************************************/
/**
* Allows widgets to retrieve an instance of this root QMainWindow.
* @return this
*/
2023-01-02 03:26:58 +00:00
static MainWindow * getMainWindow();
Qtk::QtkWidget * getQtkWidget(int64_t index = 0);
/**
* Accessor for retrieving a QtkWidget by it's objectName.
* This function will not construct a new QtkWidget if none is found.
*
* @param name The objectName associated with the QtkWidget.
* @return Pointer to an active QtkWidget or Q_NULLPTR is not found.
*/
2023-01-02 03:26:58 +00:00
Qtk::QtkWidget * getQtkWidget(const QString & name);
public slots:
2023-01-02 03:26:58 +00:00
/**
* Trigger a refresh for widgets related to a scene that has been updated.
* @param sceneName The name of the scene that has been modified.
*/
void refreshScene(QString sceneName);
2022-11-24 22:26:53 +00:00
private:
2022-11-26 18:24:38 +00:00
/***************************************************************************
* Private Members
**************************************************************************/
2023-01-02 03:26:58 +00:00
/** Do not allow copying */
MainWindow(const MainWindow &) {};
Ui::MainWindow * ui_ {};
static MainWindow * mainWindow_;
/**
* Maps a scene name to the QtkWidget viewing it.
* TODO: Value should be a vector of QtkWidget * for multiple scene views.
*/
std::unordered_map<QString, Qtk::QtkWidget *> views_ {};
};
2022-11-24 22:26:53 +00:00
#endif // MAINWINDOW_H