Skip to content

Commit

Permalink
fix: make openBrowser inline, added dev shortcut
Browse files Browse the repository at this point in the history
Ctrl+Shift+Left click for skip login
Ctrl+Shift+Right click for fake login (not trigger onLogin)
  • Loading branch information
cEvolve05 committed Aug 21, 2024
1 parent e51580f commit cca10d3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/Controller/Core/AccountManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ void AccountManager::requestLogin() {

void AccountManager::requestLogout() {
// TODO: net logout
auto& self = *this;
// if (logoutSuccess) {
self->set_is_login(false);
// }
}

UserInfoEntity AccountManager::getUserInfo() {
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/View/MenuOverlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MenuOverlay::MenuOverlay(slint::ComponentHandle<UiEntryName> uiEntry, UiBridge&

void MenuOverlay::onCreate() {
auto& self = *this;
self->on_open_link_web([this] { openBrowser("https://link.sast.fun/home"); });
self->on_open_link_web([] { openBrowser("https://link.sast.fun/home"); });
}

void MenuOverlay::onShow() {
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/View/MenuOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class MenuOverlay : public BasicView, private GlobalAgent<MenuOverlayBridge> {
void onCreate() override;
void onShow() override;
void onLogin() override;

void openLinkWeb();
};

EVENTO_UI_END
2 changes: 1 addition & 1 deletion src/Infrastructure/Utils/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace evento {

namespace urls = boost::urls;

void openBrowser(urls::url_view url) {
inline void openBrowser(urls::url_view url) {
using namespace std::string_literals;
std::string url_str = "\""s + url.data() + "\"";
#ifdef __linux__
Expand Down
2 changes: 1 addition & 1 deletion ui/logic/account_manager.slint
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export global AccountManagerBridge {
}

export global AccountManager {
out property <bool> is-login <=> AccountManagerBridge.is-login;
out property <bool> is-login: AccountManagerBridge.is-login;
public function request-login() {
AccountManagerBridge.request-login();
}
Expand Down
14 changes: 10 additions & 4 deletions ui/views/overlay/login.slint
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,16 @@ export component LoginOverlay inherits Overlay {
}
pointer-event(e) => {
// developer shortcut
if (e.modifiers.shift && e.modifiers.control && e.button == PointerEventButton.right && e.kind == PointerEventKind.up) {
debug("Warning: you are using developer shortcut, skip LoginView");
AccountManagerBridge.is-login = true;
ViewManager.prior-view();
if (e.modifiers.shift && e.modifiers.control && e.kind == PointerEventKind.up) {
if (e.button == PointerEventButton.left) {
debug("[Developer Shortcut] LoginOverlay: force close LoginView");
ViewManager.prior-view();
} else if (e.button == PointerEventButton.right) {
debug("[Developer Shortcut] LoginOverlay: fake login, skip LoginView");
AccountManagerBridge.is-login = true;
debug("[Developer Shortcut] LoginOverlay: AccountManagerBridge.is-login -> true");
ViewManager.prior-view();
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions ui/views/overlay/menu.slint
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export component MenuOverlay inherits Overlay {
label-color: ROOT-STYLES.sur-theme-colors.error.normal;
clicked => {
AccountManager.request-logout();
ViewManager.clean-navigate-to(ViewName.LoginOverlay);
}
}
}
Expand Down

0 comments on commit cca10d3

Please sign in to comment.