Queue state verbose, fixes #4058

Improvement to the Batch Queue:
- Start Queue/Stop Queue checkboxes replaced with one swith.
- It is now immediately clear whether the queue is running or not.
- The queue is visually stopped once it is empty.
- String keys fixed to use BATCHQUEUE_ prefix instead of FILEBROWSER_.
This commit is contained in:
Morgan Hardwood
2018-01-05 22:44:07 +01:00
parent ef4edc9b16
commit 888de585d4
32 changed files with 277 additions and 195 deletions

View File

@@ -46,29 +46,22 @@ BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog) : parent(nullptr)
batchQueue = Gtk::manage( new BatchQueue(aFileCatalog) );
// construct batch queue panel with the extra "start" and "stop" button
Gtk::VBox* batchQueueButtonBox = Gtk::manage (new Gtk::VBox);
batchQueueButtonBox->set_name("BatchQueueButtons");
start = Gtk::manage (new Gtk::ToggleButton ());
stop = Gtk::manage (new Gtk::ToggleButton ());
autoStart = Gtk::manage (new Gtk::CheckButton (M("BATCHQUEUE_AUTOSTART")));
start->set_tooltip_markup (M("FILEBROWSER_STARTPROCESSINGHINT"));
stop->set_tooltip_markup (M("FILEBROWSER_STOPPROCESSINGHINT"));
autoStart->set_tooltip_text (M("FILEBROWSER_TOOLTIP_STOPPROCESSING"));
start->set_active (false);
stop->set_active (true);
autoStart->set_active (options.procQueueEnabled);
qLbl = Gtk::manage (new Gtk::Label(M("MAIN_FRAME_BATCHQUEUE")));
start->set_image (*Gtk::manage (new RTImage ("gtk-media-play.png")));
start->get_style_context()->add_class("BIG");
startConnection = start->signal_toggled().connect (sigc::mem_fun(*this, &BatchQueuePanel::startBatchProc));
stop->set_image (*Gtk::manage (new RTImage ("gtk-media-stop.png")));
stop->get_style_context()->add_class("BIG");
stopConnection = stop->signal_toggled().connect (sigc::mem_fun(*this, &BatchQueuePanel::stopBatchProc));
batchQueueButtonBox->pack_start (*start, Gtk::PACK_SHRINK, 4);
batchQueueButtonBox->pack_start (*stop, Gtk::PACK_SHRINK, 4);
batchQueueButtonBox->pack_start (*autoStart, Gtk::PACK_SHRINK, 4);
qStartStop = Gtk::manage (new Gtk::Switch());
qStartStop->set_tooltip_markup (M("BATCHQUEUE_STARTSTOPHINT"));
qStartStopConn = qStartStop->property_active().signal_changed().connect (sigc::mem_fun(*this, &BatchQueuePanel::startOrStopBatchProc));
qAutoStart = Gtk::manage (new Gtk::CheckButton (M("BATCHQUEUE_AUTOSTART")));
qAutoStart->set_tooltip_text (M("BATCHQUEUE_AUTOSTARTHINT"));
qAutoStart->set_active (options.procQueueEnabled);
batchQueueButtonBox->pack_start (*qLbl, Gtk::PACK_SHRINK, 4);
batchQueueButtonBox->pack_start (*qStartStop, Gtk::PACK_SHRINK, 4);
batchQueueButtonBox->pack_start (*qAutoStart, Gtk::PACK_SHRINK, 4);
// Output directory selection
fdir = Gtk::manage (new Gtk::Frame (M("PREFERENCES_OUTDIR")));
@@ -216,7 +209,7 @@ void BatchQueuePanel::updateTab (int qsize, int forceOrientation)
if(!qsize ) {
grid->attach_next_to(*Gtk::manage (new RTImage ("processing.png")), Gtk::POS_TOP, 1, 1);
l = Gtk::manage (new Gtk::Label (Glib::ustring(" ") + M("MAIN_FRAME_BATCHQUEUE")) );
} else if( start->get_active () ) {
} else if (qStartStop->get_active()) {
grid->attach_next_to(*Gtk::manage (new RTImage ("processing-play.png")), Gtk::POS_TOP, 1, 1);
l = Gtk::manage (new Gtk::Label (Glib::ustring(" ") + M("MAIN_FRAME_BATCHQUEUE") + " [" + Glib::ustring::format( qsize ) + "]"));
} else {
@@ -236,7 +229,7 @@ void BatchQueuePanel::updateTab (int qsize, int forceOrientation)
if (!qsize ) {
grid->attach_next_to(*Gtk::manage (new RTImage ("processing.png")), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_BATCHQUEUE") )), Gtk::POS_RIGHT, 1, 1);
} else if ( start->get_active () ) {
} else if (!qStartStop->get_active()) {
grid->attach_next_to(*Gtk::manage (new RTImage ("processing-play.png")), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_BATCHQUEUE") + " [" + Glib::ustring::format( qsize ) + "]" )), Gtk::POS_RIGHT, 1, 1);
} else {
@@ -271,15 +264,22 @@ void BatchQueuePanel::queueSizeChanged (int qsize, bool queueEmptied, bool queue
}
}
void BatchQueuePanel::startOrStopBatchProc()
{
bool state = qStartStop->get_state();
if (state) {
startBatchProc();
} else {
stopBatchProc();
}
}
void BatchQueuePanel::startBatchProc ()
{
stopConnection.block (true);
startConnection.block (true);
stop->set_active (false);
start->set_active (true);
stopConnection.block (false);
startConnection.block (false);
// Update switch when queue started programmatically
qStartStopConn.block (true);
qStartStop->set_active(true);
qStartStopConn.block (false);
if (batchQueue->hasJobs()) {
fdir->set_sensitive (false);
@@ -295,13 +295,11 @@ void BatchQueuePanel::startBatchProc ()
void BatchQueuePanel::stopBatchProc ()
{
// Update switch when queue started programmatically
qStartStopConn.block (true);
qStartStop->set_active(false);
qStartStopConn.block (false);
stopConnection.block (true);
startConnection.block (true);
stop->set_active (true);
start->set_active (false);
stopConnection.block (false);
startConnection.block (false);
updateTab (batchQueue->getEntries().size());
}
@@ -310,7 +308,7 @@ void BatchQueuePanel::addBatchQueueJobs ( std::vector<BatchQueueEntry*> &entries
batchQueue->addEntries (entries, head);
if (stop->get_active () && autoStart->get_active ()) {
if (!qStartStop->get_active() && qAutoStart->get_active()) {
startBatchProc ();
}
}
@@ -318,7 +316,7 @@ void BatchQueuePanel::addBatchQueueJobs ( std::vector<BatchQueueEntry*> &entries
bool BatchQueuePanel::canStartNext ()
{
if (start->get_active ()) {
if (qStartStop->get_active()) {
return true;
} else {
fdir->set_sensitive (true);
@@ -332,7 +330,7 @@ void BatchQueuePanel::saveOptions ()
options.savePathTemplate = outdirTemplate->get_text();
options.saveUsePathTemplate = useTemplate->get_active();
options.procQueueEnabled = autoStart->get_active ();
options.procQueueEnabled = qAutoStart->get_active();
}
void BatchQueuePanel::pathFolderButtonPressed ()
@@ -375,7 +373,7 @@ bool BatchQueuePanel::handleShortcutKey (GdkEventKey* event)
if (ctrl) {
switch(event->keyval) {
case GDK_KEY_s:
if (start->get_active()) {
if (qStartStop->get_active()) {
stopBatchProc();
} else {
startBatchProc();