mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 07:34:03 -06:00
Proper localization of AppController
This commit is contained in:
parent
4f27f6c6dc
commit
478dd2a93f
6 changed files with 140 additions and 115 deletions
|
@ -33,11 +33,11 @@ void AppControllerBoilerplate::process_events()
|
|||
|
||||
AppControllerBoilerplate::PathList
|
||||
AppControllerBoilerplate::query_destination_paths(
|
||||
const std::string &title,
|
||||
const string &title,
|
||||
const std::string &extensions) const
|
||||
{
|
||||
|
||||
wxFileDialog dlg(wxTheApp->GetTopWindow(), wxString(title) );
|
||||
wxFileDialog dlg(wxTheApp->GetTopWindow(), title );
|
||||
dlg.SetWildcard(extensions);
|
||||
|
||||
dlg.ShowModal();
|
||||
|
@ -53,7 +53,7 @@ AppControllerBoilerplate::query_destination_paths(
|
|||
|
||||
AppControllerBoilerplate::Path
|
||||
AppControllerBoilerplate::query_destination_path(
|
||||
const std::string &title,
|
||||
const string &title,
|
||||
const std::string &extensions,
|
||||
const std::string& hint) const
|
||||
{
|
||||
|
@ -72,8 +72,8 @@ AppControllerBoilerplate::query_destination_path(
|
|||
}
|
||||
|
||||
bool AppControllerBoilerplate::report_issue(IssueType issuetype,
|
||||
const std::string &description,
|
||||
const std::string &brief)
|
||||
const string &description,
|
||||
const string &brief)
|
||||
{
|
||||
auto icon = wxICON_INFORMATION;
|
||||
auto style = wxOK|wxCENTRE;
|
||||
|
@ -89,6 +89,13 @@ bool AppControllerBoilerplate::report_issue(IssueType issuetype,
|
|||
return ret != wxCANCEL;
|
||||
}
|
||||
|
||||
bool AppControllerBoilerplate::report_issue(
|
||||
AppControllerBoilerplate::IssueType issuetype,
|
||||
const string &description)
|
||||
{
|
||||
return report_issue(issuetype, description, string());
|
||||
}
|
||||
|
||||
wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent);
|
||||
|
||||
namespace {
|
||||
|
@ -104,7 +111,6 @@ class GuiProgressIndicator:
|
|||
using Base = IProgressIndicator;
|
||||
wxString message_;
|
||||
int range_; wxString title_;
|
||||
// unsigned prc_ = 0;
|
||||
bool is_asynch_ = false;
|
||||
|
||||
const int id_ = wxWindow::NewControlId();
|
||||
|
@ -118,20 +124,9 @@ class GuiProgressIndicator:
|
|||
|
||||
// Status update implementation
|
||||
void _state( unsigned st) {
|
||||
// if(st < max()) {
|
||||
if(!gauge_.IsShown()) gauge_.ShowModal();
|
||||
Base::state(st);
|
||||
gauge_.Update(static_cast<int>(st), message_);
|
||||
// }
|
||||
|
||||
// if(st == max()) {
|
||||
// prc_++;
|
||||
// if(prc_ == Base::procedure_count()) {
|
||||
// //gauge_.reset();
|
||||
// gauge_.Update(static_cast<int>(st), message_);
|
||||
// prc_ = 0;
|
||||
// }
|
||||
// }
|
||||
if(!gauge_.IsShown()) gauge_.ShowModal();
|
||||
Base::state(st);
|
||||
gauge_.Update(static_cast<int>(st), message_);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -142,12 +137,12 @@ public:
|
|||
/// Get the mode of parallel operation.
|
||||
inline bool asynch() const { return is_asynch_; }
|
||||
|
||||
inline GuiProgressIndicator(int range, const std::string& title,
|
||||
const std::string& firstmsg) :
|
||||
inline GuiProgressIndicator(int range, const string& title,
|
||||
const string& firstmsg) :
|
||||
gauge_(title, firstmsg, range, wxTheApp->GetTopWindow(),
|
||||
wxPD_APP_MODAL | wxPD_AUTO_HIDE),
|
||||
message_(_(firstmsg)),
|
||||
range_(range), title_(_(title))
|
||||
message_(firstmsg),
|
||||
range_(range), title_(title)
|
||||
{
|
||||
Base::max(static_cast<float>(range));
|
||||
Base::states(static_cast<unsigned>(range));
|
||||
|
@ -163,7 +158,7 @@ public:
|
|||
}
|
||||
|
||||
virtual void state(float val) override {
|
||||
/*if( val >= 1.0) */state(static_cast<unsigned>(val));
|
||||
state(static_cast<unsigned>(val));
|
||||
}
|
||||
|
||||
void state(unsigned st) {
|
||||
|
@ -176,27 +171,26 @@ public:
|
|||
} else _state(st);
|
||||
}
|
||||
|
||||
virtual void message(const std::string & msg) override {
|
||||
message_ = _(msg);
|
||||
virtual void message(const string & msg) override {
|
||||
message_ = msg;
|
||||
}
|
||||
|
||||
virtual void messageFmt(const std::string& fmt, ...) {
|
||||
virtual void messageFmt(const string& fmt, ...) {
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
message_ = wxString::Format(_(fmt), arglist);
|
||||
message_ = wxString::Format(wxString(fmt), arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
virtual void title(const std::string & title) override {
|
||||
title_ = _(title);
|
||||
virtual void title(const string & title) override {
|
||||
title_ = title;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||
AppControllerBoilerplate::create_progress_indicator(
|
||||
unsigned statenum, const std::string& title,
|
||||
const std::string& firstmsg) const
|
||||
unsigned statenum, const string& title, const string& firstmsg) const
|
||||
{
|
||||
auto pri =
|
||||
std::make_shared<GuiProgressIndicator>(statenum, title, firstmsg);
|
||||
|
@ -208,6 +202,13 @@ AppControllerBoilerplate::create_progress_indicator(
|
|||
return pri;
|
||||
}
|
||||
|
||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||
AppControllerBoilerplate::create_progress_indicator(unsigned statenum,
|
||||
const string &title) const
|
||||
{
|
||||
return create_progress_indicator(statenum, title, string());
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// A wrapper progress indicator class around the statusbar created in perl.
|
||||
|
@ -271,18 +272,18 @@ public:
|
|||
} else _state(st);
|
||||
}
|
||||
|
||||
virtual void message(const std::string & msg) override {
|
||||
virtual void message(const string & msg) override {
|
||||
message_ = msg;
|
||||
}
|
||||
|
||||
virtual void message_fmt(const std::string& fmt, ...) override {
|
||||
virtual void message_fmt(const string& fmt, ...) override {
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
message_ = wxString::Format(_(fmt), arglist);
|
||||
message_ = wxString::Format(wxString(fmt), arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
virtual void title(const std::string & /*title*/) override {}
|
||||
virtual void title(const string & /*title*/) override {}
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -396,8 +397,8 @@ PrintController::PngExportData PrintController::query_png_export_data()
|
|||
|
||||
if(wxFileName(filepick_ctl_->GetPath()).Exists())
|
||||
if(!ctl_.report_issue(PrintController::IssueType::WARN_Q,
|
||||
"File already exists. Overwrite?",
|
||||
"Warning")) ret = wxID_CANCEL;
|
||||
_(L("File already exists. Overwrite?")),
|
||||
_(L("Warning")))) ret = wxID_CANCEL;
|
||||
EndModal(ret);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue