1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/src/widget/contentdialog.h

152 lines
4.4 KiB
C
Raw Normal View History

2015-06-19 22:58:48 +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
#include "src/widget/genericchatitemlayout.h"
#include "src/widget/tool/activatedialog.h"
#include "src/core/core.h" // Status
2015-06-19 22:58:48 +08:00
#include <memory>
#include <tuple>
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;
class Friend;
class FriendChatroom;
class FriendListLayout;
class FriendWidget;
class GenericChatForm;
2015-06-19 22:58:48 +08:00
class GenericChatroomWidget;
class Group;
class GroupChatroom;
class GroupWidget;
class QCloseEvent;
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*>;
class ContentDialog : public ActivateDialog
2015-06-19 22:58:48 +08:00
{
Q_OBJECT
public:
explicit ContentDialog(QWidget* parent = nullptr);
~ContentDialog() override;
FriendWidget* addFriend(std::shared_ptr<FriendChatroom> chatroom, GenericChatForm* form);
GroupWidget* addGroup(std::shared_ptr<GroupChatroom> chatroom, GenericChatForm* form);
void removeFriend(int friendId);
void removeGroup(int groupId);
int chatroomWidgetCount() const;
void ensureSplitterVisible();
2017-02-26 22:22:28 +08:00
void updateTitleAndStatusIcon();
void cycleContacts(bool forward, bool loop = true);
void onVideoShow(QSize size);
void onVideoHide();
void addFriendWidget(FriendWidget* widget, Status status);
bool isActiveWidget(GenericChatroomWidget* widget);
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);
void setStatusMessage(int friendId, const QString& message);
signals:
2017-07-26 18:02:32 +08:00
void friendDialogShown(const Friend* f);
void groupDialogShown(Group* g);
void activated();
void willClose();
public slots:
2017-02-26 22:22:28 +08:00
void reorderLayouts(bool newGroupOnTop);
void previousContact();
void nextContact();
2017-02-26 22:22:28 +08:00
void setUsername(const QString& newName);
2015-06-19 22:58:48 +08:00
protected:
bool event(QEvent* event) final override;
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;
void moveEvent(QMoveEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
2015-06-19 22:58:48 +08:00
public slots:
void activate(GenericChatroomWidget* widget);
2015-06-19 22:58:48 +08:00
private slots:
void updateFriendWidget(uint32_t friendId, QString alias);
void onGroupchatPositionChanged(bool top);
2015-06-19 22:58:48 +08:00
private:
void closeIfEmpty();
void closeEvent(QCloseEvent* event) override;
void retranslateUi();
2015-06-19 22:58:48 +08:00
void saveDialogGeometry();
void saveSplitterState();
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;
FriendListLayout* friendLayout;
GenericChatItemLayout groupLayout;
2015-06-19 22:58:48 +08:00
ContentLayout* contentLayout;
GenericChatroomWidget* activeChatroomWidget;
QSize videoSurfaceSize;
int videoCount;
QHash<int, GenericChatroomWidget*> friendWidgets;
QHash<int, GenericChatroomWidget*> groupWidgets;
QHash<int, GenericChatForm*> friendChatForms;
QHash<int, GenericChatForm*> groupChatForms;
QString username;
2015-06-19 22:58:48 +08:00
};
#endif // CONTENTDIALOG_H