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

@@ -2101,6 +2101,8 @@ QINFO_PIXELSHIFT;Pixel Shift / %2 frame(s)
QUEUE_AUTOSTART;Auto-start
QUEUE_AUTOSTART_TOOLTIP;Start processing automatically when a new job arrives.
QUEUE_DESTFILENAME;Path and file name
QUEUE_DESTPREVIEW_TITLE;Select a thumbnail to preview its destination path here
QUEUE_DESTPREVIEW_TOOLTIP;Destination path for the first selected image appears here
QUEUE_FORMAT_TITLE;File Format
QUEUE_LOCATION_FOLDER;Save to folder
QUEUE_LOCATION_TEMPLATE;Use template

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();
}

View File

@@ -38,6 +38,7 @@ public:
virtual ~BatchQueueListener() = default;
virtual void queueSizeChanged(int qsize, bool queueRunning, bool queueError, const Glib::ustring& queueErrorMessage) = 0;
virtual bool canStartNext() = 0;
virtual void setDestinationPreviewText(const Glib::ustring& destinationPath) = 0;
};
class FileCatalog;
@@ -59,6 +60,7 @@ public:
void selectAll ();
void openItemInEditor(ThumbBrowserEntryBase* item);
void openLastSelectedItemInEditor();
void updateDestinationPathPreview();
void startProcessing ();
@@ -79,6 +81,7 @@ public:
bool keyPressed (GdkEventKey* event) override;
void buttonPressed (LWButton* button, int actionCode, void* actionData) override;
void redrawNeeded (LWButton* button) override;
void selectionChanged () override;
void setBatchQueueListener (BatchQueueListener* l)
{

View File

@@ -108,6 +108,9 @@ BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog) : parent(nullptr)
#endif
odvb->pack_start (*hb3, Gtk::PACK_SHRINK, 4);
destinationPreviewLabel = Gtk::manage (new Gtk::Label ());
destinationPreviewLabel->set_tooltip_markup(M("QUEUE_DESTPREVIEW_TOOLTIP"));
odvb->pack_start (*destinationPreviewLabel);
Gtk::RadioButton::Group g = useTemplate->get_group();
useFolder->set_group (g);
fdir->add (*odvb);
@@ -122,6 +125,7 @@ BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog) : parent(nullptr)
outdirTemplate->set_text (options.savePathTemplate);
useTemplate->set_active (options.saveUsePathTemplate);
useFolder->set_active (!options.saveUsePathTemplate);
destinationPreviewLabel->set_text (M("QUEUE_DESTPREVIEW_TITLE"));
// setup signal handlers
outdirTemplate->signal_changed().connect (sigc::mem_fun(*this, &BatchQueuePanel::saveOptions));
@@ -329,6 +333,7 @@ void BatchQueuePanel::saveOptions ()
options.savePathTemplate = outdirTemplate->get_text();
options.saveUsePathTemplate = useTemplate->get_active();
options.procQueueEnabled = qAutoStart->get_active();
batchQueue->updateDestinationPathPreview();
}
bool BatchQueuePanel::handleShortcutKey (GdkEventKey* event)
@@ -358,6 +363,11 @@ bool BatchQueuePanel::canStartNext ()
return queueShouldRun;
}
void BatchQueuePanel::setDestinationPreviewText(const Glib::ustring &destinationPath)
{
destinationPreviewLabel->set_text(destinationPath);
}
void BatchQueuePanel::pathFolderButtonPressed ()
{
@@ -381,6 +391,7 @@ void BatchQueuePanel::pathFolderButtonPressed ()
void BatchQueuePanel::pathFolderChanged ()
{
options.savePathFolder = outdirFolder->get_filename();
batchQueue->updateDestinationPathPreview();
}
void BatchQueuePanel::formatChanged(const Glib::ustring& format)

View File

@@ -42,6 +42,7 @@ class BatchQueuePanel : public Gtk::Box,
Gtk::CheckButton* qAutoStart;
Gtk::Entry* outdirTemplate;
Gtk::Label* destinationPreviewLabel;
MyFileChooserButton* outdirFolder;
Gtk::Button* outdirFolderButton;
Gtk::RadioButton* useTemplate;
@@ -72,6 +73,7 @@ public:
// batchqueuelistener interface
void queueSizeChanged(int qsize, bool queueRunning, bool queueError, const Glib::ustring& queueErrorMessage) override;
bool canStartNext() override;
void setDestinationPreviewText(const Glib::ustring& destinationPath) override;
private:
void startBatchProc ();