窗口居中

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

View file

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