Author: mir3x
Date: Tue Dec 16 16:33:50 2014
New Revision: 27317

URL: http://svn.gna.org/viewcvs/freeciv?rev=27317&view=rev
Log:
The dialog "Are you sure you want to quit?" was implemented but not used. Fixed.

Patch submitted by Louis Moureaux <louis94>

See bug #23062



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

Modified: trunk/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=27317&r1=27316&r2=27317&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.cpp   (original)
+++ trunk/client/gui-qt/fc_client.cpp   Tue Dec 16 16:33:50 2014
@@ -32,6 +32,7 @@
 
 // gui-qt
 #include "fc_client.h"
+#include "gui_main.h"
 #include "optiondlg.h"
 #include "sprite.h"
 
@@ -41,7 +42,7 @@
 /****************************************************************************
   Constructor
 ****************************************************************************/
-fc_client::fc_client() : QObject()
+fc_client::fc_client() : QMainWindow()
 {
   /**
    * Somehow freeciv-client-common asks to switch to page when all widgets
@@ -50,7 +51,6 @@
    * were created.
    * After adding new QObjects null them here.
    */
-  main_window = NULL;
   main_wdg = NULL;
   chat_completer = NULL;
   connect_lan = NULL;
@@ -104,7 +104,6 @@
 
 void fc_client::init()
 {
-  main_window = new QMainWindow;
   central_wdg = new QWidget;
   central_layout = new QGridLayout;
   chat_completer = new QCompleter;
@@ -115,8 +114,8 @@
   history_pos = -1;
   menu_bar = new mr_menu();
   menu_bar->setup_menus();
-  main_window->setMenuBar(menu_bar);
-  status_bar = main_window->statusBar();
+  setMenuBar(menu_bar);
+  status_bar = statusBar();
   status_bar_label = new QLabel;
   status_bar_label->setAlignment(Qt::AlignCenter);
   status_bar->addWidget(status_bar_label, 1);
@@ -160,11 +159,11 @@
   central_layout->addLayout(pages_layout[PAGE_START], 1, 1);
   central_layout->addLayout(pages_layout[PAGE_GAME], 1, 1);
   central_wdg->setLayout(central_layout);
-  main_window->setCentralWidget(central_wdg);
+  setCentralWidget(central_wdg);
 
   connect(switch_page_mapper, SIGNAL(mapped( int)),
                 this, SLOT(switch_page(int)));
-  main_window->setVisible(true);
+  setVisible(true);
   
 }
 
@@ -175,7 +174,6 @@
 {
   status_bar_queue.clear();
   fc_fonts.release_fonts();
-  delete main_window;
 }
 
 /****************************************************************************
@@ -264,7 +262,7 @@
   if (page == PAGE_NETWORK){
     destroy_server_scans();
   }
-  main_window->menuBar()->setVisible(false);
+  menuBar()->setVisible(false);
 
   for (int i = 0; i <= PAGE_GAME; i++) {
     if (i == new_page) {
@@ -286,12 +284,12 @@
     break;
   case PAGE_GAME:
     if (options.gui_qt_fullscreen){
-      gui()->main_window->showFullScreen();
+      gui()->showFullScreen();
       gui()->mapview_wdg->showFullScreen();
     } else {
-      main_window->showMaximized();
-    }
-    main_window->menuBar()->setVisible(true);
+      showMaximized();
+    }
+    menuBar()->setVisible(true);
     mapview_wdg->setFocus();
     center_on_something();
     voteinfo_gui_update();
@@ -369,6 +367,14 @@
 }
 
 /****************************************************************************
+  Closes main window
+****************************************************************************/
+void fc_client::closeEvent(QCloseEvent *event) {
+  popup_quit_dialog();
+  event->ignore();
+}
+
+/****************************************************************************
   Removes notifier
 ****************************************************************************/
 void fc_client::remove_server_source()

Modified: trunk/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.h?rev=27317&r1=27316&r2=27317&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.h     (original)
+++ trunk/client/gui-qt/fc_client.h     Tue Dec 16 16:33:50 2014
@@ -24,6 +24,7 @@
 
 // Qt
 #include <QTabWidget>
+#include <QMainWindow>
 #include <QMap>
 
 // client
@@ -116,7 +117,7 @@
   void release_fonts();
 };
 
-class fc_client : public QObject
+class fc_client : public QMainWindow
 {
   Q_OBJECT
   QWidget *main_wdg;
@@ -192,7 +193,6 @@
   void update_completer();
   choice_dialog *get_diplo_dialog();
 
-  QMainWindow *main_window;
   QCompleter *chat_completer;
   QStringList chat_history;
   int history_pos;
@@ -281,6 +281,7 @@
 protected:
   void timerEvent(QTimerEvent *);
   bool eventFilter(QObject *obj, QEvent *event);
+  void closeEvent(QCloseEvent *event);
 
 signals:
   void keyCaught(QKeyEvent *e);

Modified: trunk/client/gui-qt/menu.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/menu.cpp?rev=27317&r1=27316&r2=27317&view=diff
==============================================================================
--- trunk/client/gui-qt/menu.cpp        (original)
+++ trunk/client/gui-qt/menu.cpp        Tue Dec 16 16:33:50 2014
@@ -1651,10 +1651,10 @@
 void mr_menu::slot_fullscreen()
 {
   if (!options.gui_qt_fullscreen) {
-    gui()->main_window->showFullScreen();
+    gui()->showFullScreen();
     gui()->mapview_wdg->showFullScreen();
   } else {
-    gui()->main_window->showNormal();
+    gui()->showNormal();
   }
   options.gui_qt_fullscreen = !options.gui_qt_fullscreen;
 }


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

Reply via email to