fix: video switch size abnormal

Close #15
This commit is contained in:
rankun 2019-08-20 21:38:16 +08:00
commit 8e0f656d65
2 changed files with 17 additions and 6 deletions

View file

@ -100,7 +100,6 @@ void VideoForm::updateStyleSheet(bool vertical)
border-width: 150px 142px 85px 142px; border-width: 150px 142px 85px 142px;
} }
)"); )");
layout()->setContentsMargins(10, 68, 12, 62);
} else { } else {
setStyleSheet(R"( setStyleSheet(R"(
#videoForm { #videoForm {
@ -108,8 +107,19 @@ void VideoForm::updateStyleSheet(bool vertical)
border-width: 142px 85px 142px 150px; border-width: 142px 85px 142px 150px;
} }
)"); )");
layout()->setContentsMargins(68, 12, 62, 10);
} }
layout()->setContentsMargins(getMargins(vertical));
}
QMargins VideoForm::getMargins(bool vertical)
{
QMargins margins;
if (vertical) {
margins = QMargins(10, 68, 12, 62);
} else {
margins = QMargins(68, 12, 62, 10);
}
return margins;
} }
void VideoForm::updateScreenRatio(const QSize &newSize) void VideoForm::updateScreenRatio(const QSize &newSize)
@ -119,8 +129,8 @@ void VideoForm::updateScreenRatio(const QSize &newSize)
void VideoForm::updateShowSize(const QSize &newSize) void VideoForm::updateShowSize(const QSize &newSize)
{ {
if (frameSize != newSize) { if (m_frameSize != newSize) {
frameSize = newSize; m_frameSize = newSize;
bool vertical = newSize.height() > newSize.width(); bool vertical = newSize.height() > newSize.width();
QSize showSize = newSize; QSize showSize = newSize;
QDesktopWidget* desktop = QApplication::desktop(); QDesktopWidget* desktop = QApplication::desktop();
@ -138,7 +148,7 @@ void VideoForm::updateShowSize(const QSize &newSize)
switchFullScreen(); switchFullScreen();
} }
if (layout()) { if (layout()) {
QMargins m = layout()->contentsMargins(); 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());
} }

View file

@ -34,6 +34,7 @@ public slots:
private: private:
void updateStyleSheet(bool vertical); void updateStyleSheet(bool vertical);
QMargins getMargins(bool vertical);
void initUI(); void initUI();
void showToolForm(bool show = true); void showToolForm(bool show = true);
@ -61,7 +62,7 @@ private:
QPointer<QWidget> m_loadingWidget; QPointer<QWidget> m_loadingWidget;
//inside member //inside member
QSize frameSize; QSize m_frameSize;
QPoint m_dragPosition; QPoint m_dragPosition;
float m_widthHeightRatio = 0.5f; float m_widthHeightRatio = 0.5f;