add file dropping support

This commit is contained in:
Green Sky 2023-10-18 14:23:27 +02:00
parent b9d4f594ce
commit 2a5937652e
No known key found for this signature in database
3 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}