Author: mir3x
Date: Thu Nov  3 09:24:54 2016
New Revision: 34352

URL: http://svn.gna.org/viewcvs/freeciv?rev=34352&view=rev
Log:
Qt client - added icon to move message/chat widget

See patch #7916

Modified:
    trunk/client/gui-qt/fc_client.cpp
    trunk/client/gui-qt/fc_client.h
    trunk/client/gui-qt/messagewin.cpp
    trunk/client/gui-qt/messagewin.h

Modified: trunk/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=34352&r1=34351&r2=34352&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.cpp   (original)
+++ trunk/client/gui-qt/fc_client.cpp   Thu Nov  3 09:24:54 2016
@@ -586,15 +586,25 @@
   if (s.contains("Fonts-set") == false) {
     configure_fonts();
   }
-  if (s.contains("Chat-xsize")) {
-    qt_settings.chat_width = s.value("Chat-xsize").toInt();
+  if (s.contains("Chat-x-size")) {
+    qt_settings.chat_width = s.value("Chat-x-size").toInt();
   } else {
-    qt_settings.chat_width = 33;
-  }
-  if (s.contains("Chat-ysize")) {
-    qt_settings.chat_height = s.value("Chat-ysize").toInt();
+    qt_settings.chat_width = 3300;
+  }
+  if (s.contains("Chat-y-size")) {
+    qt_settings.chat_height = s.value("Chat-y-size").toInt();
   } else {
-    qt_settings.chat_height = 33;
+    qt_settings.chat_height = 3300;
+  }
+  if (s.contains("Chat-x-pos")) {
+    qt_settings.chat_x_pos = s.value("Chat-x-pos").toInt();
+  } else {
+    qt_settings.chat_x_pos = 0;
+  }
+  if (s.contains("Chat-y-pos")) {
+    qt_settings.chat_y_pos = s.value("Chat-y-pos").toInt();
+  } else {
+    qt_settings.chat_y_pos = 10000;
   }
   if (s.contains("unit_x")) {
     qt_settings.unit_info_pos_x = s.value("unit_x").toInt();
@@ -621,6 +631,9 @@
   qt_settings.player_repo_sort_col = -1;
   qt_settings.city_repo_sort_col = -1;
 
+  if (qt_settings.chat_x_pos < 0) {
+    qt_settings.chat_x_pos = 0;
+  }
 }
 
 /****************************************************************************
@@ -631,8 +644,10 @@
   QSettings s(QSettings::IniFormat, QSettings::UserScope,
               "freeciv-qt-client");
   s.setValue("Fonts-set", true);
-  s.setValue("Chat-xsize", qt_settings.chat_width);
-  s.setValue("Chat-ysize", qt_settings.chat_height);
+  s.setValue("Chat-x-size", qt_settings.chat_width);
+  s.setValue("Chat-y-size", qt_settings.chat_height);
+  s.setValue("Chat-x-pos", qt_settings.chat_x_pos);
+  s.setValue("Chat-y-pos", qt_settings.chat_y_pos);
   s.setValue("City-dialog", qt_settings.city_geometry);
   s.setValue("splitter1", qt_settings.city_splitter1);
   s.setValue("splitter2", qt_settings.city_splitter2);
@@ -900,10 +915,13 @@
     map_canvas_resized(size.width(), size.height());
     size.setWidth(event->size().width() - gui()->sidebar_wdg->width());
     gui()->infotab->resize((size.width()
-                             * gui()->qt_settings.chat_width) / 100,
+                             * gui()->qt_settings.chat_width) / 10000,
                              (size.height()
-                             * gui()->qt_settings.chat_height) / 100);
-    gui()->infotab->move(0 , size.height() - gui()->infotab->height());
+                             * gui()->qt_settings.chat_height) / 10000);
+    gui()->infotab->move((size.width() * gui()->qt_settings.chat_x_pos)
+                         /10000,
+                         (size.height() * gui()->qt_settings.chat_y_pos)
+                         /10000 - gui()->infotab->height());
     gui()->infotab->restore_chat();
     gui()->minimapview_wdg->move(event->size().width() -
                                  gui()->minimapview_wdg->width() - 10,

Modified: trunk/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.h?rev=34352&r1=34351&r2=34352&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.h     (original)
+++ trunk/client/gui-qt/fc_client.h     Thu Nov  3 09:24:54 2016
@@ -122,8 +122,10 @@
 ****************************************************************************/
 struct fc_settings
 {
-  int chat_width; /* in percent */
-  int chat_height; /* in percent */
+  int chat_width;
+  int chat_height;
+  int chat_x_pos;
+  int chat_y_pos;
   int player_repo_sort_col;
   Qt::SortOrder player_report_sort;
   int city_repo_sort_col;

Modified: trunk/client/gui-qt/messagewin.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/messagewin.cpp?rev=34352&r1=34351&r2=34352&view=diff
==============================================================================
--- trunk/client/gui-qt/messagewin.cpp  (original)
+++ trunk/client/gui-qt/messagewin.cpp  Thu Nov  3 09:24:54 2016
@@ -46,9 +46,12 @@
   layout->setVerticalSpacing(0);
   setLayout(layout);
   resize_mode = false;
-  move_mode = false;
   resx = false;
   resy = false;
+  resxy = false;
+  mw = new move_widget(this);
+  mw->put_to_corner();
+  mw->setFixedSize(13, 13);
   setMouseTracking(true);
 }
 
@@ -84,7 +87,8 @@
     cursor = event->globalPos() - geometry().topLeft();
     if (event->y() > 0 && event->y() < 25 && event->x() > width() - 25
         && event->x() < width()) {
-      move_mode = true;
+      resize_mode = true;
+      resxy = true;
       return;
     }
     if (event->y() > 0 && event->y() < 5){
@@ -107,15 +111,19 @@
     resize_mode = false;
     resx = false;
     resy = false;
+    resxy = false;
     setCursor(Qt::ArrowCursor);
-    gui()->qt_settings.chat_width = width() * 100 / mapview.width;
-    gui()->qt_settings.chat_height = height() * 100 / mapview.height;
-  }
-  if (move_mode) {
-    move_mode = false;
-  }
-
-}
+    gui()->qt_settings.chat_width = (width() * 10000)
+                                    / gui()->mapview_wdg->width();
+    gui()->qt_settings.chat_height = (height() * 10000)
+                                    / gui()->mapview_wdg->height();
+  }
+  gui()->qt_settings.chat_x_pos = 1 + (pos().x() * 10000)
+                                     / gui()->mapview_wdg->width();
+  gui()->qt_settings.chat_y_pos = 1 + ((pos().y() + height()) * 10000)
+                                     / gui()->mapview_wdg->height();
+}
+
 
 /**************************************************************************
   Called when mouse moved (mouse track is enabled).
@@ -131,6 +139,8 @@
     move(this->x(), to_move.y());
     setCursor(Qt::SizeVerCursor);
     restore_chat();
+  } else if (event->x() > width() - 9 && event->y() > 0 && event->y() < 9) {
+    setCursor(Qt::SizeBDiagCursor);
   } else if ((event->buttons() & Qt::LeftButton) && resize_mode && resx) {
     resize(event->x(), height());
     setCursor(Qt::SizeHorCursor);
@@ -138,9 +148,14 @@
     setCursor(Qt::SizeHorCursor);
   } else if (event->y() > 0 && event->y() < 5) {
     setCursor(Qt::SizeVerCursor);
-  } else if (move_mode && (event->buttons() & Qt::LeftButton)) {
-    setCursor(Qt::SizeAllCursor);
-    move(event->globalPos() - cursor);
+  } else if (resxy && (event->buttons() & Qt::LeftButton)) {
+    QPoint to_move;
+    int newheight = event->globalY() - cursor.y() - geometry().y();
+    resize(event->x(), this->geometry().height()- newheight);
+    to_move = event->globalPos() - cursor;
+    move(this->x(), to_move.y());
+    setCursor(Qt::SizeBDiagCursor);
+    restore_chat();
   } else {
     setCursor(Qt::ArrowCursor);
   }

Modified: trunk/client/gui-qt/messagewin.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/messagewin.h?rev=34352&r1=34351&r2=34352&view=diff
==============================================================================
--- trunk/client/gui-qt/messagewin.h    (original)
+++ trunk/client/gui-qt/messagewin.h    Thu Nov  3 09:24:54 2016
@@ -76,9 +76,10 @@
   void update_menu();
   QPoint cursor;
   QSize last_size;
+  move_widget *mw;
   bool hidden_state;
   bool resize_mode;
-  bool move_mode;
+  bool resxy;
   bool resx;
   bool resy;
 protected:


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

Reply via email to