gui: Set the size of the window to the size of the contents

This commit is contained in:
Povilas Kanapickas 2021-11-01 02:52:51 +02:00
parent b7757fbd68
commit c7e6fc6c7e
3 changed files with 12 additions and 14 deletions

View File

@ -938,6 +938,14 @@ void MainWindow::changeEvent(QEvent* event)
QMainWindow::changeEvent(event); QMainWindow::changeEvent(event);
} }
bool MainWindow::event(QEvent* event)
{
if (event->type() == QEvent::LayoutRequest) {
setFixedSize(sizeHint());
}
return QMainWindow::event(event);
}
void MainWindow::updateZeroconfService() void MainWindow::updateZeroconfService()
{ {
QMutexLocker locker(&m_UpdateZeroconfMutex); QMutexLocker locker(&m_UpdateZeroconfMutex);

View File

@ -157,6 +157,7 @@ public slots:
void stopService(); void stopService();
void stopDesktop(); void stopDesktop();
void changeEvent(QEvent* event); void changeEvent(QEvent* event);
bool event(QEvent* event);
void retranslateMenuBar(); void retranslateMenuBar();
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
bool isServiceRunning(QString name); bool isServiceRunning(QString name);

View File

@ -2,31 +2,20 @@
<ui version="4.0"> <ui version="4.0">
<class>MainWindowBase</class> <class>MainWindowBase</class>
<widget class="QMainWindow" name="MainWindowBase"> <widget class="QMainWindow" name="MainWindowBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>550</height>
</rect>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>600</width>
<height>0</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Barrier</string> <string>Barrier</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item> <item>
<widget class="QGroupBox" name="m_pGroupServer"> <widget class="QGroupBox" name="m_pGroupServer">
<property name="sizePolicy"> <property name="sizePolicy">