mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-13 17:09:05 -05:00
Added profile object access to launcher
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#include <sstream>
|
||||
#include "launcherwindow.h"
|
||||
#include "filesystemaccess.h"
|
||||
#include <openspace/scene/profile.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
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<std::string> lines;
|
||||
std::string line;
|
||||
while (std::getline(f, line)) {
|
||||
lines.push_back(std::move(line));
|
||||
}
|
||||
|
||||
openspace::Profile p(lines);
|
||||
}
|
||||
|
||||
editorwindow::~editorwindow() {
|
||||
|
||||
@@ -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<std::string> 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)";
|
||||
|
||||
@@ -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<std::string> 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);
|
||||
|
||||
Reference in New Issue
Block a user