Skip to content

Commit 22a6409

Browse files
authored
V2025.7.4 (#83)
1 parent 0f7c048 commit 22a6409

13 files changed

Lines changed: 199 additions & 33 deletions

File tree

.github/workflows/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ jobs:
5151
with:
5252
pkgs: boost-json cpr gettext-libintl glib gtest libsecret maddy
5353
triplet: ${{ matrix.variant.triplet }}
54-
revision: 3c81ed09705008f13bf76f39853507bef51f71a1
54+
revision: 4103f46cb1ebb69ef5511cab840ecea0f441fbd7
5555
token: ${{ github.token }}
56-
cache-key: ${{ matrix.variant.triplet }}
56+
cache-key: ${{ matrix.variant.triplet }}-4103f46cb1ebb69ef5511cab840ecea0f441fbd7
5757
- name: "Build"
5858
working-directory: ${{github.workspace}}/build
5959
run: |

.github/workflows/macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
with:
3232
pkgs: boost-json cpr gettext-libintl glib gtest maddy
3333
triplet: arm64-osx
34-
revision: 3c81ed09705008f13bf76f39853507bef51f71a1
34+
revision: 4103f46cb1ebb69ef5511cab840ecea0f441fbd7
3535
token: ${{ github.token }}
36-
cache-key: "arm64-osx"
36+
cache-key: "arm64-osx-4103f46cb1ebb69ef5511cab840ecea0f441fbd7"
3737
- name: "Build"
3838
working-directory: ${{github.workspace}}/build
3939
run: |

.github/workflows/windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
with:
3939
pkgs: boost-json cpr gettext-libintl gtest maddy sqlcipher
4040
triplet: ${{ matrix.variant.triplet }}
41-
revision: 3c81ed09705008f13bf76f39853507bef51f71a1
41+
revision: 4103f46cb1ebb69ef5511cab840ecea0f441fbd7
4242
token: ${{ github.token }}
43-
cache-key: ${{ matrix.variant.triplet }}
43+
cache-key: ${{ matrix.variant.triplet }}-4103f46cb1ebb69ef5511cab840ecea0f441fbd7
4444
- name: "Build"
4545
working-directory: ${{github.workspace}}/build
4646
run: |

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 2025.7.4
4+
### Breaking Changes
5+
- `maddy` dependency requires >= 1.6.0
6+
### New APIs
7+
#### App
8+
- Added `CancellationToken` class
9+
### Fixes
10+
#### Localization
11+
- Fixed included headers
12+
- Fixed Gettext::changeLanguage("C") not turning off translations
13+
314
## 2025.7.3
415
### Breaking Changes
516
None

CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif()
2020
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
2121

2222
#libnick Definition
23-
project ("libnick" LANGUAGES C CXX VERSION 2025.7.3 DESCRIPTION "A cross-platform base for native Nickvision applications.")
23+
project ("libnick" LANGUAGES C CXX VERSION 2025.7.4 DESCRIPTION "A cross-platform base for native Nickvision applications.")
2424
include(CMakePackageConfigHelpers)
2525
include(GNUInstallDirs)
2626
include(CTest)
@@ -36,6 +36,7 @@ if(NOT WIN32)
3636
endif()
3737
add_library (${PROJECT_NAME}
3838
"include/app/appinfo.h"
39+
"include/app/cancellationtoken.h"
3940
"include/app/datafilebase.h"
4041
"include/app/datafilemanager.h"
4142
"include/app/windowgeometry.h"
@@ -95,6 +96,7 @@ add_library (${PROJECT_NAME}
9596
"include/update/version.h"
9697
"include/update/versiontype.h"
9798
"src/app/appinfo.cpp"
99+
"src/app/cancellationtoken.cpp"
98100
"src/app/datafilebase.cpp"
99101
"src/app/datafilemanager.cpp"
100102
"src/app/windowgeometry.cpp"
@@ -146,11 +148,8 @@ endif()
146148
find_package(Boost REQUIRED COMPONENTS json)
147149
find_package(cpr CONFIG REQUIRED)
148150
find_package(Intl REQUIRED)
149-
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::json cpr::cpr Intl::Intl)
150-
if(USING_VCPKG)
151-
find_package(unofficial-maddy CONFIG REQUIRED)
152-
target_link_libraries(${PROJECT_NAME} PRIVATE unofficial::maddy::maddy)
153-
endif()
151+
find_package(maddy CONFIG REQUIRED)
152+
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::json cpr::cpr Intl::Intl maddy::maddy)
154153
if(WIN32)
155154
find_package(sqlcipher CONFIG REQUIRED)
156155
target_link_libraries(${PROJECT_NAME} PUBLIC sqlcipher::sqlcipher Advapi32 Dnsapi Dwmapi Gdiplus Kernel32 Shell32 UxTheme Ws2_32)

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = "libnick"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = "2025.7.3"
51+
PROJECT_NUMBER = "2025.7.4"
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

cmake/config.cmake.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ endif()
1717
find_dependency(Boost REQUIRED COMPONENTS json)
1818
find_dependency(cpr CONFIG REQUIRED)
1919
find_dependency(Intl REQUIRED)
20-
if(USING_VCPKG)
21-
find_dependency(unofficial-maddy REQUIRED)
22-
endif()
20+
find_dependency(maddy CONFIG REQUIRED)
2321
if(WIN32)
2422
find_dependency(sqlcipher CONFIG REQUIRED)
2523
elseif(APPLE)

include/app/cancellationtoken.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#ifndef CANCELLATIONTOKEN_H
2+
#define CANCELLATIONTOKEN_H
3+
4+
#include <functional>
5+
#include <mutex>
6+
7+
namespace Nickvision::App
8+
{
9+
/**
10+
* @brief A token that can be used to cancel an operation.
11+
*/
12+
class CancellationToken
13+
{
14+
public:
15+
/**
16+
* @brief Constructs a CancellationToken.
17+
* @param cancelFunction A callback function to call when the token is cancelled
18+
*/
19+
CancellationToken(const std::function<void()>& cancelFunction = {});
20+
/**
21+
* @brief Gets whether or not the token is cancelled.
22+
* @return True if token is cancelled, else false
23+
*/
24+
bool isCancelled() const;
25+
/**
26+
* @brief Gets the cancel function to be called when the token is cancelled.
27+
* @return The cancel function
28+
*/
29+
const std::function<void()>& getCancelFunction() const;
30+
/**
31+
* @brief Sets the cancel function to be called when the token is cancelled.
32+
* @param cancelFunction The cancel function
33+
*/
34+
void setCancelFunction(const std::function<void()>& cancelFunction);
35+
/**
36+
* @brief Cancels the token.
37+
*/
38+
void cancel();
39+
/**
40+
* @brief Converts the token to a boolean.
41+
* @return True if token is cancelled, else false
42+
*/
43+
operator bool() const;
44+
45+
private:
46+
mutable std::mutex m_mutex;
47+
bool m_cancelled;
48+
std::function<void()> m_cancelFunction;
49+
};
50+
}
51+
52+
#endif //CANCELLATIONTOKEN_H

include/events/event.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ namespace Nickvision::Events
112112
std::lock_guard<std::mutex> lock{ m_mutex };
113113
for (const std::function<void(const T&)>& handler : m_handlers)
114114
{
115-
handler(param);
115+
if(handler)
116+
{
117+
handler(param);
118+
}
116119
}
117120
}
118121
/**

include/localization/gettext.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include <libintl.h>
3030

3131
#define GETTEXT_CONTEXT_SEPARATOR "\004"
32-
#define _(String) dgettext(::Nickvision::Localization::Gettext::getDomainName().c_str(), String)
33-
#define _n(String, StringPlural, N) dngettext(::Nickvision::Localization::Gettext::getDomainName().c_str(), String, StringPlural, static_cast<unsigned long>(N))
32+
#define _(String) ::Nickvision::Localization::Gettext::dgettext(String)
33+
#define _n(String, StringPlural, N) ::Nickvision::Localization::Gettext::dngettext(String, StringPlural, static_cast<unsigned long>(N))
3434
#define _f(String, ...) ::Nickvision::Localization::Gettext::fgettext(String, __VA_ARGS__)
3535
#define _fn(String, StringPlural, N, ...) ::Nickvision::Localization::Gettext::fngettext(String, StringPlural, static_cast<unsigned long>(N), __VA_ARGS__)
3636
#define _p(Context, String) ::Nickvision::Localization::Gettext::pgettext(Context GETTEXT_CONTEXT_SEPARATOR String, String)
@@ -57,31 +57,47 @@ namespace Nickvision::Localization::Gettext
5757
const std::vector<std::string>& getAvailableLanguages();
5858
/**
5959
* @brief Changes the current language for gettext translations.
60-
* @param language The language code to change translations to (use "C" to turn off translations and use the default language)
60+
* @param language The language code to change translations to (use "C" to turn off translations; use "" to use the system default language)
6161
* @return True if the language was changed successfully, else false
6262
*/
6363
bool changeLanguage(const std::string& language);
64+
/**
65+
* @brief Translates a message.
66+
* @param msgid The message to translate
67+
* @return The translated message
68+
*/
69+
const char* dgettext(const char* msgid);
70+
/**
71+
* @brief Translates a plural message.
72+
* @param msg The message to translate
73+
* @param msgPlural The plural version of the message to translate
74+
* @param n The number of objects (used to determine whether or not to use the plural version of the message)
75+
* @return The translated message for the given number of objects
76+
*/
77+
const char* dngettext(const char* msg, const char* msgPlural, unsigned long n);
6478
/**
6579
* @brief Translates a message and formats it with the given arguments.
6680
* @param msg The message to translate
6781
* @param args The arguments to format the translated message with
82+
* @return The formatted translated message
6883
*/
6984
template<typename... Args>
7085
std::string fgettext(const char* msg, Args&&... args)
7186
{
72-
return std::vformat(_(msg), std::make_format_args(args...));
87+
return std::vformat(Nickvision::Localization::Gettext::dgettext(msg), std::make_format_args(args...));
7388
}
7489
/**
7590
* @brief Translates a plural message and formats it with the given arguments.
7691
* @param msg The message to translate
7792
* @param msgPlural The plural version of the message to translate
7893
* @param n The number of objects (used to determine whether or not to use the plural version of the message)
7994
* @param args The arguments to format the translated message with
95+
* @return The formatted translated message for the given number of objects
8096
*/
8197
template<typename... Args>
8298
std::string fngettext(const char* msg, const char* msgPlural, unsigned long n, Args&&... args)
8399
{
84-
return std::vformat(_n(msg, msgPlural, n), std::make_format_args(args...));
100+
return std::vformat(Nickvision::Localization::Gettext::dngettext(msg, msgPlural, n), std::make_format_args(args...));
85101
}
86102
/**
87103
* @brief Translates a message for a given context.

0 commit comments

Comments
 (0)