aui::updater::AppropriatePortablePackagePredicate#
Determines whether the passed package name is a portable package that matches current arch and platform.
Header: | #include <AUI/Updater/AppropriatePortablePackagePredicate.h> |
CMake: | aui_link(my_target PUBLIC aui::updater) |
Detailed Description#
Custom qualifier#
aui::updater::AppropriatePortablePackagePredicate p { .qualifier = "windows-x86_64" };
EXPECT_TRUE(p("app-windows-x86_64.zip"));
EXPECT_FALSE(p("app-windows-x86.zip"));
Typical usage with default qualifier#
It's convenient to use it with find_if
:
struct Response {
AString fileName;
AString downloadUrl;
} foundFiles[] = {
{ "app-some_os-x86_64-portable.zip", "https://..." },
{ "app-some_os-arm64-portable.zip", "https://..." },
};
auto foundFilesIt =
ranges::find_if(foundFiles, aui::updater::AppropriatePortablePackagePredicate {}, &Response::fileName);
Public fields and Signals#
qualifier#
AString qualifier
Package qualifier which is expected to be present in package name.
If qualifier is empty, an AUI's package qualifier which is used as default name for portable packages is used.
Since AUI is only capable of unpacking ZIPs, this predicate checks for ".zip" extension.
Implemented as AString::contains with an additional check that "_" does not goes after, to distinguish
x86_64
and x86
.
Linux x86_64 -> linux-x86_64
Windows arm64 -> windows-arm64
If you wish to publish portable packages with different qualifiers, you must specify it to this variable.
As AUI's package name, it's convenient to evaluate the package name in CMake and pass it to your target
with target_compile_definitions
.
Examples#
examples/app/notes/src/main.cpp
Notes App - Note taking app that demonstrates usage of AListModel, AProperty, user data saving and loading.
},
/// [scrollarea]
AScrollArea::Builder()
.withContents(
AUI_DECLARATIVE_FOR(note, *mNotes, AVerticalLayout) {
observeChangesForDirty(note);
return notePreview(note) AUI_LET {
connect(it->clicked, [this, note] { mCurrentNote = note; });
it& mCurrentNote > [note](AView& view, const _<Note>& currentNote) {
ALOG_DEBUG(LOG_TAG) << "currentNote == note " << currentNote << " == " << note;
examples/ui/views/src/ExampleWindow.cpp
Views Example - All-in-one views building example.
}
}),
_new<ASpacerExpanding>(),
},
AUI_DECLARATIVE_FOR(i, *state->colors, AWordWrappingLayout) {
return Horizontal {
_new<ALabel>(i.toString()) AUI_WITH_STYLE {
TextColor { i.readableBlackOrWhite() },
}
} AUI_WITH_STYLE {
examples/ui/contacts/src/main.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
mSelectedContact = nullptr;
}
_<AView> indexedList() {
return AUI_DECLARATIVE_FOR(group, *mContacts | ranges::views::chunk_by([](const _<Contact>& lhs, const _<Contact>& rhs) {
return groupLetter(lhs->displayName) == groupLetter(rhs->displayName);
}), AVerticalLayout) {
auto firstContact = *ranges::begin(group);
auto firstLetter = groupLetter(firstContact->displayName);
ALogger::info("Test") << "Computing view for group " << AString(1, firstLetter);
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;
examples/7guis/crud/src/main.cpp
7GUIs CRUD - Create/Read/Update/Delete example.
Label { "Filter prefix:" },
_new<ATextField>() AUI_WITH_STYLE { Expanding(1, 0) } && mFilterPrefix,
},
AScrollArea::Builder().withExpanding().withContents(
AUI_DECLARATIVE_FOR(i, *mUsers | FILTER_VIEW, AVerticalLayout) {
auto view = _new<ALabel>();
view & i->displayName;
connect(mSelectedUser, view, [this, &view = *view, i] {
view.setAssName("selected", mSelectedUser == i);
});