1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Made scaling of left panel limited, within well-defined bounds

This commit is contained in:
Ivan Savenko 2022-12-29 16:38:43 +02:00
parent 8010bff866
commit 78ae6d6ed0
3 changed files with 70 additions and 1 deletions

View File

@ -47,6 +47,29 @@ void MainWindow::load()
settings.init();
}
void MainWindow::computeSidePanelSizes()
{
QVector<QToolButton*> widgets = {
ui->modslistButton,
ui->settingsButton,
ui->lobbyButton,
ui->startEditorButton,
ui->startGameButton
};
for(auto & widget : widgets)
{
QFontMetrics metrics(widget->font());
QSize iconSize = widget->iconSize();
// this is minimal space that is needed for our button to avoid text clipping
int buttonHeight = iconSize.height() + metrics.height() + 4;
widget->setMinimumHeight(buttonHeight);
widget->setMaximumHeight(buttonHeight * 1.2);
}
}
MainWindow::MainWindow(QWidget * parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
@ -73,6 +96,8 @@ MainWindow::MainWindow(QWidget * parent)
ui->startEditorButton->hide();
#endif
computeSidePanelSizes();
ui->tabListWidget->setCurrentIndex(0);
ui->settingsView->isExtraResolutionsModEnabled = ui->modlistView->isExtraResolutionsModEnabled();

View File

@ -46,6 +46,7 @@ public:
const CModList & getModList() const;
void updateTranslation();
void computeSidePanelSizes();
public slots:
void on_startGameButton_clicked();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>508</height>
<height>410</height>
</rect>
</property>
<property name="sizePolicy">
@ -47,6 +47,12 @@
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Mods</string>
</property>
@ -91,6 +97,12 @@
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Settings</string>
</property>
@ -135,6 +147,12 @@
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Lobby</string>
</property>
@ -165,6 +183,19 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="startEditorButton">
<property name="sizePolicy">
@ -179,6 +210,12 @@
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
@ -226,6 +263,12 @@
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>