#include "userinfo.h"
-const int BACKGROUND_WIDTH = 368; ///< Width for item
-const int BACKGROUND_TOP_HEIGHT = 20; ///< Height for item top
-const int BACKGROUND_BOTTOM_HEIGHT = 15; ///< Height for item bottom
-const int ICON_HEIGHT = 24; ///< Icon height
-const int ICON_WIDTH = 24; ///< Icon width
-const int MARGIN = 5; ///< Icon margin
-const int LINE_LENGTH = 27; ///< Line length
-const int MOUSE_PRESS_AREA_WIDTH = 20; ///< Area width for item height toggling
-const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
-
-/**
-* @var LABEL_MAX_WIDTH
-*
-* @brief All label's maximum width
-*/
-const int LABEL_MAX_WIDTH = BACKGROUND_WIDTH - 3 * MARGIN - ICON_WIDTH + 130;
+const int BACKGROUND_WIDTH = 368;
+const int BACKGROUND_TOP_HEIGHT = 20;
+const int BACKGROUND_BOTTOM_HEIGHT = 15;
+const int ICON_HEIGHT = 24;
+const int ICON_WIDTH = 24;
+const int MARGIN = 5;
+const int LABEL_MAX_WIDTH = 300;
UserInfo::UserInfo(QWidget *parent)
: QWidget(parent),
m_expandedMessageText.clear();
QString temp = "";
for(int i=0;i < text.length();i++) {
- if(fontMetrics().width(temp.append(text.at(i))) > 170) {
+ if(fontMetrics().width(temp.append(text.at(i))) > LABEL_MAX_WIDTH) {
temp.append("\n");
if(temp.startsWith(QString(" ")))
temp.remove(0, 1);
}
}
m_expandedMessageText.append(temp);
+ m_statusTextLabel->setText(m_expandedMessageText);
+
setText(false);
}
{
qDebug() << __PRETTY_FUNCTION__;
+ const int EXTRA_WIDTH_FOR_LABEL = 545;
+
if (expanded) {
m_statusTextLabel->setText(m_expandedMessageText);
}
else {
m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
m_statusTextLabel->setText(shortenText(m_statusTextLabel, m_messageText,
- LABEL_MAX_WIDTH));
+ LABEL_MAX_WIDTH + EXTRA_WIDTH_FOR_LABEL));
}
}
{
qDebug() << __PRETTY_FUNCTION__ << " " << event->pos();
+
+ const int MOUSE_PRESS_AREA_WIDTH = 20;
+ const int MOUSE_PRESS_AREA_HEIGHT = 20;
+
if ((abs(m_mousePosition.y() - event->pos().y()) <= MOUSE_PRESS_AREA_WIDTH) &&
(abs(m_mousePosition.x() - event->pos().x()) <= MOUSE_PRESS_AREA_HEIGHT)) {
if (m_expanded) {
{
qDebug() << __PRETTY_FUNCTION__;
+ const int LINE_LENGTH = 42;
+
QFontMetrics labelMetrics = label->fontMetrics();
QString textParam = text;
int index = textParam.indexOf('\n');
+
int textWidth = fontMetrics().width(textParam);
if (index > 0) {
textParam.truncate(index);
textParam.append("...");
}
- if (textWidth > 250) ///< @todo magic number
- textParam.insert(LINE_LENGTH, QString("\n"));
+
+ if (textWidth > LABEL_MAX_WIDTH)
+ textParam.insert(LINE_LENGTH, QString("\n"));
return labelMetrics.elidedText(textParam, Qt::ElideRight, textMaxWidth);
}