窗口居中

This commit is contained in:
rankun 2018-11-08 18:59:13 +08:00
commit 8affa1937d
2 changed files with 17 additions and 9 deletions

View file

@ -77,17 +77,24 @@ VideoForm::~VideoForm()
void VideoForm::updateShowSize(const QSize &newSize) void VideoForm::updateShowSize(const QSize &newSize)
{ {
if (frameSize != newSize) {
frameSize = newSize;
QSize showSize = newSize; QSize showSize = newSize;
QDesktopWidget* desktop = QApplication::desktop(); QDesktopWidget* desktop = QApplication::desktop();
if (desktop) { if (desktop) {
QSize screenSize = desktop->size(); QRect screenRect = desktop->availableGeometry();
showSize.setWidth(qMin(newSize.width(), screenSize.width())); showSize.setWidth(qMin(newSize.width(), screenRect.width()));
showSize.setHeight(qMin(newSize.height(), screenSize.height() - 100)); showSize.setHeight(qMin(newSize.height(), screenRect.height() - 100));
// 窗口居中
move(screenRect.center() - geometry().center());
} }
if (showSize != size()) { if (showSize != size()) {
resize(showSize); resize(showSize);
} }
}
} }
void VideoForm::mousePressEvent(QMouseEvent *event) void VideoForm::mousePressEvent(QMouseEvent *event)

View file

@ -33,6 +33,7 @@ protected:
private: private:
Ui::videoForm *ui; Ui::videoForm *ui;
QSize frameSize;
Server* m_server = Q_NULLPTR; Server* m_server = Q_NULLPTR;
Decoder m_decoder; Decoder m_decoder;
Frames m_frames; Frames m_frames;