- allow to favorite a project and auto load it
- added menu button to exit to project selection - re ordered settings tabs
This commit is contained in:
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
|
|||||||
noggit->initalize(argc, argv, Command);
|
noggit->initalize(argc, argv, Command);
|
||||||
|
|
||||||
auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit);
|
auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit);
|
||||||
project_selection->show();
|
// project_selection->show();
|
||||||
|
|
||||||
return q_application.exec();
|
return q_application.exec();
|
||||||
}
|
}
|
||||||
@@ -140,8 +140,6 @@ namespace Noggit::Application
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
LogError << "std::terminate: " << reason << std::endl;
|
LogError << "std::terminate: " << reason << std::endl;
|
||||||
|
|
||||||
CloseLogging();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NoggitApplication::GetCommand(int index)
|
bool NoggitApplication::GetCommand(int index)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace Noggit::Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlizzardArchive::ClientData* clientData() { return _client_data.get(); }
|
BlizzardArchive::ClientData* clientData() { return _client_data.get(); }
|
||||||
|
bool hasClientData() { return _client_data != nullptr; }
|
||||||
void setClientData(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[], std::vector<bool> Parser);
|
void initalize(int argc, char* argv[], std::vector<bool> Parser);
|
||||||
|
|||||||
@@ -117,6 +117,16 @@ namespace Noggit::Ui::Windows
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
auto proj_selec_action(file_menu->addAction("Exit to Project Selection"));
|
||||||
|
QObject::connect(proj_selec_action, &QAction::triggered, [this]
|
||||||
|
{
|
||||||
|
auto noggit = Noggit::Application::NoggitApplication::instance();
|
||||||
|
auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit);
|
||||||
|
project_selection->show();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
_menuBar->adjustSize();
|
_menuBar->adjustSize();
|
||||||
|
|
||||||
_buildMapListComponent = std::make_unique<Component::BuildMapListComponent>();
|
_buildMapListComponent = std::make_unique<Component::BuildMapListComponent>();
|
||||||
|
|||||||
@@ -23,6 +23,73 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application::
|
|||||||
{
|
{
|
||||||
setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint);
|
setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint);
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// auto load favorite project
|
||||||
|
QSettings settings;
|
||||||
|
int favorite_proj_idx = settings.value("favorite_project", -1).toInt();
|
||||||
|
|
||||||
|
bool load_favorite = settings.value("auto_load_fav_project", true).toBool();
|
||||||
|
|
||||||
|
// if it has client data, it means it already loaded before and we exited through the menu, skip autoloading favorite
|
||||||
|
if (noggit_app->hasClientData())
|
||||||
|
load_favorite = false;
|
||||||
|
|
||||||
|
if (load_favorite && favorite_proj_idx != -1)
|
||||||
|
{
|
||||||
|
Log << "Auto loading favorite project index : " << favorite_proj_idx << std::endl;
|
||||||
|
|
||||||
|
int size = settings.beginReadArray("recent_projects");
|
||||||
|
|
||||||
|
QString project_final_path;
|
||||||
|
|
||||||
|
// for (int i = 0; i < size; ++i)
|
||||||
|
if (size > favorite_proj_idx)
|
||||||
|
{
|
||||||
|
settings.setArrayIndex(favorite_proj_idx);
|
||||||
|
std::filesystem::path project_path = settings.value("project_path").toString().toStdString().c_str();
|
||||||
|
|
||||||
|
if (std::filesystem::exists(project_path) && std::filesystem::is_directory(project_path))
|
||||||
|
{
|
||||||
|
auto project_reader = Noggit::Project::ApplicationProjectReader();
|
||||||
|
|
||||||
|
auto project = project_reader.readProject(project_path);
|
||||||
|
|
||||||
|
if (project.has_value())
|
||||||
|
{
|
||||||
|
// project->projectVersion;
|
||||||
|
// project_directory = QString::fromStdString(project_path.generic_string());
|
||||||
|
// auto project_name = QString::fromStdString(project->ProjectName);
|
||||||
|
|
||||||
|
project_final_path = QString(project_path.string().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.endArray();
|
||||||
|
|
||||||
|
if (!project_final_path.isEmpty())
|
||||||
|
{
|
||||||
|
auto selected_project = _load_project_component->loadProject(this, project_final_path);
|
||||||
|
|
||||||
|
if (!selected_project)
|
||||||
|
{
|
||||||
|
LogError << "Selected Project is null, favorite loading failed." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Noggit::Project::CurrentProject::initialize(selected_project.get());
|
||||||
|
|
||||||
|
_project_selection_page = std::make_unique<Noggit::Ui::Windows::NoggitWindow>(
|
||||||
|
_noggit_application->getConfiguration(),
|
||||||
|
selected_project);
|
||||||
|
_project_selection_page->showMaximized();
|
||||||
|
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///////////////////////////
|
||||||
|
|
||||||
_ui->setupUi(this);
|
_ui->setupUi(this);
|
||||||
|
|
||||||
_ui->label->setObjectName("title");
|
_ui->label->setObjectName("title");
|
||||||
@@ -70,6 +137,7 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application::
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Component::CreateProjectComponent::createProject(this, project_reference);
|
Component::CreateProjectComponent::createProject(this, project_reference);
|
||||||
|
resetFavoriteProject();
|
||||||
Component::RecentProjectsComponent::buildRecentProjectsList(this);
|
Component::RecentProjectsComponent::buildRecentProjectsList(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -163,7 +231,7 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application::
|
|||||||
});
|
});
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
auto _set = new QSettings(this);
|
// auto _set = new QSettings(this);
|
||||||
//auto first_changelog = _set->value("first_changelog", false);
|
//auto first_changelog = _set->value("first_changelog", false);
|
||||||
|
|
||||||
// force-changelog
|
// force-changelog
|
||||||
@@ -178,7 +246,7 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application::
|
|||||||
_set->sync();
|
_set->sync();
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoggitProjectSelectionWindow::handleContextMenuProjectListItemDelete(std::string const& project_path)
|
void NoggitProjectSelectionWindow::handleContextMenuProjectListItemDelete(std::string const& project_path)
|
||||||
@@ -208,6 +276,7 @@ void NoggitProjectSelectionWindow::handleContextMenuProjectListItemDelete(std::s
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
resetFavoriteProject();
|
||||||
|
|
||||||
Component::RecentProjectsComponent::buildRecentProjectsList(this);
|
Component::RecentProjectsComponent::buildRecentProjectsList(this);
|
||||||
}
|
}
|
||||||
@@ -236,9 +305,25 @@ void NoggitProjectSelectionWindow::handleContextMenuProjectListItemForget(std::s
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetFavoriteProject();
|
||||||
Component::RecentProjectsComponent::buildRecentProjectsList(this);
|
Component::RecentProjectsComponent::buildRecentProjectsList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Noggit::Ui::Windows::NoggitProjectSelectionWindow::handleContextMenuProjectListItemFavorite(int index)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.sync();
|
||||||
|
settings.setValue("favorite_project", index);
|
||||||
|
Component::RecentProjectsComponent::buildRecentProjectsList(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Noggit::Ui::Windows::NoggitProjectSelectionWindow::resetFavoriteProject()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.sync();
|
||||||
|
settings.setValue("favorite_project", -1);
|
||||||
|
}
|
||||||
|
|
||||||
NoggitProjectSelectionWindow::~NoggitProjectSelectionWindow()
|
NoggitProjectSelectionWindow::~NoggitProjectSelectionWindow()
|
||||||
{
|
{
|
||||||
delete _ui;
|
delete _ui;
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ namespace Noggit::Ui::Windows
|
|||||||
|
|
||||||
void handleContextMenuProjectListItemDelete(std::string const& project_path);
|
void handleContextMenuProjectListItemDelete(std::string const& project_path);
|
||||||
void handleContextMenuProjectListItemForget(std::string const& project_path);
|
void handleContextMenuProjectListItemForget(std::string const& project_path);
|
||||||
|
void handleContextMenuProjectListItemFavorite(int index);
|
||||||
|
|
||||||
|
void resetFavoriteProject();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // NOGGITREDPROJECTPAGE_H
|
#endif // NOGGITREDPROJECTPAGE_H
|
||||||
@@ -21,12 +21,22 @@ namespace Noggit::Ui::Component
|
|||||||
friend Windows::NoggitProjectSelectionWindow;
|
friend Windows::NoggitProjectSelectionWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Project::NoggitProject> loadProject(Noggit::Ui::Windows::NoggitProjectSelectionWindow* parent)
|
std::shared_ptr<Project::NoggitProject> loadProject(Noggit::Ui::Windows::NoggitProjectSelectionWindow* parent, QString force_project_path = "")
|
||||||
{
|
{
|
||||||
QModelIndex index = parent->_ui->listView->currentIndex();
|
QString project_path;
|
||||||
|
|
||||||
|
if (!force_project_path.isEmpty())
|
||||||
|
project_path = force_project_path;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QModelIndex index = parent->_ui->listView->currentIndex();
|
||||||
|
project_path = index.data(Qt::UserRole).toString();
|
||||||
|
}
|
||||||
|
|
||||||
auto application_configuration = parent->_noggit_application->getConfiguration();
|
auto application_configuration = parent->_noggit_application->getConfiguration();
|
||||||
auto application_projects_folder_path = std::filesystem::path(application_configuration->ApplicationProjectPath);
|
// auto application_projects_folder_path = std::filesystem::path(application_configuration->ApplicationProjectPath);
|
||||||
QString project_path = index.data(Qt::UserRole).toString();
|
|
||||||
|
|
||||||
auto application_project_service = Noggit::Project::ApplicationProject(application_configuration);
|
auto application_project_service = Noggit::Project::ApplicationProject(application_configuration);
|
||||||
|
|
||||||
if (!QDir(project_path).exists())
|
if (!QDir(project_path).exists())
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
using namespace Noggit::Ui::Component;
|
using namespace Noggit::Ui::Component;
|
||||||
|
|
||||||
@@ -13,9 +14,11 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi
|
|||||||
{
|
{
|
||||||
parent->_ui->listView->clear();
|
parent->_ui->listView->clear();
|
||||||
|
|
||||||
auto application_configuration = parent->_noggit_application->getConfiguration();
|
// auto application_configuration = parent->_noggit_application->getConfiguration();
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
settings.sync();
|
||||||
|
int favorite_proj_idx = settings.value("favorite_project", -1).toInt();
|
||||||
int size = settings.beginReadArray("recent_projects");
|
int size = settings.beginReadArray("recent_projects");
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
@@ -40,6 +43,7 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi
|
|||||||
project_data.project_directory = QString::fromStdString(project_path.generic_string());
|
project_data.project_directory = QString::fromStdString(project_path.generic_string());
|
||||||
project_data.project_name = QString::fromStdString(project->ProjectName);
|
project_data.project_name = QString::fromStdString(project->ProjectName);
|
||||||
project_data.project_last_edited = QDateTime::currentDateTime().date().toString();
|
project_data.project_last_edited = QDateTime::currentDateTime().date().toString();
|
||||||
|
project_data.is_favorite = favorite_proj_idx == i ? true : false;
|
||||||
|
|
||||||
auto project_list_item = new Noggit::Ui::Widget::ProjectListItem(project_data, parent->_ui->listView);
|
auto project_list_item = new Noggit::Ui::Widget::ProjectListItem(project_data, parent->_ui->listView);
|
||||||
|
|
||||||
@@ -93,6 +97,48 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi
|
|||||||
});
|
});
|
||||||
|
|
||||||
context_menu.addAction(&action_4);
|
context_menu.addAction(&action_4);
|
||||||
|
|
||||||
|
// if (!project_data.is_favorite)
|
||||||
|
QAction action_5("Favorite Project(auto load)", project_list_item);
|
||||||
|
auto fav_icon = QIcon();
|
||||||
|
fav_icon.addPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16)));
|
||||||
|
action_5.setIcon(fav_icon);
|
||||||
|
|
||||||
|
if (project_data.is_favorite)
|
||||||
|
action_5.setText("Unfavorite Project");
|
||||||
|
|
||||||
|
QObject::connect(&action_5, &QAction::triggered, [=]()
|
||||||
|
{
|
||||||
|
if (!project_data.is_favorite)
|
||||||
|
parent->handleContextMenuProjectListItemFavorite(i);
|
||||||
|
else
|
||||||
|
parent->handleContextMenuProjectListItemFavorite(-1);
|
||||||
|
// QSettings settings;
|
||||||
|
// if (!project_data.is_favorite)
|
||||||
|
// settings.setValue("favorite_project", i);
|
||||||
|
// else
|
||||||
|
// settings.setValue("favorite_project", -1);
|
||||||
|
// buildRecentProjectsList(parent);
|
||||||
|
});
|
||||||
|
context_menu.addAction(&action_5);
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// QAction action_6("Unfavorite Project", project_list_item);
|
||||||
|
// auto fav_icon = QIcon();
|
||||||
|
// fav_icon.addPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16)));
|
||||||
|
// action_6.setIcon(fav_icon);
|
||||||
|
//
|
||||||
|
// QObject::connect(&action_6, &QAction::triggered, [=]()
|
||||||
|
// {
|
||||||
|
// // TODO
|
||||||
|
// // parent->handleContextMenuProjectListItemFavorite();
|
||||||
|
// QSettings settings;
|
||||||
|
// settings.setValue("favorite_project", -1);
|
||||||
|
// // project_data.is_favorite = false;
|
||||||
|
// });
|
||||||
|
// context_menu.addAction(&action_6);
|
||||||
|
// }
|
||||||
|
|
||||||
/////
|
/////
|
||||||
context_menu.exec(project_list_item->mapToGlobal(pos));
|
context_menu.exec(project_list_item->mapToGlobal(pos));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace Noggit::Ui::Widget
|
|||||||
_project_directory_label->setGeometry(48, 20, max_width, 20);
|
_project_directory_label->setGeometry(48, 20, max_width, 20);
|
||||||
_project_directory_label->setObjectName("project-information");
|
_project_directory_label->setObjectName("project-information");
|
||||||
_project_directory_label->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
_project_directory_label->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
||||||
|
_project_directory_label->setToolTip(data.project_directory);
|
||||||
|
|
||||||
auto directory_effect = new QGraphicsOpacityEffect(this);
|
auto directory_effect = new QGraphicsOpacityEffect(this);
|
||||||
directory_effect->setOpacity(0.5);
|
directory_effect->setOpacity(0.5);
|
||||||
@@ -64,6 +65,25 @@ namespace Noggit::Ui::Widget
|
|||||||
_project_last_edited_label->setGraphicsEffect(last_edited_effect);
|
_project_last_edited_label->setGraphicsEffect(last_edited_effect);
|
||||||
_project_last_edited_label->setAutoFillBackground(true);
|
_project_last_edited_label->setAutoFillBackground(true);
|
||||||
|
|
||||||
|
if (data.is_favorite)
|
||||||
|
{
|
||||||
|
_project_favorite_icon = new QLabel("", this);
|
||||||
|
_project_favorite_icon->setPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16)));
|
||||||
|
_project_favorite_icon->setGeometry(max_width-10, 10, 125, 20);
|
||||||
|
_project_favorite_icon->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||||
|
_project_favorite_icon->setObjectName("project-favorite");
|
||||||
|
_project_favorite_icon->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
||||||
|
|
||||||
|
auto colour = new QGraphicsColorizeEffect(this);
|
||||||
|
colour->setColor(QColor(255, 204, 0));
|
||||||
|
colour->setStrength(1.0f);
|
||||||
|
|
||||||
|
_project_favorite_icon->setGraphicsEffect(colour);
|
||||||
|
_project_favorite_icon->setAutoFillBackground(true);
|
||||||
|
|
||||||
|
layout.addWidget(_project_favorite_icon);
|
||||||
|
}
|
||||||
|
|
||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
layout.addWidget(_project_version_icon);
|
layout.addWidget(_project_version_icon);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace Noggit::Ui::Widget
|
|||||||
QString project_directory;
|
QString project_directory;
|
||||||
QString project_last_edited;
|
QString project_last_edited;
|
||||||
Project::ProjectVersion project_version;
|
Project::ProjectVersion project_version;
|
||||||
|
bool is_favorite;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProjectListItem : public QWidget
|
class ProjectListItem : public QWidget
|
||||||
@@ -28,6 +29,7 @@ namespace Noggit::Ui::Widget
|
|||||||
QLabel* _project_directory_label;
|
QLabel* _project_directory_label;
|
||||||
QLabel* _project_version_label;
|
QLabel* _project_version_label;
|
||||||
QLabel* _project_last_edited_label;
|
QLabel* _project_last_edited_label;
|
||||||
|
QLabel* _project_favorite_icon;
|
||||||
public:
|
public:
|
||||||
ProjectListItem(const ProjectListItemData& data, QWidget* parent);
|
ProjectListItem(const ProjectListItemData& data, QWidget* parent);
|
||||||
QSize minimumSizeHint() const override;
|
QSize minimumSizeHint() const override;
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ namespace Noggit
|
|||||||
ui->_adt_unload_dist->setValue(_settings->value("unload_dist", 5).toInt());
|
ui->_adt_unload_dist->setValue(_settings->value("unload_dist", 5).toInt());
|
||||||
ui->_adt_unload_check_interval->setValue(_settings->value("unload_interval", 5).toInt());
|
ui->_adt_unload_check_interval->setValue(_settings->value("unload_interval", 5).toInt());
|
||||||
ui->_uid_cb->setChecked(_settings->value("uid_startup_check", true).toBool());
|
ui->_uid_cb->setChecked(_settings->value("uid_startup_check", true).toBool());
|
||||||
|
ui->_load_fav_cb->setChecked(_settings->value("auto_load_fav_project", true).toBool());
|
||||||
ui->_systemWindowFrame->setChecked(_settings->value("systemWindowFrame", true).toBool());
|
ui->_systemWindowFrame->setChecked(_settings->value("systemWindowFrame", true).toBool());
|
||||||
ui->_nativeMenubar->setChecked(_settings->value("nativeMenubar", true).toBool());
|
ui->_nativeMenubar->setChecked(_settings->value("nativeMenubar", true).toBool());
|
||||||
ui->_classic_ui->setChecked(_settings->value("classicUI", false).toBool());
|
ui->_classic_ui->setChecked(_settings->value("classicUI", false).toBool());
|
||||||
@@ -275,6 +276,7 @@ namespace Noggit
|
|||||||
_settings->setValue("unload_dist", ui->_adt_unload_dist->value());
|
_settings->setValue("unload_dist", ui->_adt_unload_dist->value());
|
||||||
_settings->setValue("unload_interval", ui->_adt_unload_check_interval->value());
|
_settings->setValue("unload_interval", ui->_adt_unload_check_interval->value());
|
||||||
_settings->setValue("uid_startup_check", ui->_uid_cb->isChecked());
|
_settings->setValue("uid_startup_check", ui->_uid_cb->isChecked());
|
||||||
|
_settings->setValue("auto_load_fav_project", ui->_load_fav_cb->isChecked());
|
||||||
_settings->setValue("additional_file_loading_log", ui->_additional_file_loading_log->isChecked());
|
_settings->setValue("additional_file_loading_log", ui->_additional_file_loading_log->isChecked());
|
||||||
_settings->setValue("keyboard_locale", ui->_keyboard_locale->currentText());
|
_settings->setValue("keyboard_locale", ui->_keyboard_locale->currentText());
|
||||||
_settings->setValue("systemWindowFrame", ui->_systemWindowFrame->isChecked());
|
_settings->setValue("systemWindowFrame", ui->_systemWindowFrame->isChecked());
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user