Skip to content

Commit

Permalink
All - Remove Matplot++ and Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed May 20, 2024
1 parent 1d322a6 commit ea6be13
Show file tree
Hide file tree
Showing 42 changed files with 1,207 additions and 1,320 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: johnwason/vcpkg-action@v5
id: vcpkg
with:
pkgs: boost-date-time gtest libnick matplotplusplus podofo rapidcsv
pkgs: boost-date-time gtest libnick podofo rapidcsv
triplet: x64-windows
cache-key: windows-latest
revision: 4af63c6f3ed667437b8fe0789a7fbc29936c9802
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
uses: johnwason/vcpkg-action@v5
id: vcpkg
with:
pkgs: boost-date-time gtest libnick matplotplusplus podofo rapidcsv
pkgs: boost-date-time gtest libnick podofo rapidcsv
triplet: x64-linux
cache-key: ubuntu-latest
revision: 4af63c6f3ed667437b8fe0789a7fbc29936c9802
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: johnwason/vcpkg-action@v5
id: vcpkg
with:
pkgs: boost-date-time libnick matplotplusplus podofo rapidcsv
pkgs: boost-date-time libnick podofo rapidcsv
triplet: x64-windows
cache-key: windows-latest
revision: 4af63c6f3ed667437b8fe0789a7fbc29936c9802
Expand Down
2 changes: 1 addition & 1 deletion docs/po/denaro.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-05-12 23:58-0400\n"
"POT-Creation-Date: 2024-05-20 11:34-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
18 changes: 0 additions & 18 deletions flatpak/org.nickvision.money.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,6 @@
}
]
},
{
"name": "matplotplusplus",
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
"-DCMAKE_BUILD_TYPE=Release",
"-DMATPLOTPP_BUILD_EXAMPLES=OFF",
"-DMATPLOTPP_BUILD_TESTS=OFF",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
],
"sources": [
{
"type": "git",
"url": "https://github.com/alandefreitas/matplotplusplus",
"tag": "v1.2.0"
}
]
},
{
"name": "podofo",
"buildsystem": "cmake-ninja",
Expand Down
5 changes: 2 additions & 3 deletions libdenaro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ endif()

find_package(libnick CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS date_time)
find_package(Matplot++ CONFIG REQUIRED)
find_package(podofo CONFIG REQUIRED)
find_path(RAPIDCSV_INCLUDE_DIRS "rapidcsv.h")
target_link_libraries(libdenaro PUBLIC libnick::libnick Boost::boost Boost::date_time Matplot++::cimg Matplot++::matplot $<IF:$<TARGET_EXISTS:podofo_shared>,podofo_shared,podofo_static>)
target_link_libraries(libdenaro PUBLIC libnick::libnick Boost::boost Boost::date_time $<IF:$<TARGET_EXISTS:podofo_shared>,podofo_shared,podofo_static>)
target_include_directories(libdenaro PUBLIC ${RAPIDCSV_INCLUDE_DIRS})

add_custom_target(shared_commands ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/__shared.h")
Expand Down Expand Up @@ -98,4 +97,4 @@ if (BUILD_TESTING)
add_custom_command(TARGET libdenaro_test POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_SOURCE_DIR}/libdenaro/tests/DenaroTestAccount2.ofx" "${CMAKE_CURRENT_BINARY_DIR}/DenaroTestAccount2.ofx")
add_custom_command(TARGET libdenaro_test POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_SOURCE_DIR}/libdenaro/tests/DenaroTestAccount3.qif" "${CMAKE_CURRENT_BINARY_DIR}/DenaroTestAccount3.qif")
endif()
endif()
endif()
19 changes: 9 additions & 10 deletions libdenaro/include/controllers/mainwindowcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "controllers/dashboardviewcontroller.h"
#include "controllers/newaccountdialogcontroller.h"
#include "controllers/preferencesviewcontroller.h"
#include "models/accounttype.h"
#include "models/color.h"
#include "models/recentaccount.h"
#include "models/theme.h"

Expand Down Expand Up @@ -54,11 +52,6 @@ namespace Nickvision::Money::Shared::Controllers
* @return The preferred theme
*/
Models::Theme getTheme() const;
/**
* @brief Gets the list of recently opened accounts.
* @return The list of recent accounts
*/
std::vector<Models::RecentAccount> getRecentAccounts() const;
/**
* @brief Gets the Saved event for the application's configuration.
* @return The configuration Saved event
Expand All @@ -74,11 +67,16 @@ namespace Nickvision::Money::Shared::Controllers
* @return The shell notification sent event
*/
Nickvision::Events::Event<Nickvision::Notifications::ShellNotificationSentEventArgs>& shellNotificationSent();
/**
* @brief Gets the event for when the recent accounts are changed.
* @reeturn The recent accounts changed event
*/
Nickvision::Events::Event<Nickvision::Events::ParamEventArgs<std::vector<Models::RecentAccount>>>& recentAccountsChanged();
/**
* @brief Gets the event for when an account is added.
* @return The account added event
*/
Nickvision::Events::Event<Nickvision::Events::ParamEventArgs<std::shared_ptr<AccountViewController>>>& accountAdded();
Nickvision::Events::Event<Nickvision::Events::ParamEventArgs<const std::shared_ptr<AccountViewController>&>>& accountAdded();
/**
* @brief Gets the debugging information for the application.
* @param extraInformation Extra, ui-specific, information to include in the debug info statement
Expand Down Expand Up @@ -176,9 +174,10 @@ namespace Nickvision::Money::Shared::Controllers
Nickvision::Taskbar::TaskbarItem m_taskbar;
Nickvision::Events::Event<Nickvision::Notifications::NotificationSentEventArgs> m_notificationSent;
Nickvision::Events::Event<Nickvision::Notifications::ShellNotificationSentEventArgs> m_shellNotificationSent;
Nickvision::Events::Event<Nickvision::Events::ParamEventArgs<std::shared_ptr<AccountViewController>>> m_accountAdded;
Nickvision::Events::Event<Nickvision::Events::ParamEventArgs<std::vector<Models::RecentAccount>>> m_recentAccountsChanged;
Nickvision::Events::Event<Nickvision::Events::ParamEventArgs<const std::shared_ptr<AccountViewController>&>> m_accountAdded;
std::unordered_map<std::filesystem::path, std::shared_ptr<Controllers::AccountViewController>> m_accountViewControllers;
};
}

#endif //MAINWINDOWCONTROLLER_H
#endif //MAINWINDOWCONTROLLER_H
30 changes: 17 additions & 13 deletions libdenaro/src/controllers/mainwindowcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ namespace Nickvision::Money::Shared::Controllers
return Aura::getActive().getConfig<Configuration>("config").getTheme();
}

std::vector<Models::RecentAccount> MainWindowController::getRecentAccounts() const
{
return Aura::getActive().getConfig<Configuration>("config").getRecentAccounts();
}

Event<EventArgs>& MainWindowController::configurationSaved()
{
return Aura::getActive().getConfig<Configuration>("config").saved();
Expand All @@ -80,7 +75,12 @@ namespace Nickvision::Money::Shared::Controllers
return m_shellNotificationSent;
}

Event<ParamEventArgs<std::shared_ptr<AccountViewController>>>& MainWindowController::accountAdded()
Event<ParamEventArgs<std::vector<RecentAccount>>>& MainWindowController::recentAccountsChanged()
{
return m_recentAccountsChanged;
}

Event<ParamEventArgs<const std::shared_ptr<AccountViewController>&>>& MainWindowController::accountAdded()
{
return m_accountAdded;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ namespace Nickvision::Money::Shared::Controllers
{
return std::make_shared<NewAccountDialogController>();
}

std::shared_ptr<DashboardViewController> MainWindowController::createDashboardViewController() const
{
std::vector<std::shared_ptr<AccountViewController>> openAccounts;
Expand Down Expand Up @@ -195,6 +195,7 @@ namespace Nickvision::Money::Shared::Controllers
checkForUpdates();
}
#endif
m_recentAccountsChanged.invoke({ Aura::getActive().getConfig<Configuration>("config").getRecentAccounts() });
m_started = true;
}
}
Expand Down Expand Up @@ -252,7 +253,7 @@ namespace Nickvision::Money::Shared::Controllers
{
return false;
}
Account a{ path };
Account a{ path };
return a.isEncrypted();
}

Expand Down Expand Up @@ -299,10 +300,11 @@ namespace Nickvision::Money::Shared::Controllers
}
if(controller)
{
m_accountViewControllers.emplace(std::make_pair(newAccountDialogController->getFilePath(), controller));
m_accountViewControllers[newAccountDialogController->getFilePath()] = controller;
config.addRecentAccount(controller->toRecentAccount());
config.save();
m_accountAdded.invoke(controller);
m_recentAccountsChanged.invoke({ config.getRecentAccounts() });
m_accountAdded.invoke({ m_accountViewControllers[newAccountDialogController->getFilePath()] });
}
}

Expand Down Expand Up @@ -332,11 +334,12 @@ namespace Nickvision::Money::Shared::Controllers
}
if(controller)
{
m_accountViewControllers.emplace(std::make_pair(path, controller));
m_accountViewControllers[path] = controller;
Configuration& config{ Aura::getActive().getConfig<Configuration>("config") };
config.addRecentAccount(controller->toRecentAccount());
config.save();
m_accountAdded.invoke(controller);
m_recentAccountsChanged.invoke({ config.getRecentAccounts() });
m_accountAdded.invoke({ m_accountViewControllers[path] });
}
}
}
Expand All @@ -346,5 +349,6 @@ namespace Nickvision::Money::Shared::Controllers
Configuration& config{ Aura::getActive().getConfig<Configuration>("config") };
config.removeRecentAccount(account);
config.save();
m_recentAccountsChanged.invoke({ config.getRecentAccounts() });
}
}
}
34 changes: 5 additions & 29 deletions libdenaro/src/models/account.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#include "models/account.h"
#include <algorithm>
#include <chrono>
#include <filesystem>
#include <format>
#include <fstream>
#include <regex>
#include <thread>
#include <libnick/app/aura.h>
#include <libnick/filesystem/userdirectories.h>
#include <libnick/helpers/stringhelpers.h>
#include <libnick/localization/gettext.h>
#include <matplot/matplot.h>
#include <rapidcsv.h>
#include "helpers/currencyhelpers.h"
#include "helpers/datehelpers.h"
Expand All @@ -26,7 +24,7 @@ namespace Nickvision::Money::Shared::Models
m_repository{ m_path },
m_metadata{ m_path.stem().string(), AccountType::Checking }
{

}

const std::filesystem::path& Account::getPath() const
Expand Down Expand Up @@ -246,10 +244,7 @@ namespace Nickvision::Money::Shared::Models
return false;
}
//Group names must be unique
if(std::find_if(m_groups.begin(), m_groups.end(), [&group](const std::pair<const int, Group>& pair)
{
return pair.second.getName() == group.getName();
}) != m_groups.end())
if(std::find_if(m_groups.begin(), m_groups.end(), [&group](const std::pair<const int, Group>& pair){ return pair.second.getName() == group.getName(); }) != m_groups.end())
{
return false;
}
Expand All @@ -268,10 +263,7 @@ namespace Nickvision::Money::Shared::Models
return false;
}
//Group names must be unique
if(std::find_if(m_groups.begin(), m_groups.end(), [&group](const std::pair<const int, Group>& pair)
{
return pair.second.getName() == group.getName();
}) != m_groups.end())
if(std::find_if(m_groups.begin(), m_groups.end(), [&group](const std::pair<const int, Group>& pair){ return pair.second.getName() == group.getName(); }) != m_groups.end())
{
return false;
}
Expand Down Expand Up @@ -605,21 +597,10 @@ namespace Nickvision::Money::Shared::Models
std::vector<std::uint8_t> Account::generateGraph(GraphType type, bool darkMode, const std::vector<int>& filteredIds, int width, int height) const
{
std::string tempPath{ StringHelpers::replace((UserDirectories::getApplicationCache() / "TEMP_DENARO_GRAPH.png").string(), "\\", "/") }; //gnuplot accepts paths with only / as separator
matplot::figure_handle figure{ matplot::figure(true) };
//Set graph size
if(width != -1 && height != -1)
{
figure->size(static_cast<unsigned int>(width), static_cast<unsigned int>(height));
}
//TODO: Support dark mode
//Render graph
if(type == GraphType::IncomeExpensePie)
{
std::vector<double> values{ getIncome(filteredIds), getExpense(filteredIds) };
std::vector<std::string> labels{ _("Income"), _("Expense") };
matplot::circles_handle pie{ figure->current_axes()->pie(values, labels) };
pie->labels()->color(darkMode ? "white" : "black");
//TODO: Change pie colors
//TODO Implement
}
else if(type == GraphType::IncomeExpensePerGroup)
{
Expand All @@ -638,11 +619,6 @@ namespace Nickvision::Money::Shared::Models
//TODO: Implement
}
//Get graph bytes
figure->save(tempPath);
while(!std::filesystem::exists(tempPath))
{
std::this_thread::sleep_for(std::chrono::seconds(1));
}
std::ifstream in{ tempPath, std::ios_base::binary };
std::vector<std::uint8_t> bytes{ std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>() };
in.close();
Expand Down
4 changes: 2 additions & 2 deletions libdenaro/tests/accounttests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,5 @@ TEST_F(AccountTest, IncomeExpensePieGraph)
return;
}
#endif
ASSERT_TRUE(!m_account->generateGraph(GraphType::IncomeExpensePie, false).empty());
}
ASSERT_FALSE(m_account->generateGraph(GraphType::IncomeExpensePie, false).empty());
}
4 changes: 2 additions & 2 deletions libdenaro/tests/receipttests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ReceiptTest : public testing::Test
WebHelpers::downloadFile("https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png", m_receiptPath);
}

static void TearDownTestSuite()
static void TearDownTestSuite()
{
std::filesystem::remove(m_receiptPath);
std::filesystem::remove(m_receiptPath2);
Expand All @@ -45,4 +45,4 @@ TEST_F(ReceiptTest, EnsureReceiptObject)
TEST_F(ReceiptTest, SaveToDisk)
{
ASSERT_NO_THROW(m_receipt->saveToDisk(m_receiptPath2));
}
}
15 changes: 8 additions & 7 deletions org.nickvision.money.gnome/include/views/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Nickvision::Money::GNOME::Views
void show();
/**
* @brief Handles when the window requests to close.
* @return True to prevent closing, else false
* @return True to prevent closing, else false
*/
bool onCloseRequested();
/**
Expand Down Expand Up @@ -91,11 +91,11 @@ namespace Nickvision::Money::GNOME::Views
void onNavItemSelected(GtkListBox* box, GtkListBoxRow* row);
/**
* @brief Handles when an account is added.
* @param args Nickvision::Events::ParamEventArgs<Nickvision::Money::Shared::Controllers::AccountViewController>
* @param args Nickvision::Events::ParamEventArgs<const Nickvision::Money::Shared::Controllers::AccountViewController&>
*/
void onAccountAdded(const ::Nickvision::Events::ParamEventArgs<std::shared_ptr<::Nickvision::Money::Shared::Controllers::AccountViewController>>& args);
void onAccountAdded(const Nickvision::Events::ParamEventArgs<const std::shared_ptr<Nickvision::Money::Shared::Controllers::AccountViewController>&>& args);
/**
* @brief Opens the new account dialog for account creation.
* @brief Opens the new account dialog for account creation.
*/
void newAccount();
/**
Expand All @@ -106,16 +106,17 @@ namespace Nickvision::Money::GNOME::Views
private:
/**
* @brief Loads the recent accounts list.
* @param args Nickvision::Events::ParamEventArgs<std::vector<Nickvision::Money::Shared::Models::RecentAccount>>
*/
void loadRecentAccounts();
void loadRecentAccounts(const Nickvision::Events::ParamEventArgs<std::vector<Shared::Models::RecentAccount>>& args);
/**
* @brief Removes a recent account from the list.
* @param path The path of the account file to remove
*/
void removeRecentAccount(const std::filesystem::path& path);
/**
* @brief Opens an account.
* @param path The path of the account file to open
* @param path The path of the account file to open
*/
void openAccount(const std::filesystem::path& path);
std::shared_ptr<Shared::Controllers::MainWindowController> m_controller;
Expand All @@ -127,4 +128,4 @@ namespace Nickvision::Money::GNOME::Views
};
}

#endif //MAINWINDOW_H
#endif //MAINWINDOW_H
2 changes: 1 addition & 1 deletion org.nickvision.money.gnome/src/views/accountpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace Nickvision::Money::GNOME::Views
adw_preferences_group_add(ADW_PREFERENCES_GROUP(gtk_builder_get_object(m_builder, "groupsGroup")), GTK_WIDGET(row));
g_object_unref(colorTexture);
g_object_unref(colorBuf);
}
}
}

AccountPage::~AccountPage()
Expand Down
Loading

0 comments on commit ea6be13

Please sign in to comment.