32 #include <QApplication>
37 #include <QCloseEvent>
38 #include <QPushButton>
39 #include <QDesktopWidget>
43 const auto BTN_STATE_NONE = QVariant(
"none");
44 const auto BTN_STATE_RED = QVariant(
"red");
45 const int BTN_PANEL_HEIGHT = 55;
46 const int BTN_PANEL_WIDTH = 250;
47 const auto BTN_STYLE_SHEET_PATH = QStringLiteral(
"chatForm/fullScreenButtons.css");
55 verLayout =
new QVBoxLayout(
this);
56 setWindowTitle(tr(
"Tox video"));
58 buttonLayout =
new QHBoxLayout();
60 toggleMessagesButton =
new QPushButton();
61 enterFullScreenButton =
new QPushButton();
62 enterFullScreenButton->setText(tr(
"Full Screen"));
64 buttonLayout->addStretch();
65 buttonLayout->addWidget(toggleMessagesButton);
66 buttonLayout->addWidget(enterFullScreenButton);
71 verLayout->addLayout(buttonLayout);
72 verLayout->setContentsMargins(0, 0, 0, 0);
74 setShowMessages(
false);
76 setStyleSheet(
"NetCamView { background-color: #c1c1c1; }");
77 buttonPanel =
new QFrame(
this);
79 buttonPanel->setGeometry(0, 0, BTN_PANEL_WIDTH, BTN_PANEL_HEIGHT);
81 QHBoxLayout* buttonPanelLayout =
new QHBoxLayout(buttonPanel);
82 buttonPanelLayout->setContentsMargins(20, 0, 20, 0);
84 videoPreviewButton = createButton(
"videoPreviewButton",
"none");
85 videoPreviewButton->setToolTip(tr(
"Toggle video preview"));
87 volumeButton = createButton(
"volButtonFullScreen",
"none");
88 volumeButton->setToolTip(tr(
"Mute audio"));
90 microphoneButton = createButton(
"micButtonFullScreen",
"none");
91 microphoneButton->setToolTip(tr(
"Mute microphone"));
93 endVideoButton = createButton(
"videoButtonFullScreen",
"none");
94 endVideoButton->setToolTip(tr(
"End video call"));
96 exitFullScreenButton = createButton(
"exitFullScreenButton",
"none");
97 exitFullScreenButton->setToolTip(tr(
"Exit full screen"));
105 buttonPanelLayout->addStretch();
106 buttonPanelLayout->addWidget(videoPreviewButton);
107 buttonPanelLayout->addWidget(volumeButton);
108 buttonPanelLayout->addWidget(microphoneButton);
109 buttonPanelLayout->addWidget(endVideoButton);
110 buttonPanelLayout->addWidget(exitFullScreenButton);
111 buttonPanelLayout->addStretch();
114 videoSurface->setMinimumHeight(256);
116 verLayout->insertWidget(0, videoSurface, 1);
119 selfVideoSurface->setObjectName(QStringLiteral(
"CamVideoSurface"));
120 selfVideoSurface->setMouseTracking(
true);
121 selfVideoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
126 QHBoxLayout* frameLayout =
new QHBoxLayout(selfFrame);
127 frameLayout->addWidget(selfVideoSurface);
128 frameLayout->setMargin(0);
135 QRect boundingRect = videoSurface->getBoundingRect();
136 updateFrameSize(boundingRect.size());
137 selfFrame->setBoundary(boundingRect);
141 selfFrame->setMinimumWidth(selfFrame->minimumHeight() * selfVideoSurface->getRatio());
142 QRect boundingRect = videoSurface->getBoundingRect();
143 updateFrameSize(boundingRect.size());
144 selfFrame->resetBoundary(boundingRect);
148 [
this](
const QPixmap& pixmap) { selfVideoSurface->setAvatar(pixmap); });
151 [
this](
ToxPk friendPk,
const QPixmap& pixmap) {
152 if (this->friendPk == friendPk)
153 videoSurface->setAvatar(pixmap);
157 qDebug() <<
"SIZER" << videoSize;
195 setWindowTitle(title);
212 selfFrame->setMaximumSize(size.height() / 3, size.width() / 3);
224 QSize panelSize(0, 45);
226 return surfaceSize + buttonSize + panelSize;
246 if (isFullScreen()) {
255 setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
259 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
260 const auto screenSize = QGuiApplication::screenAt(this->pos())->geometry();
262 const QRect screenSize = QApplication::desktop()->screenGeometry(
this);
265 screenSize.height() - BTN_PANEL_HEIGHT - 25, BTN_PANEL_WIDTH, BTN_PANEL_HEIGHT);
273 setWindowFlags(Qt::Widget);
298 QPushButton* btn =
new QPushButton();
299 btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
300 btn->setObjectName(name);
301 btn->setProperty(
"state", QVariant(state));
319 if (btn->property(
"state") == BTN_STATE_RED) {
320 btn->setProperty(
"state", BTN_STATE_NONE);
322 btn->setProperty(
"state", BTN_STATE_RED);
331 btn->setProperty(
"state", BTN_STATE_NONE);
333 btn->setProperty(
"state", BTN_STATE_RED);
341 int key =
event->key();
342 if (key == Qt::Key_Escape && isFullScreen()) {