Skip to content

Commit

Permalink
V2022.11.0-beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Nov 6, 2022
1 parent 9e9ce9f commit 078dd2a
Show file tree
Hide file tree
Showing 26 changed files with 207 additions and 103 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/

# Gettext model
*.pot

# Prerequisites
*.d

Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sqlitecpp = dependency('SQLiteCpp')
boost = dependency('boost')

subdir('src')
subdir('po')

executable('org.nickvision.money', sources, dependencies: [threads, adwaita, jsoncpp, dl, sqlitecpp, boost], install: true)
install_data(resources, install_dir: 'share/icons/hicolor/scalable/apps')
Expand Down
2 changes: 1 addition & 1 deletion org.nickvision.money.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{
"type": "git",
"url": "https://github.com/nlogozzo/NickvisionMoney.git",
"tag": "2022.11.0-beta1"
"tag": "2022.11.0-beta2"
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion org.nickvision.money.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
<binary>org.nickvision.money</binary>
</provides>
<releases>
<release version="2022.11.0-beta1" date="2022-11-05">
<release version="2022.11.0-beta2" date="2022-11-06">
<description>
<p>- Introducing Groups: Add groups to an account and associate transactions with groups for a more precise finance management system</p>
<p>- Added support for translations</p>
</description>
</release>
</releases>
Expand Down
Empty file added po/LINGUAS
Empty file.
14 changes: 14 additions & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
src/controllers/accountviewcontroller.cpp
src/controllers/transactiondialogcontroller.cpp
src/models/transaction.cpp
src/ui/application.cpp
src/ui/controls/comboboxdialog.cpp
src/ui/controls/entrydialog.cpp
src/ui/controls/grouprow.cpp
src/ui/controls/transactionrow.cpp
src/ui/views/accountview.cpp
src/ui/views/groupdialog.cpp
src/ui/views/mainwindow.cpp
src/ui/views/preferencesdialog.cpp
src/ui/views/shortcutsdialog.cpp
src/ui/views/transactiondialog.cpp
5 changes: 5 additions & 0 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
i18n = import('i18n')
# define GETTEXT_PACKAGE and LOCALE_DIR
add_project_arguments('-DGETTEXT_PACKAGE="' + meson.project_name() + '"', language:'cpp')
add_project_arguments('-DLOCALE_DIR="' + join_paths(get_option('prefix'), get_option('localedir')) + '"', language:'cpp')
i18n.gettext(meson.project_name())
9 changes: 6 additions & 3 deletions src/controllers/accountviewcontroller.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "accountviewcontroller.hpp"
#include <sstream>
#include "../helpers/stringhelpers.hpp"
#include "../helpers/translation.hpp"

using namespace NickvisionMoney::Controllers;
using namespace NickvisionMoney::Helpers;
using namespace NickvisionMoney::Models;

AccountViewController::AccountViewController(const std::string& path, const std::string& currencySymbol, bool displayCurrencySymbolOnRight, const std::function<void(const std::string& message)>& sendToastCallback) : m_currencySymbol{ currencySymbol }, m_displayCurrencySymbolOnRight{ displayCurrencySymbolOnRight }, m_account{ path }, m_sendToastCallback{ sendToastCallback }
Expand Down Expand Up @@ -89,11 +92,11 @@ void AccountViewController::exportAsCSV(std::string& path)
}
if(m_account.exportAsCSV(path))
{
m_sendToastCallback("Exported account to CSV successfully.");
m_sendToastCallback(_("Exported account to CSV successfully."));
}
else
{
m_sendToastCallback("Unable to export account as CSV.");
m_sendToastCallback(_("Unable to export account as CSV."));
}
}

Expand All @@ -104,7 +107,7 @@ void AccountViewController::importFromCSV(std::string& path)
{
m_accountInfoChangedCallback();
}
m_sendToastCallback("Imported " + std::to_string(imported) + " transactions from CSV.");
m_sendToastCallback(StringHelpers::format(_("Imported %d transactions from CSV."), imported));
}

void AccountViewController::addGroup(const Group& group)
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/transactiondialogcontroller.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "transactiondialogcontroller.hpp"
#include <sstream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include "../helpers/translation.hpp"

using namespace NickvisionMoney::Controllers;
using namespace NickvisionMoney::Models;

