mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 20:22:34 +02:00
add a modes menu and hook it up to the existing model widget
This commit is contained in:
parent
31bf012503
commit
4e0aba10bc
8 changed files with 130 additions and 21 deletions
|
@ -12,7 +12,6 @@
|
|||
#include <SettingInterface.h>
|
||||
|
||||
#include "ui/OvenMainWindow.h"
|
||||
#include "ui/ModelBakeWidget.h"
|
||||
|
||||
#include "Oven.h"
|
||||
|
||||
|
@ -30,20 +29,7 @@ Oven::Oven(int argc, char* argv[]) :
|
|||
// check if we were passed any command line arguments that would tell us just to run without the GUI
|
||||
|
||||
// setup the GUI
|
||||
setupGUI();
|
||||
}
|
||||
|
||||
void Oven::setupGUI() {
|
||||
_mainWindow = new OvenMainWindow;
|
||||
|
||||
_mainWindow->setWindowTitle("High Fidelity Oven");
|
||||
|
||||
// give the window a fixed width that will never change
|
||||
const int FIXED_WINDOW_WIDTH = 640;
|
||||
_mainWindow->setFixedWidth(FIXED_WINDOW_WIDTH);
|
||||
|
||||
_mainWindow->setCentralWidget(new ModelBakeWidget);
|
||||
|
||||
_mainWindow->show();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ public:
|
|||
Oven(int argc, char* argv[]);
|
||||
|
||||
private:
|
||||
void setupGUI();
|
||||
|
||||
OvenMainWindow* _mainWindow;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QStackedWidget>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
|
@ -76,12 +77,24 @@ void ModelBakeWidget::setupUI() {
|
|||
// start a new row for the next component
|
||||
++rowIndex;
|
||||
|
||||
// add a horizontal line to split the bake/cancel buttons off
|
||||
QFrame* lineFrame = new QFrame;
|
||||
lineFrame->setFrameShape(QFrame::HLine);
|
||||
lineFrame->setFrameShadow(QFrame::Sunken);
|
||||
gridLayout->addWidget(lineFrame, rowIndex, 0, 1, -1);
|
||||
|
||||
// start a new row for the next component
|
||||
++rowIndex;
|
||||
|
||||
// add a button that will kickoff the bake
|
||||
QPushButton* bakeButton = new QPushButton("Bake");
|
||||
connect(bakeButton, &QPushButton::clicked, this, &ModelBakeWidget::bakeButtonClicked);
|
||||
gridLayout->addWidget(bakeButton, rowIndex, 3);
|
||||
|
||||
// add the bake button to the grid
|
||||
gridLayout->addWidget(bakeButton, rowIndex, 0, -1, -1);
|
||||
// add a cancel button to go back to the modes page
|
||||
QPushButton* cancelButton = new QPushButton("Cancel");
|
||||
connect(cancelButton, &QPushButton::clicked, this, &ModelBakeWidget::cancelButtonClicked);
|
||||
gridLayout->addWidget(cancelButton, rowIndex, 4);
|
||||
|
||||
setLayout(gridLayout);
|
||||
}
|
||||
|
@ -141,11 +154,13 @@ void ModelBakeWidget::bakeButtonClicked() {
|
|||
|
||||
if (!outputDirectory.exists()) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure we have a non empty URL to a model to bake
|
||||
if (_modelLineEdit->text().isEmpty()) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// split the list from the model line edit to see how many models we need to bake
|
||||
|
@ -164,6 +179,13 @@ void ModelBakeWidget::bakeButtonClicked() {
|
|||
baker->start();
|
||||
_bakers.emplace_back(baker);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ModelBakeWidget::cancelButtonClicked() {
|
||||
// the user wants to go back to the mode selection screen
|
||||
// remove ourselves from the stacked widget and call delete later so we'll be cleaned up
|
||||
auto stackedWidget = qobject_cast<QStackedWidget*>(parentWidget());
|
||||
stackedWidget->removeWidget(this);
|
||||
|
||||
this->deleteLater();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ private slots:
|
|||
void chooseFileButtonClicked();
|
||||
void chooseOutputDirButtonClicked();
|
||||
void bakeButtonClicked();
|
||||
void cancelButtonClicked();
|
||||
|
||||
void outputDirectoryChanged(const QString& newDirectory);
|
||||
|
||||
|
|
51
tools/oven/src/ui/ModesWidget.cpp
Normal file
51
tools/oven/src/ui/ModesWidget.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// ModesWidget.cpp
|
||||
// tools/oven/src/ui
|
||||
//
|
||||
// Created by Stephen Birarda on 4/7/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QStackedWidget>
|
||||
|
||||
#include "ModelBakeWidget.h"
|
||||
|
||||
#include "ModesWidget.h"
|
||||
|
||||
ModesWidget::ModesWidget(QWidget* parent, Qt::WindowFlags flags) :
|
||||
QWidget(parent, flags)
|
||||
{
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void ModesWidget::setupUI() {
|
||||
// setup a horizontal box layout to hold our mode buttons
|
||||
QHBoxLayout* horizontalLayout = new QHBoxLayout;
|
||||
|
||||
// add a button for model baking
|
||||
QPushButton* modelsButton = new QPushButton("Bake Models");
|
||||
connect(modelsButton, &QPushButton::clicked, this, &ModesWidget::showModelBakingWidget);
|
||||
horizontalLayout->addWidget(modelsButton);
|
||||
|
||||
// add a button for domain baking
|
||||
QPushButton* domainButton = new QPushButton("Bake Domain");
|
||||
horizontalLayout->addWidget(domainButton);
|
||||
|
||||
// add a button for texture baking
|
||||
QPushButton* textureButton = new QPushButton("Bake Textures");
|
||||
horizontalLayout->addWidget(textureButton);
|
||||
|
||||
setLayout(horizontalLayout);
|
||||
}
|
||||
|
||||
void ModesWidget::showModelBakingWidget() {
|
||||
auto stackedWidget = qobject_cast<QStackedWidget*>(parentWidget());
|
||||
|
||||
// add a new widget for making baking to the stack, and switch to it
|
||||
stackedWidget->setCurrentIndex(stackedWidget->addWidget(new ModelBakeWidget));
|
||||
}
|
29
tools/oven/src/ui/ModesWidget.h
Normal file
29
tools/oven/src/ui/ModesWidget.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// ModesWidget.h
|
||||
// tools/oven/src/ui
|
||||
//
|
||||
// Created by Stephen Birarda on 4/7/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_ModesWidget_h
|
||||
#define hifi_ModesWidget_h
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
class ModesWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ModesWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
|
||||
private slots:
|
||||
void showModelBakingWidget();
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
};
|
||||
|
||||
#endif // hifi_ModesWidget_h
|
|
@ -9,4 +9,24 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtWidgets/QStackedWidget>
|
||||
|
||||
#include "ModesWidget.h"
|
||||
|
||||
#include "OvenMainWindow.h"
|
||||
|
||||
OvenMainWindow::OvenMainWindow(QWidget *parent, Qt::WindowFlags flags) :
|
||||
QMainWindow(parent, flags)
|
||||
{
|
||||
setWindowTitle("High Fidelity Oven");
|
||||
|
||||
// give the window a fixed width that will never change
|
||||
const int FIXED_WINDOW_WIDTH = 640;
|
||||
setFixedWidth(FIXED_WINDOW_WIDTH);
|
||||
|
||||
// setup a stacked layout for the main "modes" menu and subseq
|
||||
QStackedWidget* stackedWidget = new QStackedWidget(this);
|
||||
stackedWidget->addWidget(new ModesWidget);
|
||||
|
||||
setCentralWidget(stackedWidget);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
class OvenMainWindow : public QMainWindow {
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
OvenMainWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
};
|
||||
|
||||
#endif // hifi_OvenMainWindow_h
|
||||
|
|
Loading…
Reference in a new issue