Browse Source

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

Ivan Savenko 2 years ago
parent
commit
78ae6d6ed0
3 changed files with 70 additions and 1 deletions
  1. 25 0
      launcher/mainwindow_moc.cpp
  2. 1 0
      launcher/mainwindow_moc.h
  3. 44 1
      launcher/mainwindow_moc.ui

+ 25 - 0
launcher/mainwindow_moc.cpp

@@ -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();

+ 1 - 0
launcher/mainwindow_moc.h

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

+ 44 - 1
launcher/mainwindow_moc.ui

@@ -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>