Show webfinger if displayName is unknown for an author.
[larjonas-pumpa.git] / src / messagewindow.h
blob2158804ed0a32692bcae8c5bcd7e9e41eb8b6eb5
1 /*
2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Pumpa is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef MESSAGE_WINDOW_H
21 #define MESSAGE_WINDOW_H
23 #include <QDialog>
24 #include <QShowEvent>
25 #include <QVBoxLayout>
26 #include <QLabel>
27 #include <QHBoxLayout>
28 #include <QPushButton>
29 #include <QFormLayout>
30 #include <QLineEdit>
31 #include <QCheckBox>
32 #include <QScrollArea>
33 #include <QSplitter>
35 #include "messageedit.h"
36 #include "qactivitystreams.h"
37 #include "pumpasettings.h"
38 #include "texttoolbutton.h"
39 #include "richtextlabel.h"
40 #include "messagerecipients.h"
42 //------------------------------------------------------------------------------
44 class PictureLabel : public QLabel {
45 Q_OBJECT
47 public:
48 PictureLabel(QWidget* parent);
49 void setOriginalPixmap(QPixmap);
51 protected:
52 virtual void resizeEvent(QResizeEvent* event);
54 QPixmap m_originalPixmap;
57 //------------------------------------------------------------------------------
59 class MessageWindow : public QDialog {
60 Q_OBJECT
62 public:
63 MessageWindow(PumpaSettings* s, const RecipientList* rl, QWidget* parent=0);
64 virtual void accept();
66 void newMessage(QASObject* obj, QASObjectList* to, QASObjectList* cc);
67 void editMessage(QASObject* obj);
68 void clear();
69 void setCompletions(const MessageEdit::completion_t* completions);
71 protected:
72 virtual void showEvent(QShowEvent*);
74 signals:
75 void sendMessage(QString, QString, RecipientList, RecipientList);
76 void sendImage(QString, QString, QString, RecipientList, RecipientList);
77 void sendReply(QASObject*, QString, RecipientList, RecipientList);
78 void sendEdit(QASObject*, QString, QString);
80 private slots:
81 void onAddPicture();
82 void onRemovePicture();
83 void togglePreview();
84 void updatePreview(bool force=false);
85 void onAddRecipient(QASActor*);
86 void onAddTo();
87 void onAddCc();
88 void onMarkdownChecked(int);
90 private:
91 void initWindow(QString title, QString buttonText, bool showRecipients);
92 void addRecipientWindow(MessageRecipients*, QString);
93 void updateAddPicture();
95 void copyRecipients(MessageRecipients*, QASObjectList*);
96 void setDefaultRecipients(MessageRecipients*, int);
97 void addToRecipientList(QString, QASObject*);
99 QVBoxLayout* m_layout;
101 QLabel* m_infoLabel;
102 QLabel* m_markupLabel;
103 QHBoxLayout* m_infoLayout;
105 QCheckBox* m_markdownCheckBox;
107 QFormLayout* m_addressLayout;
109 MessageEdit* m_textEdit;
110 QHBoxLayout* m_buttonLayout;
112 QHBoxLayout* m_pictureButtonLayout;
113 TextToolButton* m_addPictureButton;
114 TextToolButton* m_removePictureButton;
115 TextToolButton* m_addToButton;
116 TextToolButton* m_addCcButton;
118 QLabel* m_toLabel;
119 QLabel* m_ccLabel;
121 QLabel* m_charCountLabel;
122 RichTextLabel* m_previewLabel;
123 QScrollArea* m_previewArea;
124 QSplitter* m_splitter;
126 PictureLabel* m_pictureLabel;
127 QLineEdit* m_title;
129 QPushButton* m_cancelButton;
130 QPushButton* m_sendButton;
131 QPushButton* m_previewButton;
133 QString m_imageFileName;
135 MessageRecipients* m_toRecipients;
136 MessageRecipients* m_ccRecipients;
138 QMap<QString, QASObject*> m_recipientSelection;
139 QStringList m_recipientList;
141 bool m_editing;
142 bool m_isReply;
144 QASObject* m_obj;
145 PumpaSettings* m_s;
146 const RecipientList* m_rl;
149 #endif