Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions include/utility/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ struct skiv_image_directory_s {
struct fl_s {
fd_s* getActiveFile (void)
{
return (_ptr != nullptr) ? _ptr : nullptr;
return _it._Ptr;
}

std::vector<fd_s> getList (void)
Expand All @@ -376,15 +376,20 @@ struct skiv_image_directory_s {
void setList (std::vector<fd_s> list)
{
_list = std::move(list);
_it = _list.begin();
_ptr = _it._Ptr;

if (_list.empty())
_list.push_back({ L"", L"", WIN32_FIND_DATA { } });

_it = _list.begin();
}

void clear (void)
{
_list.clear();
_it = _list.begin();
_ptr = nullptr;

_list.push_back({ L"", L"", WIN32_FIND_DATA { } });

_it = _list.begin();
}

bool empty (void)
Expand All @@ -403,7 +408,6 @@ struct skiv_image_directory_s {
private:
std::vector<fd_s> _list;
std::vector<fd_s>::iterator _it;
fd_s* _ptr;
} fileList;

//std::wstring orig_path; // Holds a cached copy of cover.path
Expand Down
8 changes: 4 additions & 4 deletions src/tabs/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2965,11 +2965,11 @@ SKIF_UI_Tab_DrawViewer (void)
}

// Identify when the folder was changed outside of the app
//PLOG_VERBOSE << "_current_folder.watch was signaled! Delay checking the folder for another 5000 ms...";
//PLOG_VERBOSE << "_current_folder.watch was signaled! Delay checking the folder for another 500 ms...";
if (_current_folder.watch.isSignaled (_current_folder.folder_path))
dwLastSignaled = SKIF_Util_timeGetTime();

if (dwLastSignaled != 0 && dwLastSignaled + 5000 < SKIF_Util_timeGetTime())
if (dwLastSignaled != 0 && dwLastSignaled + 500 < SKIF_Util_timeGetTime())
{
if (! _current_folder.fileList.fileDeleted)
_current_folder.workerThread (true);
Expand All @@ -2988,7 +2988,7 @@ SKIF_UI_Tab_DrawViewer (void)
PLOG_VERBOSE << "_current_folder.fileList.getActiveFile(): " << _current_folder.fileList.getActiveFile()->path;

// If the selected file was changed from within _current_folder, also update dragDroppedFilePath
if (_current_folder.fileList.getActiveFile() != nullptr &&
if (! _current_folder.fileList.getActiveFile()->path.empty() &&
cover.file_info.filename != _current_folder.fileList.getActiveFile()->filename)
dragDroppedFilePath = _current_folder.fileList.getActiveFile()->path;

Expand All @@ -3000,7 +3000,7 @@ SKIF_UI_Tab_DrawViewer (void)
// Only apply changes to the scaling method if we actually have an image loaded
if (cover.pRawTexSRV.p != nullptr)
{
if (_current_folder.fileList.getActiveFile() != nullptr && ! _current_folder.fileList.getActiveFile()->path.empty() &&
if (! _current_folder.fileList.getActiveFile()->path.empty() &&
ImGui::GetKeyData (ImGuiKey_Delete)->DownDuration == 0.0f) // Delete - Delete the opened image
_DeleteImage ();

Expand Down
17 changes: 6 additions & 11 deletions src/utility/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4048,11 +4048,12 @@ skiv_image_directory_s::reset (void)
void
skiv_image_directory_s::fl_s::setImage (const std::wstring& path)
{
_it = _list.begin();

if (_list.empty())
return;

_it = std::find_if (_list.begin(), _list.end(), [&](const fd_s& file) { return file.path == path; });
_ptr = _it._Ptr;
_it = std::find_if (_list.begin(), _list.end(), [&](const fd_s& file) { return file.path == path; });
}

std::wstring
Expand All @@ -4074,7 +4075,6 @@ skiv_image_directory_s::fl_s::nextImage (void)
else
std::advance (_it, 1);

_ptr = _it._Ptr;
return _it->path;
}

Expand All @@ -4097,7 +4097,6 @@ skiv_image_directory_s::fl_s::prevImage (void)
else
std::advance (_it, -1);

_ptr = _it._Ptr;
return _it->path;
}

Expand All @@ -4115,23 +4114,19 @@ skiv_image_directory_s::fl_s::deleteImage (void)
if (_it->path.empty() && ! _list.empty())
prevImage();

_ptr = _it._Ptr;

return _it->path;
}

// Find the position of the image in the current folder
void
skiv_image_directory_s::fl_s::updateFileIterator (const std::wstring& path)
{
_it = std::find_if (_list.begin(), _list.end(), [&](const fd_s& file) { return file.path == path; });

// If the file was removed from File Explorer, reset to first item
// TODO: Fix proper file tracking so we can detect removed files and just go to one of the nearby ones
if (_it->path.empty() && ! _list.empty())
_it = _list.begin();
_it = std::find_if (_list.begin(), _list.end(), [&](const fd_s& file) { return file.path == path; });

_ptr = _it._Ptr;
if (_it == _list.end())
_it = _list.begin();
}

int
Expand Down
Loading