Save last used path to raw layout data.

This commit is contained in:
Roman Telezhynskyi 2023-10-13 16:17:36 +03:00
parent bc6b9468b7
commit 3db18228c8
3 changed files with 23 additions and 2 deletions

View File

@ -3635,11 +3635,15 @@ void VPMainWindow::on_actionImportRawLayout_triggered()
{
const QString filter(tr("Raw Layout files") + QStringLiteral(" (*.rld)"));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter, nullptr,
VAbstractApplication::VApp()->NativeFileDialog());
auto *settings = VPApplication::VApp()->PuzzleSettings();
const QString filePath =
QFileDialog::getOpenFileName(this, tr("Open file"), settings->GetPathRawLayoutData(), filter, nullptr,
VAbstractApplication::VApp()->NativeFileDialog());
if (not filePath.isEmpty())
{
settings->SetPathRawLayoutData(QFileInfo(filePath).absolutePath());
ImportRawLayouts({filePath});
}
}

View File

@ -28,6 +28,7 @@
#include "vpsettings.h"
#include "../vmisc/compatibility.h"
#include <QDir>
#include <QMarginsF>
using namespace Qt::Literals::StringLiterals;
@ -71,6 +72,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, ("layout/pieceGa
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, ("layout/exportFormat"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, ("layout/lineWidth"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, ("layout/showGrainline"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsRawLayoutData, ("paths/rawLatoutData"_L1)) // NOLINT
QT_WARNING_POP
@ -129,6 +131,18 @@ void VPSettings::SetDockWidgetPropertiesContentsActive(bool value)
setValue(*settingDockPropertiesContentsActive, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetPathRawLayoutData() const -> QString
{
return value(*settingPathsRawLayoutData, QDir::homePath()).toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VPSettings::SetPathRawLayoutData(const QString &value)
{
setValue(*settingPathsRawLayoutData, value);
}
//---------------------------------------------------------------------------------------------------------------------
void VPSettings::SetLayoutUnit(Unit unit)
{

View File

@ -50,6 +50,9 @@ public:
static auto GetDefDockWidgetPropertiesContentsActive() -> bool;
void SetDockWidgetPropertiesContentsActive(bool value);
auto GetPathRawLayoutData() const -> QString;
void SetPathRawLayoutData(const QString &value);
void SetLayoutUnit(Unit unit);
auto LayoutUnit() const -> Unit;