Skip to content

Commit

Permalink
Merge branch 'dev' into feat/net/cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Serein207 authored Aug 12, 2024
2 parents dad2d5c + 45b18a2 commit d33a079
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 16 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,performance-*,readability-*,bugprone-*,clang-analyzer-*,cppcoreguidelines-*,mpi-*,misc-*,-readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-vararg,-clang-analyzer-optin.mpi*,-bugprone-exception-escape,-cppcoreguidelines-pro-bounds-pointer-arithmetic'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
CheckOptions:
- key: performance-unnecessary-copy-initialization.ExcludedContainerTypes
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,26 @@ jobs:
!${{ github.workspace }}/build/corrosion/**/target/**/incremental
key: corrosion-${{ runner.os }}

- name: Setup CMake
uses: lukka/get-cmake@latest

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgConfigurationJsonGlob: 'vcpkg-configuration.json'
vcpkgJsonGlob: 'vcpkg.json'

- name: CMake Generate
run: cmake --preset native -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Run clang-tidy
uses: ZedThree/[email protected]
id: review
with:
build_dir: build
config_file: ".clang-tidy"
exclude: "3rdpart/*, build/*"
cmake_command: |
cmake --preset native -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: If there are any comments, fail the check
if: steps.review.outputs.total_comments > 0
run: exit 1
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
- "CMakePresets.json"
- "vcpkg*"
- ".github/workflows/codeql.yml"
branches:
- main
- dev
pull_request:
paths:
- "src/**"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
paths:
- "src/**"
- ".github/workflows/format-check.yml"
branches:
- main
- dev

jobs:
format-check:
name: Format Check
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Core/AccountManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

EVENTO_UI_START

