Author: mir3x
Date: Mon Dec 28 09:45:27 2015
New Revision: 31226

URL: http://svn.gna.org/viewcvs/freeciv?rev=31226&view=rev
Log:
Added close button to unit selection and also 
forced closing when 'escape' pressed.

See patch #6724


Modified:
    branches/S2_6/client/gui-qt/dialogs.cpp
    branches/S2_6/client/gui-qt/dialogs.h

Modified: branches/S2_6/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.cpp?rev=31226&r1=31225&r2=31226&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.cpp     (original)
+++ branches/S2_6/client/gui-qt/dialogs.cpp     Mon Dec 28 09:45:27 2015
@@ -2314,6 +2314,7 @@
   h_pix = NULL;
   create_pixmap();
   p = mapFromGlobal(QCursor::pos());
+  cw = new close_widget(this);
   setMouseTracking(true);
   final_p.setX(p.x());
   final_p.setY(p.y());
@@ -2324,6 +2325,7 @@
     final_p.setY(height());
   }
   move(final_p.x(), final_p.y() - height());
+  setFocus();
 }
 /****************************************************************
   Destructor for unit select
@@ -2333,6 +2335,7 @@
     delete h_pix;
     delete pix;
     delete ufont;
+    delete cw;
 }
 
 /****************************************************************
@@ -2544,6 +2547,7 @@
   } else {
     info_font->setPointSize(*f_size);
   }
+  cw->put_to_corner();
 }
 /****************************************************************
   Paint event, redirects to paint(...)
@@ -2563,6 +2567,9 @@
 *****************************************************************/
 void unit_select::update_menu()
 {
+  was_destroyed = true;
+  close();
+  destroy();
 }
 
 /****************************************************************
@@ -2619,6 +2626,19 @@
   event->accept();
 }
 
+/****************************************************************
+  Keyboard handler for unit_select
+*****************************************************************/
+void unit_select::keyPressEvent(QKeyEvent *event)
+{
+  if (event->key() == Qt::Key_Escape) {
+    was_destroyed = true;
+    close();
+    destroy();
+  }
+  QWidget::keyPressEvent(event);
+}
+
 /***************************************************************************
  Set current diplo dialog
 ***************************************************************************/

Modified: branches/S2_6/client/gui-qt/dialogs.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.h?rev=31226&r1=31225&r2=31226&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.h       (original)
+++ branches/S2_6/client/gui-qt/dialogs.h       Mon Dec 28 09:45:27 2015
@@ -168,6 +168,7 @@
   QFont *ufont;
   QFont *info_font;
   int row_count;
+  close_widget *cw;
 public:
   unit_select(struct tile *ptile, QWidget *parent);
   ~unit_select();
@@ -179,6 +180,7 @@
   void paint(QPainter *painter, QPaintEvent *event);
   void paintEvent(QPaintEvent *event);
   void mousePressEvent(QMouseEvent *event);
+  void keyPressEvent(QKeyEvent *event);
   void mouseMoveEvent(QMouseEvent *event);
   void wheelEvent(QWheelEvent *event);
 private:


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

Reply via email to