Skip to content

Commit

Permalink
V2022.1.3
Browse files Browse the repository at this point in the history
- Added keyboard shortcuts
  • Loading branch information
nlogozzo committed Jan 14, 2022
1 parent df53af8 commit 023a2f4
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(MODELS models/configuration.h models/configuration.cpp models/update/version.h models/update/version.cpp models/update/updateconfig.h models/update/updateconfig.cpp models/update/updater.h models/update/updater.cpp models/transaction.h models/transaction.cpp models/account.h models/account.cpp models/datatransactionscolumns.h models/datatransactionscolumns.cpp)
set(CONTROLS controls/headerbar.h controls/headerbar.cpp controls/infobar.h controls/infobar.cpp controls/progressdialog.h controls/progressdialog.cpp)
set(VIEWS views/mainwindow.h views/mainwindow.cpp views/settingsdialog.h views/settingsdialog.cpp views/transactiondialog.h views/transactiondialog.cpp)
set(VIEWS views/mainwindow.h views/mainwindow.cpp views/settingsdialog.h views/settingsdialog.cpp views/shortcutswindow.h views/shortcutswindow.cpp views/transactiondialog.h views/transactiondialog.cpp)

add_executable(NickvisionMoney main.cpp ${MODELS} ${CONTROLS} ${VIEWS})

Expand Down
2 changes: 1 addition & 1 deletion UpdateConfig.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"LatestVersion":"2022.1.2","Changelog":"- Fixed issue with date handling","LinkToExe":"https://github.com/nlogozzo/NickvisionMoney/releases/download/2022.1.2/NickvisionMoney"}
{"LatestVersion":"2022.1.3","Changelog":"- Added keyboard shortcuts","LinkToExe":"https://github.com/nlogozzo/NickvisionMoney/releases/download/2022.1.3/NickvisionMoney"}
7 changes: 7 additions & 0 deletions controls/headerbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace NickvisionMoney::Controls
m_actionGitHubRepo = m_actionHelp->add_action("gitHubRepo");
m_actionReportABug = m_actionHelp->add_action("reportABug");
m_actionSettings = m_actionHelp->add_action("settings");
m_actionShortcuts = m_actionHelp->add_action("shortcuts");
m_actionChangelog = m_actionHelp->add_action("changelog");
m_actionAbout = m_actionHelp->add_action("about");
insert_action_group("help", m_actionHelp);
Expand All @@ -71,6 +72,7 @@ namespace NickvisionMoney::Controls
m_menuHelpLinks->append("Report a Bug", "help.reportABug");
m_menuHelpActions = Gio::Menu::create();
m_menuHelpActions->append("Settings", "help.settings");
m_menuHelpActions->append("Keyboard Shortcuts", "help.shortcuts");
m_menuHelpActions->append("Changelog", "help.changelog");
m_menuHelpActions->append("About Money", "help.about");
m_menuHelp->append_section(m_menuHelpUpdate);
Expand Down Expand Up @@ -178,6 +180,11 @@ namespace NickvisionMoney::Controls
return m_actionSettings;
}

const std::shared_ptr<Gio::SimpleAction>& HeaderBar::getActionShortcuts() const
{
return m_actionShortcuts;
}

