| 1 |
/* |
| 2 |
* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd. |
| 3 |
* |
| 4 |
* Author: ZhangYong <[email protected]> |
| 5 |
* |
| 6 |
* Maintainer: ZhangYong <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
#include "videoinfodialog.h" |
| 22 |
#include "controller/signalmanager.h" |
| 23 |
#include "utils/imageutils.h" |
| 24 |
#include "imageengineapi.h" |
| 25 |
#include "utils/unionimage.h" |
| 26 |
#include "widgets/formlabel.h" |
| 27 |
|
| 28 |
#include "dfmdarrowlineexpand.h" |
| 29 |
|
| 30 |
#include <QFormLayout> |
| 31 |
#include <QLocale> |
| 32 |
#include <QApplication> |
| 33 |
#include <QScrollBar> |
| 34 |
|
| 35 |
#include <DTitlebar> |
| 36 |
#include <DApplicationHelper> |
| 37 |
#include <DFontSizeManager> |
| 38 |
#include "application.h" |
| 39 |
#include "mainwindow.h" |
| 40 |
#include "movieservice.h" |
| 41 |
|
| 42 |
struct MetaData { |
| 43 |
QString key; |
| 44 |
const char *name; |
| 45 |
}; |
| 46 |
|
| 47 |
VideoInfoDialog::VideoInfoDialog(const QString &path, QWidget *parent): DDialog(parent) |
| 48 |
{ |
| 49 |
QFont font; |
| 50 |
m_currentFontSize = DFontSizeManager::instance()->fontPixelSize(font); |
| 51 |
QLocale locale; |
| 52 |
if (locale.language() == QLocale::Chinese) //语言为中文 |
| 53 |
m_title_maxwidth = 60; |
| 54 |
else |
| 55 |
m_title_maxwidth = 108; |
| 56 |
this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); |
| 57 |
initUI(); |
| 58 |
setVideoInfo(path); |
| 59 |
} |
| 60 |
|
| 61 |
void VideoInfoDialog::setVideoInfo(const QString &path) |
| 62 |
{ |
| 63 |
bool is = false; |
| 64 |
//获取视频信息 |
| 65 |
m_movieInfo = MovieService::instance()->getMovieInfo(QUrl::fromLocalFile(path)); |
| 66 |
m_maxFieldWidth = width() - m_title_maxwidth - 20 * 2 - 10 * 2; |
| 67 |
updateBasicInfo(); |
| 68 |
updateCodecInfo(); |
| 69 |
updateAudioInfo(); |
| 70 |
|
| 71 |
m_expandGroup.clear(); |
| 72 |
|
| 73 |
if (m_containBaseInfo) { |
| 74 |
appendExpandWidget(tr("Basic info")); |
| 75 |
m_expandGroup.at(0)->setContent(m_basicInfoFrame); |
| 76 |
m_expandGroup.at(0)->setExpand(true); |
| 77 |
} |
| 78 |
|
| 79 |
if (m_containCodecInfo) { |
| 80 |
appendExpandWidget(tr("Codec info")); |
| 81 |
int index = m_expandGroup.size() > 0 ? (m_expandGroup.size() - 1) : 0; |
| 82 |
m_expandGroup.at(index)->setContent(m_codecInfoFrame); |
| 83 |
m_expandGroup.at(index)->setExpand(true); |
| 84 |
} |
| 85 |
|
| 86 |
if (m_containAudioInfo) { |
| 87 |
appendExpandWidget(tr("Audio info")); |
| 88 |
int index = m_expandGroup.size() > 0 ? (m_expandGroup.size() - 1) : 0; |
| 89 |
m_expandGroup.at(index)->setContent(m_audioInfoFrame); |
| 90 |
m_expandGroup.at(index)->setExpand(true); |
| 91 |
} |
| 92 |
|
| 93 |
//剔除多余不需要的焦点 |
| 94 |
QList<QWidget *>allwidgetlist = this->findChildren<QWidget *>(); |
| 95 |
for (int i = 0; i < allwidgetlist.size() ; i++) { |
| 96 |
allwidgetlist.at(i)->setFocusPolicy(Qt::NoFocus); |
| 97 |
} |
| 98 |
for (int j = 0; j < m_expandGroup.size(); j++) { |
| 99 |
QList<DIconButton *> expandlist = m_expandGroup.at(j)->findChildren<DIconButton *>(); |
| 100 |
for (int k = 0; k < expandlist.size(); k++) { |
| 101 |
expandlist.at(k)->setFocusPolicy(Qt::TabFocus); |
| 102 |
} |
| 103 |
} |
| 104 |
QWidget *closeButton = this->findChild<QWidget *>("DTitlebarDWindowCloseButton"); |
| 105 |
if (closeButton) { |
| 106 |
closeButton->setFocusPolicy(Qt::TabFocus); |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
void VideoInfoDialog::updateCodecInfo() |
| 111 |
{ |
| 112 |
// clearLayout(m_basicInfoFrameLayout); |
| 113 |
QMap<QString, QString> codecInfoMap; |
| 114 |
QList<QString> codecInfoKeys; |
| 115 |
codecInfoMap[tr("Video CodecID")] = m_movieInfo.videoCodec(); |
| 116 |
codecInfoKeys.append(tr("Video CodecID")); |
| 117 |
|
| 118 |
codecInfoMap[tr("Video CodeRate")] = QString::number(m_movieInfo.vCodeRate) + " kbps"; |
| 119 |
codecInfoKeys.append(tr("Video CodeRate")); |
| 120 |
|
| 121 |
codecInfoMap[tr("FPS")] = QString::number(m_movieInfo.fps) + " fps"; |
| 122 |
codecInfoKeys.append(tr("FPS")); |
| 123 |
|
| 124 |
codecInfoMap[tr("Proportion")] = QString::number(static_cast<double>(m_movieInfo.proportion)); |
| 125 |
codecInfoKeys.append(tr("Proportion")); |
| 126 |
|
| 127 |
codecInfoMap[tr("Resolution")] = m_movieInfo.resolution; |
| 128 |
codecInfoKeys.append(tr("Resolution")); |
| 129 |
|
| 130 |
|
| 131 |
for (int i = 0; i < codecInfoKeys.size(); i++) { |
| 132 |
QString key = codecInfoKeys.at(i); |
| 133 |
QString value = codecInfoMap[key]; |
| 134 |
if (value.isEmpty()) { |
| 135 |
continue; |
| 136 |
} |
| 137 |
|
| 138 |
m_containBaseInfo = true; |
| 139 |
SimpleFormField *field = new SimpleFormField; |
| 140 |
field->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 141 |
DFontSizeManager::instance()->bind(field, DFontSizeManager::T8); |
| 142 |
DPalette pa1 = DApplicationHelper::instance()->palette(field); |
| 143 |
pa1.setBrush(DPalette::Text, pa1.color(DPalette::TextTitle)); |
| 144 |
field->setPalette(pa1); |
| 145 |
field->setText(SpliteText(value, field->font(), m_maxFieldWidth)); |
| 146 |
// field->setText(value); |
| 147 |
// field->setWordWrap(true); |
| 148 |
// field->adjustSize(); |
| 149 |
|
| 150 |
SimpleFormLabel *title = new SimpleFormLabel(key); |
| 151 |
title->setMinimumHeight(field->minimumHeight()); |
| 152 |
// title->setFixedWidth(m_title_maxwidth); |
| 153 |
title->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 154 |
//2020/03/13-xiaolong |
| 155 |
DFontSizeManager::instance()->bind(title, DFontSizeManager::T8); |
| 156 |
DPalette pa2 = DApplicationHelper::instance()->palette(title); |
| 157 |
pa2.setBrush(DPalette::Text, pa2.color(DPalette::TextTitle)); |
| 158 |
title->setPalette(pa2); |
| 159 |
title->setText(SpliteText((key), title->font(), m_title_maxwidth)); |
| 160 |
// title->setText((key + ":")); |
| 161 |
// title->setWordWrap(true); |
| 162 |
// title->adjustSize(); |
| 163 |
|
| 164 |
m_codecInfoFrameLayout->addRow(title, field); |
| 165 |
QFontMetrics fm(field->font()); |
| 166 |
// m_codecInfoFrame->setFixedHeight(m_codecInfoFrame->height() + field->height()); |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
void VideoInfoDialog::updateAudioInfo() |
| 171 |
{ |
| 172 |
QMap<QString, QString> audioInfoMap; |
| 173 |
QList<QString> audioInfoKeys; |
| 174 |
audioInfoMap[tr("Audio CodecID")] = m_movieInfo.audioCodec(); |
| 175 |
audioInfoKeys.append(tr("Audio CodecID")); |
| 176 |
|
| 177 |
audioInfoMap[tr("Audio CodeRate")] = QString::number(m_movieInfo.aCodeRate) + " kbps"; |
| 178 |
audioInfoKeys.append(tr("Audio CodeRate")); |
| 179 |
|
| 180 |
audioInfoMap[tr("Audio digit")] = QString::number(m_movieInfo.aDigit) + " bits"; |
| 181 |
audioInfoKeys.append(tr("Audio digit")); |
| 182 |
|
| 183 |
audioInfoMap[tr("Channels")] = QString::number(m_movieInfo.channels) + tr("Channel"); |
| 184 |
audioInfoKeys.append(tr("Channels")); |
| 185 |
|
| 186 |
audioInfoMap[tr("Sampling")] = QString::number(m_movieInfo.sampling) + " hz"; |
| 187 |
audioInfoKeys.append(tr("Sampling")); |
| 188 |
|
| 189 |
|
| 190 |
for (int i = 0; i < audioInfoKeys.size(); i++) { |
| 191 |
QString key = audioInfoKeys.at(i); |
| 192 |
QString value = audioInfoMap[key]; |
| 193 |
if (value.isEmpty()) { |
| 194 |
continue; |
| 195 |
} |
| 196 |
|
| 197 |
m_containAudioInfo = true; |
| 198 |
SimpleFormField *field = new SimpleFormField; |
| 199 |
field->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 200 |
DFontSizeManager::instance()->bind(field, DFontSizeManager::T8); |
| 201 |
DPalette pa1 = DApplicationHelper::instance()->palette(field); |
| 202 |
pa1.setBrush(DPalette::Text, pa1.color(DPalette::TextTitle)); |
| 203 |
field->setPalette(pa1); |
| 204 |
field->setText(SpliteText(value, field->font(), m_maxFieldWidth)); |
| 205 |
// field->setText(value); |
| 206 |
// field->setWordWrap(true); |
| 207 |
// field->adjustSize(); |
| 208 |
|
| 209 |
SimpleFormLabel *title = new SimpleFormLabel(key); |
| 210 |
title->setMinimumHeight(field->minimumHeight()); |
| 211 |
// title->setFixedWidth(m_title_maxwidth); |
| 212 |
title->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 213 |
//2020/03/13-xiaolong |
| 214 |
DFontSizeManager::instance()->bind(title, DFontSizeManager::T8); |
| 215 |
DPalette pa2 = DApplicationHelper::instance()->palette(title); |
| 216 |
pa2.setBrush(DPalette::Text, pa2.color(DPalette::TextTitle)); |
| 217 |
title->setPalette(pa2); |
| 218 |
title->setText(SpliteText((key), title->font(), m_title_maxwidth)); |
| 219 |
// title->setText((key + ":")); |
| 220 |
// title->setWordWrap(true); |
| 221 |
// title->adjustSize(); |
| 222 |
|
| 223 |
m_audioInfoFrameLayout->addRow(title, field); |
| 224 |
QFontMetrics fm(field->font()); |
| 225 |
// m_audioInfoFrame->setFixedHeight(m_audioInfoFrame->height() + field->height()); |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
void VideoInfoDialog::updateBasicInfo() |
| 230 |
{ |
| 231 |
// clearLayout(m_basicInfoFrameLayout); |
| 232 |
QMap<QString, QString> basicInfoMap; |
| 233 |
QList<QString> basicInfoKeys; |
| 234 |
basicInfoMap[tr("Video name")] = m_movieInfo.title; |
| 235 |
basicInfoKeys.append(tr("Video name")); |
| 236 |
|
| 237 |
QDateTime dateTime = QDateTime::fromString(m_movieInfo.creation); |
| 238 |
// basicInfoMap[tr("Date captured")] = m_movieInfo.creation; |
| 239 |
basicInfoMap[tr("Date captured")] = dateTime.toString("yyyy/MM/dd HH:mm"); |
| 240 |
basicInfoKeys.append(tr("Date captured")); |
| 241 |
|
| 242 |
QFileInfo info(m_movieInfo.filePath); |
| 243 |
if (info.lastModified().isValid()) { |
| 244 |
basicInfoMap[tr("Date modified")] = info.lastModified().toString("yyyy/MM/dd HH:mm"); |
| 245 |
basicInfoKeys.append(tr("Date modified")); |
| 246 |
} else if (info.birthTime().isValid()) { |
| 247 |
basicInfoMap[tr("Date modified")] = info.birthTime().toString("yyyy/MM/dd HH:mm"); |
| 248 |
basicInfoKeys.append(tr("Date modified")); |
| 249 |
} |
| 250 |
basicInfoMap[tr("Type")] = m_movieInfo.fileType; |
| 251 |
basicInfoKeys.append(tr("Type")); |
| 252 |
|
| 253 |
basicInfoMap[tr("File size")] = m_movieInfo.sizeStr(); |
| 254 |
basicInfoKeys.append(tr("File size")); |
| 255 |
|
| 256 |
basicInfoMap[tr("Duration")] = m_movieInfo.durationStr(); |
| 257 |
basicInfoKeys.append(tr("Duration")); |
| 258 |
|
| 259 |
basicInfoMap[tr("Path")] = m_movieInfo.filePath; |
| 260 |
basicInfoKeys.append(tr("Path")); |
| 261 |
|
| 262 |
for (int i = 0; i < basicInfoKeys.size(); i++) { |
| 263 |
QString key = basicInfoKeys.at(i); |
| 264 |
QString value = basicInfoMap[key]; |
| 265 |
if (value.isEmpty()) { |
| 266 |
continue; |
| 267 |
} |
| 268 |
|
| 269 |
m_containCodecInfo = true; |
| 270 |
SimpleFormField *field = new SimpleFormField; |
| 271 |
field->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 272 |
DFontSizeManager::instance()->bind(field, DFontSizeManager::T8); |
| 273 |
DPalette pa1 = DApplicationHelper::instance()->palette(field); |
| 274 |
pa1.setBrush(DPalette::Text, pa1.color(DPalette::TextTitle)); |
| 275 |
field->setPalette(pa1); |
| 276 |
field->setText(SpliteText(value, field->font(), m_maxFieldWidth)); |
| 277 |
|
| 278 |
SimpleFormLabel *title = new SimpleFormLabel(key); |
| 279 |
title->setMinimumHeight(field->minimumHeight()); |
| 280 |
title->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 281 |
DFontSizeManager::instance()->bind(title, DFontSizeManager::T8); |
| 282 |
DPalette pa2 = DApplicationHelper::instance()->palette(title); |
| 283 |
pa2.setBrush(DPalette::Text, pa2.color(DPalette::TextTitle)); |
| 284 |
title->setPalette(pa2); |
| 285 |
title->setText(SpliteText((key), title->font(), m_title_maxwidth)); |
| 286 |
|
| 287 |
m_basicInfoFrameLayout->addRow(title, field); |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
//QList<DDrawer *> VideoInfoDialog::addExpandWidget(const QStringList &titleList) |
| 292 |
//{ |
| 293 |
// QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(m_scrollArea->widget()->layout()); |
| 294 |
// QList<DDrawer *> group; |
| 295 |
|
| 296 |
// for (const QString &title : titleList) { |
| 297 |
// DFMDArrowLineExpand *expand = new DFMDArrowLineExpand;//DArrowLineExpand; |
| 298 |
// expand->setTitle(title); |
| 299 |
// initExpand(layout, expand); |
| 300 |
// group.push_back(expand); |
| 301 |
// } |
| 302 |
|
| 303 |
// return group; |
| 304 |
//} |
| 305 |
|
| 306 |
void VideoInfoDialog::appendExpandWidget(const QString &title) |
| 307 |
{ |
| 308 |
// QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(m_scrollArea->widget()->layout()); |
| 309 |
|
| 310 |
DFMDArrowLineExpand *expand = new DFMDArrowLineExpand;//DArrowLineExpand; |
| 311 |
expand->setTitle(title); |
| 312 |
initExpand(m_scrollAreaLayout, expand); |
| 313 |
m_expandGroup.push_back(expand); |
| 314 |
} |
| 315 |
|
| 316 |
void VideoInfoDialog::initExpand(QVBoxLayout *layout, DDrawer *expand) |
| 317 |
{ |
| 318 |
expand->setFixedHeight(22); |
| 319 |
QMargins cm = layout->contentsMargins(); |
| 320 |
QRect rc1 = contentsRect(); |
| 321 |
expand->setFixedWidth(rc1.width() - cm.left() - cm.right()); |
| 322 |
// 去掉界面的横线 |
| 323 |
expand->setExpandedSeparatorVisible(false); |
| 324 |
expand->setSeparatorVisible(false); |
| 325 |
layout->addWidget(expand, 0, Qt::AlignTop); |
| 326 |
|
| 327 |
DEnhancedWidget *hanceedWidget = new DEnhancedWidget(expand, this); |
| 328 |
connect(hanceedWidget, &DEnhancedWidget::heightChanged, hanceedWidget, [ = ]() { |
| 329 |
QRect rc = geometry(); |
| 330 |
if (m_expandGroup.count() == 2) { |
| 331 |
rc.setHeight(qMin(615, contentHeight() + 15)); |
| 332 |
// setGeometry(rc); |
| 333 |
// this->setFixedHeight(qMin(615, contentHeight() + 15)); |
| 334 |
setGeometry(rc); |
| 335 |
} else { |
| 336 |
rc.setHeight(qMin(615, contentHeight() + 25)); |
| 337 |
setGeometry(rc); |
| 338 |
// this->setFixedHeight(qMin(615, contentHeight() + 25)); |
| 339 |
} |
| 340 |
}); |
| 341 |
} |
| 342 |
|
| 343 |
int VideoInfoDialog::contentHeight() const |
| 344 |
{ |
| 345 |
int expandsHeight = 10; |
| 346 |
QList<DDrawer *>::const_iterator expand = m_expandGroup.cbegin(); |
| 347 |
while (expand != m_expandGroup.cend()) { |
| 348 |
expandsHeight += (*expand)->height(); |
| 349 |
++expand; |
| 350 |
} |
| 351 |
return (50 + expandsHeight + contentsMargins().top() + |
| 352 |
contentsMargins().bottom()); |
| 353 |
} |
| 354 |
|
| 355 |
QString VideoInfoDialog::SpliteText(const QString &text, const QFont &font, int nLabelSize) |
| 356 |
{ |
| 357 |
QFontMetrics fm(font); |
| 358 |
double dobuleTextSize = fm.horizontalAdvance(text); |
| 359 |
double dobuleLabelSize = nLabelSize; |
| 360 |
if (dobuleTextSize > dobuleLabelSize && dobuleLabelSize > 0 && dobuleTextSize < 10000) { |
| 361 |
double splitCount = dobuleTextSize / dobuleLabelSize; |
| 362 |
int nCount = int(splitCount + 1); |
| 363 |
QString textSplite; |
| 364 |
QString textTotal = text; |
| 365 |
for (int index = 0; index < nCount; ++index) { |
| 366 |
int nPos = 0; |
| 367 |
long nOffset = 0; |
| 368 |
for (int i = 0; i < text.size(); i++) { |
| 369 |
nOffset += fm.width(text.at(i)); |
| 370 |
if (nOffset >= nLabelSize) { |
| 371 |
nPos = i; |
| 372 |
break; |
| 373 |
} |
| 374 |
} |
| 375 |
nPos = (nPos - 1 < 0) ? 0 : nPos - 1; |
| 376 |
QString qstrLeftData; |
| 377 |
if (nCount - 1 == index) { |
| 378 |
qstrLeftData = textTotal; |
| 379 |
textSplite += qstrLeftData; |
| 380 |
} else { |
| 381 |
qstrLeftData = textTotal.left(nPos); |
| 382 |
textSplite += qstrLeftData + "\n"; |
| 383 |
} |
| 384 |
textTotal = textTotal.mid(nPos); |
| 385 |
} |
| 386 |
return textSplite; |
| 387 |
} else { |
| 388 |
return text; |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
bool VideoInfoDialog::event(QEvent *event) |
| 393 |
{ |
| 394 |
if (event->type() == QEvent::ActivationChange) { |
| 395 |
if (QApplication::activeWindow() != this) { |
| 396 |
this->close(); |
| 397 |
} |
| 398 |
} |
| 399 |
return QWidget::event(event); |
| 400 |
} |
| 401 |
|
| 402 |
void VideoInfoDialog::showEvent(QShowEvent *e) |
| 403 |
{ |
| 404 |
this->move((dApp->getMainWindow()->width() - this->width() - 50 + dApp->getMainWindow()->mapToGlobal(QPoint(0, 0)).x()) |
| 405 |
, 100 + dApp->getMainWindow()->mapToGlobal(QPoint(0, 0)).y()); |
| 406 |
return QWidget::showEvent(e); |
| 407 |
} |
| 408 |
|
| 409 |
void VideoInfoDialog::initUI() |
| 410 |
{ |
| 411 |
setAttribute(Qt::WA_TranslucentBackground, true); |
| 412 |
setFixedWidth(320); |
| 413 |
setMaximumHeight(540); |
| 414 |
setContentLayoutContentsMargins(QMargins(0, 0, 0, 0)); |
| 415 |
//标题 |
| 416 |
DLabel *title = new DLabel(this); |
| 417 |
title->setText(tr("Video info")); |
| 418 |
title->setGeometry(this->x() + (this->width() - title->width()) / 2, this->y(), 112, 50); |
| 419 |
title->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
| 420 |
DFontSizeManager::instance()->bind(title, DFontSizeManager::T6); |
| 421 |
DPalette pa = DApplicationHelper::instance()->palette(title); |
| 422 |
pa.setBrush(DPalette::Text, pa.color(DPalette::TextTitle)); |
| 423 |
title->setPalette(pa); |
| 424 |
setContentsMargins(0, 0, 0, 0); |
| 425 |
//基本信息 |
| 426 |
m_basicInfoFrame = new QFrame(this); |
| 427 |
m_basicInfoFrame->setFixedWidth(280); |
| 428 |
m_basicInfoFrameLayout = new QFormLayout(); |
| 429 |
m_basicInfoFrameLayout->setVerticalSpacing(7); |
| 430 |
m_basicInfoFrameLayout->setHorizontalSpacing(16); |
| 431 |
m_basicInfoFrameLayout->setContentsMargins(10, 1, 7, 10); |
| 432 |
m_basicInfoFrameLayout->setLabelAlignment(Qt::AlignLeft); |
| 433 |
m_basicInfoFrame->setLayout(m_basicInfoFrameLayout); |
| 434 |
//编码信息 |
| 435 |
m_codecInfoFrame = new QFrame(this); |
| 436 |
m_codecInfoFrame->setFixedWidth(280); |
| 437 |
m_codecInfoFrameLayout = new QFormLayout(); |
| 438 |
m_codecInfoFrameLayout->setVerticalSpacing(7); |
| 439 |
m_codecInfoFrameLayout->setHorizontalSpacing(16); |
| 440 |
m_codecInfoFrameLayout->setContentsMargins(10, 1, 7, 10); |
| 441 |
m_codecInfoFrameLayout->setLabelAlignment(Qt::AlignLeft); |
| 442 |
m_codecInfoFrame->setLayout(m_codecInfoFrameLayout); |
| 443 |
//音频流信息 |
| 444 |
m_audioInfoFrame = new QFrame(this); |
| 445 |
m_audioInfoFrame->setFixedWidth(280); |
| 446 |
m_audioInfoFrameLayout = new QFormLayout(); |
| 447 |
m_audioInfoFrameLayout->setVerticalSpacing(7); |
| 448 |
m_audioInfoFrameLayout->setHorizontalSpacing(16); |
| 449 |
m_audioInfoFrameLayout->setContentsMargins(10, 1, 7, 10); |
| 450 |
m_audioInfoFrameLayout->setLabelAlignment(Qt::AlignLeft); |
| 451 |
m_audioInfoFrame->setLayout(m_audioInfoFrameLayout); |
| 452 |
|
| 453 |
DWidget *content = new DWidget(); |
| 454 |
addContent(content); |
| 455 |
m_mainLayout = new QVBoxLayout; |
| 456 |
m_mainLayout->setContentsMargins(0, 0, 0, 0); |
| 457 |
m_mainLayout->setMargin(0); |
| 458 |
m_mainLayout->setSpacing(0); |
| 459 |
content->setLayout(m_mainLayout); |
| 460 |
|
| 461 |
m_scrollArea = new DScrollArea(); |
| 462 |
DPalette palette = m_scrollArea->viewport()->palette(); |
| 463 |
palette.setBrush(DPalette::Background, Qt::NoBrush); |
| 464 |
m_scrollArea->viewport()->setPalette(palette); |
| 465 |
m_scrollArea->setFrameShape(QFrame::Shape::NoFrame); |
| 466 |
m_scrollArea->setWidgetResizable(true); |
| 467 |
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff); |
| 468 |
m_scrollArea->viewport()->installEventFilter(this); |
| 469 |
|
| 470 |
QFrame *infoframe = new QFrame; |
| 471 |
m_scrollAreaLayout = new QVBoxLayout; |
| 472 |
m_scrollAreaLayout->setContentsMargins(10, 0, 10, 0); |
| 473 |
m_scrollAreaLayout->setSpacing(10); |
| 474 |
infoframe->setLayout(m_scrollAreaLayout); |
| 475 |
m_scrollArea->setWidget(infoframe); |
| 476 |
|
| 477 |
QVBoxLayout *scrolllayout = new QVBoxLayout; |
| 478 |
scrolllayout->addWidget(m_scrollArea); |
| 479 |
m_mainLayout->insertLayout(1, scrolllayout, 1); |
| 480 |
} |
| 481 |
|