Author: mir3x
Date: Wed Oct 28 10:29:35 2015
New Revision: 30269

URL: http://svn.gna.org/viewcvs/freeciv?rev=30269&view=rev
Log:
Resized unit upkeep window for non iso tilesets in qt client
Submitted by: anonymous

See bug #23383


Modified:
    branches/S2_6/client/gui-qt/citydlg.cpp

Modified: branches/S2_6/client/gui-qt/citydlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/citydlg.cpp?rev=30269&r1=30268&r2=30269&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/citydlg.cpp     (original)
+++ branches/S2_6/client/gui-qt/citydlg.cpp     Wed Oct 28 10:29:35 2015
@@ -58,6 +58,18 @@
 static city_dialog *city_dlg;
 
 /****************************************************************************
+  Calculates extra space needed for upkeep sprites for non-isometric tileset
+****************************************************************************/
+static float overhead_upkeep_scale()
+{
+  float ret = 1.0f;
+  if (!tileset_is_isometric(tileset)) {
+    ret = 1.33f;
+  }
+  return ret;
+}
+
+/****************************************************************************
   Draws X on pixmap pointing its useless
 ****************************************************************************/
 static void pixmap_put_x(QPixmap *pix)
@@ -87,7 +99,8 @@
   qunit = punit;
   if (punit) {
     unit_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
-                                    tileset_tile_height(tileset) * 3 / 2);
+                                    overhead_upkeep_scale()
+                                    * tileset_tile_height(tileset) * 3 / 2);
     unit_pixmap->map_pixmap.fill(Qt::transparent);
     put_unit(punit, unit_pixmap, 1.0, 0, 0);
     if (supported) {
@@ -343,7 +356,8 @@
   }
   if (qunit) {
     unit_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
-                                    tileset_tile_height(tileset) * 3 / 2);
+                                    overhead_upkeep_scale()
+                                    * tileset_tile_height(tileset) * 3 / 2);
     unit_pixmap->map_pixmap.fill(QColor(200, 200, 200));
     put_unit(qunit, unit_pixmap, 1.0, 0, 0);
     if (supported) {
@@ -365,7 +379,8 @@
   }
   if (qunit) {
     unit_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
-                                    tileset_tile_height(tileset) * 3 / 2);
+                                    overhead_upkeep_scale()
+                                    * tileset_tile_height(tileset) * 3 / 2);
     unit_pixmap->map_pixmap.fill(Qt::transparent);
     put_unit(qunit, unit_pixmap, 1.0, 0, 0);
     if (supported) {
@@ -438,7 +453,8 @@
   QSizePolicy size_fixed_policy(QSizePolicy::Fixed, QSizePolicy::Fixed);
   layout->setContentsMargins(3, 6, 3, 6);
   setSizePolicy(size_fixed_policy);
-  setFixedHeight(tileset_tile_height(tileset) * 3 / 2 + 6);
+  setFixedHeight(overhead_upkeep_scale() * tileset_tile_height(tileset)
+                 * 3 / 2 + 6);
   setLayout(layout);
 }
 
@@ -643,7 +659,6 @@
   QLabel *ql;
   QLabel *lab2;
   int h = 2 * fm.height() + 2;
-  int scroll_height = QStyle::PM_ScrollBarExtent;
   small_font = gui()->fc_fonts.get_font("gui_qt_font_city_label");
   QString city_stl = "QPushButton{font-weight: bold italic; border: "
                      "0px;text-align: right;}"
@@ -702,11 +717,8 @@
               << _("Change in:") << _("Corruption:") << _("Waste:")
               << _("Culture:") << _("Pollution:") << _("Plague Risk:");
     info_nr = info_list.count();
-    info_widget->setMinimumHeight(tileset_tile_height(tileset) * 3 +
-                                  2 * fm.height() + 2 * scroll_height + 50);
-    info_widget->setMaximumHeight(tileset_tile_height(tileset) * 3 +
-                                  2 * fm.height() + 2 * scroll_height + 50);
     info_widget->setFont(*small_font);
+    info_grid_layout->setSpacing(0);
     for (iter = 0; iter < info_nr; iter++) {
       ql = new QLabel(info_list[iter], info_widget);
       info_grid_layout->addWidget(ql, iter, 0);
@@ -752,7 +764,8 @@
     supported_units = new unit_info(this, true);
     scroll = new QScrollArea;
     scroll->setWidgetResizable(true);
-    scroll->setMaximumHeight(tileset_tile_height(tileset) * 2);
+    scroll->setMaximumHeight(tileset_tile_height(tileset) * 2
+                             * overhead_upkeep_scale());
     scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     scroll->setWidget(supported_units);
     current_units = new unit_info(this, false);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to