Update ApplicationEntry.cpp, NoggitApplication.cpp, and 8 more files... | update project system
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Noggit::RegisterErrorHandlers();
|
||||
std::set_terminate(Noggit::Application::NoggitApplication::TerminationHandler);
|
||||
std::set_terminate(Noggit::Application::NoggitApplication::terminationHandler);
|
||||
|
||||
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
|
||||
qApplication.setOrganizationName ("Noggit");
|
||||
|
||||
auto noggit = Noggit::Application::NoggitApplication::instance();
|
||||
noggit->Initalize(argc, argv);
|
||||
noggit->initalize(argc, argv);
|
||||
|
||||
auto projectSelectionPage = std::make_unique<Noggit::Ui::Windows::NoggitProjectSelectionWindow>(noggit);
|
||||
projectSelectionPage->show();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace Noggit::Application
|
||||
{
|
||||
void NoggitApplication::Initalize(int argc, char* argv[])
|
||||
void NoggitApplication::initalize(int argc, char* argv[])
|
||||
{
|
||||
InitLogging();
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Noggit::Application
|
||||
LogDebug << "GL: Renderer: " << gl.getString(GL_RENDERER) << std::endl;
|
||||
|
||||
|
||||
_applicationConfiguration = std::make_shared<Noggit::Application::NoggitApplicationConfiguration>(applicationConfiguration);
|
||||
_application_configuration = std::make_shared<Noggit::Application::NoggitApplicationConfiguration>(applicationConfiguration);
|
||||
//All of the below should be Project Initalisation
|
||||
srand(::time(nullptr));
|
||||
|
||||
@@ -114,10 +114,10 @@ namespace Noggit::Application
|
||||
|
||||
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> NoggitApplication::getConfiguration()
|
||||
{
|
||||
return _applicationConfiguration;
|
||||
return _application_configuration;
|
||||
}
|
||||
|
||||
void NoggitApplication::TerminationHandler()
|
||||
void NoggitApplication::terminationHandler()
|
||||
{
|
||||
std::string const reason{ ::util::exception_to_string(std::current_exception()) };
|
||||
|
||||
|
||||
@@ -46,16 +46,16 @@ namespace Noggit::Application {
|
||||
}
|
||||
|
||||
BlizzardArchive::ClientData* clientData() { return _client_data.get(); }
|
||||
void clientData(std::shared_ptr<BlizzardArchive::ClientData> data) { _client_data = data; }
|
||||
void setClientData(std::shared_ptr<BlizzardArchive::ClientData> data) { _client_data = data; }
|
||||
|
||||
void Initalize(int argc, char* argv[]);
|
||||
void initalize(int argc, char* argv[]);
|
||||
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> getConfiguration();
|
||||
static void TerminationHandler();
|
||||
static void terminationHandler();
|
||||
private:
|
||||
NoggitApplication() = default;
|
||||
|
||||
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> _applicationConfiguration;
|
||||
std::unique_ptr<Noggit::Ui::Windows::NoggitProjectSelectionWindow> projectSelectionPage;
|
||||
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> _application_configuration;
|
||||
std::unique_ptr<Noggit::Ui::Windows::NoggitProjectSelectionWindow> _project_selection_page;
|
||||
std::shared_ptr<BlizzardArchive::ClientData> _client_data;
|
||||
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ NoggitProjectCreationDialog::NoggitProjectCreationDialog(ProjectInformation& pro
|
||||
QObject::connect(ui->projectPathField_browse, &QPushButton::clicked, [this]
|
||||
{
|
||||
QString folder_name = QFileDialog::getExistingDirectory(this
|
||||
, "Select Client Directory"
|
||||
, "Select Project Directory"
|
||||
, "/"
|
||||
, QFileDialog::ShowDirsOnly |
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
|
||||
@@ -48,7 +48,41 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application::
|
||||
|
||||
QObject::connect(_ui->button_open_existing_project, &QPushButton::clicked, [=]
|
||||
{
|
||||
return;
|
||||
auto project_reader = Noggit::Project::ApplicationProjectReader();
|
||||
|
||||
QString proj_file = QFileDialog::getOpenFileName(this, "Open File",
|
||||
"/",
|
||||
"Noggit Project (*.noggitproj");
|
||||
|
||||
if (proj_file.isEmpty())
|
||||
return;
|
||||
|
||||
std::filesystem::path filepath(proj_file.toStdString());
|
||||
|
||||
auto project = project_reader.ReadProject(filepath.parent_path());
|
||||
|
||||
if (!project.has_value())
|
||||
{
|
||||
QMessageBox::critical(this, "Error", "Failed to read project");
|
||||
return;
|
||||
}
|
||||
|
||||
Component::RecentProjectsComponent::registerProjectChange(filepath.parent_path());
|
||||
|
||||
auto application_configuration = _noggit_application->getConfiguration();
|
||||
auto application_projects_folder_path = std::filesystem::path(application_configuration->ApplicationProjectPath);
|
||||
auto application_project_service = Noggit::Project::ApplicationProject(application_configuration);
|
||||
auto project_to_launch = application_project_service.loadProject(filepath.parent_path());
|
||||
Noggit::Application::NoggitApplication::instance()->setClientData(project_to_launch->ClientData);
|
||||
|
||||
Noggit::Project::CurrentProject::initialize(project_to_launch.get());
|
||||
|
||||
_project_selection_page = std::make_unique<Noggit::Ui::Windows::NoggitWindow>(
|
||||
_noggit_application->getConfiguration(),
|
||||
project_to_launch);
|
||||
_project_selection_page->showMaximized();
|
||||
|
||||
close();
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -22,232 +22,226 @@
|
||||
</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>791</width>
|
||||
<height>419</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Recent Projects</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="button_convert_project">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Convert Project</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Getting Started</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="button_create_new_project">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create a new project</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="button_open_existing_project">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open an exsisting project</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Recent Projects</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="button_convert_project">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Convert Project</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Getting Started</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="button_create_new_project">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create a new project</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="button_open_existing_project">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open an exsisting project</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include "CreateProjectComponent.hpp"
|
||||
#include <QList>
|
||||
#include <noggit/ui/windows/projectSelection/components/RecentProjectsComponent.hpp>
|
||||
|
||||
using namespace Noggit::Ui::Component;
|
||||
|
||||
@@ -19,33 +19,7 @@ void CreateProjectComponent::createProject(Noggit::Ui::Windows::NoggitProjectSel
|
||||
project_information.GameClientVersion,
|
||||
project_information.ProjectName);
|
||||
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
|
||||
QList<QString> recent_projects;
|
||||
|
||||
std::size_t size = settings.beginReadArray("recent_projects");
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
recent_projects.append(settings.value("project_path").toString());
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
settings.beginWriteArray("recent_projects");
|
||||
|
||||
settings.setArrayIndex(0);
|
||||
settings.setValue("project_path", QString(project_information.ProjectPath.c_str()));
|
||||
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
settings.setArrayIndex(i + 1);
|
||||
settings.setValue("project_path", recent_projects[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
settings.sync();
|
||||
|
||||
RecentProjectsComponent::registerProjectChange(project_information.ProjectPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Noggit::Ui::Component
|
||||
auto project = application_project_service.loadProject(project_path);
|
||||
|
||||
//This to not be static, but its hard to remove
|
||||
Noggit::Application::NoggitApplication::instance()->clientData(project->ClientData);
|
||||
Noggit::Application::NoggitApplication::instance()->setClientData(project->ClientData);
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include "RecentProjectsComponent.hpp"
|
||||
|
||||
#include <QList>
|
||||
|
||||
|
||||
using namespace Noggit::Ui::Component;
|
||||
|
||||
|
||||
@@ -64,4 +67,45 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi
|
||||
}
|
||||
|
||||
settings.endArray();
|
||||
}
|
||||
}
|
||||
|
||||
void RecentProjectsComponent::registerProjectChange(std::string const& project_path)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
|
||||
QList<QString> recent_projects;
|
||||
|
||||
std::size_t size = settings.beginReadArray("recent_projects");
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
recent_projects.append(settings.value("project_path").toString());
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
// remove duplicates
|
||||
auto it = std::find(recent_projects.begin(), recent_projects.end(), project_path.c_str());
|
||||
|
||||
if (it != recent_projects.end())
|
||||
{
|
||||
recent_projects.erase(it);
|
||||
size--;
|
||||
}
|
||||
|
||||
settings.remove("recent_projects");
|
||||
settings.beginWriteArray("recent_projects");
|
||||
|
||||
settings.setArrayIndex(0);
|
||||
settings.setValue("project_path", QString(project_path.c_str()));
|
||||
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
settings.setArrayIndex(i + 1);
|
||||
settings.setValue("project_path", recent_projects[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
settings.sync();
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace Noggit::Ui::Component
|
||||
|
||||
public:
|
||||
static void buildRecentProjectsList(Noggit::Ui::Windows::NoggitProjectSelectionWindow* parent);
|
||||
static void registerProjectChange(std::string const& project_path);
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user