diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index cc38e72031..4a8ac23822 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -4,9 +4,9 @@ project(profileGUIw LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_AUTOUIC ON) +#set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) +#set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -39,5 +39,10 @@ set(SOURCE_FILES ) add_library(profileGUIw STATIC ${HEADER_FILES} ${SOURCE_FILES}) +target_include_directories(profileGUIw PRIVATE ${OPENSPACE_BASE_DIR}/include) +target_include_directories(profileGUIw PRIVATE ${OPENSPACE_BASE_DIR}/ext/ghoul/include) +target_include_directories(profileGUIw PRIVATE ${OPENSPACE_BASE_DIR}/ext/ghoul/ext/glm) +target_include_directories(profileGUIw PRIVATE ${OPENSPACE_BASE_DIR}/ext/ghoul/ext/cppformat/include) +target_include_directories(profileGUIw PRIVATE ${OPENSPACE_BASE_DIR}/ext/ghoul/ext/lua/src) target_link_libraries(profileGUIw PUBLIC Qt5::Widgets) diff --git a/apps/OpenSpace/ext/launcher/editorwindow.cpp b/apps/OpenSpace/ext/launcher/editorwindow.cpp index 503ec9256f..941b7e06fc 100644 --- a/apps/OpenSpace/ext/launcher/editorwindow.cpp +++ b/apps/OpenSpace/ext/launcher/editorwindow.cpp @@ -29,6 +29,10 @@ #include #include "launcherwindow.h" #include "filesystemaccess.h" +#include +#include +#include + std::string testContents = "0Dir_1\n" @@ -52,7 +56,7 @@ std::string testContents = "0 Dir B1\n" "0 File C1\n"; -editorwindow::editorwindow(QString assetPath, QWidget *parent) +editorwindow::editorwindow(const QString assetPath, const std::string& profilePath, QWidget *parent) : QDialog(parent) , ui(new Ui::editorwindow) , _assetTreeModel(tr("Asset"), tr("Enabled")) @@ -83,6 +87,26 @@ editorwindow::editorwindow(QString assetPath, QWidget *parent) connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(parseSelections())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(cancel())); + + if (profilePath.length() != 0) { + loadProfile(profilePath); + } +} + +void editorwindow::loadProfile(const std::string& filepath) { + if (!std::filesystem::exists(filepath)) { + throw std::runtime_error("Could not find file)"); + } + + std::ifstream f(filepath); + + std::vector lines; + std::string line; + while (std::getline(f, line)) { + lines.push_back(std::move(line)); + } + + openspace::Profile p(lines); } editorwindow::~editorwindow() { diff --git a/apps/OpenSpace/ext/launcher/editorwindow.h b/apps/OpenSpace/ext/launcher/editorwindow.h index 8c7a301731..d64dc2f1ed 100644 --- a/apps/OpenSpace/ext/launcher/editorwindow.h +++ b/apps/OpenSpace/ext/launcher/editorwindow.h @@ -45,7 +45,8 @@ public slots: void cancel(); public: - explicit editorwindow(QString assetPath, QWidget* parent = nullptr); + explicit editorwindow(QString assetPath, const std::string& profileName, + QWidget* parent = nullptr); ~editorwindow(); std::vector parseSelections(); void setProfileName(QString name); @@ -56,6 +57,7 @@ public: private: bool traverseToExpandSelectedItems(int nRows, QModelIndex parent); + void loadProfile(const std::string& profilePath); Ui::editorwindow *ui; QString _helperTextProfileName = "Enter profile name"; QString _helperTextStartTime = "YYYY-MM-DDThh:mm:ss (leave blank for default time)"; diff --git a/apps/OpenSpace/ext/launcher/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/launcherwindow.cpp index 7c8190572e..62f23f5591 100644 --- a/apps/OpenSpace/ext/launcher/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/launcherwindow.cpp @@ -72,14 +72,17 @@ void LauncherWindow::populateWindowConfigsList() { } void LauncherWindow::openWindow_new() { - myEditorWindow = new editorwindow(_basePath + "/data/assets"); + myEditorWindow = new editorwindow(_basePath + "/data/assets", ""); myEditorWindow->exec(); std::vector results = myEditorWindow->parseSelections(); receiveAssets(results); } void LauncherWindow::openWindow_edit() { - myEditorWindow = new editorwindow(_basePath + "/data/assets"); + std::string editProfilePath = _basePath.toUtf8().constData(); + editProfilePath += "/profiles/"; + editProfilePath += ui->comboBoxProfiles->currentText().toUtf8().constData(); + myEditorWindow = new editorwindow(_basePath + "/data/assets", editProfilePath); int selectedProfileIdx = ui->comboBoxProfiles->currentIndex(); QString profileToSet = ui->comboBoxProfiles->itemText(selectedProfileIdx);