RecentAssetPath.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "RecentAssetPath.h"
  9. #include "CommonSettingsConfigurations.h"
  10. #include <QSettings>
  11. #define SCRIPTCANVASEDITOR_SETTINGS_RECENT_OPEN_FILE_LOCATION_KEY (QString("Recent Open File Location") + " " + QString::fromLocal8Bit(ScriptCanvasEditor::GetEditingGameDataFolder().c_str()) + "/")
  12. namespace ScriptCanvasEditor
  13. {
  14. void SetRecentAssetId(SourceHandle assetId)
  15. {
  16. QSettings settings(QSettings::IniFormat, QSettings::UserScope,
  17. SCRIPTCANVASEDITOR_AZ_QCOREAPPLICATION_SETTINGS_ORGANIZATION_NAME);
  18. AZStd::string guidStr = assetId.Id().ToString<AZStd::string>();
  19. settings.beginGroup(SCRIPTCANVASEDITOR_NAME_SHORT);
  20. settings.setValue(SCRIPTCANVASEDITOR_SETTINGS_RECENT_OPEN_FILE_LOCATION_KEY,
  21. QVariant::fromValue(QString(guidStr.c_str())));
  22. settings.endGroup();
  23. }
  24. void ClearRecentAssetId()
  25. {
  26. QSettings settings(QSettings::IniFormat, QSettings::UserScope,
  27. SCRIPTCANVASEDITOR_AZ_QCOREAPPLICATION_SETTINGS_ORGANIZATION_NAME);
  28. settings.beginGroup(SCRIPTCANVASEDITOR_NAME_SHORT);
  29. settings.remove(SCRIPTCANVASEDITOR_SETTINGS_RECENT_OPEN_FILE_LOCATION_KEY);
  30. settings.endGroup();
  31. }
  32. }