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>
|
2020-02-08 11:44:15 +00:00
|
|
|
|
2020-04-03 22:28:15 +00:00
|
|
|
#include "shared/message.h"
|
2019-12-20 15:41:20 +00:00
|
|
|
#include "order.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"
|
2020-02-08 11:44:15 +00:00
|
|
|
#include "ui/utils/messageline.h"
|
|
|
|
#include "ui/utils/flowlayout.h"
|
|
|
|
#include "ui/utils/badge.h"
|
2020-08-15 21:48:28 +00:00
|
|
|
#include "ui/utils/feedview.h"
|
2020-08-20 21:32:30 +00:00
|
|
|
#include "ui/utils/messagedelegate.h"
|
2020-04-12 15:55:05 +00:00
|
|
|
#include "shared/icons.h"
|
|
|
|
#include "shared/utils.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-05-15 17:36:37 +00:00
|
|
|
void showEvent(QShowEvent * event) override;
|
2019-09-12 20:54:44 +00:00
|
|
|
void responseLocalFile(const QString& messageId, const QString& path);
|
2019-11-12 13:38:01 +00:00
|
|
|
void fileError(const QString& messageId, const QString& error);
|
|
|
|
void responseFileProgress(const QString& messageId, qreal progress);
|
2019-12-23 06:28:23 +00:00
|
|
|
virtual void setAvatar(const QString& path);
|
2020-02-08 11:44:15 +00:00
|
|
|
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
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);
|
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);
|
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);
|
2019-06-19 14:15:20 +00:00
|
|
|
void applyVisualEffects();
|
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;
|
2019-04-09 15:04:08 +00:00
|
|
|
|
|
|
|
protected slots:
|
2019-04-09 22:01:25 +00:00
|
|
|
void onEnterPressed();
|
2019-06-21 19:33:38 +00:00
|
|
|
void onAttach();
|
|
|
|
void onFileSelected();
|
2019-09-10 14:33:39 +00:00
|
|
|
void onScrollResize();
|
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);
|
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-04-13 20:38:20 +00:00
|
|
|
enum Scroll {
|
|
|
|
nothing,
|
|
|
|
keep,
|
|
|
|
down
|
|
|
|
};
|
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-13 20:38:20 +00:00
|
|
|
Scroll scroll;
|
2019-04-14 20:37:02 +00:00
|
|
|
bool manualSliderChange;
|
2019-05-15 17:36:37 +00:00
|
|
|
bool requestingHistory;
|
|
|
|
bool everShown;
|
2020-02-04 15:14:51 +00:00
|
|
|
bool tsb; //transient scroll bars
|
2019-04-08 21:40:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONVERSATION_H
|