mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
leverage settings to remember paths used before
This commit is contained in:
parent
e1840eb4fe
commit
425385d982
6 changed files with 53 additions and 5 deletions
|
@ -106,6 +106,10 @@ namespace Setting {
|
|||
return (_isSet) ? _value : other;
|
||||
}
|
||||
|
||||
bool isSet() const {
|
||||
return _isSet;
|
||||
}
|
||||
|
||||
const T& getDefault() const {
|
||||
return _defaultValue;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace Setting {
|
|||
class Manager;
|
||||
|
||||
void init();
|
||||
void cleanupSettings();
|
||||
|
||||
class Interface {
|
||||
public:
|
||||
|
|
|
@ -2,4 +2,4 @@ set(TARGET_NAME oven)
|
|||
|
||||
setup_hifi_project(Widgets Gui)
|
||||
|
||||
link_hifi_libraries(model-baking)
|
||||
link_hifi_libraries(model-baking shared)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SettingInterface.h>
|
||||
|
||||
#include "ui/OvenMainWindow.h"
|
||||
#include "ui/ModelBakeWidget.h"
|
||||
|
||||
|
@ -22,6 +24,9 @@ Oven::Oven(int argc, char* argv[]) :
|
|||
QCoreApplication::setOrganizationName("High Fidelity");
|
||||
QCoreApplication::setApplicationName("Oven");
|
||||
|
||||
// init the settings interface so we can save and load settings
|
||||
Setting::init();
|
||||
|
||||
// check if we were passed any command line arguments that would tell us just to run without the GUI
|
||||
|
||||
// setup the GUI
|
||||
|
|
|
@ -20,8 +20,13 @@
|
|||
|
||||
#include "ModelBakeWidget.h"
|
||||
|
||||
static const QString EXPORT_DIR_SETTING_KEY = "model_export_directory";
|
||||
static const QString MODEL_START_DIR_SETTING_KEY = "model_search_directory";
|
||||
|
||||
ModelBakeWidget::ModelBakeWidget(QWidget* parent, Qt::WindowFlags flags) :
|
||||
QWidget(parent, flags)
|
||||
QWidget(parent, flags),
|
||||
_exportDirectory(EXPORT_DIR_SETTING_KEY),
|
||||
_modelStartDirectory(MODEL_START_DIR_SETTING_KEY)
|
||||
{
|
||||
setupUI();
|
||||
}
|
||||
|
@ -53,6 +58,12 @@ void ModelBakeWidget::setupUI() {
|
|||
|
||||
_outputDirLineEdit = new QLineEdit;
|
||||
|
||||
// set the current export directory to whatever was last used
|
||||
_outputDirLineEdit->setText(_exportDirectory.get());
|
||||
|
||||
// whenever the output directory line edit changes, update the value in settings
|
||||
connect(_outputDirLineEdit, &QLineEdit::textChanged, this, &ModelBakeWidget::outputDirectoryChanged);
|
||||
|
||||
QPushButton* chooseOutputDirectoryButton = new QPushButton("Browse...");
|
||||
connect(chooseOutputDirectoryButton, &QPushButton::clicked, this, &ModelBakeWidget::chooseOutputDirButtonClicked);
|
||||
|
||||
|
@ -76,17 +87,34 @@ void ModelBakeWidget::setupUI() {
|
|||
|
||||
void ModelBakeWidget::chooseFileButtonClicked() {
|
||||
// pop a file dialog so the user can select the model file
|
||||
auto selectedFile = QFileDialog::getOpenFileName(this, "Choose Model", QDir::homePath());
|
||||
|
||||
// if we have picked an FBX before, start in the folder that matches the last path
|
||||
// otherwise start in the home directory
|
||||
auto startDir = _modelStartDirectory.get();
|
||||
if (startDir.isEmpty()) {
|
||||
startDir = QDir::homePath();
|
||||
}
|
||||
|
||||
auto selectedFile = QFileDialog::getOpenFileName(this, "Choose Model", startDir);
|
||||
|
||||
if (!selectedFile.isEmpty()) {
|
||||
// set the contents of the model file text box to be the path to the selected file
|
||||
_modelLineEdit->setText(selectedFile);
|
||||
_modelStartDirectory.set(QDir(selectedFile).absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBakeWidget::chooseOutputDirButtonClicked() {
|
||||
// pop a file dialog so the user can select the output directory
|
||||
auto selectedDir = QFileDialog::getExistingDirectory(this, "Choose Output Directory", QDir::homePath());
|
||||
|
||||
// if we have a previously selected output directory, use that as the initial path in the choose dialog
|
||||
// otherwise use the user's home directory
|
||||
auto startDir = _exportDirectory.get();
|
||||
if (startDir.isEmpty()) {
|
||||
startDir = QDir::homePath();
|
||||
}
|
||||
|
||||
auto selectedDir = QFileDialog::getExistingDirectory(this, "Choose Output Directory", startDir);
|
||||
|
||||
if (!selectedDir.isEmpty()) {
|
||||
// set the contents of the output directory text box to be the path to the directory
|
||||
|
@ -94,6 +122,11 @@ void ModelBakeWidget::chooseOutputDirButtonClicked() {
|
|||
}
|
||||
}
|
||||
|
||||
void ModelBakeWidget::outputDirectoryChanged(const QString& newDirectory) {
|
||||
// update the export directory setting so we can re-use it next time
|
||||
_exportDirectory.set(newDirectory);
|
||||
}
|
||||
|
||||
void ModelBakeWidget::bakeButtonClicked() {
|
||||
// make sure we have a valid output directory
|
||||
QDir outputDirectory(_outputDirLineEdit->text());
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include <FBXBaker.h>
|
||||
|
||||
class QLineEdit;
|
||||
|
@ -29,6 +31,8 @@ private slots:
|
|||
void chooseOutputDirButtonClicked();
|
||||
void bakeButtonClicked();
|
||||
|
||||
void outputDirectoryChanged(const QString& newDirectory);
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
|
||||
|
@ -38,6 +42,9 @@ private:
|
|||
QLineEdit* _outputDirLineEdit;
|
||||
|
||||
QUrl modelToBakeURL;
|
||||
|
||||
Setting::Handle<QString> _exportDirectory;
|
||||
Setting::Handle<QString> _modelStartDirectory;
|
||||
};
|
||||
|
||||
#endif // hifi_ModelBakeWidget_h
|
||||
|
|
Loading…
Reference in a new issue