TransactionDialogController::TransactionDialogController(unsigned int newId, const std::string& currencySymbol, const std::map<unsigned int, Group>& groups) : m_response{ "cancel" }, m_currencySymbol{ currencySymbol }, m_transaction{ newId }, m_groups{ groups }
{
m_groupNames.push_back("None");
m_groupNames.push_back(_("None"));
for(const std::pair<const unsigned int, Group>& pair : m_groups)
{
m_groupNames.push_back(pair.second.getName());
Expand All @@ -16,7 +17,7 @@ TransactionDialogController::TransactionDialogController(unsigned int newId, con

TransactionDialogController::TransactionDialogController(const Transaction& transaction, const std::string& currencySymbol, const std::map<unsigned int, Group>& groups) : m_response{ "cancel" }, m_currencySymbol{ currencySymbol }, m_transaction{ transaction }, m_groups{ groups }
{
m_groupNames.push_back("None");
m_groupNames.push_back(_("None"));
for(const std::pair<const unsigned int, Group>& pair : m_groups)
{
m_groupNames.push_back(pair.second.getName());
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/stringhelpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "stringhelpers.hpp"

using namespace NickvisionMoney::Helpers;
29 changes: 29 additions & 0 deletions src/helpers/stringhelpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <memory>
#include <stdexcept>
#include <string>

namespace NickvisionMoney::Helpers::StringHelpers
{
/**
* Formats a string similarly to sprintf in C
*
* @param format The source string
* @param args The arguments to be added
* @returns The formatted string
*/
template <typename... Args>
std::string format(const std::string& format, Args... args)
{
int size_s{ std::snprintf(nullptr, 0, format.c_str(), args...) + 1 }; // Extra space for '\0'
if (size_s <= 0)
{
throw std::runtime_error("Error during formatting.");
}
size_t size{ static_cast<size_t>(size_s) };
std::unique_ptr<char[]> buf{ new char[size] };
std::snprintf(buf.get(), size, format.c_str(), args...);
return { buf.get(), buf.get() + size - 1 }; // We don't want the '\0' inside
}
}
5 changes: 5 additions & 0 deletions src/helpers/translation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include <libintl.h>

#define _(String) gettext(String)
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <libintl.h>
#include "ui/application.hpp"

using namespace NickvisionMoney::UI;
Expand All @@ -12,6 +13,12 @@ using namespace NickvisionMoney::UI;
*/
int main(int argc, char* argv[])
{
//Translations
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
//Start App
Application app("org.nickvision.money");
return app.run(argc, argv);
}
3 changes: 3 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources = files('main.cpp',
'helpers/translation.hpp',
'helpers/stringhelpers.hpp',
'helpers/stringhelpers.cpp',
'models/appinfo.hpp',
'models/appinfo.cpp',
'models/configuration.hpp',
Expand Down
15 changes: 8 additions & 7 deletions src/models/transaction.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "transaction.hpp"
#include "../helpers/translation.hpp"

using namespace NickvisionMoney::Models;

Expand Down Expand Up @@ -51,31 +52,31 @@ std::string Transaction::getRepeatIntervalAsString() const
{
if(m_repeatInterval == RepeatInterval::Never)
{
return "Never";
return _("Never");
}
else if(m_repeatInterval == RepeatInterval::Daily)
{
return "Daily";
return _("Daily");
}
else if(m_repeatInterval == RepeatInterval::Weekly)
{
return "Weekly";
return _("Weekly");
}
else if(m_repeatInterval == RepeatInterval::Monthly)
{
return "Monthly";
return _("Monthly");
}
else if(m_repeatInterval == RepeatInterval::Quarterly)
{
return "Quarterly";
return _("Quarterly");
}
else if(m_repeatInterval == RepeatInterval::Yearly)
{
return "Yearly";
return _("Yearly");
}
else if(m_repeatInterval == RepeatInterval::Biyearly)
{
return "Biyearly";
return _("Biyearly");
}
return "";
}
Expand Down
7 changes: 4 additions & 3 deletions src/ui/application.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "application.hpp"
#include "../controllers/mainwindowcontroller.hpp"
#include "../helpers/translation.hpp"

using namespace NickvisionMoney::Controllers;
using namespace NickvisionMoney::Models;
Expand All @@ -12,9 +13,9 @@ Application::Application(const std::string& id, GApplicationFlags flags) : m_adw
m_appInfo.setId(id);
m_appInfo.setName("Nickvision Money");
m_appInfo.setShortName("Money");
m_appInfo.setDescription("A personal finance manager.");
m_appInfo.setVersion("2022.11.0-beta1");
m_appInfo.setChangelog("<ul><li>Introducing Groups: Add groups to an account and associate transactions with groups for a more precise finance management system</li></ul>");
m_appInfo.setDescription(_("A personal finance manager."));
m_appInfo.setVersion("2022.11.0-beta2");
m_appInfo.setChangelog("<ul><li>Introducing Groups: Add groups to an account and associate transactions with groups for a more precise finance management system</li><li>Added support for translations</li></ul>");
m_appInfo.setGitHubRepo("https://github.com/nlogozzo/NickvisionMoney");
m_appInfo.setIssueTracker("https://github.com/nlogozzo/NickvisionMoney/issues/new");
m_appInfo.setSupportUrl("https://github.com/nlogozzo/NickvisionMoney/discussions");
Expand Down
3 changes: 2 additions & 1 deletion src/ui/controls/comboboxdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "comboboxdialog.hpp"
#include "../../helpers/translation.hpp"

using namespace NickvisionMoney::UI::Controls;

ComboBoxDialog::ComboBoxDialog(GtkWindow* parent, const std::string& title, const std::string& description, const std::string& rowTitle, const std::vector<std::string>& choices) : m_choices{ choices }, m_response{ "cancel" }, m_gobj{ adw_message_dialog_new(parent, title.c_str(), description.c_str()) }
{
//Dialog Settings
gtk_window_set_hide_on_close(GTK_WINDOW(m_gobj), true);
adw_message_dialog_add_responses(ADW_MESSAGE_DIALOG(m_gobj), "cancel", "Cancel", "ok", "OK", nullptr);
adw_message_dialog_add_responses(ADW_MESSAGE_DIALOG(m_gobj), "cancel", _("Cancel"), "ok", _("OK"), nullptr);
adw_message_dialog_set_response_appearance(ADW_MESSAGE_DIALOG(m_gobj), "ok", ADW_RESPONSE_SUGGESTED);
adw_message_dialog_set_default_response(ADW_MESSAGE_DIALOG(m_gobj), "cancel");
adw_message_dialog_set_close_response(ADW_MESSAGE_DIALOG(m_gobj), "cancel");
Expand Down
3 changes: 2 additions & 1 deletion src/ui/controls/entrydialog.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "entrydialog.hpp"
#include "../../helpers/translation.hpp"

using namespace NickvisionMoney::UI::Controls;

EntryDialog::EntryDialog(GtkWindow* parent, const std::string& title, const std::string& description, const std::string& entryTitle) : m_response{ "cancel" }, m_gobj{ adw_message_dialog_new(parent, title.c_str(), description.c_str()) }
{
//Dialog Settings
gtk_window_set_hide_on_close(GTK_WINDOW(m_gobj), true);
adw_message_dialog_add_responses(ADW_MESSAGE_DIALOG(m_gobj), "cancel", "Cancel", "ok", "OK", nullptr);
adw_message_dialog_add_responses(ADW_MESSAGE_DIALOG(m_gobj), "cancel", _("Cancel"), "ok", _("OK"), nullptr);
adw_message_dialog_set_response_appearance(ADW_MESSAGE_DIALOG(m_gobj), "ok", ADW_RESPONSE_SUGGESTED);
adw_message_dialog_set_default_response(ADW_MESSAGE_DIALOG(m_gobj), "cancel");
adw_message_dialog_set_close_response(ADW_MESSAGE_DIALOG(m_gobj), "cancel");
Expand Down
5 changes: 3 additions & 2 deletions src/ui/controls/grouprow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "grouprow.hpp"
#include <sstream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include "../../helpers/translation.hpp"

using namespace NickvisionMoney::Models;
using namespace NickvisionMoney::UI::Controls;
Expand All @@ -27,15 +28,15 @@ GroupRow::GroupRow(const Group& group, const std::string& currencySymbol, bool d
gtk_widget_set_valign(m_btnEdit, GTK_ALIGN_CENTER);
gtk_style_context_add_class(gtk_widget_get_style_context(m_btnEdit), "flat");
gtk_button_set_icon_name(GTK_BUTTON(m_btnEdit), "edit-symbolic");
gtk_widget_set_tooltip_text(m_btnEdit, "Edit Group");
gtk_widget_set_tooltip_text(m_btnEdit, _("Edit Group"));
adw_action_row_set_activatable_widget(ADW_ACTION_ROW(m_gobj), m_btnEdit);
g_signal_connect(m_btnEdit, "clicked", G_CALLBACK((void (*)(GtkButton*, gpointer))[](GtkButton*, gpointer data) { reinterpret_cast<GroupRow*>(data)->onEdit(); }), this);
//Delete Button
m_btnDelete = gtk_button_new();
gtk_widget_set_valign(m_btnDelete, GTK_ALIGN_CENTER);
gtk_style_context_add_class(gtk_widget_get_style_context(m_btnDelete), "flat");
gtk_button_set_icon_name(GTK_BUTTON(m_btnDelete), "user-trash-symbolic");
gtk_widget_set_tooltip_text(m_btnDelete, "Delete Group");
gtk_widget_set_tooltip_text(m_btnDelete, _("Delete Group"));
g_signal_connect(m_btnDelete, "clicked", G_CALLBACK((void (*)(GtkButton*, gpointer))[](GtkButton*, gpointer data) { reinterpret_cast<GroupRow*>(data)->onDelete(); }), this);
//Box
m_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
Expand Down
7 changes: 4 additions & 3 deletions src/ui/controls/transactionrow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "transactionrow.hpp"
#include <sstream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include "../../helpers/translation.hpp"

using namespace NickvisionMoney::Models;
using namespace NickvisionMoney::UI::Controls;
Expand All @@ -16,7 +17,7 @@ TransactionRow::TransactionRow(const Transaction& transaction, const std::string
builder << boost::gregorian::to_iso_extended_string(m_transaction.getDate());
if(m_transaction.getRepeatInterval() != RepeatInterval::Never)
{
builder << "\n" << "Repeat Interval: " << m_transaction.getRepeatIntervalAsString();
builder << "\n" << _("Repeat Interval: ") << m_transaction.getRepeatIntervalAsString();
}
adw_action_row_set_subtitle(ADW_ACTION_ROW(m_gobj), builder.str().c_str());
//Amount Label
Expand All @@ -37,15 +38,15 @@ TransactionRow::TransactionRow(const Transaction& transaction, const std::string
gtk_widget_set_valign(m_btnEdit, GTK_ALIGN_CENTER);
gtk_style_context_add_class(gtk_widget_get_style_context(m_btnEdit), "flat");
gtk_button_set_icon_name(GTK_BUTTON(m_btnEdit), "edit-symbolic");
gtk_widget_set_tooltip_text(m_btnEdit, "Edit Transaction");
gtk_widget_set_tooltip_text(m_btnEdit, _("Edit Transaction"));
adw_action_row_set_activatable_widget(ADW_ACTION_ROW(m_gobj), m_btnEdit);
g_signal_connect(m_btnEdit, "clicked", G_CALLBACK((void (*)(GtkButton*, gpointer))[](GtkButton*, gpointer data) { reinterpret_cast<TransactionRow*>(data)->onEdit(); }), this);
//Delete Button
m_btnDelete = gtk_button_new();
gtk_widget_set_valign(m_btnDelete, GTK_ALIGN_CENTER);
gtk_style_context_add_class(gtk_widget_get_style_context(m_btnDelete), "flat");
gtk_button_set_icon_name(GTK_BUTTON(m_btnDelete), "user-trash-symbolic");
gtk_widget_set_tooltip_text(m_btnDelete, "Delete Transaction");
gtk_widget_set_tooltip_text(m_btnDelete, _("Delete Transaction"));
g_signal_connect(m_btnDelete, "clicked", G_CALLBACK((void (*)(GtkButton*, gpointer))[](GtkButton*, gpointer data) { reinterpret_cast<TransactionRow*>(data)->onDelete(); }), this);
//Box
m_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
Expand Down
Loading

0 comments on commit 078dd2a

Please sign in to comment.