Skip to content

Commit

Permalink
add file dropping support
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Oct 18, 2023
1 parent b9d4f59 commit 2a59376
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/chat_gui4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,12 @@ void ChatGui4::render(void) {
_msg_tc.workLoadQueue();
}

void ChatGui4::sendFilePath(const char* file_path) {
if (_selected_contact && std::filesystem::is_regular_file(file_path)) {
_rmm.sendFilePath(*_selected_contact, std::filesystem::path(file_path).filename().u8string(), file_path);
}
}

// has MessageText
void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) {
const auto& msgtext = reg.get<Message::Components::MessageText>(e).text;
Expand Down
2 changes: 2 additions & 0 deletions src/chat_gui4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ChatGui4 {
public:
bool any_unread {false};

void sendFilePath(const char* file_path);

private:
void renderMessageBodyText(Message3Registry& reg, const Message3 e);
void renderMessageBodyFile(Message3Registry& reg, const Message3 e);
Expand Down
6 changes: 6 additions & 0 deletions src/main_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ MainScreen::~MainScreen(void) {
}

bool MainScreen::handleEvent(SDL_Event& e) {
if (e.type == SDL_EVENT_DROP_FILE) {
std::cout << "DROP FILE: " << e.drop.file << "\n";
cg.sendFilePath(e.drop.file);
return true; // TODO: forward return succ from sendFilePath()
}

return false;
}

Expand Down

0 comments on commit 2a59376

Please sign in to comment.