tweaks an locale updates

This commit is contained in:
GenevensiS
2026-02-16 13:49:14 +01:00
parent 46414307fd
commit adccdef933
26 changed files with 630 additions and 90 deletions
+2 -2
View File
@@ -197,11 +197,11 @@ bool KeywordReminderTextValue::checkScript(const ScriptP& script) {
// ----------------------------------------------------------------------------- : Changing keywords : mode
ChangeKeywordModeAction::ChangeKeywordModeAction(Keyword& keyword, const String& new_mode)
: keyword(keyword), mode(new_mode)
: keyword(keyword), mode(new_mode)
{}
String ChangeKeywordModeAction::getName(bool to_undo) const {
return _("Keyword mode");
return _ACTION_("keyword mode");
}
void ChangeKeywordModeAction::perform(bool to_undo) {
+14 -12
View File
@@ -57,7 +57,6 @@ AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const vector<CardP>&
LINK_PAIRS(linked_pairs, added_card);
FOR_EACH(linked_pair, linked_pairs) {
String& linked_uid = linked_pair.first.get();
String& linked_relation = linked_pair.second.get();
if (linked_uid.empty()) continue;
// If it's an added card, replace the link
if (all_added_uids.find(linked_uid) != all_added_uids.end()) {
@@ -99,7 +98,7 @@ ReorderCardsAction::ReorderCardsAction(Set& set, size_t card_id1, size_t card_id
{}
String ReorderCardsAction::getName(bool to_undo) const {
return _("Reorder cards");
return _ACTION_("reorder cards");
}
void ReorderCardsAction::perform(bool to_undo) {
@@ -120,31 +119,34 @@ OneWayLinkCardsAction::OneWayLinkCardsAction(Set& set, CardP& card, const String
: CardListAction(set), card(card), uid(uid), relation(relation)
{
switch (index) {
case 1: {
case 0: {
linked_uid = &card->linked_card_1;
linked_relation = &card->linked_relation_1;
return;
}
case 2: {
case 1: {
linked_uid = &card->linked_card_2;
linked_relation = &card->linked_relation_2;
return;
}
case 3: {
case 2: {
linked_uid = &card->linked_card_3;
linked_relation = &card->linked_relation_3;
return;
}
default: {
case 3: {
linked_uid = &card->linked_card_4;
linked_relation = &card->linked_relation_4;
return;
}
default: {
throw ScriptError(_("OneWayLinkCardsAction created with invalid index"));
}
}
}
String OneWayLinkCardsAction::getName(bool to_undo) const {
return _("Change link");
return _ACTION_("change link");
}
void OneWayLinkCardsAction::perform(bool to_undo) {
@@ -167,7 +169,7 @@ ChangeCardStyleAction::ChangeCardStyleAction(const CardP& card, const StyleSheet
: card(card), stylesheet(stylesheet), has_styling(false) // styling_data(empty)
{}
String ChangeCardStyleAction::getName(bool to_undo) const {
return _("Change style");
return _ACTION_("change style");
}
void ChangeCardStyleAction::perform(bool to_undo) {
swap(card->stylesheet, stylesheet);
@@ -180,7 +182,7 @@ ChangeSetStyleAction::ChangeSetStyleAction(Set& set, const CardP& card)
: set(set), card(card)
{}
String ChangeSetStyleAction::getName(bool to_undo) const {
return _("Change style (all cards)");
return _ACTION_("change all styles");
}
void ChangeSetStyleAction::perform(bool to_undo) {
if (!to_undo) {
@@ -216,7 +218,7 @@ ChangeCardHasStylingAction::ChangeCardHasStylingAction(Set& set, const CardP& ca
}
}
String ChangeCardHasStylingAction::getName(bool to_undo) const {
return _("Use custom style");
return _ACTION_("use custom style");
}
void ChangeCardHasStylingAction::perform(bool to_undo) {
card->has_styling = !card->has_styling;
@@ -229,7 +231,7 @@ ChangeCardNotesAction::ChangeCardNotesAction(const CardP& card, const String& no
: card(card), notes(notes)
{}
String ChangeCardNotesAction::getName(bool to_undo) const {
return _("Change notes");
return _ACTION_("change notes");
}
void ChangeCardNotesAction::perform(bool to_undo) {
swap(card->notes, notes);
@@ -241,7 +243,7 @@ ChangeCardUIDAction::ChangeCardUIDAction(Set& set, const CardP& card, const Stri
: CardListAction(set), card(card), uid(uid)
{}
String ChangeCardUIDAction::getName(bool to_undo) const {
return _("Change ID");
return _ACTION_("change id");
}
void ChangeCardUIDAction::perform(bool to_undo) {
FOR_EACH(c, set.cards) {
+11 -5
View File
@@ -334,7 +334,7 @@ TextToggleReminderAction::TextToggleReminderAction(const TextValueP& value, size
old = enable ? _('1') : _('0');
}
String TextToggleReminderAction::getName(bool to_undo) const {
return enable ? _("Show reminder text") : _("Hide reminder text");
return enable ? _ACTION_("show reminder text") : _ACTION_("hide reminder text");
}
void TextToggleReminderAction::perform(bool to_undo) {
@@ -375,12 +375,18 @@ void ScriptStyleEvent::perform(bool) {
// ----------------------------------------------------------------------------- : Bulk action
BulkAction::BulkAction(const vector<ActionP>& actions, const SetP& set, CardListBase* card_list_window)
BulkAction::BulkAction(const vector<ActionP>& actions, const SetP& set, CardListBase* card_list_window, bool change_name)
: actions(actions), set(set), card_list_window(card_list_window)
{
if (actions.empty()) throw ScriptError(_("BulkAction created with no actions"));
name_do = _ACTION_1_("bulk", actions.front()->getName(false));
name_undo = _ACTION_1_("bulk", actions.front()->getName(true));
if (actions.empty()) throw ScriptError(_("BulkAction created with no actions"));
if (change_name) {
name_do = _ACTION_1_("bulk", actions.front()->getName(false));
name_undo = _ACTION_1_("bulk", actions.front()->getName(true));
}
else {
name_do = actions.front()->getName(false);
name_undo = actions.front()->getName(true);
}
}
BulkAction::~BulkAction() {}
+1 -1
View File
@@ -214,7 +214,7 @@ public:
// An action that's just a list of other actions
class BulkAction : public Action {
public:
BulkAction(const vector<ActionP>& actions, const SetP& set, CardListBase* card_list_window);
BulkAction(const vector<ActionP>& actions, const SetP& set, CardListBase* card_list_window, bool change_name);
~BulkAction() override;
String getName(bool to_undo) const override;
+13 -11
View File
@@ -76,7 +76,7 @@ vector<int> Card::findFreeLinks(vector<String>& linked_uids, const unordered_set
for (int j = 0; j < linked_pairs.size(); ++j) {
auto& linked_pair = linked_pairs[j];
if (linked_pair.first.get() == linked_uid &&
std::find(freeIndexes.begin(), freeIndexes.end(), j) != freeIndexes.end()
std::find(freeIndexes.begin(), freeIndexes.end(), j) == freeIndexes.end()
) {
freeIndexes.push_back(j);
goto continue_outer;
@@ -86,7 +86,7 @@ vector<int> Card::findFreeLinks(vector<String>& linked_uids, const unordered_set
for (int j = 0; j < linked_pairs.size(); ++j) {
auto& linked_pair = linked_pairs[j];
if (linked_pair.first.get().empty() &&
std::find(freeIndexes.begin(), freeIndexes.end(), j) != freeIndexes.end()
std::find(freeIndexes.begin(), freeIndexes.end(), j) == freeIndexes.end()
) {
freeIndexes.push_back(j);
goto continue_outer;
@@ -96,7 +96,7 @@ vector<int> Card::findFreeLinks(vector<String>& linked_uids, const unordered_set
for (int j = 0; j < linked_pairs.size(); ++j) {
auto& linked_pair = linked_pairs[j];
if (all_existing_uids.find(linked_pair.first.get()) == all_existing_uids.end() &&
std::find(freeIndexes.begin(), freeIndexes.end(), j) != freeIndexes.end()
std::find(freeIndexes.begin(), freeIndexes.end(), j) == freeIndexes.end()
) {
freeIndexes.push_back(j);
goto continue_outer;
@@ -131,18 +131,20 @@ vector<int> Card::findRelationLinks(const String& linked_relation) {
String& Card::getLinkedUID(int index) {
switch (index) {
case 3: return linked_card_4;
case 2: return linked_card_3;
case 0: return linked_card_1;
case 1: return linked_card_2;
default: return linked_card_1;
case 2: return linked_card_3;
case 3: return linked_card_4;
default: throw ScriptError(_("getLinkedUID called with invalid index"));
}
}
String& Card::getLinkedRelation(int index) {
switch (index) {
case 3: return linked_relation_4;
case 2: return linked_relation_3;
case 0: return linked_relation_1;
case 1: return linked_relation_2;
default: return linked_relation_1;
case 2: return linked_relation_3;
case 3: return linked_relation_4;
default: throw ScriptError(_("getLinkedRelation called with invalid index"));
}
}
@@ -215,7 +217,7 @@ void Card::addLink(const Set& set, CardP& linked_card, const String& selected_re
return;
}
getLinkedUID(index) = linked_card->uid;
getLinkedRelation(index) = selected_relation;
getLinkedRelation(index) = linked_relation;
index = linked_card->findFreeLink(uid, all_existing_uids);
if (index < 0) {
@@ -223,7 +225,7 @@ void Card::addLink(const Set& set, CardP& linked_card, const String& selected_re
}
else {
linked_card->getLinkedUID(index) = uid;
linked_card->getLinkedRelation(index) = linked_relation;
linked_card->getLinkedRelation(index) = selected_relation;
}
}
+1 -1
View File
@@ -378,7 +378,7 @@ void BulkModificationWindow::onOk(wxCommandEvent&) {
return;
}
else {
set->actions.addAction(make_unique<BulkAction>(actions, set, card_list_window), false);
set->actions.addAction(make_unique<BulkAction>(actions, set, card_list_window, actions.size() > 1), false);
wxMessageDialog dial = wxMessageDialog(this, _ERROR_1_("bulk modify success", String() << actions.size()));
dial.ShowModal();
EndModal(wxID_OK);
+10 -4
View File
@@ -112,9 +112,15 @@ void CardLinkWindow::onOk(wxCommandEvent&) {
getSelection(linked_cards);
// Check that we are not linking to self
if (std::find(linked_cards.begin(), linked_cards.end(), selected_card) != linked_cards.end()) {
queue_message(MESSAGE_WARNING, _ERROR_("cant link to self"));
wxMessageDialog dial = wxMessageDialog(this, _ERROR_("cant link to self"), _TITLE_("warning"), wxICON_WARNING | wxOK);
dial.ShowModal();
linked_cards.erase(std::remove(linked_cards.begin(), linked_cards.end(), selected_card), linked_cards.end());
}
if (linked_cards.empty()) {
wxMessageDialog dial = wxMessageDialog(this, _ERROR_("no cards selected"), _TITLE_("warning"), wxICON_WARNING | wxOK);
dial.ShowModal();
return;
}
vector<String> linked_uids;
for (int i = 0; i < linked_cards.size(); ++i) {
linked_uids.push_back(linked_cards[i]->uid);
@@ -151,7 +157,7 @@ void CardLinkWindow::onOk(wxCommandEvent&) {
vector<ActionP> actions;
for (int i = 0; i < free_link_indexes.size(); ++i) {
if (free_link_indexes[i] >= 0) {
actions.push_back(make_intrusive<OneWayLinkCardsAction>(*set, selected_card, linked_uids[i], selected_relation_string, free_link_indexes[i]));
actions.push_back(make_intrusive<OneWayLinkCardsAction>(*set, selected_card, linked_uids[i], linked_relation_string, free_link_indexes[i]));
}
}
// Find reciprocal free slots and make actions
@@ -159,11 +165,11 @@ void CardLinkWindow::onOk(wxCommandEvent&) {
for (int i = 0; i < linked_cards.size(); ++i) {
int free_link_index = linked_cards[i]->findFreeLink(selected_uid, all_existing_uids);
if (free_link_index >= 0) {
actions.push_back(make_intrusive<OneWayLinkCardsAction>(*set, linked_cards[i], selected_uid, linked_relation_string, free_link_index));
actions.push_back(make_intrusive<OneWayLinkCardsAction>(*set, linked_cards[i], selected_uid, selected_relation_string, free_link_index));
}
}
// Add action to set
set->actions.addAction(make_unique<BulkAction>(actions, set, card_list_window), false);
set->actions.addAction(make_unique<BulkAction>(actions, set, card_list_window, false), false);
// Done
EndModal(wxID_OK);
}
+10 -4
View File
@@ -74,7 +74,7 @@ void CardListBase::onChangeSet() {
rebuild();
}
struct Freezer{
struct Freezer {
Window* window;
Freezer(Window* window) : window(window) { window->Freeze(); }
~Freezer() { window->Thaw(); }
@@ -439,8 +439,14 @@ bool CardListBase::parseData(bool ignore_cards_from_own_card_list) {
bool CardListBase::canLink() const {
vector<CardP> selected_cards;
getSelection(selected_cards);
return selected_cards.size() == 1;
getSelection(selected_cards);
if (selected_cards.size() != 1) return false;
unordered_set<String> all_existing_uids;
FOR_EACH(card, set->cards) {
all_existing_uids.insert(card->uid);
}
CardP card = selected_cards[0];
return card->findFreeLink(card->uid, all_existing_uids) >= 0;
}
bool CardListBase::doLink() {
CardLinkWindow wnd(this, set, getCard());
@@ -455,7 +461,7 @@ bool CardListBase::doUnlink(CardP linked_card) {
vector<ActionP> actions;
actions.emplace_back(make_intrusive<OneWayLinkCardsAction>(*set, selected_card, _(""), _(""), selected_card->findUIDLink(linked_card->uid)));
actions.emplace_back(make_intrusive<OneWayLinkCardsAction>(*set, linked_card, _(""), _(""), linked_card->findUIDLink(selected_card->uid)));
set->actions.addAction(make_unique<BulkAction>(actions, set, this), false);
set->actions.addAction(make_unique<BulkAction>(actions, set, this, false), false);
return true;
}
+2 -2
View File
@@ -37,7 +37,7 @@ wxSize CardViewer::DoGetBestSize() const {
double dpi_factor = stylesheet->card_dpi <= 150.0 ? 1.0 : 150.0 / stylesheet->card_dpi;
double width = stylesheet->card_width * dpi_factor * ss.card_zoom();
double height = stylesheet->card_height * dpi_factor * ss.card_zoom();
double link_factor = GetId() == ID_CARD_LINK_VIEWER ? (height * 0.5 - 41.0) / height : GetId() == ID_CARD_LINK_EDITOR ? (height * 0.97 - 41.0) / height : 1.0; // Subtract 41 pixels for the link title
double link_factor = GetId() == ID_CARD_LINK_VIEWER ? (height * 0.5 - 41.0) / height : GetId() == ID_CARD_LINK_EDITOR ? (height * 0.96 - 41.0) / height : 1.0; // Subtract 41 pixels for the link title
wxSize size(int(link_factor * width), int(link_factor * height));
if (is_sideways(deg_to_rad(ss.card_angle()))) swap(size.x, size.y);
return size + ws - cs;
@@ -169,7 +169,7 @@ Rotation CardViewer::getRotation() const {
int dy = CanScroll(wxVERTICAL) ? GetScrollPos(wxVERTICAL) : 0;
double dpi_factor = stylesheet->card_dpi <= 150.0 ? 1.0 : 150.0 / stylesheet->card_dpi;
double height = stylesheet->card_height * dpi_factor * ss.card_zoom();
double link_factor = GetId() == ID_CARD_LINK_VIEWER ? (height * 0.5 - 41.0) / height : GetId() == ID_CARD_LINK_EDITOR ? (height * 0.97 - 41.0) / height : 1.0; // Subtract 41 pixels for the link title
double link_factor = GetId() == ID_CARD_LINK_VIEWER ? (height * 0.5 - 41.0) / height : GetId() == ID_CARD_LINK_EDITOR ? (height * 0.96 - 41.0) / height : 1.0; // Subtract 41 pixels for the link title
return Rotation(deg_to_rad(ss.card_angle()), stylesheet->getCardRect().move(-dx,-dy,0,0), link_factor * dpi_factor * ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT);
}
+5
View File
@@ -12,6 +12,7 @@
#include <gui/packages_window.hpp>
#include <wx/wfstream.h>
#include <wx/webrequest.h>
#include <wx/dialup.h>
class DownloadableInstallerList;
@@ -28,6 +29,10 @@ public:
/// Check for updates if the settings say so
inline void check_updates() {
settings.check_updates_counter++;
wxDialUpManager* manager = wxDialUpManager::Create();
bool connected = manager->IsOk() && manager->IsOnline();
delete manager;
if (!connected) return;
if (
(settings.check_updates_when == CHECK_ALWAYS)
|| (settings.check_updates_when == CHECK_5 && settings.check_updates_counter > 4)
+17 -7
View File
@@ -448,13 +448,23 @@ void CardsPanel::onCommand(int id) {
card_list->doLink();
setCard(card_list->getCard(), true);
break;
case ID_CARD_LINK_UNLINK_1: case ID_CARD_LINK_UNLINK_2: case ID_CARD_LINK_UNLINK_3: case ID_CARD_LINK_UNLINK_4: {
card_list->doUnlink((
id == ID_CARD_LINK_UNLINK_1 ? link_viewer_1
: id == ID_CARD_LINK_UNLINK_2 ? link_viewer_2
: id == ID_CARD_LINK_UNLINK_3 ? link_viewer_3
: link_viewer_4
)->getCard());
case ID_CARD_LINK_UNLINK_1: {
card_list->doUnlink(link_viewer_1->getCard());
setCard(card_list->getCard(), true);
break;
}
case ID_CARD_LINK_UNLINK_2: {
card_list->doUnlink(link_viewer_2->getCard());
setCard(card_list->getCard(), true);
break;
}
case ID_CARD_LINK_UNLINK_3: {
card_list->doUnlink(link_viewer_3->getCard());
setCard(card_list->getCard(), true);
break;
}
case ID_CARD_LINK_UNLINK_4: {
card_list->doUnlink(link_viewer_4->getCard());
setCard(card_list->getCard(), true);
break;
}
+1 -1
View File
@@ -65,7 +65,7 @@ SymbolWindow::~SymbolWindow() {
}
void SymbolWindow::init(Window* parent, SymbolP symbol) {
Create(parent, wxID_ANY, _TITLE_("symbol editor"), wxDefaultPosition, wxSize(650,600), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
Create(parent, wxID_ANY, _TITLE_("symbol editor"), wxDefaultPosition, wxSize(750,600), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
SetIcon(load_resource_icon(_("app")));
inSelectionEvent = false;