Author: mir3x
Date: Mon Nov 16 19:49:45 2015
New Revision: 30628

URL: http://svn.gna.org/viewcvs/freeciv?rev=30628&view=rev
Log:
Added shortcuts on map view via mouse + modifier key(shift, ctrl, alt). 
Those shortcuts are the same like in gtk client, they allow to:
Wake up sentries, Append focus unit, Quickselect a sea unit,
Adjust workers, Quickselect a land unit, Copy/Paste Production. 

See patch #6577


Modified:
    trunk/client/gui-qt/mapctrl.cpp
    trunk/client/gui-qt/mapview.cpp

Modified: trunk/client/gui-qt/mapctrl.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/mapctrl.cpp?rev=30628&r1=30627&r2=30628&view=diff
==============================================================================
--- trunk/client/gui-qt/mapctrl.cpp     (original)
+++ trunk/client/gui-qt/mapctrl.cpp     Mon Nov 16 19:49:45 2015
@@ -167,13 +167,16 @@
 **************************************************************************/
 void map_view::mousePressEvent(QMouseEvent *event)
 {
-  struct tile *ptile = NULL;
+  struct tile *ptile = nullptr;
+  struct city *pcity = nullptr;
   bool alt;
   bool ctrl;
+  bool shft;
   QPoint pos;
 
   alt = false;
   ctrl = false;
+  shft = false;
 
   if (event->modifiers() & Qt::AltModifier) {
     alt = true;
@@ -181,28 +184,59 @@
   if (event->modifiers() & Qt::ControlModifier) {
     ctrl = true;
   }
+  if (event->modifiers() & Qt::ShiftModifier) {
+    shft = true;
+  }
   pos = gui()->mapview_wdg->mapFromGlobal(QCursor::pos());
-
+  ptile = canvas_pos_to_tile(pos.x(), pos.y());
+  pcity = ptile ? tile_city(ptile) : NULL;
+
+  /* Right Mouse Button pressed */
   if (event->button() == Qt::RightButton) {
-    if (alt && ctrl){
-      ptile = canvas_pos_to_tile(pos.x(), pos.y());
-      if (ptile) {
+    if (alt && ctrl && ptile) {
         gui()->infotab->chtwdg->make_link(ptile);
-      }
+      /* <SHIFT + CONTROL> + RMB: Paste Production. */
+    } else if (shft && ctrl && pcity != NULL) {
+      clipboard_paste_production(pcity);
+      /* <SHIFT> + RMB on city/unit: Copy Production. */
+    } else if (shft && clipboard_copy_production(ptile)) {
+      /* <CONTROL> + RMB : Quickselect a land unit. */
+    } else if (ctrl) {
+      action_button_pressed(event->pos().x(),event->pos().y(), SELECT_LAND);
+      /* <SHIFT> + <ALT> + RMB : Show/hide workers. */
+    } else if (shft && alt) {
+      key_city_overlay(event->pos().x(), event->pos().y());
     } else {
-      recenter_button_pressed(event->x(), event->y());
+      recenter_button_pressed(event->pos().x(), event->pos().y());
     }
   }
 
   /* Left Button */
   if (event->button() == Qt::LeftButton) {
-    action_button_pressed(event->pos().x(), event->pos().y(), SELECT_POPUP);
-  }
+    /* <SHIFT> + <CONTROL> + LMB : Adjust workers. */
+    if (shft && ctrl) {
+      adjust_workers_button_pressed(event->pos().x(), event->pos().y());
+      /* <CONTROL> + LMB : Quickselect a sea unit. */
+    } else if (ctrl) {
+      action_button_pressed(event->pos().x(), event->pos().y(), SELECT_SEA);
+      /* <SHIFT> + LMB: Append focus unit. */
+    } else if (ptile && shft) {
+      action_button_pressed(event->pos().x(), event->pos().y(),
+                            SELECT_APPEND);
+    } else {
+      action_button_pressed(event->pos().x(), event->pos().y(), SELECT_POPUP);
+    }
+  }
+
   /* Middle Button */
   if (event->button() == Qt::MiddleButton) {
-    ptile = canvas_pos_to_tile(pos.x(), pos.y());
-   gui()->popup_tile_info(ptile);
- }
+    /* <CONTROL> + MMB: Wake up sentries. */
+    if (ctrl) {
+      wakeup_button_pressed(event->pos().x(), event->pos().y());
+    } else {
+      gui()->popup_tile_info(ptile);
+    }
+  }
 
 }
 /**************************************************************************

Modified: trunk/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/mapview.cpp?rev=30628&r1=30627&r2=30628&view=diff
==============================================================================
--- trunk/client/gui-qt/mapview.cpp     (original)
+++ trunk/client/gui-qt/mapview.cpp     Mon Nov 16 19:49:45 2015
@@ -1088,6 +1088,7 @@
   const struct sprite *sprite;
   int d;
   QSize delta;
+  QFontMetrics fm(this->font());
 
   if (client_is_global_observer()) {
     return;
@@ -1116,6 +1117,8 @@
                                     "rates. Use mouse wheel to change them"));
   }
 
+  setMinimumHeight(fm.height() + 1 + client_research_sprite()->pm->height()
+                   + get_tax_sprite(tileset, O_LUXURY)->pm->height() + 10);
   delta = gui()->mapview_wdg->size() - gui()->end_turn_rect->sizeHint();
   move(delta.width(), delta.height());
 }


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

Reply via email to