Author: mir3x
Date: Tue Dec 16 16:33:40 2014
New Revision: 27316

URL: http://svn.gna.org/viewcvs/freeciv?rev=27316&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:
    branches/S2_5/client/gui-qt/fc_client.cpp
    branches/S2_5/client/gui-qt/fc_client.h
    branches/S2_5/client/gui-qt/menu.cpp

Modified: branches/S2_5/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.cpp?rev=27316&r1=27315&r2=27316&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_5/client/gui-qt/fc_client.cpp   Tue Dec 16 16:33:40 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()
 {
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
   QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
@@ -53,7 +54,6 @@
    * were created.
    * After adding new QObjects null them here.
    */
-  main_window = NULL;
   main_wdg = NULL;
   chat_completer = NULL;
   connect_lan = NULL;
@@ -109,7 +109,6 @@
 
 void fc_client::init()
 {
-  main_window = new QMainWindow;
   central_wdg = new QWidget;
   central_layout = new QGridLayout;
   chat_completer = new QCompleter;
@@ -120,8 +119,8 @@
   fc_fonts.init_fonts();
   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);
@@ -167,11 +166,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);
 }
 
 /****************************************************************************
@@ -181,7 +180,6 @@
 {
   status_bar_queue.clear();
   fc_fonts.release_fonts();
-  delete main_window;
 }
 
 /****************************************************************************
@@ -270,7 +268,7 @@
   if (page == PAGE_NETWORK){
     destroy_server_scans();
   }
-  main_window->menuBar()->setVisible(false);
+  menuBar()->setVisible(false);
 
   for (int i = 0; i < PAGE_GGZ + 1; i++) {
     if (i == new_page) {
@@ -292,12 +290,12 @@
     break;
   case PAGE_GAME:
     if (fullscreen_mode){
-      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();
@@ -376,6 +374,14 @@
 }
 
 /****************************************************************************
+  Closes main window
+****************************************************************************/
+void fc_client::closeEvent(QCloseEvent *event) {
+  popup_quit_dialog();
+  event->ignore();
+}
+
+/****************************************************************************
   Removes notifier
 ****************************************************************************/
 void fc_client::remove_server_source()

Modified: branches/S2_5/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.h?rev=27316&r1=27315&r2=27316&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.h     (original)
+++ branches/S2_5/client/gui-qt/fc_client.h     Tue Dec 16 16:33:40 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;
@@ -196,7 +197,6 @@
   void update_completer();
   choice_dialog *get_diplo_dialog();
 
-  QMainWindow *main_window;
   QCompleter *chat_completer;
   QStringList chat_history;
   int history_pos;
@@ -285,6 +285,7 @@
 protected:
   void timerEvent(QTimerEvent *);
   bool eventFilter(QObject *obj, QEvent *event);
+  void closeEvent(QCloseEvent *event);
 
 signals:
   void keyCaught(QKeyEvent *e);

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


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

Reply via email to