2015-06-19 22:58:48 +08:00
|
|
|
/*
|
2016-11-28 21:33:38 +08:00
|
|
|
Copyright © 2015 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
|
|
|
|
|
|
|
|
#include <tuple>
|
2016-06-30 18:29:30 +08:00
|
|
|
|
2016-11-15 16:00:23 +08:00
|
|
|
#include "core/corestructs.h"
|
|
|
|
#include "widget/genericchatitemlayout.h"
|
|
|
|
#include "widget/tool/activatedialog.h"
|
2015-06-19 22:58:48 +08:00
|
|
|
|
|
|
|
template <typename K, typename V> class QHash;
|
2015-07-03 02:38:18 +08:00
|
|
|
template <typename T> class QSet;
|
2015-06-19 22:58:48 +08:00
|
|
|
|
|
|
|
class QSplitter;
|
|
|
|
class QVBoxLayout;
|
|
|
|
class ContentLayout;
|
|
|
|
class GenericChatroomWidget;
|
2015-06-23 02:01:50 +08:00
|
|
|
class FriendWidget;
|
|
|
|
class GroupWidget;
|
2015-06-27 04:13:20 +08:00
|
|
|
class FriendListLayout;
|
2015-06-30 00:26:49 +08:00
|
|
|
class SettingsWidget;
|
2016-08-19 20:44:30 +08:00
|
|
|
class Friend;
|
|
|
|
class Group;
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
class ContentDialog : public ActivateDialog
|
2015-06-19 22:58:48 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-06-30 00:26:49 +08:00
|
|
|
ContentDialog(SettingsWidget* settingsWidget, QWidget* parent = 0);
|
2015-06-19 22:58:48 +08:00
|
|
|
~ContentDialog();
|
2015-06-23 02:01:50 +08:00
|
|
|
|
|
|
|
FriendWidget* addFriend(int friendId, QString id);
|
|
|
|
GroupWidget* addGroup(int groupId, const QString& name);
|
|
|
|
void removeFriend(int friendId);
|
|
|
|
void removeGroup(int groupId);
|
|
|
|
bool hasFriendWidget(int friendId, GenericChatroomWidget* chatroomWidget);
|
|
|
|
bool hasGroupWidget(int groupId, GenericChatroomWidget* chatroomWidget);
|
|
|
|
int chatroomWidgetCount() const;
|
2015-07-01 19:49:36 +08:00
|
|
|
void ensureSplitterVisible();
|
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
|
|
|
|
2015-06-19 22:58:48 +08:00
|
|
|
static ContentDialog* current();
|
2015-06-23 02:01:50 +08:00
|
|
|
static bool existsFriendWidget(int friendId, bool focus);
|
|
|
|
static bool existsGroupWidget(int groupId, bool focus);
|
|
|
|
static void updateFriendStatus(int friendId);
|
|
|
|
static void updateFriendStatusMessage(int friendId, const QString &message);
|
|
|
|
static void updateGroupStatus(int groupId);
|
|
|
|
static bool isFriendWidgetActive(int friendId);
|
|
|
|
static bool isGroupWidgetActive(int groupId);
|
|
|
|
static ContentDialog* getFriendDialog(int friendId);
|
|
|
|
static ContentDialog* getGroupDialog(int groupId);
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
signals:
|
2016-08-19 20:44:30 +08:00
|
|
|
void friendDialogShown(Friend* f);
|
|
|
|
void groupDialogShown(Group* g);
|
|
|
|
#ifdef Q_OS_MAC
|
2015-07-30 07:46:19 +08:00
|
|
|
void activated();
|
|
|
|
#endif
|
|
|
|
|
2015-06-30 00:26:49 +08:00
|
|
|
public slots:
|
2016-01-05 05:34:30 +08:00
|
|
|
void updateTitleAndStatusIcon(const QString& username);
|
2015-07-03 01:16:11 +08:00
|
|
|
void updateTitle(GenericChatroomWidget* chatroomWidget);
|
2015-06-30 00:26:49 +08:00
|
|
|
void previousContact();
|
|
|
|
void nextContact();
|
|
|
|
|
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
|
|
|
|
|
|
|
private slots:
|
2015-06-23 02:01:50 +08:00
|
|
|
void onChatroomWidgetClicked(GenericChatroomWidget* widget, bool group);
|
|
|
|
void updateFriendWidget(FriendWidget* w, Status s);
|
|
|
|
void updateGroupWidget(GroupWidget* w);
|
2015-06-30 00:26:49 +08:00
|
|
|
void onGroupchatPositionChanged(bool top);
|
2015-06-19 22:58:48 +08:00
|
|
|
|
|
|
|
private:
|
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;
|
2015-06-19 22:58:48 +08:00
|
|
|
|
2015-06-23 02:01:50 +08:00
|
|
|
bool hasWidget(int id, GenericChatroomWidget* chatroomWidget, const QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>>& list);
|
|
|
|
static bool existsWidget(int id, bool focus, const QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>>& list);
|
|
|
|
static void updateStatus(int id, const QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>>& list);
|
|
|
|
static bool isWidgetActive(int id, const QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>>& list);
|
|
|
|
static ContentDialog* getDialog(int id, const QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>>& list);
|
|
|
|
|
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;
|
2015-07-03 01:16:11 +08:00
|
|
|
GenericChatroomWidget* displayWidget = nullptr;
|
2015-06-30 00:26:49 +08:00
|
|
|
SettingsWidget* settingsWidget;
|
2016-06-30 18:29:30 +08:00
|
|
|
QSize videoSurfaceSize;
|
|
|
|
int videoCount;
|
|
|
|
|
2015-06-19 22:58:48 +08:00
|
|
|
static ContentDialog* currentDialog;
|
|
|
|
static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> friendList;
|
2015-06-23 02:01:50 +08:00
|
|
|
static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> groupList;
|
2015-06-19 22:58:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONTENTDIALOG_H
|