Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/project/internal/exportprojectscenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ std::vector<INotationWriter::UnitType> ExportProjectScenario::supportedUnitTypes
}

RetVal<muse::io::path_t> ExportProjectScenario::askExportPath(const INotationPtrList& notations, const ExportType& exportType,
INotationWriter::UnitType unitType, muse::io::path_t defaultPath) const
INotationWriter::UnitType unitType, muse::io::path_t defaultDirPath) const
{
INotationProjectPtr project = context()->currentProject();

Expand Down Expand Up @@ -84,8 +84,12 @@ RetVal<muse::io::path_t> ExportProjectScenario::askExportPath(const INotationPtr
}
}

if (defaultPath == "") {
muse::io::path_t defaultPath;
if (defaultDirPath == "") {
defaultPath = configuration()->defaultSavingFilePath(project, filenameAddition, exportType.suffixes.front().toStdString());
} else {
defaultPath = defaultDirPath.appendingComponent(io::filename(project->path(), false) + filenameAddition)
.appendingSuffix(exportType.suffixes.front().toStdString());
}

RetVal<muse::io::path_t> exportPath;
Expand Down
2 changes: 1 addition & 1 deletion src/project/internal/exportprojectscenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ExportProjectScenario : public IExportProjectScenario, public muse::async:

muse::RetVal<muse::io::path_t> askExportPath(const notation::INotationPtrList& notations, const ExportType& exportType,
INotationWriter::UnitType unitType = INotationWriter::UnitType::PER_PART,
muse::io::path_t defaultPath = "") const override;
muse::io::path_t defaultDirPath = "") const override;

bool exportScores(notation::INotationPtrList notations, const muse::io::path_t destinationPath,
INotationWriter::UnitType unitType = INotationWriter::UnitType::PER_PART,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void ExportDialogModel::init()
selectExportTypeById(info.id);
}

m_exportPath = info.exportPath;
m_exportDirPath = info.exportDirPath;
setUnitType(info.unitType);

beginResetModel();
Expand Down Expand Up @@ -387,28 +387,15 @@ bool ExportDialogModel::exportScores()
return false;
}

INotationProjectPtr project = context()->currentProject();
muse::io::path_t filename = io::filename(project->path());
// TODO: only restore filename if exactly the same notations are selected and the same unit type.
// These settings may namely cause extra things to be added to the name, but these extra things
// are not applicable to other values of these settings.
//if (project && project->path() == exportProjectScenario()->exportInfo().projectPath) {
// filename = io::filename(m_exportPath);
//}
muse::io::path_t defaultPath;
if (m_exportPath != "" && filename != "") {
defaultPath = io::absoluteDirpath(m_exportPath)
.appendingComponent(io::filename(filename, false))
.appendingSuffix(m_selectedExportType.suffixes[0]);
}
std::shared_ptr<IExportProjectScenario> scenario = exportProjectScenario();

RetVal<muse::io::path_t> exportPath
= exportProjectScenario()->askExportPath(notations, m_selectedExportType, m_selectedUnitType, defaultPath);
= scenario->askExportPath(notations, m_selectedExportType, m_selectedUnitType, m_exportDirPath);
if (!exportPath.ret) {
return false;
}

m_exportPath = exportPath.val;
m_exportDirPath = io::absoluteDirpath(exportPath.val);

struct Params {
INotationPtrList notations;
Expand All @@ -422,11 +409,9 @@ bool ExportDialogModel::exportScores()
//! Therefore, we save everything we need in variables
//! and pass them to the lambda.
//! We can't access the dialog class member in the lambda body.
Params params{ notations, m_exportPath, m_selectedUnitType,
Params params{ notations, exportPath.val, m_selectedUnitType,
shouldDestinationFolderBeOpenedOnExport() };

std::shared_ptr<IExportProjectScenario> scenario = exportProjectScenario();

//! NOTE We can't use Async here
// because the async::processMessages is called deep within the functions,
// and this can't be done in Async's callback.
Expand Down Expand Up @@ -806,7 +791,7 @@ void ExportDialogModel::updateExportInfo()
{
ExportInfo info;
info.id = m_selectedExportType.id;
info.exportPath = m_exportPath;
info.exportDirPath = m_exportDirPath;
info.unitType = m_selectedUnitType;

for (const QModelIndex& index : m_selectionModel->selectedIndexes()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class ExportDialogModel : public QAbstractListModel, public QQmlParserStatus, pu

ExportTypeList m_exportTypeList {};
ExportType m_selectedExportType = ExportType();
muse::io::path_t m_exportPath;
muse::io::path_t m_exportDirPath;
project::INotationWriter::UnitType m_selectedUnitType = project::INotationWriter::UnitType::PER_PART;
};
}
2 changes: 1 addition & 1 deletion src/project/types/projecttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct CloudAudioInfo {

struct ExportInfo {
QString id;
muse::io::path_t exportPath;
muse::io::path_t exportDirPath;
INotationWriter::UnitType unitType;
std::vector<notation::INotationWeakPtr> notations;
};
Expand Down
Loading