summaryrefslogtreecommitdiff
path: root/src/bookmouse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmouse.cpp')
-rw-r--r--src/bookmouse.cpp83
1 files changed, 10 insertions, 73 deletions
diff --git a/src/bookmouse.cpp b/src/bookmouse.cpp
index 2e13b4e..d367af1 100644
--- a/src/bookmouse.cpp
+++ b/src/bookmouse.cpp
@@ -107,9 +107,9 @@ void Bookmouse::updateState()
// m_imgui.getIO().AddKeyEvent()
- if (ImGui::IsKeyPressed(ImGuiKey_O) && m_imgui.getIO().KeyCtrl && !m_openDialog) {
- m_openDialog = true;
- }
+ // if (ImGui::IsKeyPressed(ImGuiKey_O) && m_imgui.getIO().KeyCtrl && !m_openDialog) {
+ // m_openDialog = true;
+ // }
if (ImMenuBar menuBar{}) {
IM_ASSERT(menuBar);
@@ -176,83 +176,20 @@ void Bookmouse::openDialog()
ImGui::CloseCurrentPopup();
}
}
-}
-
-void Bookmouse::openDialog2()
-{
- if (m_getContents) {
- m_getContents = false;
-
- m_directoryName = fud::String{"./"};
- m_directory = fud::Directory{m_directoryName};
-
- auto directoryStatsResult = m_directory.info();
- if (directoryStatsResult.isError()) {
- m_openDialog = false;
- ImGui::CloseCurrentPopup();
- }
- auto directoryStats = directoryStatsResult.getOkay();
- size_t count{0};
- m_directoryContents.reserve(directoryStats.links);
+ auto result = m_fileDialog->pickFiles();
- while (true && count < SIZE_MAX) {
- auto dirEntryResult = m_directory.getNextEntry();
- if (dirEntryResult.isError()) {
- break;
- }
-
- auto dirEntryOpt = dirEntryResult.getOkay();
- if (dirEntryOpt == std::nullopt) {
- break;
- }
-
- if (dirEntryOpt->inode == directoryStats.inode) {
- continue;
- }
-
- m_directoryContents.emplace_back(std::move(*dirEntryOpt));
- auto status = m_directoryContents.back().formatTime(m_timeFormat);
- if (status != FudStatus::Success) {
- spdlog::error("Could not convert time: {}", fud::FudStatusToString(status));
- }
+ if (result != std::nullopt) {
+ auto selectedFiles = *result;
+ for (const auto& name : selectedFiles) {
+ spdlog::info("Selected {}", name.c_str());
}
- }
-
- ImText("%s %zu", m_directory.name().c_str(), m_directoryContents.size());
- if (ImTable table{"Entries", 4, ImGuiTableFlags_Borders}) {
- auto colFlags = ImGuiSelectableFlags_NoAutoClosePopups;
- IM_ASSERT(table);
- ImNextColumn();
- ImSelectable("T", &m_typeSelected, colFlags);
- ImNextColumn();
- ImSelectable("Name", &m_nameSelectede, colFlags);
- ImNextColumn();
- ImSelectable("Size", &m_sizeSelected, colFlags);
- ImNextColumn();
- ImSelectable("Date", &m_dateSelected, colFlags);
- for (auto& entry : m_directoryContents) {
- ImNextRow();
- const char entryLetter = DirEntryTypeToChar(entry.entryType);
- ImNextColumn();
- ImText("%c", entryLetter);
- ImNextColumn();
- ImSelectable(entry.name.c_str(), &entry.selected, colFlags | ImGuiSelectableFlags_SpanAllColumns);
- ImNextColumn();
- ImText("%zu\n", entry.isDirectory() ? entry.links : entry.size);
- ImNextColumn();
- ImText("%s", entry.niceTime.c_str());
- }
- }
-
- if (ImButton("Accept")) {
m_openDialog = false;
ImGui::CloseCurrentPopup();
+ return;
}
- ImSameLine();
-
- if (ImButton("Cancel")) {
+ if (m_fileDialog->canceled()) {
m_openDialog = false;
ImGui::CloseCurrentPopup();
}