add BakeWidget, leverage for skybox widget cancellation

This commit is contained in:
Stephen Birarda 2017-04-17 17:32:23 -07:00
parent 8a1eb5f077
commit 95e2cc4eea
8 changed files with 90 additions and 79 deletions

View file

@ -0,0 +1,46 @@
//
// BakeWidget.cpp
// tools/oven/src/ui
//
// Created by Stephen Birarda on 4/17/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/QStackedWidget>
#include "../Oven.h"
#include "OvenMainWindow.h"
#include "BakeWidget.h"
BakeWidget::BakeWidget(QWidget* parent, Qt::WindowFlags flags) :
QWidget(parent, flags)
{
}
BakeWidget::~BakeWidget() {
// if we're going down, our bakers are about to too
// enumerate them, send a cancelled status to the results table, and remove them
auto it = _bakers.begin();
while (it != _bakers.end()) {
auto resultRow = it->second;
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
resultsWindow->changeStatusForRow(resultRow, "Cancelled");
it = _bakers.erase(it);
}
}
void BakeWidget::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();
}

View file

@ -0,0 +1,33 @@
//
// BakeWidget.h
// tools/oven/src/ui
//
// Created by Stephen Birarda on 4/17/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_BakeWidget_h
#define hifi_BakeWidget_h
#include <QtWidgets/QWidget>
#include <Baker.h>
class BakeWidget : public QWidget {
Q_OBJECT
public:
BakeWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~BakeWidget();
void cancelButtonClicked();
protected:
using BakerRowPair = std::pair<std::unique_ptr<Baker>, int>;
using BakerRowPairList = std::list<BakerRowPair>;
BakerRowPairList _bakers;
};
#endif // hifi_BakeWidget_h

View file

@ -16,7 +16,6 @@
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QStackedWidget>
#include <QtCore/QDir>
#include <QtCore/QDebug>
@ -32,7 +31,7 @@ static const QString BROWSE_START_DIR_SETTING_KEY = "domain_search_directory";
static const QString DESTINATION_PATH_SETTING_KEY = "destination_path";
DomainBakeWidget::DomainBakeWidget(QWidget* parent, Qt::WindowFlags flags) :
QWidget(parent, flags),
BakeWidget(parent, flags),
_domainNameSetting(DOMAIN_NAME_SETTING_KEY),
_exportDirectory(EXPORT_DIR_SETTING_KEY),
_browseStartDirectory(BROWSE_START_DIR_SETTING_KEY),
@ -41,20 +40,6 @@ DomainBakeWidget::DomainBakeWidget(QWidget* parent, Qt::WindowFlags flags) :
setupUI();
}
DomainBakeWidget::~DomainBakeWidget() {
// if we're going down, our bakers are about to too
// enumerate them, send a cancelled status to the results table, and remove them
auto it = _bakers.begin();
while (it != _bakers.end()) {
auto resultRow = it->second;
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
resultsWindow->changeStatusForRow(resultRow, "Cancelled");
it = _bakers.erase(it);
}
}
void DomainBakeWidget::setupUI() {
// setup a grid layout to hold everything
QGridLayout* gridLayout = new QGridLayout;
@ -296,12 +281,3 @@ void DomainBakeWidget::handleFinishedBaker() {
}
}
}
void DomainBakeWidget::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();
}

View file

