fix: videoWidget width/height rate

This commit is contained in:
rankun 2020-02-15 17:25:16 +08:00
commit 0bafca754c

View file

@ -26,7 +26,7 @@ VideoForm::VideoForm(bool skin, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, ui(new Ui::videoForm) , ui(new Ui::videoForm)
, m_skin(skin) , m_skin(skin)
{ {
ui->setupUi(this); ui->setupUi(this);
initUI(); initUI();
updateShowSize(size()); updateShowSize(size());
@ -37,7 +37,7 @@ VideoForm::VideoForm(bool skin, QWidget *parent)
} }
VideoForm::~VideoForm() VideoForm::~VideoForm()
{ {
delete ui; delete ui;
} }
@ -59,9 +59,9 @@ void VideoForm::initUI()
#endif #endif
} }
setMouseTracking(true); setMouseTracking(true);
ui->videoWidget->setMouseTracking(true); ui->videoWidget->setMouseTracking(true);
ui->videoWidget->hide(); ui->videoWidget->hide();
} }
void VideoForm::onGrabCursor(bool grab) void VideoForm::onGrabCursor(bool grab)
@ -155,7 +155,7 @@ void VideoForm::updateShowSize(const QSize &newSize)
if (isFullScreen()) { if (isFullScreen()) {
switchFullScreen(); switchFullScreen();
} }
if (layout()) { if (m_skin) {
QMargins m = getMargins(vertical); QMargins m = getMargins(vertical);
showSize.setWidth(showSize.width() + m.left() + m.right()); showSize.setWidth(showSize.width() + m.left() + m.right());
showSize.setHeight(showSize.height() + m.top() + m.bottom()); showSize.setHeight(showSize.height() + m.top() + m.bottom());
@ -165,9 +165,11 @@ void VideoForm::updateShowSize(const QSize &newSize)
move(screenRect.center() - QRect(0, 0, showSize.width(), showSize.height()).center()); move(screenRect.center() - QRect(0, 0, showSize.width(), showSize.height()).center());
} }
// 减去标题栏高度 (mark:已经没有标题栏了) if (!m_skin) {
//int titleBarHeight = style()->pixelMetric(QStyle::PM_TitleBarHeight); // 减去标题栏高度 (mark:已经没有标题栏了)
//showSize.setHeight(showSize.height() - titleBarHeight); int titleBarHeight = style()->pixelMetric(QStyle::PM_TitleBarHeight);
showSize.setHeight(showSize.height() - titleBarHeight);
}
if (showSize != size()) { if (showSize != size()) {
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
@ -302,7 +304,7 @@ void VideoForm::mouseReleaseEvent(QMouseEvent *event)
} }
void VideoForm::mouseMoveEvent(QMouseEvent *event) void VideoForm::mouseMoveEvent(QMouseEvent *event)
{ {
if (ui->videoWidget->geometry().contains(event->pos())) { if (ui->videoWidget->geometry().contains(event->pos())) {
if (!m_controller) { if (!m_controller) {
return; return;