qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
addfriendform.h
Go to the documentation of this file.
1 /*
2  Copyright © 2014-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it 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.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "src/core/toxid.h"
23 
24 #include <QVBoxLayout>
25 #include <QHBoxLayout>
26 #include <QLabel>
27 #include <QLineEdit>
28 #include <QPushButton>
29 #include <QSet>
30 #include <QTextEdit>
31 #include <QVBoxLayout>
32 
33 class QTabWidget;
34 
35 class ContentLayout;
36 
37 class AddFriendForm : public QObject
38 {
39  Q_OBJECT
40 public:
41  enum Mode
42  {
43  AddFriend = 0,
46  };
47 
48  AddFriendForm(ToxId _ownId);
49  AddFriendForm(const AddFriendForm&) = delete;
50  AddFriendForm& operator=(const AddFriendForm&) = delete;
52 
53  bool isShown() const;
54  void show(ContentLayout* contentLayout);
55  void setMode(Mode mode);
56 
57  bool addFriendRequest(const QString& friendAddress, const QString& message);
58 
59 signals:
60  void friendRequested(const ToxId& friendAddress, const QString& message);
61  void friendRequestAccepted(const ToxPk& friendAddress);
62  void friendRequestsSeen();
63 
64 public slots:
65  void onUsernameSet(const QString& userName);
66 
67 private slots:
68  void onSendTriggered();
69  void onIdChanged(const QString& id);
70  void onImportSendClicked();
71  void onImportOpenClicked();
74  void onCurrentChanged(int index);
75 
76 private:
77  void addFriend(const QString& idText);
78  void retranslateUi();
79  void addFriendRequestWidget(const QString& friendAddress, const QString& message);
80  void removeFriendRequestWidget(QWidget* friendWidget);
81  void retranslateAcceptButton(QPushButton* acceptButton);
82  void retranslateRejectButton(QPushButton* rejectButton);
83  void deleteFriendRequest(const ToxId& toxId);
84  void setIdFromClipboard();
85  QString getMessage() const;
86  QString getImportMessage() const;
87 
88 private:
89  QLabel headLabel;
90  QLabel toxIdLabel;
91  QLabel messageLabel;
94 
95  QPushButton sendButton;
96  QPushButton importFileButton;
97  QPushButton importSendButton;
98  QLineEdit toxId;
99  QTextEdit message;
100  QTextEdit importMessage;
101  QVBoxLayout layout;
102  QVBoxLayout headLayout;
103  QVBoxLayout importContactsLayout;
104  QHBoxLayout importFileLine;
105  QWidget* head;
106  QWidget* main;
107  QWidget* importContacts;
108  QString lastUsername;
109  QTabWidget* tabWidget;
110  QVBoxLayout* requestsLayout;
114 
116 };
AddFriendForm::layout
QVBoxLayout layout
Definition: addfriendform.h:101
AddFriendForm::importMessage
QTextEdit importMessage
Definition: addfriendform.h:100
AddFriendForm::onSendTriggered
void onSendTriggered()
Definition: addfriendform.cpp:220
AddFriendForm::onIdChanged
void onIdChanged(const QString &id)
Definition: addfriendform.cpp:279
toxid.h
AddFriendForm::show
void show(ContentLayout *contentLayout)
Definition: addfriendform.cpp:149
AddFriendForm::AddFriend
@ AddFriend
Definition: addfriendform.h:43
AddFriendForm::onImportSendClicked
void onImportSendClicked()
Definition: addfriendform.cpp:229
AddFriendForm::importMessageLabel
QLabel importMessageLabel
Definition: addfriendform.h:93
AddFriendForm::contactsToImport
QList< QString > contactsToImport
Definition: addfriendform.h:113
AddFriendForm::AddFriendForm
AddFriendForm(ToxId _ownId)
Definition: addfriendform.cpp:64
AddFriendForm::onImportOpenClicked
void onImportOpenClicked()
Definition: addfriendform.cpp:240
AddFriendForm::isShown
bool isShown() const
Definition: addfriendform.cpp:139
AddFriendForm::setIdFromClipboard
void setIdFromClipboard()
Definition: addfriendform.cpp:301
AddFriendForm::friendRequestAccepted
void friendRequestAccepted(const ToxPk &friendAddress)
AddFriendForm::deleteFriendRequest
void deleteFriendRequest(const ToxId &toxId)
Definition: addfriendform.cpp:312
AddFriendForm::retranslateRejectButton
void retranslateRejectButton(QPushButton *rejectButton)
Definition: addfriendform.cpp:442
QList< QPushButton * >
AddFriendForm::importContacts
QWidget * importContacts
Definition: addfriendform.h:107
AddFriendForm::friendRequestsSeen
void friendRequestsSeen()
AddFriendForm::onFriendRequestAccepted
void onFriendRequestAccepted()
Definition: addfriendform.cpp:324
AddFriendForm::message
QTextEdit message
Definition: addfriendform.h:99
AddFriendForm::toxId
QLineEdit toxId
Definition: addfriendform.h:98
AddFriendForm::importFileLine
QHBoxLayout importFileLine
Definition: addfriendform.h:104
AddFriendForm::friendRequested
void friendRequested(const ToxId &friendAddress, const QString &message)
AddFriendForm::lastUsername
QString lastUsername
Cached username so we can retranslate the invite message.
Definition: addfriendform.h:108
AddFriendForm::tabWidget
QTabWidget * tabWidget
Definition: addfriendform.h:109
AddFriendForm::onUsernameSet
void onUsernameSet(const QString &userName)
Definition: addfriendform.cpp:194
AddFriendForm::sendButton
QPushButton sendButton
Definition: addfriendform.h:95
AddFriendForm::Mode
Mode
Definition: addfriendform.h:41
AddFriendForm::ownId
ToxId ownId
Definition: addfriendform.h:115
ToxPk
This class represents a Tox Public Key, which is a part of Tox ID.
Definition: toxpk.h:26
AddFriendForm
Definition: addfriendform.h:37
AddFriendForm::acceptButtons
QList< QPushButton * > acceptButtons
Definition: addfriendform.h:111
AddFriendForm::getImportMessage
QString getImportMessage() const
Definition: addfriendform.cpp:170
AddFriendForm::onFriendRequestRejected
void onFriendRequestRejected()
Definition: addfriendform.cpp:337
AddFriendForm::addFriendRequest
bool addFriendRequest(const QString &friendAddress, const QString &message)
Definition: addfriendform.cpp:181
AddFriendForm::retranslateAcceptButton
void retranslateAcceptButton(QPushButton *acceptButton)
Definition: addfriendform.cpp:437
AddFriendForm::onCurrentChanged
void onCurrentChanged(int index)
Definition: addfriendform.cpp:348
AddFriendForm::removeFriendRequestWidget
void removeFriendRequestWidget(QWidget *friendWidget)
Definition: addfriendform.cpp:428
ToxId
This class represents a Tox ID.
Definition: toxid.h:29
AddFriendForm::importFileButton
QPushButton importFileButton
Definition: addfriendform.h:96
AddFriendForm::messageLabel
QLabel messageLabel
Definition: addfriendform.h:91
AddFriendForm::main
QWidget * main
Definition: addfriendform.h:106
AddFriendForm::getMessage
QString getMessage() const
Definition: addfriendform.cpp:164
AddFriendForm::importContactsLayout
QVBoxLayout importContactsLayout
Definition: addfriendform.h:103
AddFriendForm::importSendButton
QPushButton importSendButton
Definition: addfriendform.h:97
AddFriendForm::operator=
AddFriendForm & operator=(const AddFriendForm &)=delete
ContentLayout
Definition: contentlayout.h:25
AddFriendForm::importFileLabel
QLabel importFileLabel
Definition: addfriendform.h:92
AddFriendForm::addFriend
void addFriend(const QString &idText)
Definition: addfriendform.cpp:200
AddFriendForm::FriendRequest
@ FriendRequest
Definition: addfriendform.h:45
AddFriendForm::addFriendRequestWidget
void addFriendRequestWidget(const QString &friendAddress, const QString &message)
Definition: addfriendform.cpp:393
AddFriendForm::setMode
void setMode(Mode mode)
Definition: addfriendform.cpp:176
AddFriendForm::head
QWidget * head
Definition: addfriendform.h:105
AddFriendForm::headLabel
QLabel headLabel
Definition: addfriendform.h:89
AddFriendForm::rejectButtons
QList< QPushButton * > rejectButtons
Definition: addfriendform.h:112
AddFriendForm::headLayout
QVBoxLayout headLayout
Definition: addfriendform.h:102
AddFriendForm::requestsLayout
QVBoxLayout * requestsLayout
Definition: addfriendform.h:110
AddFriendForm::ImportContacts
@ ImportContacts
Definition: addfriendform.h:44
AddFriendForm::~AddFriendForm
~AddFriendForm()
Definition: addfriendform.cpp:132
AddFriendForm::toxIdLabel
QLabel toxIdLabel
Definition: addfriendform.h:90
AddFriendForm::retranslateUi
void retranslateUi()
Definition: addfriendform.cpp:357