Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Nov 21, 2024
1 parent 4d408b2 commit 39e0225
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/src/gui/friendchatboard/chatitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool ChatItem::processEventDefault(const SDL_Event &event, bool valid)
setFocus(true);
}

if(auto chatPage = dynamic_cast<ChatPage *>(parent(3))){
if(auto chatPage = hasParent<ChatPage>()){
if(chatPage->menu){
chatPage->removeChild(chatPage->menu, true);
chatPage->menu = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion client/src/gui/friendchatboard/chatitemcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool ChatItemContainer::hasChatItem() const

const SDChatPeer &ChatItemContainer::getChatPeer() const
{
return dynamic_cast<const ChatPage *>(parent())->peer;
return hasParent<ChatPage>()->peer;
}

void ChatItemContainer::append(const SDChatMessage &sdCM, std::function<void(const ChatItem *)> fnOp)
Expand Down
6 changes: 3 additions & 3 deletions client/src/gui/friendchatboard/searchautocompletionitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ bool SearchAutoCompletionItem::processEventDefault(const SDL_Event &event, bool
case SDL_MOUSEBUTTONDOWN:
{
if(in(event.button.x, event.button.y)){
dynamic_cast<SearchPage *>(this->parent(2))->candidates.setShow(true);
dynamic_cast<SearchPage *>(this->parent(2))->autocompletes.setShow(false);
dynamic_cast<SearchPage *>(this->parent(2))->input.input.setInput(byID ? std::to_string(candidate.id).c_str() : candidate.name.c_str());
hasParent<SearchPage>()->candidates.setShow(true);
hasParent<SearchPage>()->autocompletes.setShow(false);
hasParent<SearchPage>()->input.input.setInput(byID ? std::to_string(candidate.id).c_str() : candidate.name.c_str());
return consumeFocus(true);
}
return false;
Expand Down
20 changes: 10 additions & 10 deletions client/src/gui/friendchatboard/searchinputline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ SearchInputLine::SearchInputLine(Widget::VarDir argDir,
nullptr,
[this]()
{
dynamic_cast<SearchPage *>(parent())->candidates.setShow(true);
dynamic_cast<SearchPage *>(parent())->autocompletes.setShow(false);
hasParent<SearchPage>()->candidates.setShow(true);
hasParent<SearchPage>()->autocompletes.setShow(false);
},

[this](std::string query)
{
hint.setShow(query.empty());

if(query.empty()){
dynamic_cast<SearchPage *>(parent())->candidates.clearChild();
dynamic_cast<SearchPage *>(parent())->autocompletes.clearChild();
hasParent<SearchPage>()->candidates.clearChild();
hasParent<SearchPage>()->autocompletes.clearChild();

dynamic_cast<SearchPage *>(parent())->candidates.setShow(false);
dynamic_cast<SearchPage *>(parent())->autocompletes.setShow(true);
hasParent<SearchPage>()->candidates.setShow(false);
hasParent<SearchPage>()->autocompletes.setShow(true);
}
else{
CMQueryChatPeerList cmQPC;
Expand All @@ -130,12 +130,12 @@ SearchInputLine::SearchInputLine(Widget::VarDir argDir,
switch(headCode){
case SM_OK:
{
dynamic_cast<SearchPage *>(parent())->candidates.clearChild();
dynamic_cast<SearchPage *>(parent())->autocompletes.clearChild();
hasParent<SearchPage>()->candidates.clearChild();
hasParent<SearchPage>()->autocompletes.clearChild();

for(const auto &candidate: cerealf::deserialize<SDChatPeerList>(data, size)){
dynamic_cast<SearchPage *>(parent())->appendFriendItem(candidate);
dynamic_cast<SearchPage *>(parent())->appendAutoCompletionItem(query == std::to_string(candidate.id), candidate, [&candidate, &query]
hasParent<SearchPage>()->appendFriendItem(candidate);
hasParent<SearchPage>()->appendAutoCompletionItem(query == std::to_string(candidate.id), candidate, [&candidate, &query]
{
if(const auto pos = candidate.name.find(query); pos != std::string::npos){
return str_printf(R"###(<par>%s<t color="red">%s</t>%s(%llu)</par>)###", candidate.name.substr(0, pos).c_str(), query.c_str(), candidate.name.substr(pos + query.size()).c_str(), to_llu(candidate.id));
Expand Down

0 comments on commit 39e0225

Please sign in to comment.