2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Integrate IV menu hiding by click inside WebView.

This commit is contained in:
John Preston
2024-03-14 11:22:52 +04:00
parent 5c8e6c3012
commit 5c32423597
3 changed files with 43 additions and 1 deletions

View File

@@ -429,6 +429,10 @@ void Controller::createWebview(const QString &dataPath) {
const auto url = object.value("url").toString();
const auto context = object.value("context").toString();
processLink(url, context);
} else if (event == "menu_page_blocker_click") {
if (_menu) {
_menu->hideMenu();
}
} else if (event == u"ready"_q) {
_ready = true;
auto script = QByteArray();
@@ -443,6 +447,9 @@ void Controller::createWebview(const QString &dataPath) {
if (base::take(_reloadInitialWhenReady)) {
script += reloadScript(0);
}
if (_menu) {
script += "IV.menuShown(true);";
}
if (!script.isEmpty()) {
_webview->eval(script);
}
@@ -648,7 +655,7 @@ bool Controller::active() const {
}
void Controller::showJoinedTooltip() {
if (_webview) {
if (_webview && _ready) {
_webview->eval("IV.showTooltip('"
+ EscapeForScriptString(
tr::lng_action_you_joined(tr::now).toUtf8())
@@ -679,6 +686,9 @@ void Controller::showMenu() {
_menu = base::make_unique_q<Ui::PopupMenu>(
_window.get(),
st::popupMenuWithIcons);
if (_webview && _ready) {
_webview->eval("IV.menuShown(true);");
}
_menu->setDestroyedCallback(crl::guard(_window.get(), [
this,
weakButton = Ui::MakeWeak(_menuToggle.data()),
@@ -686,6 +696,13 @@ void Controller::showMenu() {
if (_menu == menu && weakButton) {
weakButton->setForceRippled(false);
}
if (const auto widget = _webview ? _webview->widget() : nullptr) {
InvokeQueued(widget, crl::guard(_window.get(), [=] {
if (_webview && _ready) {
_webview->eval("IV.menuShown(false);");
}
}));
}
}));
_menuToggle->setForceRippled(true);