Author: mir3x Date: Mon Dec 28 09:45:16 2015 New Revision: 31225 URL: http://svn.gna.org/viewcvs/freeciv?rev=31225&view=rev Log: Added close button to unit selection and also forced closing when 'escape' pressed.
See patch #6724 Modified: branches/S2_5/client/gui-qt/dialogs.cpp branches/S2_5/client/gui-qt/dialogs.h Modified: branches/S2_5/client/gui-qt/dialogs.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/dialogs.cpp?rev=31225&r1=31224&r2=31225&view=diff ============================================================================== --- branches/S2_5/client/gui-qt/dialogs.cpp (original) +++ branches/S2_5/client/gui-qt/dialogs.cpp Mon Dec 28 09:45:16 2015 @@ -2108,6 +2108,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()); @@ -2118,6 +2119,7 @@ final_p.setY(height()); } move(final_p.x(), final_p.y() - height()); + setFocus(); } /**************************************************************** Destructor for unit select @@ -2127,6 +2129,7 @@ delete h_pix; delete pix; delete ufont; + delete cw; } /**************************************************************** @@ -2338,6 +2341,7 @@ } else { info_font->setPointSize(*f_size); } + cw->put_to_corner(); } /**************************************************************** Paint event, redirects to paint(...) @@ -2357,6 +2361,9 @@ *****************************************************************/ void unit_select::update_menu() { + was_destroyed = true; + close(); + destroy(); } /**************************************************************** @@ -2413,6 +2420,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 unit handled in diplo dialog ***************************************************************************/ Modified: branches/S2_5/client/gui-qt/dialogs.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/dialogs.h?rev=31225&r1=31224&r2=31225&view=diff ============================================================================== --- branches/S2_5/client/gui-qt/dialogs.h (original) +++ branches/S2_5/client/gui-qt/dialogs.h Mon Dec 28 09:45:16 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