1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#include "QtRosterHeader.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QIcon>
#include <QSizePolicy>
#include "QtStatusWidget.h"
namespace Swift {
QtRosterHeader::QtRosterHeader(QWidget* parent) : QWidget(parent) {
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->setSpacing(0);
vLayout->setContentsMargins(0,0,0,0);
setLayout(vLayout);
//QHBoxLayout* topLayout = new QHBoxLayout();
//vLayout->addLayout(topLayout);
toolBar_ = new QToolBar(this);
vLayout->addWidget(toolBar_);
statusWidget_ = new QtStatusWidget(this);
toolBar_->addWidget(statusWidget_);
statusWidget_->resize(50, statusWidget_->height());
connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type)), this, SLOT(handleChangeStatusRequest(StatusShow::Type)));
nameLabel_ = new QLabel(this);
setName("Me");
//topLayout->addWidget(nameLabel_);
toolBar_->addWidget(nameLabel_);
QHBoxLayout* expandedLayout = new QHBoxLayout();
expandedLayout->setContentsMargins(5,5,5,5);
expandedLayout->setSpacing(11);
avatarLabel_ = new QLabel(this);
setAvatar(":/icons/avatar.png");
expandedLayout->addWidget(avatarLabel_);
statusEdit_ = new QTextEdit(this);
expandedLayout->addWidget(statusEdit_);
statusEdit_->resize(statusEdit_->width(), 64);
statusEdit_->setAcceptRichText(false);
statusEdit_->setReadOnly(false);
setStatusText("Could be here, could be away.");
vLayout->addLayout(expandedLayout);
setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
}
void QtRosterHeader::handleChangeStatusRequest(StatusShow::Type type) {
emitStatus();
}
void QtRosterHeader::emitStatus() {
emit onChangeStatusRequest(statusWidget_->getSelectedStatusShow(), statusEdit_->toPlainText());
}
void QtRosterHeader::setStatusText(const QString& statusMessage) {
statusEdit_->setText(statusMessage);
}
void QtRosterHeader::setName(const QString& name) {
QString escapedName = name;
escapedName.replace("<","<");
nameLabel_->setText("<b>" + escapedName + "</b>");
}
void QtRosterHeader::setAvatar(const QString& path) {
avatarLabel_->setPixmap(QIcon(path).pixmap(64, 64));
}
QSize QtRosterHeader::sizeHint() const {
return minimumSizeHint();
}
}
|