2022-11-26 18:24:38 +00:00
|
|
|
/*##############################################################################
|
|
|
|
## Author: Shaun Reed ##
|
|
|
|
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
|
|
|
## About: MainWindow for creating an example Qt application ##
|
|
|
|
## ##
|
|
|
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
|
|
|
##############################################################################*/
|
|
|
|
|
2022-08-07 17:12:12 +00:00
|
|
|
#include <mainwindow.h>
|
2022-08-21 19:37:42 +00:00
|
|
|
#include <qtkwidget.h>
|
|
|
|
#include "ui_mainwindow.h"
|
2022-03-13 22:00:00 +00:00
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
MainWindow::MainWindow(QWidget * parent) :
|
|
|
|
QMainWindow(parent), ui(new Ui::MainWindow) {
|
2022-08-21 19:37:42 +00:00
|
|
|
// For use in design mode using Qt Creator
|
|
|
|
// + We can use the `ui` member to access nested widgets by name
|
2022-11-26 18:24:38 +00:00
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
// Find all QtkWidgets in this QMainWindow and initialize their scenes.
|
2022-12-11 17:36:07 +00:00
|
|
|
auto children = ui->centralwidget->findChildren<Qtk::QtkWidget *>();
|
|
|
|
for(const auto qtkWidget : children) {
|
|
|
|
std::string key = qtkWidget->objectName().toStdString();
|
|
|
|
// Initialize each scene into a map if it doesn't exist.
|
|
|
|
if(mScenes[key] == nullptr) {
|
|
|
|
mScenes[key] = new ExampleScene();
|
2022-08-21 19:37:42 +00:00
|
|
|
}
|
2022-12-11 17:36:07 +00:00
|
|
|
// Set the QtkWidget to use the scene associated with this widget.
|
|
|
|
qtkWidget->setScene(mScenes[key]);
|
2022-08-21 19:37:42 +00:00
|
|
|
}
|
2022-12-11 17:36:07 +00:00
|
|
|
// TODO: Use QPlainTextEdit or similar for debug console
|
2022-11-26 18:24:38 +00:00
|
|
|
|
|
|
|
// Set the window icon used for Qtk.
|
|
|
|
// TODO: Update this to be something other than kilroy.
|
2022-03-13 22:00:00 +00:00
|
|
|
setWindowIcon(QIcon("../resources/icon.png"));
|
|
|
|
}
|
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
MainWindow::~MainWindow() {
|
2022-03-13 22:00:00 +00:00
|
|
|
delete ui;
|
|
|
|
}
|