[Qt] Add MainWindow class
This commit is contained in:
@@ -179,8 +179,8 @@ set(RENDERER_SW_SOURCE_FILES src/core/renderer_sw/renderer_sw.cpp)
|
|||||||
|
|
||||||
# Frontend source files
|
# Frontend source files
|
||||||
if(ENABLE_QT_GUI)
|
if(ENABLE_QT_GUI)
|
||||||
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp)
|
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp)
|
||||||
set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp)
|
set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp)
|
||||||
|
|
||||||
source_group("Source Files\\Qt" FILES ${FRONTEND_SOURCE_FILES})
|
source_group("Source Files\\Qt" FILES ${FRONTEND_SOURCE_FILES})
|
||||||
source_group("Header Files\\Qt" FILES ${FRONTEND_HEADER_FILES})
|
source_group("Header Files\\Qt" FILES ${FRONTEND_HEADER_FILES})
|
||||||
|
|||||||
16
include/panda_qt/main_window.hpp
Normal file
16
include/panda_qt/main_window.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
#include "panda_qt/screen.hpp"
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
ScreenWidget screen;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MainWindow(QApplication* app, QWidget* parent = nullptr);
|
||||||
|
};
|
||||||
@@ -1,18 +1,12 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
|
#include "panda_qt/main_window.hpp"
|
||||||
#include "panda_qt/screen.hpp"
|
#include "panda_qt/screen.hpp"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
QWidget window;
|
MainWindow window(&app);
|
||||||
|
|
||||||
window.resize(320, 240);
|
|
||||||
window.show();
|
window.show();
|
||||||
window.setWindowTitle("Alber");
|
|
||||||
ScreenWidget screen(&window);
|
|
||||||
screen.show();
|
|
||||||
screen.resize(320, 240);
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
10
src/panda_qt/main_window.cpp
Normal file
10
src/panda_qt/main_window.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "panda_qt/main_window.hpp"
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), screen(this) {
|
||||||
|
setWindowTitle("Alber");
|
||||||
|
// Enable drop events for loading ROMs
|
||||||
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
resize(320, 240);
|
||||||
|
screen.show();
|
||||||
|
}
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
#ifdef PANDA3DS_ENABLE_OPENGL
|
#ifdef PANDA3DS_ENABLE_OPENGL
|
||||||
ScreenWidget::ScreenWidget(QWidget* parent) : QWidget(parent) {
|
ScreenWidget::ScreenWidget(QWidget* parent) : QWidget(parent) {
|
||||||
// Create a native window for use with our graphics API of choice
|
// Create a native window for use with our graphics API of choice
|
||||||
|
resize(320, 240);
|
||||||
|
|
||||||
setAutoFillBackground(false);
|
setAutoFillBackground(false);
|
||||||
setAttribute(Qt::WA_NativeWindow, true);
|
setAttribute(Qt::WA_NativeWindow, true);
|
||||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user