Compare commits

2 Commits

Author SHA1 Message Date
GenevensiS 23463c4b96 don't print scientific notation in to_json 2026-05-24 16:14:13 +02:00
GenevensiS 6f526a81f1 fix link window appearing on wrong monitor 2026-05-24 13:25:26 +02:00
3 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
// ----------------------------------------------------------------------------- : ExportCardSelectionChoice
CardLinkWindow::CardLinkWindow(Window* parent, const SetP& set, const CardP& selected_card, bool sizer)
: wxDialog(parent, wxID_ANY, _TITLE_("link cards"), wxPoint(400,-1), wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
: wxDialog(parent, wxID_ANY, _TITLE_("link cards"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
, set(set), parent(parent), selected_card(selected_card)
{
// init controls
+2 -1
View File
@@ -533,7 +533,8 @@ bool CardListBase::canLink() const {
return card->findFreeLink(card->uid, set->card_uids) >= 0;
}
bool CardListBase::doLink() {
CardLinkWindow wnd(this, set, getCard());
CardLinkWindow wnd(this, set, getCard());
wnd.CentreOnParent();
if (wnd.ShowModal() == wxID_OK) {
// The actual linking is done in this window's onOk function
return true;
+16 -2
View File
@@ -33,7 +33,7 @@
// ----------------------------------------------------------------------------- : JSON to String
void pretty_print(std::ostream& os, const boost::json::value& jv, std::string* indent)
void pretty_print(std::ostringstream& os, const boost::json::value& jv, std::string* indent)
{
std::string indent_;
if(! indent)
@@ -94,10 +94,24 @@ void pretty_print(std::ostream& os, const boost::json::value& jv, std::string* i
case boost::json::kind::uint64:
case boost::json::kind::int64:
case boost::json::kind::double_:
os << jv;
break;
case boost::json::kind::double_: {
std::ostringstream oss;
oss << std::fixed << std::setprecision(10) << jv.as_double();
std::string str = oss.str();
// remove trailing zeros
if (str.find('.') != std::string::npos) {
str.erase(str.find_last_not_of('0') + 1);
if (str.back() == '.') {
str.pop_back();
}
}
os << str;
break;
}
case boost::json::kind::bool_:
if(jv.get_bool())
os << "true";