File indexing completed on 2024-12-01 04:37:00

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "dialogs/uploadfiledialog.h"
0010 #include "libruqolawidgets_private_export.h"
0011 #include "uploadfilejob.h"
0012 #include <QPointer>
0013 #include <QWidget>
0014 
0015 class MessageTextEdit;
0016 class QToolButton;
0017 class EmoticonMenuWidget;
0018 class RocketChatAccount;
0019 class QMimeData;
0020 class MessagesModel;
0021 
0022 class LIBRUQOLAWIDGETS_TESTS_EXPORT MessageLineWidget : public QWidget
0023 {
0024     Q_OBJECT
0025 public:
0026     enum class EditingMode {
0027         EditMessage,
0028         NewMessage,
0029     };
0030 
0031     explicit MessageLineWidget(QWidget *parent = nullptr);
0032     ~MessageLineWidget() override;
0033 
0034     void setCurrentRocketChatAccount(RocketChatAccount *account, bool threadMessageDialog);
0035 
0036     void setText(const QString &text);
0037     [[nodiscard]] QString text() const;
0038 
0039     MessageTextEdit *messageTextEdit() const;
0040 
0041     [[nodiscard]] EditingMode mode() const;
0042     void setMode(EditingMode mode);
0043 
0044     void setRoomId(const QString &roomId);
0045     [[nodiscard]] QString roomId() const;
0046 
0047     [[nodiscard]] QString messageIdBeingEdited() const;
0048     void setMessageIdBeingEdited(const QString &messageIdBeingEdited);
0049 
0050     void setEditMessage(const QString &messageId, const QString &text);
0051     void setQuoteMessage(const QString &permalink, const QString &text);
0052 
0053     bool handleMimeData(const QMimeData *mimeData);
0054 
0055     void clearMessageIdBeingEdited();
0056 
0057     [[nodiscard]] QString threadMessageId() const;
0058     void setThreadMessageId(const QString &threadMessageId, const QString &text = {}, bool replyInDialogBox = false);
0059 
0060     void slotPublicSettingChanged();
0061     void slotOwnUserPreferencesChanged();
0062 
0063     [[nodiscard]] QString quotePermalink() const;
0064 
0065     [[nodiscard]] QString quoteText() const;
0066 
0067 Q_SIGNALS:
0068     void keyPressed(QKeyEvent *ev);
0069     void threadMessageIdChanged(const QString &threadMessageId, const QString &text);
0070     void quoteMessageChanged(const QString &permalink, const QString &text);
0071     void createUploadJob(const RocketChatRestApi::UploadFileJob::UploadFileInfo &info);
0072 
0073 private:
0074     LIBRUQOLAWIDGETS_NO_EXPORT void slotSendMessage(const QString &msg);
0075     LIBRUQOLAWIDGETS_NO_EXPORT void slotTextEditing(bool clearNotification);
0076     LIBRUQOLAWIDGETS_NO_EXPORT void slotSendFile();
0077     LIBRUQOLAWIDGETS_NO_EXPORT void keyPressedInLineEdit(QKeyEvent *ev);
0078     LIBRUQOLAWIDGETS_NO_EXPORT void textEditClicked();
0079     [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT MessagesModel *messageModel() const;
0080     LIBRUQOLAWIDGETS_NO_EXPORT void clearEditingMode();
0081     LIBRUQOLAWIDGETS_NO_EXPORT void sendFile(const UploadFileDialog::UploadFileInfo &uploadFileInfo);
0082     LIBRUQOLAWIDGETS_NO_EXPORT void slotSendVideoMessage();
0083     LIBRUQOLAWIDGETS_NO_EXPORT void slotSendSoundMessage();
0084     LIBRUQOLAWIDGETS_NO_EXPORT void slotPrivateSettingsChanged();
0085 
0086     QString mThreadMessageId;
0087     QString mMessageIdBeingEdited;
0088     QString mQuotePermalink;
0089     QString mQuoteText;
0090     EditingMode mMode = EditingMode::NewMessage;
0091     MessageTextEdit *const mMessageTextEdit;
0092     QToolButton *const mSendFileButton;
0093     QToolButton *const mEmoticonButton;
0094     QToolButton *const mSendMessageButton;
0095     QToolButton *const mVideoMessageButton;
0096     QToolButton *const mSoundMessageButton;
0097     EmoticonMenuWidget *mEmoticonMenuWidget = nullptr;
0098     QPointer<RocketChatAccount> mCurrentRocketChatAccount;
0099     bool mReplyInThreadDialogBox = false;
0100 };