class AccountManager : private GlobalAgent<::AccountManager>,
class AccountManager : private GlobalAgent<AccountManagerBridge>,
std::enable_shared_from_this<AccountManager> {
friend class UiBridge;
UiBridge& bridge;
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Core/MessageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

EVENTO_UI_START

class MessageManager : GlobalAgent<::MessageManager> {
class MessageManager : GlobalAgent<MessageManagerBridge> {
friend class UiBridge;
UiBridge& bridge;
std::string logOrigin = "MessageManager";
Expand Down
5 changes: 2 additions & 3 deletions src/Controller/Core/ViewManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ void ViewManager::hideView(ViewName target) {
visibleViews.erase(target);
}

void ViewManager::onEnterEventLoop() {
auto stack = viewStack;
}
void ViewManager::onEnterEventLoop() {}

void ViewManager::onExitEventLoop() {
// clean up
spdlog::debug("ViewManager: --- onExitEventLoop: clean up all pages ---");
Expand Down
5 changes: 4 additions & 1 deletion src/Controller/Core/ViewManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

EVENTO_UI_START

class ViewManager : private GlobalAgent<::ViewManager> {
class ViewManager : private GlobalAgent<ViewManagerBridge> {
friend class UiBridge;
UiBridge& bridge;
std::string logOrigin = "ViewManager";
Expand All @@ -26,12 +26,15 @@ class ViewManager : private GlobalAgent<::ViewManager> {
// view will be added to stack and show on top, overlay won't hide prior view.
// auto refresh
void navigateTo(ViewName newView);

// stack will be clean (init view left), and push new view.
// auto refresh
void cleanNavigateTo(ViewName newView);

// current page pop and new view pushed.
// auto refresh
void replaceNavigateTo(ViewName newView);

// view will be pop from stack, new top will be show if it not.
// auto refresh
void priorView();
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/UiBridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ UiBridge::UiBridge(slint::ComponentHandle<UiEntryName> uiEntry)
, messageManager(std::make_shared<MessageManager>(uiEntry, *this)) {
attachAllViews();

slint::invoke_from_event_loop([this] { return onEnterEventLoop(); });

uiEntry->window().on_close_requested([this] {
onExitEventLoop();
return slint::CloseRequestResponse::HideWindow;
});
slint::invoke_from_event_loop([this] { return onEnterEventLoop(); });

viewManager->initStack(ViewName::DiscoveryPage);
if (!accountManager->isLogin()) {
Expand Down
1 change: 1 addition & 0 deletions src/Controller/UiBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ EVENTO_UI_START
class UiBridge : GlobalAgent<::UiBridge> {
friend class ViewManager;
friend class AccountManager;
friend class MessageManager;

slint::ComponentHandle<UiEntryName> uiEntry;
bool eventLoopRunning = false;
Expand Down
10 changes: 8 additions & 2 deletions ui/app.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { Token } from "./global.slint";
import { Button } from "std-widgets.slint";
import { Empty } from "./components/index.slint";
import {
ViewManagerBridge,
AccountManagerBridge,
MessageManagerBridge,
ViewManager,
ViewName,
AccountManager,
MessageManager,
ViewName,
MessageType
} from "./logic/index.slint";

Expand Down Expand Up @@ -35,10 +38,13 @@ import { SAlert } from "modules/surrealism-ui/src/alert/index.slint";

// export for C++ interact
export {
ViewManagerBridge,
AccountManagerBridge,
MessageManagerBridge,
ViewManager,
ViewName,
AccountManager,
MessageManager,
ViewName,
MessageType,
LoginOverlayBridge,
MenuOverlayBridge,
Expand Down
12 changes: 11 additions & 1 deletion ui/logic/account_manager.slint
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
export global AccountManager {
export global AccountManagerBridge {
in-out property <bool> is-login;
callback request-login();
callback request-logout();
}

export global AccountManager {
out property <bool> is-login <=> AccountManagerBridge.is-login;
public function request-login() {
AccountManagerBridge.request-login();
}
public function request-logout() {
AccountManagerBridge.request-logout();
}
}
7 changes: 6 additions & 1 deletion ui/logic/index.slint
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
export { EventoStyleToken } from "./style_token.slint";
export {
ViewManager,
ViewManagerBridge,
ViewName,
} from "./view_manager.slint";
export { AccountManager } from "./account_manager.slint";
export {
AccountManager,
AccountManagerBridge,
} from "./account_manager.slint";
export {
MessageManager,
MessageManagerBridge,
MessageType,
} from "./message_manager.slint";
12 changes: 11 additions & 1 deletion ui/logic/message_manager.slint
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ export enum MessageType{
Error
}

export global MessageManager {
export global MessageManagerBridge {
in-out property <string> content: "Test content";
in-out property <bool> visible;
in-out property <MessageType> type;
in-out property <duration> timeout: 3s;
callback show-message(string, MessageType);
}

export global MessageManager {
out property <string> content <=> MessageManagerBridge.content;
out property <bool> visible <=> MessageManagerBridge.visible;
out property <MessageType> type <=> MessageManagerBridge.type;
out property <duration> timeout <=> MessageManagerBridge.timeout;
public function show-message(content: string, type: MessageType) {
MessageManagerBridge.show-message(content, type);
}
}
22 changes: 21 additions & 1 deletion ui/logic/view_manager.slint
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export enum ViewName{
MenuOverlay,
}

export global ViewManager {
export global ViewManagerBridge {
// nav request
callback navigate-to(ViewName);
callback clean-navigate-to(ViewName);
Expand All @@ -20,3 +20,23 @@ export global ViewManager {
pure callback is-show(ViewName) -> bool;
in-out property <bool> refresh;
}

export global ViewManager {
// nav request
public function navigate-to(view: ViewName) {
ViewManagerBridge.navigate-to(view);
}
public function clean-navigate-to(view: ViewName) {
ViewManagerBridge.clean-navigate-to(view);
}
public function replace-navigate-to(view: ViewName) {
ViewManagerBridge.replace-navigate-to(view);
}
public function prior-view() {
ViewManagerBridge.prior-view();
}
// control view visibility
public pure function is-show(view: ViewName) -> bool {
return ViewManagerBridge.is-show(view);
}
}

0 comments on commit d33a079

Please sign in to comment.