@ -17,21 +17,20 @@
#include <SettingHandle.h>
#include "../DomainBaker.h"
#include "BakeWidget.h"
class QLineEdit;
class DomainBakeWidget : public QWidget {
class DomainBakeWidget : public BakeWidget {
Q_OBJECT
public:
DomainBakeWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~DomainBakeWidget();
private slots:
void chooseFileButtonClicked();
void chooseOutputDirButtonClicked();
void bakeButtonClicked();
void cancelButtonClicked();
void outputDirectoryChanged(const QString& newDirectory);
@ -41,10 +40,6 @@ private slots:
private:
void setupUI();
using BakerRowPair = std::pair<std::unique_ptr<DomainBaker>, int>;
using BakerRowPairList = std::list<BakerRowPair>;
BakerRowPairList _bakers;
QLineEdit* _domainNameLineEdit;
QLineEdit* _entitiesFileLineEdit;
QLineEdit* _outputDirLineEdit;

View file

@ -29,27 +29,13 @@ static const auto EXPORT_DIR_SETTING_KEY = "model_export_directory";
static const auto MODEL_START_DIR_SETTING_KEY = "model_search_directory";
ModelBakeWidget::ModelBakeWidget(QWidget* parent, Qt::WindowFlags flags) :
QWidget(parent, flags),
BakeWidget(parent, flags),
_exportDirectory(EXPORT_DIR_SETTING_KEY),
_modelStartDirectory(MODEL_START_DIR_SETTING_KEY)
{
setupUI();
}
ModelBakeWidget::~ModelBakeWidget() {
// if we're about to go down, whatever bakers we're managing are about to as well
// enumerate them, send the results table a cancelled status, and clean them up
auto it = _bakers.begin();
while (it != _bakers.end()) {
auto resultRow = it->second;
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
resultsWindow->changeStatusForRow(resultRow, "Cancelled");
it = _bakers.erase(it);
}
}
void ModelBakeWidget::setupUI() {
// setup a grid layout to hold everything
QGridLayout* gridLayout = new QGridLayout;
@ -236,12 +222,3 @@ void ModelBakeWidget::handleFinishedBaker() {
}
}
}
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();
}

View file

@ -18,21 +18,21 @@
#include <FBXBaker.h>
#include "BakeWidget.h"
class QLineEdit;
class QThread;
class ModelBakeWidget : public QWidget {
class ModelBakeWidget : public BakeWidget {
Q_OBJECT
public:
ModelBakeWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~ModelBakeWidget();
private slots:
void chooseFileButtonClicked();
void chooseOutputDirButtonClicked();
void bakeButtonClicked();
void cancelButtonClicked();
void outputDirectoryChanged(const QString& newDirectory);
@ -41,10 +41,6 @@ private slots:
private:
void setupUI();
using BakerRowPair = std::pair<std::unique_ptr<FBXBaker>, int>;
using BakerRowPairList = std::list<BakerRowPair>;
BakerRowPairList _bakers;
QLineEdit* _modelLineEdit;
QLineEdit* _outputDirLineEdit;

View file

@ -29,7 +29,7 @@ static const auto EXPORT_DIR_SETTING_KEY = "skybox_export_directory";
static const auto SELECTION_START_DIR_SETTING_KEY = "skybox_search_directory";
SkyboxBakeWidget::SkyboxBakeWidget(QWidget* parent, Qt::WindowFlags flags) :
QWidget(parent, flags),
BakeWidget(parent, flags),
_exportDirectory(EXPORT_DIR_SETTING_KEY),
_selectionStartDirectory(SELECTION_START_DIR_SETTING_KEY)
{
@ -221,12 +221,3 @@ void SkyboxBakeWidget::handleFinishedBaker() {
}
}
}
void SkyboxBakeWidget::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();
}

View file

@ -18,9 +18,11 @@
#include <TextureBaker.h>
#include "BakeWidget.h"
class QLineEdit;
class SkyboxBakeWidget : public QWidget {
class SkyboxBakeWidget : public BakeWidget {
Q_OBJECT
public:
@ -30,7 +32,6 @@ private slots:
void chooseFileButtonClicked();
void chooseOutputDirButtonClicked();
void bakeButtonClicked();
void cancelButtonClicked();
void outputDirectoryChanged(const QString& newDirectory);
@ -39,10 +40,6 @@ private slots:
private:
void setupUI();
using BakerRowPair = std::pair<std::unique_ptr<TextureBaker>, int>;
using BakerRowPairList = std::list<BakerRowPair>;
BakerRowPairList _bakers;
QLineEdit* _selectionLineEdit;
QLineEdit* _outputDirLineEdit;