fix audo connection for sinks and add a try catch block for the file sorting
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
This commit is contained in:
@ -111,56 +111,60 @@ void FileSelector::render(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// do sorting here
|
||||
// TODO: cache the result (lol)
|
||||
if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); sorts_specs != nullptr && sorts_specs->SpecsCount >= 1) {
|
||||
switch (static_cast<SortID>(sorts_specs->Specs->ColumnUserID)) {
|
||||
break; case SortID::name:
|
||||
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path() < b.path();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path().filename() < b.path().filename();
|
||||
});
|
||||
} else {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path() > b.path();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path().filename() > b.path().filename();
|
||||
});
|
||||
}
|
||||
break; case SortID::size:
|
||||
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
|
||||
// TODO: sort dirs?
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.file_size() < b.file_size();
|
||||
});
|
||||
} else {
|
||||
// TODO: sort dirs?
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.file_size() > b.file_size();
|
||||
});
|
||||
}
|
||||
break; case SortID::date:
|
||||
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() < b.last_write_time();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() < b.last_write_time();
|
||||
});
|
||||
} else {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() > b.last_write_time();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() > b.last_write_time();
|
||||
});
|
||||
}
|
||||
break; default: ;
|
||||
try {
|
||||
// do sorting here
|
||||
// TODO: cache the result (lol)
|
||||
if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); sorts_specs != nullptr && sorts_specs->SpecsCount >= 1) {
|
||||
switch (static_cast<SortID>(sorts_specs->Specs->ColumnUserID)) {
|
||||
break; case SortID::name:
|
||||
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path() < b.path();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path().filename() < b.path().filename();
|
||||
});
|
||||
} else {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path() > b.path();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.path().filename() > b.path().filename();
|
||||
});
|
||||
}
|
||||
break; case SortID::size:
|
||||
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
|
||||
// TODO: sort dirs?
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.file_size() < b.file_size();
|
||||
});
|
||||
} else {
|
||||
// TODO: sort dirs?
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.file_size() > b.file_size();
|
||||
});
|
||||
}
|
||||
break; case SortID::date:
|
||||
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() < b.last_write_time();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() < b.last_write_time();
|
||||
});
|
||||
} else {
|
||||
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() > b.last_write_time();
|
||||
});
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.last_write_time() > b.last_write_time();
|
||||
});
|
||||
}
|
||||
break; default: ;
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
// we likely saw a file disapear
|
||||
}
|
||||
|
||||
for (auto const& dir_entry : dirs) {
|
||||
|
Reference in New Issue
Block a user