const std::shared_ptr<Gio::SimpleAction>& HeaderBar::getActionChangelog() const
{
return m_actionChangelog;
Expand Down
2 changes: 2 additions & 0 deletions controls/headerbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace NickvisionMoney::Controls
const std::shared_ptr<Gio::SimpleAction>& getActionGitHubRepo() const;
const std::shared_ptr<Gio::SimpleAction>& getActionReportABug() const;
const std::shared_ptr<Gio::SimpleAction>& getActionSettings() const;
const std::shared_ptr<Gio::SimpleAction>& getActionShortcuts() const;
const std::shared_ptr<Gio::SimpleAction>& getActionChangelog() const;
const std::shared_ptr<Gio::SimpleAction>& getActionAbout() const;

Expand Down Expand Up @@ -63,6 +64,7 @@ namespace NickvisionMoney::Controls
std::shared_ptr<Gio::SimpleAction> m_actionGitHubRepo;
std::shared_ptr<Gio::SimpleAction> m_actionReportABug;
std::shared_ptr<Gio::SimpleAction> m_actionSettings;
std::shared_ptr<Gio::SimpleAction> m_actionShortcuts;
std::shared_ptr<Gio::SimpleAction> m_actionChangelog;
std::shared_ptr<Gio::SimpleAction> m_actionAbout;
std::shared_ptr<Gio::Menu> m_menuHelp;
Expand Down
121 changes: 118 additions & 3 deletions views/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <filesystem>
#include "../models/configuration.h"
#include "../controls/progressdialog.h"
#include "shortcutswindow.h"
#include "settingsdialog.h"
#include "transactiondialog.h"

Expand All @@ -10,7 +11,7 @@ namespace NickvisionMoney::Views
using namespace NickvisionMoney::Models;
using namespace NickvisionMoney::Controls;

MainWindow::MainWindow() : m_opened(false), m_updater("https://raw.githubusercontent.com/nlogozzo/NickvisionMoney/main/UpdateConfig.json", { "2022.1.2" }), m_account(std::nullopt)
MainWindow::MainWindow() : m_opened(false), m_updater("https://raw.githubusercontent.com/nlogozzo/NickvisionMoney/main/UpdateConfig.json", { "2022.1.3" }), m_account(std::nullopt)
{
//==Settings==//
set_default_size(800, 600);
Expand All @@ -31,6 +32,7 @@ namespace NickvisionMoney::Views
m_headerBar.getActionGitHubRepo()->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::gitHubRepo));
m_headerBar.getActionReportABug()->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::reportABug));
m_headerBar.getActionSettings()->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::settings));
m_headerBar.getActionShortcuts()->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::shortcuts));
m_headerBar.getActionChangelog()->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::changelog));
m_headerBar.getActionAbout()->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::about));
m_headerBar.getActionCloseAccount()->set_enabled(false);
Expand Down Expand Up @@ -101,6 +103,109 @@ namespace NickvisionMoney::Views
m_scrollDataTransactions.set_child(m_dataTransactions);
m_scrollDataTransactions.set_margin(6);
m_scrollDataTransactions.set_expand(true);
//==Shortcuts==//
m_shortcutController = Gtk::ShortcutController::create();
m_shortcutController->set_scope(Gtk::ShortcutScope::GLOBAL);
//New Account
m_shortcutNewAccountTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_N, Gdk::ModifierType::CONTROL_MASK);
m_shortcutNewAccountAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
newAccount(args);
return true;
});
m_shortcutNewAccount = Gtk::Shortcut::create(m_shortcutNewAccountTrigger, m_shortcutNewAccountAction);
m_shortcutController->add_shortcut(m_shortcutNewAccount);
//Open Account
m_shortcutOpenAccountTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_O, Gdk::ModifierType::CONTROL_MASK);
m_shortcutOpenAccountAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
openAccount(args);
return true;
});
m_shortcutOpenAccount = Gtk::Shortcut::create(m_shortcutOpenAccountTrigger, m_shortcutOpenAccountAction);
m_shortcutController->add_shortcut(m_shortcutOpenAccount);
//Close Account
m_shortcutCloseAccountTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_W, Gdk::ModifierType::CONTROL_MASK);
m_shortcutCloseAccountAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
if(m_account.has_value())
{
closeAccount(args);
}
return true;
});
m_shortcutCloseAccount = Gtk::Shortcut::create(m_shortcutCloseAccountTrigger, m_shortcutCloseAccountAction);
m_shortcutController->add_shortcut(m_shortcutCloseAccount);
//Backup Account
m_shortcutBackupAccountTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_B, Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK);
m_shortcutBackupAccountAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
if(m_account.has_value())
{
backupAccount();
}
return true;
});
m_shortcutBackupAccount = Gtk::Shortcut::create(m_shortcutBackupAccountTrigger, m_shortcutBackupAccountAction);
m_shortcutController->add_shortcut(m_shortcutBackupAccount);
//Restore Account
m_shortcutRestoreAccountTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_R, Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK);
m_shortcutRestoreAccountAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
if(m_account.has_value())
{
restoreAccount();
}
return true;
});
m_shortcutRestoreAccount = Gtk::Shortcut::create(m_shortcutRestoreAccountTrigger, m_shortcutRestoreAccountAction);
m_shortcutController->add_shortcut(m_shortcutRestoreAccount);
//New Transaction
m_shortcutNewTransactionTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_N, Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK);
m_shortcutNewTransactionAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
if(m_account.has_value())
{
newTransaction();
}
return true;
});
m_shortcutNewTransaction = Gtk::Shortcut::create(m_shortcutNewTransactionTrigger, m_shortcutNewTransactionAction);
m_shortcutController->add_shortcut(m_shortcutNewTransaction);
//Edit Transaction
m_shortcutEditTransactionTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_O, Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK);
m_shortcutEditTransactionAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
if(m_dataTransactions.get_selection()->get_selected_rows().size() == 1)
{
editTransaction();
}
return true;
});
m_shortcutEditTransaction = Gtk::Shortcut::create(m_shortcutEditTransactionTrigger, m_shortcutEditTransactionAction);
m_shortcutController->add_shortcut(m_shortcutEditTransaction);
//Delete Transaction
m_shortcutDeleteTransactionTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_Delete);
m_shortcutDeleteTransactionAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
if(m_dataTransactions.get_selection()->get_selected_rows().size() == 1)
{
m_headerBar.getPopDeleteTransaction().popup();
}
return true;
});
m_shortcutDeleteTransaction = Gtk::Shortcut::create(m_shortcutDeleteTransactionTrigger, m_shortcutDeleteTransactionAction);
m_shortcutController->add_shortcut(m_shortcutDeleteTransaction);
//About
m_shortcutAboutTrigger = Gtk::KeyvalTrigger::create(GDK_KEY_F1);
m_shortcutAboutAction = Gtk::CallbackAction::create([&](Gtk::Widget& widget, const Glib::VariantBase& args)
{
about(args);
return true;
});
m_shortcutAbout = Gtk::Shortcut::create(m_shortcutAboutTrigger, m_shortcutAboutAction);
m_shortcutController->add_shortcut(m_shortcutAbout);
add_controller(m_shortcutController);
//==Layout==//
m_mainBox.set_orientation(Gtk::Orientation::VERTICAL);
m_mainBox.append(m_infoBar);
Expand Down Expand Up @@ -387,10 +492,20 @@ namespace NickvisionMoney::Views
settingsDialog->show();
}

void MainWindow::shortcuts(const Glib::VariantBase& args)
{
ShortcutsWindow* shortcutsWindow = new ShortcutsWindow(*this);
shortcutsWindow->signal_hide().connect(sigc::bind([](ShortcutsWindow* window)
{
delete window;
}, shortcutsWindow));
shortcutsWindow->show();
}

void MainWindow::changelog(const Glib::VariantBase& args)
{
Gtk::MessageDialog* changelogDialog = new Gtk::MessageDialog(*this, "What's New?", false, Gtk::MessageType::INFO, Gtk::ButtonsType::OK, true);
changelogDialog->set_secondary_text("\n- Fixed issue with date handling");
changelogDialog->set_secondary_text("\n- Added keyboard shortcuts");
changelogDialog->signal_response().connect(sigc::bind([](int response, Gtk::MessageDialog* dialog)
{
delete dialog;
Expand All @@ -405,7 +520,7 @@ namespace NickvisionMoney::Views
aboutDialog->set_modal(true);
aboutDialog->set_hide_on_close(true);
aboutDialog->set_program_name("Nickvision Money");
aboutDialog->set_version("2022.1.2");
aboutDialog->set_version("2022.1.3");
aboutDialog->set_comments("A personal finance manager.");
aboutDialog->set_copyright("(C) Nickvision 2021-2022");
aboutDialog->set_license_type(Gtk::License::GPL_3_0);
Expand Down
39 changes: 39 additions & 0 deletions views/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,44 @@ namespace NickvisionMoney::Views
Gtk::TreeView m_dataTransactions;
NickvisionMoney::Models::DataTransactionsColumns m_dataTransactionsColumns;
std::shared_ptr<Gtk::ListStore> m_dataTransactionsModel;
//==Shortcuts==//
std::shared_ptr<Gtk::ShortcutController> m_shortcutController;
//New Account
std::shared_ptr<Gtk::Shortcut> m_shortcutNewAccount;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutNewAccountTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutNewAccountAction;
//Open Account
std::shared_ptr<Gtk::Shortcut> m_shortcutOpenAccount;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutOpenAccountTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutOpenAccountAction;
//Close Account
std::shared_ptr<Gtk::Shortcut> m_shortcutCloseAccount;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutCloseAccountTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutCloseAccountAction;
//Backup Account
std::shared_ptr<Gtk::Shortcut> m_shortcutBackupAccount;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutBackupAccountTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutBackupAccountAction;
//Restore Account
std::shared_ptr<Gtk::Shortcut> m_shortcutRestoreAccount;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutRestoreAccountTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutRestoreAccountAction;
//New Transaction
std::shared_ptr<Gtk::Shortcut> m_shortcutNewTransaction;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutNewTransactionTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutNewTransactionAction;
//Edit Transaction
std::shared_ptr<Gtk::Shortcut> m_shortcutEditTransaction;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutEditTransactionTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutEditTransactionAction;
//Delete Transaction
std::shared_ptr<Gtk::Shortcut> m_shortcutDeleteTransaction;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutDeleteTransactionTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutDeleteTransactionAction;
//About
std::shared_ptr<Gtk::Shortcut> m_shortcutAbout;
std::shared_ptr<Gtk::KeyvalTrigger> m_shortcutAboutTrigger;
std::shared_ptr<Gtk::CallbackAction> m_shortcutAboutAction;
//==Slots==//
void onShow();
void newAccount(const Glib::VariantBase& args);
Expand All @@ -51,6 +89,7 @@ namespace NickvisionMoney::Views
void gitHubRepo(const Glib::VariantBase& args);
void reportABug(const Glib::VariantBase& args);
void settings(const Glib::VariantBase& args);
void shortcuts(const Glib::VariantBase& args);
void changelog(const Glib::VariantBase& args);
void about(const Glib::VariantBase& args);
void onRowDoubleClick(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
Expand Down
3 changes: 3 additions & 0 deletions views/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ namespace NickvisionMoney::Views
m_chkRememberLastOpenedAccount.set_tooltip_text("If checked, Money will remember the last opened account and automatically open it again when the application starts again.");
m_listGeneral.append(m_chkRememberLastOpenedAccount);
//==Layout==//
Gtk::Button* btnSave = add_button("Save", Gtk::ResponseType::CLOSE);
btnSave->get_style_context()->add_class("suggested-action");
btnSave->signal_clicked().connect(sigc::mem_fun(*this, &Gtk::Dialog::hide));
m_mainBox.set_orientation(Gtk::Orientation::VERTICAL);
m_mainBox.append(m_lblGeneral);
m_mainBox.append(m_listGeneral);
Expand Down
51 changes: 51 additions & 0 deletions views/shortcutswindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "shortcutswindow.h"

namespace NickvisionMoney::Views
{
ShortcutsWindow::ShortcutsWindow(Gtk::Window& parent)
{
//==Settings==//
set_title("Shortcuts");
set_transient_for(parent);
set_modal(true);
set_hide_on_close(true);
//==Account==//
m_grpAccount.property_title().set_value("Account");
m_shortNewAccount.property_accelerator().set_value("<Ctrl>N");
m_shortNewAccount.property_title().set_value("New Account");
m_shortOpenAccount.property_accelerator().set_value("<Ctrl>O");
m_shortOpenAccount.property_title().set_value("Open Account");
m_shortCloseAccount.property_accelerator().set_value("<Ctrl>W");
m_shortCloseAccount.property_title().set_value("Close Account");
m_shortBackupAccount.property_accelerator().set_value("<Ctrl><Shift>B");
m_shortBackupAccount.property_title().set_value("Backup Account");
m_shortRestoreAccount.property_accelerator().set_value("<Ctrl><Shift>R");
m_shortRestoreAccount.property_title().set_value("Restore Account");
m_grpAccount.append(m_shortNewAccount);
m_grpAccount.append(m_shortOpenAccount);
m_grpAccount.append(m_shortCloseAccount);
m_grpAccount.append(m_shortBackupAccount);
m_grpAccount.append(m_shortRestoreAccount);
m_section.append(m_grpAccount);
//==Transaction==//
m_grpTransaction.property_title().set_value("Transaction");
m_shortNewTransaction.property_accelerator().set_value("<Ctrl><Shift>N");
m_shortNewTransaction.property_title().set_value("New Transaction");
m_shortEditTransaction.property_accelerator().set_value("<Ctrl><Shift>O");
m_shortEditTransaction.property_title().set_value("Edit Transaction");
m_shortDeleteTransaction.property_accelerator().set_value("Delete");
m_shortDeleteTransaction.property_title().set_value("Delete Transaction");
m_grpTransaction.append(m_shortNewTransaction);
m_grpTransaction.append(m_shortEditTransaction);
m_grpTransaction.append(m_shortDeleteTransaction);
m_section.append(m_grpTransaction);
//==Application==//
m_grpApplication.property_title().set_value("Application");
m_shortAbout.property_accelerator().set_value("F1");
m_shortAbout.property_title().set_value("About");
m_grpApplication.append(m_shortAbout);
m_section.append(m_grpApplication);
//==Layout==//
set_child(m_section);
}
}
30 changes: 30 additions & 0 deletions views/shortcutswindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef SHORTCUTSWINDOW_H
#define SHORTCUTSWINDOW_H

#include <gtkmm.h>

namespace NickvisionMoney::Views
{
class ShortcutsWindow : public Gtk::ShortcutsWindow
{
public:
ShortcutsWindow(Gtk::Window& parent);

private:
Gtk::ShortcutsSection m_section;
Gtk::ShortcutsGroup m_grpAccount;
Gtk::ShortcutsShortcut m_shortNewAccount;
Gtk::ShortcutsShortcut m_shortOpenAccount;
Gtk::ShortcutsShortcut m_shortCloseAccount;
Gtk::ShortcutsShortcut m_shortBackupAccount;
Gtk::ShortcutsShortcut m_shortRestoreAccount;
Gtk::ShortcutsGroup m_grpTransaction;
Gtk::ShortcutsShortcut m_shortNewTransaction;
Gtk::ShortcutsShortcut m_shortEditTransaction;
Gtk::ShortcutsShortcut m_shortDeleteTransaction;
Gtk::ShortcutsGroup m_grpApplication;
Gtk::ShortcutsShortcut m_shortAbout;
};
}

#endif // SHORTCUTSWINDOW_H
Loading

0 comments on commit 023a2f4

Please sign in to comment.