Author: cazfi
Date: Mon Nov 17 06:18:35 2014
New Revision: 27055

URL: http://svn.gna.org/viewcvs/freeciv?rev=27055&view=rev
Log:
Made "freeciv-qt -- --help" to work

See bug #22926

Modified:
    branches/S2_5/client/gui-qt/gui_main.cpp

Modified: branches/S2_5/client/gui-qt/gui_main.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/gui_main.cpp?rev=27055&r1=27054&r2=27055&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/gui_main.cpp    (original)
+++ branches/S2_5/client/gui-qt/gui_main.cpp    Mon Nov 17 06:18:35 2014
@@ -95,23 +95,60 @@
 }
 
 /**************************************************************************
+  Print extra usage information, including one line help on each option,
+  to stderr. 
+**************************************************************************/
+static void print_usage()
+{
+  /* add client-specific usage information here */
+  fc_fprintf(stderr,
+             _("This client accepts the standard Qt command-line options\n"
+               "after '--'. See the Qt documentation.\n\n"));
+
+  /* TRANS: No full stop after the URL, could cause confusion. */
+  fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
+}
+
+/**************************************************************************
+  Search for gui-specic command line options, that are not handled by Qt
+  (QApplication). Returns true iff program is to be executed, and not
+  to exit after showing the results from option parsing. 
+**************************************************************************/
+static bool parse_options(int argc, char **argv)
+{
+  int i = 1;
+
+  while (i < argc) {
+    if (is_option("--help", argv[i])) {
+      print_usage();
+      return false;
+    }
+    i++;
+  }
+
+  return true;
+}
+
+/**************************************************************************
   The main loop for the UI.  This is called from main(), and when it
   exits the client will exit.
 **************************************************************************/
 void qtg_ui_main(int argc, char *argv[])
 {
-  qapp = new QApplication(argc, argv);
-  QPixmap *qpm = new QPixmap;
-  QIcon app_icon;
-
-  tileset_init(tileset);
-  tileset_load_tiles(tileset);
-  populate_unit_pixmap_table();
-  qpm = get_icon_sprite(tileset, ICON_FREECIV)->pm;
-  app_icon = ::QIcon(*qpm);
-  qapp->setWindowIcon(app_icon);
-  freeciv_qt = new fc_client();
-  freeciv_qt->main(qapp);
+  if (parse_options(argc, argv)) {
+    qapp = new QApplication(argc, argv);
+    QPixmap *qpm = new QPixmap;
+    QIcon app_icon;
+
+    tileset_init(tileset);
+    tileset_load_tiles(tileset);
+    populate_unit_pixmap_table();
+    qpm = get_icon_sprite(tileset, ICON_FREECIV)->pm;
+    app_icon = ::QIcon(*qpm);
+    qapp->setWindowIcon(app_icon);
+    freeciv_qt = new fc_client();
+    freeciv_qt->main(qapp);
+  }
 }
 
 /****************************************************************************


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

Reply via email to