MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
MainWindow Class Reference

Main application window for the MXMOD model viewer launcher. More...

#include <model_viewer/model_view.hpp>

Inheritance diagram for MainWindow:

Public Member Functions

 MainWindow (QWidget *parent=nullptr)
 Constructs the launcher window and restores persisted settings.
 ~MainWindow () override
 Persists settings and stops any running renderer process.

Protected Member Functions

void closeEvent (QCloseEvent *event) override
 Confirms shutdown when the viewer process is still running.
void dragEnterEvent (QDragEnterEvent *event) override
 Accepts drag events that contain file or directory URLs.
void dropEvent (QDropEvent *event) override
 Assigns dropped model, texture, or directory paths to the matching input.

Detailed Description

Main application window for the MXMOD model viewer launcher.

MainWindow does not render models directly. It collects model, texture, texture-directory, and resolution options from the user, resolves the command-line viewer executable, launches it as a QProcess, and streams process output into the in-app console.

Definition at line 47 of file model_view.hpp.

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( QWidget * parent = nullptr)
explicit

Constructs the launcher window and restores persisted settings.

Parameters
parentOptional Qt parent widget.

Definition at line 15 of file model_view.cpp.

15 : QMainWindow(parent), activeProcess(nullptr) {
16 settings = new QSettings("MXModel", "ModelViewer", this);
17 initWindow();
18 loadSettings();
19 loadRecentFiles();
20}

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

Persists settings and stops any running renderer process.

Definition at line 22 of file model_view.cpp.

22 {
23 saveSettings();
24 if (activeProcess && activeProcess->state() != QProcess::NotRunning) {
25 activeProcess->kill();
26 activeProcess->waitForFinished();
27 }
28}

Member Function Documentation

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent * event)
overrideprotected

Confirms shutdown when the viewer process is still running.

Parameters
eventClose event to accept or ignore.

Definition at line 237 of file model_view.cpp.

237 {
238 if (activeProcess && activeProcess->state() != QProcess::NotRunning) {
239 auto reply = QMessageBox::question(this, tr("Viewer Running"), tr("The model viewer is still running. Do you want to close it and exit?"), QMessageBox::Yes | QMessageBox::No);
240
241 if (reply == QMessageBox::Yes) {
242 activeProcess->kill();
243 activeProcess->waitForFinished(3000);
244 event->accept();
245 } else {
246 event->ignore();
247 }
248 } else {
249 event->accept();
250 }
251}

◆ dragEnterEvent()

void MainWindow::dragEnterEvent ( QDragEnterEvent * event)
overrideprotected

Accepts drag events that contain file or directory URLs.

Parameters
eventDrag-enter event supplied by Qt.

Definition at line 253 of file model_view.cpp.

253 {
254 if (event->mimeData()->hasUrls()) {
255 event->acceptProposedAction();
256 }
257}

◆ dropEvent()

void MainWindow::dropEvent ( QDropEvent * event)
overrideprotected

Assigns dropped model, texture, or directory paths to the matching input.

Parameters
eventDrop event supplied by Qt.

Definition at line 259 of file model_view.cpp.

259 {
260 const QMimeData *mimeData = event->mimeData();
261
262 if (mimeData->hasUrls()) {
263 QList<QUrl> urls = mimeData->urls();
264 if (!urls.isEmpty()) {
265 QString filePath = urls.first().toLocalFile();
266 QFileInfo fileInfo(filePath);
267
268 const QString suffix = fileInfo.suffix().toLower();
269 if (suffix == "mxmod" || filePath.endsWith(".mxmod.z") || suffix == "obj") {
270 modelLineEdit->setText(filePath);
271 } else if (suffix == "tex" || suffix == "png" || suffix == "jpg" || suffix == "jpeg" || suffix == "bmp" || suffix == "mtl") {
272 textureLineEdit->setText(filePath);
273 } else if (fileInfo.isDir()) {
274 textureDirLineEdit->setText(filePath);
275 }
276 }
277 event->acceptProposedAction();
278 }
279}

The documentation for this class was generated from the following files: