mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 13:04:37 +03:00
add flag_reorder
This commit is contained in:
@@ -81,6 +81,58 @@ namespace NekoGui {
|
|||||||
defaultGroup->name = QObject::tr("Default");
|
defaultGroup->name = QObject::tr("Default");
|
||||||
NekoGui::profileManager->AddGroup(defaultGroup);
|
NekoGui::profileManager->AddGroup(defaultGroup);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
if (dataStore->flag_reorder) {
|
||||||
|
{
|
||||||
|
// remove all (contains orphan)
|
||||||
|
for (const auto &profile: profiles) {
|
||||||
|
QFile::remove(profile.second->fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::map<int, int> gidOld2New;
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int ii = 0;
|
||||||
|
QList<int> newProfilesIdOrder;
|
||||||
|
std::map<int, std::shared_ptr<ProxyEntity>> newProfiles;
|
||||||
|
for (auto gid: groupsTabOrder) {
|
||||||
|
auto group = GetGroup(gid);
|
||||||
|
gidOld2New[gid] = ii++;
|
||||||
|
for (auto const &profile: group->ProfilesWithOrder()) {
|
||||||
|
auto oldId = profile->id;
|
||||||
|
auto newId = i++;
|
||||||
|
profile->id = newId;
|
||||||
|
profile->gid = gidOld2New[gid];
|
||||||
|
profile->fn = QString("profiles/%1.json").arg(newId);
|
||||||
|
profile->Save();
|
||||||
|
newProfiles[newId] = profile;
|
||||||
|
newProfilesIdOrder << newId;
|
||||||
|
}
|
||||||
|
group->order = {};
|
||||||
|
group->Save();
|
||||||
|
}
|
||||||
|
profiles = newProfiles;
|
||||||
|
profilesIdOrder = newProfilesIdOrder;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QList<int> newGroupsIdOrder;
|
||||||
|
std::map<int, std::shared_ptr<Group>> newGroups;
|
||||||
|
for (auto oldGid: groupsTabOrder) {
|
||||||
|
auto newId = gidOld2New[oldGid];
|
||||||
|
auto group = groups[oldGid];
|
||||||
|
QFile::remove(group->fn);
|
||||||
|
group->id = newId;
|
||||||
|
group->fn = QString("groups/%1.json").arg(newId);
|
||||||
|
group->Save();
|
||||||
|
newGroups[newId] = group;
|
||||||
|
newGroupsIdOrder << newId;
|
||||||
|
}
|
||||||
|
groups = newGroups;
|
||||||
|
groupsIdOrder = newGroupsIdOrder;
|
||||||
|
groupsTabOrder = newGroupsIdOrder;
|
||||||
|
}
|
||||||
|
MessageBoxInfo(software_name, "Profiles and groups reorder complete.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileManager::SaveManager() {
|
void ProfileManager::SaveManager() {
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ namespace NekoGui {
|
|||||||
bool flag_debug = false;
|
bool flag_debug = false;
|
||||||
bool flag_linux_run_core_as_admin = false;
|
bool flag_linux_run_core_as_admin = false;
|
||||||
bool flag_restart_tun_on = false;
|
bool flag_restart_tun_on = false;
|
||||||
|
bool flag_reorder = false;
|
||||||
|
|
||||||
// Saved
|
// Saved
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ int main(int argc, char* argv[]) {
|
|||||||
if (NekoGui::dataStore->argv.contains("-debug")) NekoGui::dataStore->flag_debug = true;
|
if (NekoGui::dataStore->argv.contains("-debug")) NekoGui::dataStore->flag_debug = true;
|
||||||
if (NekoGui::dataStore->argv.contains("-flag_linux_run_core_as_admin")) NekoGui::dataStore->flag_linux_run_core_as_admin = true;
|
if (NekoGui::dataStore->argv.contains("-flag_linux_run_core_as_admin")) NekoGui::dataStore->flag_linux_run_core_as_admin = true;
|
||||||
if (NekoGui::dataStore->argv.contains("-flag_restart_tun_on")) NekoGui::dataStore->flag_restart_tun_on = true;
|
if (NekoGui::dataStore->argv.contains("-flag_restart_tun_on")) NekoGui::dataStore->flag_restart_tun_on = true;
|
||||||
|
if (NekoGui::dataStore->argv.contains("-flag_reorder")) NekoGui::dataStore->flag_reorder = true;
|
||||||
#ifdef NKR_CPP_USE_APPDATA
|
#ifdef NKR_CPP_USE_APPDATA
|
||||||
NekoGui::dataStore->flag_use_appdata = true; // Example: Package & MacOS
|
NekoGui::dataStore->flag_use_appdata = true; // Example: Package & MacOS
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user