qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
chatlinecontentproxy.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 "chatlinecontent.h"
23 #include <QGraphicsProxyWidget>
24 
25 class FileTransferWidget;
26 
28 {
29  Q_OBJECT
30 
31 public:
33  {
36  };
37 
38 public:
39  ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent = 1.0f);
40  ChatLineContentProxy(FileTransferWidget* widget, int minWidth, float widthInPercent = 1.0f);
41 
42  QRectF boundingRect() const override;
43  void setWidth(qreal width) override;
44  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
45  qreal getAscent() const override;
46 
47  QWidget* getWidget() const;
49 
50 protected:
51  ChatLineContentProxy(QWidget* widget, ChatLineContentProxyType type, int minWidth,
52  float widthInPercent);
53 
54 private:
55  QGraphicsProxyWidget* proxy;
56  float widthPercent;
57  int widthMin;
59 };
ChatLineContentProxy::widgetType
const ChatLineContentProxyType widgetType
Definition: chatlinecontentproxy.h:58
ChatLineContentProxy::widthPercent
float widthPercent
Definition: chatlinecontentproxy.h:56
FileTransferWidget
Definition: filetransferwidget.h:37
ChatLineContentProxy::getWidgetType
ChatLineContentProxyType getWidgetType() const
Definition: chatlinecontentproxy.cpp:85
ChatLineContentProxy::GenericType
@ GenericType
Definition: chatlinecontentproxy.h:34
ChatLineContentProxy::setWidth
void setWidth(qreal width) override
Definition: chatlinecontentproxy.cpp:79
ChatLineContentProxy::ChatLineContentProxyType
ChatLineContentProxyType
Type tag to avoid dynamic_cast of contained QWidget*.
Definition: chatlinecontentproxy.h:32
ChatLineContentProxy::FileTransferWidgetType
@ FileTransferWidgetType
Definition: chatlinecontentproxy.h:35
ChatLineContentProxy::boundingRect
QRectF boundingRect() const override
Definition: chatlinecontentproxy.cpp:55
ChatLineContentProxy::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition: chatlinecontentproxy.cpp:62
chatlinecontent.h
ChatLineContentProxy::getAscent
qreal getAscent() const override
Definition: chatlinecontentproxy.cpp:69
ChatLineContentProxy::getWidget
QWidget * getWidget() const
Definition: chatlinecontentproxy.cpp:74
ChatLineContent::type
int type() const final
Definition: chatlinecontent.cpp:33
ChatLineContent
Definition: chatlinecontent.h:26
ChatLineContentProxy
Definition: chatlinecontentproxy.h:27
ChatLineContentProxy::ChatLineContentProxy
ChatLineContentProxy(QWidget *widget, int minWidth, float widthInPercent=1.0f)
Definition: chatlinecontentproxy.cpp:45
ChatLineContentProxy::proxy
QGraphicsProxyWidget * proxy
Definition: chatlinecontentproxy.h:55
ChatLineContentProxy::widthMin
int widthMin
Definition: chatlinecontentproxy.h:57