Add destination path preview label to batch queue panel.

Label initially says "Destination path for the first selected image appears here"
so the feature is discoverable. Select a file and it shows the destination path
that would be used if it is the first file to be processed and the file does
not already exist. Label is updated as the template is edited, so you can see the
effect of the edits. If "Save to folder" is selected, the previewed path uses
that folder.
This commit is contained in:
Scott Gilbertson
2024-01-06 16:00:19 -05:00
parent 255a0c7086
commit 380d964077
5 changed files with 58 additions and 0 deletions

View File

@@ -567,6 +567,41 @@ void BatchQueue::openLastSelectedItemInEditor()
}
}
void BatchQueue::updateDestinationPathPreview()
{
MYWRITERLOCK(l, entryRW);
if (selected.size())
{
auto &entry = *selected.at(0);
int sequence = 0; // Sequence during subsequent queue processing can't be determined here
Glib::ustring baseDestination;
if (options.saveUsePathTemplate)
{
baseDestination = calcAutoFileNameBase(entry.filename, sequence);
}
else
{
Glib::ustring baseFilename;
int extpos = entry.filename.size() - 1;
for (; extpos >= 0 && entry.filename[extpos] != '.'; extpos--)
{
}
for (int k = extpos - 1; k >= 0 && entry.filename[k] != '/' && entry.filename[k] != '\\'; k--)
{
baseFilename = entry.filename[k] + baseFilename;
}
baseDestination = options.savePathFolder + '/' + baseFilename;
}
Glib::ustring destination = Glib::ustring::compose ("%1.%2", baseDestination, options.saveFormatBatch.format);
if (listener)
{
listener->setDestinationPreviewText(destination);
}
}
}
void BatchQueue::openItemInEditor(ThumbBrowserEntryBase* item)
{
if (item) {
@@ -1021,3 +1056,8 @@ void BatchQueue::redrawNeeded (LWButton* button)
GThreadLock lock;
queue_draw ();
}
void BatchQueue::selectionChanged()
{
updateDestinationPathPreview();
}