MXVK Vulkan Framework 0.24.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.

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

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

Persists settings and stops any running renderer process.

Definition at line 23 of file model_view.cpp.

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

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 239 of file model_view.cpp.

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

◆ 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 257 of file model_view.cpp.

257 {
258 if (event->mimeData()->hasUrls()) {
259 event->acceptProposedAction();
260 }
261}

◆ 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 263 of file model_view.cpp.

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

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