AyuGramDesktop/Telegram/SourceFiles/boxes/add_local_message_box.h
google-labs-jules[bot] 31cb5f620b feat: Implement local messages feature
This commit introduces the ability for you to add messages locally to a chat. These messages are displayed only on the client and are not sent to the server.

Key changes include:

- Data Layer:
    - Added a new `LocalMessage` class inheriting from `AyuMessageBase` in `ayu/data/entities.h`.
    - Implemented functions in `ayu/data/messages_storage.cpp` and `.h` (`addLocalMessage`, `getLocalMessages`, `hasLocalMessages`) to manage the storage of these messages in the AyuGram SQLite database, including creating a new table for local messages.
- UI and Display:
    - Modified `ayu/ui/message_history/history_item.cpp` to ensure `LocalMessage` objects are rendered in the chat history.
    - Added a visual distinction for local messages by prepending "[Local] " to their text content.
- UI Flow:
    - Implemented a new dialog box (`AddLocalMessageBox` in `boxes/add_local_message_box.cpp` and `.h`) for composing local messages, allowing you to specify a sender name (defaults to the current user) and the message text.
    - Added a context menu option ("Add Local Message") to the message input field in `HistoryWidget` to launch this dialog.
- Testing:
    - Defined a suite of manual test cases covering data storage, retrieval, UI display, and the creation flow via the new UI, ensuring the feature's correctness and usability.

This feature enhances AyuGram by allowing you to annotate chats or add notes directly within the message flow, visible only to yourselves.
2025-05-21 22:00:04 +00:00

37 lines
826 B
C++

#pragma once
#include "ui/layers/box_content.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/buttons.h"
namespace Ui {
class VerticalLayout;
} // namespace Ui
class AddLocalMessageBox : public Ui::BoxContent {
public:
AddLocalMessageBox(QWidget*, not_null<Window::SessionController*> controller);
struct LocalMessageData {
QString senderName;
QString messageText;
};
rpl::producer<LocalMessageData> saveLocalMessageRequests() const;
protected:
void prepare() override;
void setInnerFocus() override;
private:
void setupControls();
void save();
not_null<Window::SessionController*> _controller;
object_ptr<Ui::InputField> _senderField;
object_ptr<Ui::InputField> _messageField;
object_ptr<Ui::RoundButton> _submitButton;
rpl::event_stream<LocalMessageData> _saveLocalMessageRequests;
};