2019-04-08 21:40:49 +00:00
|
|
|
/*
|
2019-08-14 14:54:46 +00:00
|
|
|
* Squawk messenger.
|
2019-04-08 21:40:49 +00:00
|
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONVERSATION_H
|
|
|
|
#define CONVERSATION_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QScopedPointer>
|
2020-02-08 11:44:15 +00:00
|
|
|
#include <QMap>
|
2020-04-14 16:30:33 +00:00
|
|
|
#include <QMimeData>
|
|
|
|
#include <QFileInfo>
|
2021-05-03 11:23:41 +00:00
|
|
|
#include <QGraphicsOpacityEffect>
|
2021-05-04 14:09:41 +00:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QDesktopServices>
|
2020-02-08 11:44:15 +00:00
|
|
|
|
2020-04-03 22:28:15 +00:00
|
|
|
#include "shared/message.h"
|
2021-05-11 17:29:08 +00:00
|
|
|
#include "shared/order.h"
|
2021-05-15 22:07:49 +00:00
|
|
|
#include "shared/icons.h"
|
|
|
|
#include "shared/utils.h"
|
|
|
|
|
2020-02-08 11:44:15 +00:00
|
|
|
#include "ui/models/account.h"
|
2020-04-11 20:00:15 +00:00
|
|
|
#include "ui/models/roster.h"
|
2021-05-15 22:07:49 +00:00
|
|
|
|
2020-02-08 11:44:15 +00:00
|
|
|
#include "ui/utils/flowlayout.h"
|
|
|
|
#include "ui/utils/badge.h"
|
2021-05-03 00:35:43 +00:00
|
|
|
#include "ui/utils/shadowoverlay.h"
|
2021-05-15 22:07:49 +00:00
|
|
|
|
|
|
|
#include "ui/widgets/messageline/feedview.h"
|
|
|
|
#include "ui/widgets/messageline/messagedelegate.h"
|
2019-04-08 21:40:49 +00:00
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class Conversation;
|
|
|
|
}
|
|
|
|
|
2019-04-09 22:01:25 +00:00
|
|
|
class KeyEnterReceiver : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-04-10 15:22:52 +00:00
|
|
|
public:
|
|
|
|
KeyEnterReceiver(QObject* parent = 0);
|
2019-04-09 22:01:25 +00:00
|
|
|
protected:
|
2019-04-10 15:22:52 +00:00
|
|
|
bool ownEvent;
|
2019-04-09 22:01:25 +00:00
|
|
|
bool eventFilter(QObject* obj, QEvent* event);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void enterPressed();
|
|
|
|
};
|
|
|
|
|
2019-04-08 21:40:49 +00:00
|
|
|
class Conversation : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-04-09 15:04:08 +00:00
|
|
|
public:
|
2020-08-12 16:55:01 +00:00
|
|
|
Conversation(bool muc, Models::Account* acc, Models::Element* el, const QString pJid, const QString pRes, QWidget* parent = 0);
|
2019-04-09 15:04:08 +00:00
|
|
|
~Conversation();
|
|
|
|
|
|
|
|
QString getJid() const;
|
|
|
|
QString getAccount() const;
|
2019-04-12 15:22:10 +00:00
|
|
|
QString getPalResource() const;
|
2020-04-11 20:00:15 +00:00
|
|
|
Models::Roster::ElId getId() const;
|
2019-04-09 15:04:08 +00:00
|
|
|
|
2019-04-12 15:22:10 +00:00
|
|
|
void setPalResource(const QString& res);
|
2019-12-23 06:28:23 +00:00
|
|
|
virtual void setAvatar(const QString& path);
|
2020-04-11 20:00:15 +00:00
|
|
|
void setFeedFrames(bool top, bool right, bool bottom, bool left);
|
2019-04-12 15:22:10 +00:00
|
|
|
|
2019-04-10 20:53:42 +00:00
|
|
|
signals:
|
2019-04-11 14:58:59 +00:00
|
|
|
void sendMessage(const Shared::Message& message);
|
2021-05-22 22:03:14 +00:00
|
|
|
void resendMessage(const QString& id);
|
2019-05-15 17:36:37 +00:00
|
|
|
void requestArchive(const QString& before);
|
2019-06-18 15:08:03 +00:00
|
|
|
void shown();
|
2019-09-12 20:54:44 +00:00
|
|
|
void requestLocalFile(const QString& messageId, const QString& url);
|
|
|
|
void downloadFile(const QString& messageId, const QString& url);
|
2021-04-27 19:29:15 +00:00
|
|
|
void notifyableMessage(const QString& account, const Shared::Message& msg);
|
2019-04-10 20:53:42 +00:00
|
|
|
|
2019-04-09 15:04:08 +00:00
|
|
|
protected:
|
2019-08-28 11:40:55 +00:00
|
|
|
virtual void setName(const QString& name);
|
2020-04-15 13:48:49 +00:00
|
|
|
virtual Shared::Message createMessage() const;
|
2019-09-03 20:28:58 +00:00
|
|
|
void setStatus(const QString& status);
|
2019-09-19 14:31:27 +00:00
|
|
|
void addAttachedFile(const QString& path);
|
|
|
|
void removeAttachedFile(Badge* badge);
|
|
|
|
void clearAttachedFiles();
|
2020-04-14 16:30:33 +00:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
2021-05-03 00:35:43 +00:00
|
|
|
void initializeOverlay();
|
2021-04-27 19:29:15 +00:00
|
|
|
virtual void onMessage(const Shared::Message& msg);
|
2019-04-09 15:04:08 +00:00
|
|
|
|
|
|
|
protected slots:
|
2019-04-09 22:01:25 +00:00
|
|
|
void onEnterPressed();
|
2021-12-18 09:00:33 +00:00
|
|
|
void onImageInserted(const QImage& image);
|
|
|
|
void onFileInserted(const QString& localPath);
|
2019-06-21 19:33:38 +00:00
|
|
|
void onAttach();
|
|
|
|
void onFileSelected();
|
2019-09-19 14:31:27 +00:00
|
|
|
void onBadgeClose();
|
2019-11-14 11:43:43 +00:00
|
|
|
void onClearButton();
|
2020-03-30 21:17:10 +00:00
|
|
|
void onTextEditDocSizeChanged(const QSizeF& size);
|
2020-08-07 23:33:03 +00:00
|
|
|
void onAccountChanged(Models::Item* item, int row, int col);
|
2021-04-27 19:29:15 +00:00
|
|
|
void onFeedMessage(const Shared::Message& msg);
|
2021-05-03 00:35:43 +00:00
|
|
|
void positionShadow();
|
2021-05-04 14:09:41 +00:00
|
|
|
void onFeedContext(const QPoint &pos);
|
2019-04-09 15:04:08 +00:00
|
|
|
|
2019-08-29 14:19:35 +00:00
|
|
|
public:
|
|
|
|
const bool isMuc;
|
|
|
|
|
2019-08-23 09:51:33 +00:00
|
|
|
protected:
|
2019-12-20 15:41:20 +00:00
|
|
|
Models::Account* account;
|
2020-08-12 16:55:01 +00:00
|
|
|
Models::Element* element;
|
2019-08-23 09:51:33 +00:00
|
|
|
QString palJid;
|
|
|
|
QString activePalResource;
|
2019-04-08 21:40:49 +00:00
|
|
|
QScopedPointer<Ui::Conversation> m_ui;
|
2019-04-09 22:01:25 +00:00
|
|
|
KeyEnterReceiver ker;
|
2019-04-12 15:22:10 +00:00
|
|
|
QString thread;
|
2019-08-23 09:51:33 +00:00
|
|
|
QLabel* statusIcon;
|
|
|
|
QLabel* statusLabel;
|
2019-09-19 14:31:27 +00:00
|
|
|
FlowLayout* filesLayout;
|
2020-04-14 16:30:33 +00:00
|
|
|
QWidget* overlay;
|
2019-09-19 14:31:27 +00:00
|
|
|
W::Order<Badge*, Badge::Comparator> filesToAttach;
|
2020-08-15 21:48:28 +00:00
|
|
|
FeedView* feed;
|
2020-08-20 21:32:30 +00:00
|
|
|
MessageDelegate* delegate;
|
2019-04-14 20:37:02 +00:00
|
|
|
bool manualSliderChange;
|
2020-02-04 15:14:51 +00:00
|
|
|
bool tsb; //transient scroll bars
|
2021-10-06 15:09:18 +00:00
|
|
|
|
2021-05-03 00:35:43 +00:00
|
|
|
ShadowOverlay shadow;
|
2021-05-04 14:09:41 +00:00
|
|
|
QMenu* contextMenu;
|
2019-04-08 21:40:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONVERSATION_H
|