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 #ifndef GENERICCHATROOMWIDGET_H 21 #define GENERICCHATROOMWIDGET_H 22 23 #include "genericchatitemwidget.h" 24 25 class CroppingLabel; 26 class MaskablePixmapWidget; 27 class QVBoxLayout; 28 class QHBoxLayout; 29 class ContentLayout; 30 class Friend; 31 class Group; 32 class Contact; 33 class GenericChatroomWidget : public GenericChatItemWidget 34 { 35 Q_OBJECT 36 public: 37 explicit GenericChatroomWidget(bool compact, QWidget* parent = nullptr); 38 39 public slots: 40 virtual void setAsActiveChatroom() = 0; 41 virtual void setAsInactiveChatroom() = 0; 42 virtual void updateStatusLight() = 0; 43 virtual void resetEventFlags() = 0; 44 virtual QString getStatusString() const = 0; 45 virtual const Contact* getContact() const = 0; getFriend()46 virtual const Friend* getFriend() const 47 { 48 return nullptr; 49 } getGroup()50 virtual Group* getGroup() const 51 { 52 return nullptr; 53 } 54 55 virtual bool eventFilter(QObject*, QEvent*) final override; 56 57 bool isActive(); 58 59 void setName(const QString& name); 60 void setStatusMsg(const QString& status); 61 QString getStatusMsg() const; 62 QString getTitle() const; 63 64 void reloadTheme(); 65 66 void activate(); 67 void compactChange(bool compact); 68 69 signals: 70 void chatroomWidgetClicked(GenericChatroomWidget* widget); 71 void newWindowOpened(GenericChatroomWidget* widget); 72 void middleMouseClicked(); 73 74 protected: 75 void mouseReleaseEvent(QMouseEvent* event) override; 76 void enterEvent(QEvent* e) override; 77 void leaveEvent(QEvent* e) override; 78 void setActive(bool active); 79 80 protected: 81 QPoint dragStartPos; 82 QColor lastColor; 83 QHBoxLayout* mainLayout = nullptr; 84 QVBoxLayout* textLayout = nullptr; 85 MaskablePixmapWidget* avatar; 86 CroppingLabel* statusMessageLabel; 87 bool active; 88 }; 89 90 #endif // GENERICCHATROOMWIDGET_H 91