Author: mir3x
Date: Wed Dec  2 13:02:33 2015
New Revision: 30831

URL: http://svn.gna.org/viewcvs/freeciv?rev=30831&view=rev
Log:
Default width of chat/messagess has been set to 95% of mapview 
minus width of end turn area. 
Size is scalable during resizes. 
And width and height in percent are written to settings file, 
so they will be restored at next restart.
Reported by Jacob Nevins <jtn>

See bug #24107


Modified:
    branches/S2_5/client/gui-qt/fc_client.cpp
    branches/S2_5/client/gui-qt/fc_client.h
    branches/S2_5/client/gui-qt/gui_main.cpp
    branches/S2_5/client/gui-qt/mapview.cpp
    branches/S2_5/client/gui-qt/messagewin.cpp

Modified: branches/S2_5/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.cpp?rev=30831&r1=30830&r2=30831&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_5/client/gui-qt/fc_client.cpp   Wed Dec  2 13:02:33 2015
@@ -158,6 +158,9 @@
   pages[PAGE_NETWORK]->setVisible(false);
 
   // PAGE_GAME
+  QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope,
+                     "$HOME/.config");
+  read_settings();
   pages[PAGE_GAME] = new QWidget(central_wdg);
   init_mapcanvas_and_overview();
   create_game_page();
@@ -557,6 +560,36 @@
 }
 
 /****************************************************************************
+  Loads qt-specific options
+****************************************************************************/
+void fc_client::read_settings()
+{
+  QSettings s(QSettings::IniFormat, QSettings::UserScope, 
+              "freeciv-qt-client");
+  if (s.contains("InfoTab-xsize")) {
+    qt_settings.infotab_width = s.value("InfoTab-xsize").toInt();
+  } else {
+    qt_settings.infotab_width = 95;
+  }
+  if (s.contains("InfoTab-ysize")) {
+    qt_settings.infotab_height = s.value("InfoTab-ysize").toInt();
+  } else {
+    qt_settings.infotab_height = 29;
+  }
+}
+
+/****************************************************************************
+  Save qt-specific options
+****************************************************************************/
+void fc_client::write_settings()
+{
+  QSettings s(QSettings::IniFormat, QSettings::UserScope,
+              "freeciv-qt-client");
+  s.setValue("InfoTab-xsize", qt_settings.infotab_width);
+  s.setValue("InfoTab-ysize", qt_settings.infotab_height);
+}
+
+/****************************************************************************
   Updates autocompleter for chat widgets
 ****************************************************************************/
 void fc_client::update_completer()

Modified: branches/S2_5/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.h?rev=30831&r1=30830&r2=30831&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.h     (original)
+++ branches/S2_5/client/gui-qt/fc_client.h     Wed Dec  2 13:02:33 2015
@@ -118,6 +118,15 @@
   QFont* get_font(QString name);
   void init_fonts();
   void release_fonts();
+};
+
+/****************************************************************************
+  Some qt-specific options like size to save between restarts
+****************************************************************************/
+struct fc_settings
+{
+  int infotab_width; /* in percent */
+  int infotab_height; /* in percent */
 };
 
 class fc_client : public QMainWindow
@@ -220,10 +229,12 @@
   goto_dialog *gtd;
   QCursor *fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES];
   pregame_options *pr_options;
+  fc_settings qt_settings;
   void gimme_place(QWidget* widget, QString str);
   int gimme_index_of(QString str);
   void remove_repo_dlg(QString str);
   bool is_repo_dlg_open(QString str);
+  void write_settings();
   bool is_closing();
 
 private slots:
@@ -278,6 +289,7 @@
   void set_connection_state(enum connection_state state);
   void update_buttons();
   void init();
+  void read_settings();
 
   enum client_pages page;
   QMap<QString, QWidget*> opened_repo_dlgs;

Modified: branches/S2_5/client/gui-qt/gui_main.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/gui_main.cpp?rev=30831&r1=30830&r2=30831&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/gui_main.cpp    (original)
+++ branches/S2_5/client/gui-qt/gui_main.cpp    Wed Dec  2 13:02:33 2015
@@ -458,6 +458,7 @@
     return;
     break;
   case QMessageBox::Ok:
+    gui()->write_settings();
     qapp->quit();
     break;
   }

Modified: branches/S2_5/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/mapview.cpp?rev=30831&r1=30830&r2=30831&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/mapview.cpp     (original)
+++ branches/S2_5/client/gui-qt/mapview.cpp     Wed Dec  2 13:02:33 2015
@@ -284,10 +284,13 @@
   QSize delta;
 
   size = event->size();
-
   if (C_S_RUNNING <= client_state()) {
     map_canvas_resized(size.width(), size.height());
-    gui()->infotab->resize(size.width() / 2, size.height() / 3);
+    gui()->infotab->resize(((size.width()
+                             - gui()->end_turn_rect->sizeHint().width())
+                             * gui()->qt_settings.infotab_width) / 100,
+                             (size.height()
+                             * gui()->qt_settings.infotab_height) / 100);
     gui()->infotab->move(0 , size.height() - gui()->infotab->height());
     gui()->unitinfo_wdg->move(width() - gui()->unitinfo_wdg->width(), 0);
     delta = size - gui()->end_turn_rect->sizeHint();

Modified: branches/S2_5/client/gui-qt/messagewin.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/messagewin.cpp?rev=30831&r1=30830&r2=30831&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/messagewin.cpp  (original)
+++ branches/S2_5/client/gui-qt/messagewin.cpp  Wed Dec  2 13:02:33 2015
@@ -125,6 +125,9 @@
     resx = false;
     resy = false;
     setCursor(Qt::ArrowCursor);
+    gui()->qt_settings.infotab_width = width() * 100 / (mapview.width
+                                       -  gui()->end_turn_rect->width());
+    gui()->qt_settings.infotab_height = height() * 100 / mapview.height;
   }
 }
 


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

Reply via email to