Hide the StatusTimeout awfulness in a util function

This commit is contained in:
Thomas Goyne 2013-01-30 06:44:51 -08:00
parent a9467836f9
commit 09aa873ed7
6 changed files with 18 additions and 13 deletions

View file

@ -46,6 +46,7 @@
#include "../include/aegisub/context.h" #include "../include/aegisub/context.h"
#include "../main.h" #include "../main.h"
#include "../options.h" #include "../options.h"
#include "../utils.h"
#include "../video_context.h" #include "../video_context.h"
namespace { namespace {
@ -62,7 +63,7 @@ struct reload_all : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxGetApp().global_scripts->Reload(); wxGetApp().global_scripts->Reload();
c->local_scripts->Reload(); c->local_scripts->Reload();
wxGetApp().frame->StatusTimeout(_("Reloaded all Automation scripts")); StatusTimeout(_("Reloaded all Automation scripts"));
} }
}; };
@ -74,7 +75,7 @@ struct reload_autoload : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
wxGetApp().global_scripts->Reload(); wxGetApp().global_scripts->Reload();
wxGetApp().frame->StatusTimeout(_("Reloaded autoload Automation scripts")); StatusTimeout(_("Reloaded autoload Automation scripts"));
} }
}; };

View file

@ -42,9 +42,7 @@
#include "../ass_file.h" #include "../ass_file.h"
#include "../audio_controller.h" #include "../audio_controller.h"
#include "../audio_timing.h" #include "../audio_timing.h"
#include "../frame_main.h"
#include "../include/aegisub/context.h" #include "../include/aegisub/context.h"
#include "../main.h"
#include "../options.h" #include "../options.h"
#include "../selection_controller.h" #include "../selection_controller.h"
#include "../utils.h" #include "../utils.h"
@ -288,7 +286,7 @@ struct grid_tag_cycle_hiding : public Command {
if (tagMode == 0) message = _("ASS Override Tag mode set to show full tags."); if (tagMode == 0) message = _("ASS Override Tag mode set to show full tags.");
if (tagMode == 1) message = _("ASS Override Tag mode set to simplify tags."); if (tagMode == 1) message = _("ASS Override Tag mode set to simplify tags.");
if (tagMode == 2) message = _("ASS Override Tag mode set to hide tags."); if (tagMode == 2) message = _("ASS Override Tag mode set to hide tags.");
wxGetApp().frame->StatusTimeout(message,10000); StatusTimeout(message,10000);
// Set option // Set option
OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(tagMode); OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(tagMode);

View file

@ -26,14 +26,13 @@
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "compat.h" #include "compat.h"
#include "frame_main.h"
#include "help_button.h" #include "help_button.h"
#include "include/aegisub/context.h" #include "include/aegisub/context.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h"
#include "options.h" #include "options.h"
#include "search_replace_engine.h" #include "search_replace_engine.h"
#include "selection_controller.h" #include "selection_controller.h"
#include "utils.h"
#include <libaegisub/of_type_adaptor.h> #include <libaegisub/of_type_adaptor.h>
@ -232,7 +231,7 @@ void DialogSelection::Process(wxCommandEvent&) {
if (count == 0) if (count == 0)
wxMessageBox(message, _("Selection"), wxOK | wxCENTER, this); wxMessageBox(message, _("Selection"), wxOK | wxCENTER, this);
else else
wxGetApp().frame->StatusTimeout(message); StatusTimeout(message);
if (new_sel.size() && !new_sel.count(con->selectionController->GetActiveLine())) if (new_sel.size() && !new_sel.count(con->selectionController->GetActiveLine()))
con->selectionController->SetActiveLine(*new_sel.begin()); con->selectionController->SetActiveLine(*new_sel.begin());

View file

@ -23,12 +23,11 @@
#include "ass_style.h" #include "ass_style.h"
#include "compat.h" #include "compat.h"
#include "command/command.h" #include "command/command.h"
#include "frame_main.h"
#include "include/aegisub/context.h" #include "include/aegisub/context.h"
#include "main.h"
#include "options.h" #include "options.h"
#include "subtitle_format.h" #include "subtitle_format.h"
#include "text_file_reader.h" #include "text_file_reader.h"
#include "utils.h"
#include "video_context.h" #include "video_context.h"
#include <libaegisub/fs.h> #include <libaegisub/fs.h>
@ -71,13 +70,13 @@ SubsController::SubsController(agi::Context *context)
try { try {
auto fn = AutoSave(); auto fn = AutoSave();
if (!fn.empty()) if (!fn.empty())
wxTheApp->frame->StatusTimeout(wxString::Format(_("File backup saved as \"%s\"."), fn.wstring())); StatusTimeout(wxString::Format(_("File backup saved as \"%s\"."), fn.wstring()));
} }
catch (const agi::Exception& err) { catch (const agi::Exception& err) {
wxTheApp->frame->StatusTimeout(to_wx("Exception when attempting to autosave file: " + err.GetMessage())); StatusTimeout(to_wx("Exception when attempting to autosave file: " + err.GetMessage()));
} }
catch (...) { catch (...) {
wxTheApp->frame->StatusTimeout("Unhandled exception when attempting to autosave file."); StatusTimeout("Unhandled exception when attempting to autosave file.");
} }
}); });
} }

View file

@ -37,6 +37,8 @@
#include "utils.h" #include "utils.h"
#include "compat.h" #include "compat.h"
#include "frame_main.h"
#include "main.h"
#include "options.h" #include "options.h"
#include <libaegisub/dispatch.h> #include <libaegisub/dispatch.h>
@ -88,6 +90,10 @@ wxString PrettySize(int bytes) {
return wxString::Format(fmt, size) + " " + suffix[i]; return wxString::Format(fmt, size) + " " + suffix[i];
} }
void StatusTimeout(wxString const& msg, int ms) {
wxGetApp().frame->StatusTimeout(msg, ms);
}
int SmallestPowerOf2(int x) { int SmallestPowerOf2(int x) {
x--; x--;
x |= (x >> 1); x |= (x >> 1);

View file

@ -54,6 +54,8 @@ wxString AegiFloatToString(double value);
wxString AegiIntegerToString(int value); wxString AegiIntegerToString(int value);
wxString PrettySize(int bytes); wxString PrettySize(int bytes);
void StatusTimeout(wxString const& msg, int ms = 10000);
/// @brief Get the smallest power of two that is greater or equal to x /// @brief Get the smallest power of two that is greater or equal to x
/// ///
/// Algorithm from http://bob.allegronetwork.com/prog/tricks.html /// Algorithm from http://bob.allegronetwork.com/prog/tricks.html