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

chatlinecontentproxy: scaling behaviour

This commit is contained in:
krepa098 2015-01-02 11:34:28 +01:00
parent 4997788b13
commit 3c9e071a39
3 changed files with 8 additions and 5 deletions

View File

@ -19,7 +19,9 @@
#include <QWidget>
#include <QDebug>
ChatLineContentProxy::ChatLineContentProxy(QWidget* widget)
ChatLineContentProxy::ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent)
: widthMin(minWidth)
, widthPercent(widthInPercent)
{
proxy = new QGraphicsProxyWidget(this);
proxy->setWidget(widget);
@ -47,5 +49,5 @@ qreal ChatLineContentProxy::getAscent() const
void ChatLineContentProxy::setWidth(qreal width)
{
proxy->widget()->setFixedWidth(qMax(width,0.0));
proxy->widget()->setFixedWidth(qMax(static_cast<int>(width*widthPercent), widthMin));
}

View File

@ -23,7 +23,7 @@
class ChatLineContentProxy : public ChatLineContent
{
public:
ChatLineContentProxy(QWidget* widget);
ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent = 1.0f);
virtual QRectF boundingRect() const;
virtual QRectF boundingSceneRect() const;
@ -33,7 +33,8 @@ public:
private:
QGraphicsProxyWidget* proxy;
int widthMin;
float widthPercent;
};
#endif // CHATLINECONTENTPROXY_H

View File

@ -135,7 +135,7 @@ ChatMessage *ChatLog::addFileTransferMessage(const QString &sender, const ToxFil
{
ChatMessage* line = new ChatMessage(scene, QString());
line->addColumn(new Text(sender, self ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
line->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file)), ColumnFormat(1.0, ColumnFormat::VariableSize));
line->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file), 380, 0.6f), ColumnFormat(1.0, ColumnFormat::VariableSize));
line->addColumn(new Text(timestamp.toString("hh:mm"), Style::getFont(Style::Big)), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
insertChatline(line);