Author: mir3x
Date: Sun Nov 13 22:33:44 2016
New Revision: 34500

URL: http://svn.gna.org/viewcvs/freeciv?rev=34500&view=rev
Log:
Qt client - added menu option to lock interface

See patch #7979


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

Modified: trunk/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.cpp   (original)
+++ trunk/client/gui-qt/fc_client.cpp   Sun Nov 13 22:33:44 2016
@@ -108,6 +108,7 @@
   update_info_timer = nullptr;
   game_layout = nullptr;
   unitinfo_wdg = nullptr;
+  interface_locked = false;
   for (int i = 0; i <= PAGE_GAME; i++) {
     pages_layout[i] = NULL;
     pages[i] = NULL;

Modified: trunk/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.h?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.h     (original)
+++ trunk/client/gui-qt/fc_client.h     Sun Nov 13 22:33:44 2016
@@ -259,6 +259,7 @@
   trade_generator trade_gen;
   qfc_rally_list rallies;
   hud_units *unitinfo_wdg;
+  bool interface_locked;
   fc_sidewidget *sw_cunit;
   fc_sidewidget *sw_science;
   fc_sidewidget *sw_endturn;

Modified: trunk/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/mapview.cpp?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/mapview.cpp     (original)
+++ trunk/client/gui-qt/mapview.cpp     Sun Nov 13 22:33:44 2016
@@ -384,7 +384,9 @@
 ****************************************************************************/
 void move_widget::mouseMoveEvent(QMouseEvent *event)
 {
-  parentWidget()->move(event->globalPos() - point);
+  if(gui()->interface_locked == false) {
+    parentWidget()->move(event->globalPos() - point);
+  }
 }
 
 /****************************************************************************
@@ -392,7 +394,9 @@
 ****************************************************************************/
 void move_widget::mousePressEvent(QMouseEvent* event)
 {
-  point = event->globalPos() - parentWidget()->geometry().topLeft();
+  if (gui()->interface_locked == false) {
+    point = event->globalPos() - parentWidget()->geometry().topLeft();
+  }
   update();
 }
 
@@ -422,6 +426,9 @@
 {
   QPoint qp, np;
 
+  if (gui()->interface_locked) {
+    return;
+  }
   qp = event->globalPos();
   np.setX(qp.x() - point.x());
   np.setY(qp.y() - point.y());
@@ -437,6 +444,9 @@
 {
   QPoint qp;
 
+  if (gui()->interface_locked) {
+    return;
+  }
   qp = event->globalPos();
   point.setX(qp.x() - parentWidget()->width());
   point.setY(qp.y() - parentWidget()->height());
@@ -466,6 +476,9 @@
 ****************************************************************************/
 void close_widget::mousePressEvent(QMouseEvent* event)
 {
+  if (gui()->interface_locked) {
+    return;
+  }
   if (event->button() == Qt::LeftButton) {
     parentWidget()->hide();
     notify_parent();
@@ -830,6 +843,9 @@
   int x, y;
 
   if (event->button() == Qt::LeftButton) {
+    if (gui()->interface_locked) {
+      return;
+    }
     cursor = event->globalPos() - geometry().topLeft();
   }
   if (event->button() == Qt::RightButton) {
@@ -857,6 +873,9 @@
 **************************************************************************/
 void minimap_view::mouseMoveEvent(QMouseEvent* event)
 {
+  if (gui()->interface_locked) {
+    return;
+  }
   if (event->buttons() & Qt::LeftButton) {
     move(event->globalPos() - cursor);
     setCursor(Qt::SizeAllCursor);

Modified: trunk/client/gui-qt/menu.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/menu.cpp?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/menu.cpp        (original)
+++ trunk/client/gui-qt/menu.cpp        Sun Nov 13 22:33:44 2016
@@ -61,6 +61,7 @@
 extern QApplication *qapp;
 
 static bool tradecity_rand(const trade_city *t1, const trade_city *t2);
+static void enable_interface(bool enable);
 /**************************************************************************
   New turn callback
 **************************************************************************/
@@ -1019,6 +1020,12 @@
   minimap_status->setChecked(true);
   connect(minimap_status, SIGNAL(triggered()), this,
           SLOT(slot_minimap_view()));
+  minimap_status = menu->addAction(_("Lock interface"));
+  minimap_status->setCheckable(true);
+  minimap_status->setShortcut(QKeySequence(shortcut_to_string(
+                             fc_shortcuts::sc()->get_shortcut(SC_LOCK))));
+  minimap_status->setChecked(false);
+  connect(minimap_status, SIGNAL(triggered()), this, SLOT(slot_lock()));
   menu->addSeparator();
   act = menu->addAction(_("City Outlines"));
   act->setCheckable(true);
@@ -2731,6 +2738,44 @@
   request_center_focus_unit();
 }
 
+/****************************************************************
+  Action "Lock interface"
+*****************************************************************/
+void mr_menu::slot_lock()
+{
+  if (gui()->interface_locked) {
+    enable_interface(false);
+  } else {
+    enable_interface(true);
+  }
+  gui()->interface_locked = !gui()->interface_locked;
+}
+
+/****************************************************************
+  Helper function to hide/show widgets
+*****************************************************************/
+void enable_interface(bool enable)
+{
+  QList<close_widget *> lc;
+  QList<move_widget *> lm;
+  QList<resize_widget *> lr;
+  int i;
+
+  lc = gui()->findChildren<close_widget *>();
+  lm = gui()->findChildren<move_widget *>();
+  lr = gui()->findChildren<resize_widget *>();
+
+  for (i = 0; i < lc.size(); ++i) {
+    lc.at(i)->setVisible(!enable);
+  }
+  for (i = 0; i < lm.size(); ++i) {
+    lm.at(i)->setVisible(!enable);
+  }
+  for (i = 0; i < lr.size(); ++i) {
+    lr.at(i)->setVisible(!enable);
+  }
+}
+
 /***************************************************************************
   Action "SET FULLSCREEN"
 ***************************************************************************/

Modified: trunk/client/gui-qt/menu.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/menu.h?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/menu.h  (original)
+++ trunk/client/gui-qt/menu.h  Sun Nov 13 22:33:44 2016
@@ -355,6 +355,7 @@
   void slot_center_view();
   void slot_minimap_view();
   void slot_fullscreen();
+  void slot_lock();
   void slot_city_outlines();
   void slot_city_output();
   void slot_map_grid();

Modified: trunk/client/gui-qt/messagewin.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/messagewin.cpp?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/messagewin.cpp  (original)
+++ trunk/client/gui-qt/messagewin.cpp  Sun Nov 13 22:33:44 2016
@@ -83,6 +83,9 @@
 ***************************************************************************/
 void info_tab::mousePressEvent(QMouseEvent *event)
 {
+  if (gui()->interface_locked) {
+    return;
+  }
   if (event->button() == Qt::LeftButton) {
     cursor = event->globalPos() - geometry().topLeft();
     if (event->y() > 0 && event->y() < 25 && event->x() > width() - 25
@@ -107,6 +110,9 @@
 ***************************************************************************/
 void info_tab::mouseReleaseEvent(QMouseEvent* event)
 {
+  if (gui()->interface_locked) {
+    return;
+  }
   if (resize_mode) {
     resize_mode = false;
     resx = false;
@@ -131,6 +137,9 @@
 **************************************************************************/
 void info_tab::mouseMoveEvent(QMouseEvent *event)
 {
+  if (gui()->interface_locked) {
+    return;
+  }
   if ((event->buttons() & Qt::LeftButton) && resize_mode && resy) {
     QPoint to_move;
     int newheight = event->globalY() - cursor.y() - geometry().y();

Modified: trunk/client/gui-qt/shortcuts.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/shortcuts.cpp?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/shortcuts.cpp   (original)
+++ trunk/client/gui-qt/shortcuts.cpp   Sun Nov 13 22:33:44 2016
@@ -50,7 +50,7 @@
   RESPONSE_SAVE
 };
 
-static int num_shortcuts = 43;
+static int num_shortcuts = 44;
 fc_shortcut default_shortcuts[] = {
   {SC_SCROLL_MAP, 0, Qt::RightButton, Qt::NoModifier, "Scroll map" },
   {SC_CENTER_VIEW, Qt::Key_C, Qt::AllButtons, Qt::NoModifier,
@@ -136,6 +136,8 @@
     _("Unload") },
   {SC_BUY_MAP, 0, Qt::BackButton, Qt::NoModifier,
     _("Quick buy current production from map") },
+  {SC_LOCK, Qt::Key_L, Qt::AllButtons, Qt::ControlModifier
+    | Qt::ShiftModifier, _("Lock/unlock interface") },
 };
 
 

Modified: trunk/client/gui-qt/shortcuts.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/shortcuts.h?rev=34500&r1=34499&r2=34500&view=diff
==============================================================================
--- trunk/client/gui-qt/shortcuts.h     (original)
+++ trunk/client/gui-qt/shortcuts.h     Sun Nov 13 22:33:44 2016
@@ -73,7 +73,8 @@
   SC_NUKE = 40,
   SC_LOAD = 41,
   SC_UNLOAD = 42,
-  SC_BUY_MAP
+  SC_BUY_MAP = 43,
+  SC_LOCK = 44
 };
 
 


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

Reply via email to