33 #include <QHBoxLayout>
34 #include <QPushButton>
36 #include <QTextDocument>
37 #include <QToolButton>
39 static const QSize AVATAR_SIZE{40, 40};
40 static const short HEAD_LAYOUT_SPACING = 5;
41 static const short MIC_BUTTONS_LAYOUT_SPACING = 4;
42 static const short BUTTONS_LAYOUT_HOR_SPACING = 4;
45 const QString STYLE_PATH = QStringLiteral(
"chatForm/buttons.css");
47 const QString STATE_NAME[] = {
49 QStringLiteral(
"green"),
50 QStringLiteral(
"red"),
51 QStringLiteral(
"yellow"),
52 QStringLiteral(
"yellow"),
55 const QString CALL_TOOL_TIP[] = {
56 ChatFormHeader::tr(
"Can't start audio call"),
57 ChatFormHeader::tr(
"Start audio call"),
58 ChatFormHeader::tr(
"End audio call"),
59 ChatFormHeader::tr(
"Cancel audio call"),
60 ChatFormHeader::tr(
"Accept audio call"),
63 const QString VIDEO_TOOL_TIP[] = {
64 ChatFormHeader::tr(
"Can't start video call"),
65 ChatFormHeader::tr(
"Start video call"),
66 ChatFormHeader::tr(
"End video call"),
67 ChatFormHeader::tr(
"Cancel video call"),
68 ChatFormHeader::tr(
"Accept video call"),
71 const QString VOL_TOOL_TIP[] = {
72 ChatFormHeader::tr(
"Sound can be disabled only during a call"),
73 ChatFormHeader::tr(
"Mute call"),
74 ChatFormHeader::tr(
"Unmute call"),
77 const QString MIC_TOOL_TIP[] = {
78 ChatFormHeader::tr(
"Microphone can be muted only during a call"),
79 ChatFormHeader::tr(
"Mute microphone"),
80 ChatFormHeader::tr(
"Unmute microphone"),
83 template <
class T,
class Fun>
84 QPushButton* createButton(
const QString& name, T*
self, Fun onClickSlot)
86 QPushButton* btn =
new QPushButton();
87 btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
88 btn->setObjectName(name);
90 QObject::connect(btn, &QPushButton::clicked,
self, onClickSlot);
95 void setStateToolTip(QAbstractButton* btn, State state,
const QString toolTip[])
97 const int index =
static_cast<int>(state);
98 btn->setToolTip(toolTip[index]);
101 template<
class State>
102 void setStateName(QAbstractButton* btn, State state)
104 const int index =
static_cast<int>(state);
105 btn->setProperty(
"state", STATE_NAME[index]);
106 btn->setEnabled(index != 0);
114 , callState{CallButtonState::Disabled}
115 , videoState{CallButtonState::Disabled}
116 , volState{ToolButtonState::Disabled}
117 , micState{ToolButtonState::Disabled}
119 QHBoxLayout* headLayout =
new QHBoxLayout();
121 avatar->setObjectName(
"avatar");
123 nameLine =
new QHBoxLayout();
124 nameLine->setSpacing(3);
129 nameLabel->setObjectName(
"nameLabel");
131 nameLabel->setEditable(
true);
132 nameLabel->setTextFormat(Qt::PlainText);
135 nameLine->addWidget(extensionStatus);
136 nameLine->addWidget(nameLabel);
138 headTextLayout =
new QVBoxLayout();
139 headTextLayout->addStretch();
140 headTextLayout->addLayout(nameLine);
141 headTextLayout->addStretch();
148 QVBoxLayout* micButtonsLayout =
new QVBoxLayout();
149 micButtonsLayout->setSpacing(MIC_BUTTONS_LAYOUT_SPACING);
150 micButtonsLayout->addWidget(micButton, Qt::AlignTop | Qt::AlignRight);
151 micButtonsLayout->addWidget(volButton, Qt::AlignTop | Qt::AlignRight);
153 QGridLayout* buttonsLayout =
new QGridLayout();
154 buttonsLayout->addLayout(micButtonsLayout, 0, 0, 2, 1, Qt::AlignTop | Qt::AlignRight);
155 buttonsLayout->addWidget(callButton, 0, 1, 2, 1, Qt::AlignTop);
156 buttonsLayout->addWidget(videoButton, 0, 2, 2, 1, Qt::AlignTop);
157 buttonsLayout->setVerticalSpacing(0);
158 buttonsLayout->setHorizontalSpacing(BUTTONS_LAYOUT_HOR_SPACING);
160 headLayout->addWidget(avatar);
161 headLayout->addSpacing(HEAD_LAYOUT_SPACING);
162 headLayout->addLayout(headTextLayout);
163 headLayout->addLayout(buttonsLayout);
165 setLayout(headLayout);
179 nameLabel->setToolTip(Qt::convertFromPlainText(newName, Qt::WhiteSpaceNormal));
185 if (
mode == Mode::None) {
244 const bool audioAvaliable = online && (
mode & Mode::Audio);
245 const bool videoAvaliable = online && (
mode & Mode::Video);
246 if (!audioAvaliable) {
256 if (!videoAvaliable) {