2015-06-19 22:58:48 +08:00
|
|
|
/*
|
2018-04-13 04:02:28 +08:00
|
|
|
Copyright © 2015-2018 by The qTox Project Contributors
|
2015-06-19 22:58:48 +08:00
|
|
|
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
qTox is libre 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.
|
|
|
|
|
|
|
|
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONTENTDIALOG_H
|
|
|
|
#define CONTENTDIALOG_H
|
|
|
|
|
2016-12-19 10:26:26 +08:00
|
|
|
#include "src/widget/genericchatitemlayout.h"
|
|
|
|
#include "src/widget/tool/activatedialog.h"
|
2018-12-25 02:36:36 +08:00
|
|
|
#include "src/core/core.h" // Status
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2018-07-17 20:29:36 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <tuple>
|
|
|
|
|
2017-02-26 19:52:45 +08:00
|
|
|
template <typename K, typename V>
|
|
|
|
class QHash;
|
|
|
|
template <typename T>
|
|
|
|
class QSet;
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2017-02-26 22:22:28 +08:00
|
|
|
class ContentDialog;
|
2015-06-19 22:58:48 +08:00
|
|
|
class ContentLayout;
|
2018-02-10 00:45:31 +08:00
|
|
|
class Friend;
|
|
|
|
class FriendChatroom;
|
|
|
|
class FriendListLayout;
|
|
|
|
class FriendWidget;
|
2018-02-02 04:49:21 +08:00
|
|
|
class GenericChatForm;
|
2015-06-19 22:58:48 +08:00
|
|
|
class GenericChatroomWidget;
|
2016-08-19 20:44:30 +08:00
|
|
|
class Group;
|
2018-07-17 20:29:36 +08:00
|
|
|
class GroupChatroom;
|
2018-02-10 00:45:31 +08:00
|
|
|
class GroupWidget;
|
2018-12-25 02:36:36 +08:00
|
|
|
class QCloseEvent;
|
2018-02-10 00:45:31 +08:00
|
|
|
class QSplitter;
|
|
|
|
class QVBoxLayout;
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2017-02-26 22:22:28 +08:00
|
|
|
using ContactInfo = std::tuple<ContentDialog*, GenericChatroomWidget*>;
|
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
class ContentDialog : public ActivateDialog
|
2015-06-19 22:58:48 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-10-31 02:35:54 +08:00
|
|
|
explicit ContentDialog(QWidget* parent = nullptr);
|
|
|
|
~ContentDialog() override;
|
2015-06-23 02:01:50 +08:00
|
|
|
|
2018-07-17 20:29:36 +08:00
|
|
|
FriendWidget* addFriend(std::shared_ptr<FriendChatroom> chatroom, GenericChatForm* form);
|
|
|
|
GroupWidget* addGroup(std::shared_ptr<GroupChatroom> chatroom, GenericChatForm* form);
|
2018-12-25 02:36:39 +08:00
|
|
|
void removeFriend(int friendId);
|
|
|
|
void removeGroup(int groupId);
|
2015-06-23 02:01:50 +08:00
|
|
|
int chatroomWidgetCount() const;
|
2015-07-01 19:49:36 +08:00
|
|
|
void ensureSplitterVisible();
|
2017-02-26 22:22:28 +08:00
|
|
|
void updateTitleAndStatusIcon();
|
2015-06-23 02:01:50 +08:00
|
|
|
|
2015-06-30 00:26:49 +08:00
|
|
|
void cycleContacts(bool forward, bool loop = true);
|
2016-06-30 18:29:30 +08:00
|
|
|
void onVideoShow(QSize size);
|
|
|
|
void onVideoHide();
|
2015-06-30 00:26:49 +08:00
|
|
|
|
2018-12-25 02:36:36 +08:00
|
|
|
void addFriendWidget(FriendWidget* widget, Status status);
|
|
|
|
bool isActiveWidget(GenericChatroomWidget* widget);
|
|
|
|
|
2018-12-25 02:36:39 +08:00
|
|
|
bool hasFriendWidget(int friendId) const;
|
|
|
|
bool hasGroupWidget(int groupId) const;
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2018-12-25 02:36:48 +08:00
|
|
|
void focusFriend(int friendId);
|
|
|
|
void focusGroup(int groupId);
|
|
|
|
|
2018-12-25 02:36:51 +08:00
|
|
|
bool containsFriend(int friendId) const;
|
|
|
|
bool containsGroup(int groupId) const;
|
|
|
|
|
2018-12-25 02:04:22 +08:00
|
|
|
void updateFriendStatus(int friendId, Status status);
|
|
|
|
void updateFriendStatusLight(int friendId);
|
|
|
|
void updateGroupStatusLight(int groupId);
|
|
|
|
|
|
|
|
bool isFriendWidgetActive(int friendId);
|
|
|
|
bool isGroupWidgetActive(int groupId);
|
|
|
|
|
2018-12-25 02:20:01 +08:00
|
|
|
void setStatusMessage(int friendId, const QString& message);
|
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
signals:
|
2017-07-26 18:02:32 +08:00
|
|
|
void friendDialogShown(const Friend* f);
|
2016-08-19 20:44:30 +08:00
|
|
|
void groupDialogShown(Group* g);
|
2015-07-30 07:46:19 +08:00
|
|
|
void activated();
|
2018-12-25 02:36:36 +08:00
|
|
|
void willClose();
|
2015-07-30 07:46:19 +08:00
|
|
|
|
2015-06-30 00:26:49 +08:00
|
|
|
public slots:
|
2017-02-26 22:22:28 +08:00
|
|
|
void reorderLayouts(bool newGroupOnTop);
|
2015-06-30 00:26:49 +08:00
|
|
|
void previousContact();
|
|
|
|
void nextContact();
|
2017-02-26 22:22:28 +08:00
|
|
|
void setUsername(const QString& newName);
|
2015-06-30 00:26:49 +08:00
|
|
|
|
2015-06-19 22:58:48 +08:00
|
|
|
protected:
|
2015-07-01 19:49:36 +08:00
|
|
|
bool event(QEvent* event) final override;
|
2015-06-23 02:01:50 +08:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event) final override;
|
|
|
|
void dropEvent(QDropEvent* event) final override;
|
|
|
|
void changeEvent(QEvent* event) override;
|
2015-06-19 22:58:48 +08:00
|
|
|
void resizeEvent(QResizeEvent* event) override;
|
2015-07-03 01:16:11 +08:00
|
|
|
void moveEvent(QMoveEvent* event) override;
|
2015-07-03 21:16:27 +08:00
|
|
|
void keyPressEvent(QKeyEvent* event) override;
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2018-12-25 02:36:36 +08:00
|
|
|
public slots:
|
|
|
|
void activate(GenericChatroomWidget* widget);
|
|
|
|
|
2015-06-19 22:58:48 +08:00
|
|
|
private slots:
|
2016-08-24 08:13:26 +08:00
|
|
|
void updateFriendWidget(uint32_t friendId, QString alias);
|
2015-06-30 00:26:49 +08:00
|
|
|
void onGroupchatPositionChanged(bool top);
|
2015-06-19 22:58:48 +08:00
|
|
|
|
|
|
|
private:
|
2018-12-25 02:36:39 +08:00
|
|
|
void closeIfEmpty();
|
2018-12-25 02:36:36 +08:00
|
|
|
void closeEvent(QCloseEvent* event) override;
|
|
|
|
|
2015-07-03 02:38:18 +08:00
|
|
|
void retranslateUi();
|
2015-06-19 22:58:48 +08:00
|
|
|
void saveDialogGeometry();
|
|
|
|
void saveSplitterState();
|
2015-06-30 00:26:49 +08:00
|
|
|
QLayout* nextLayout(QLayout* layout, bool forward) const;
|
2017-02-26 22:22:28 +08:00
|
|
|
int getCurrentLayout(QLayout*& layout);
|
2018-12-25 02:36:48 +08:00
|
|
|
void focusCommon(int id, QHash<int, GenericChatroomWidget*> list);
|
|
|
|
|
|
|
|
private:
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2017-02-26 22:22:28 +08:00
|
|
|
QList<QLayout*> layouts;
|
2015-06-19 22:58:48 +08:00
|
|
|
QSplitter* splitter;
|
2015-06-27 04:13:20 +08:00
|
|
|
FriendListLayout* friendLayout;
|
2015-06-30 00:26:49 +08:00
|
|
|
GenericChatItemLayout groupLayout;
|
2015-06-19 22:58:48 +08:00
|
|
|
ContentLayout* contentLayout;
|
|
|
|
GenericChatroomWidget* activeChatroomWidget;
|
2016-06-30 18:29:30 +08:00
|
|
|
QSize videoSurfaceSize;
|
|
|
|
int videoCount;
|
|
|
|
|
2018-12-25 02:36:39 +08:00
|
|
|
QHash<int, GenericChatroomWidget*> friendWidgets;
|
|
|
|
QHash<int, GenericChatroomWidget*> groupWidgets;
|
|
|
|
|
2018-02-02 04:49:21 +08:00
|
|
|
QHash<int, GenericChatForm*> friendChatForms;
|
2018-02-02 06:13:46 +08:00
|
|
|
QHash<int, GenericChatForm*> groupChatForms;
|
2018-12-25 02:36:36 +08:00
|
|
|
|
|
|
|
QString username;
|
2015-06-19 22:58:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONTENTDIALOG_H
|