xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/examples/hello-c++-kde/hello.cc (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 // Example for use of GNU gettext.
2 // Copyright (C) 2003 Free Software Foundation, Inc.
3 // This file is published under the GNU General Public License.
4 
5 // Source code of the C++ program.
6 
7 #if HAVE_CONFIG_H
8 # include <config.h>
9 #endif
10 
11 #include <stdlib.h>
12 /* Declare KCmdLineArgs, KCmdLineOptions.  */
13 #include <kcmdlineargs.h>
14 /* Declare KApplication.  */
15 #include <kapplication.h>
16 /* Declare KAboutData.  */
17 #include <kaboutdata.h>
18 /* Declare main window widget.  */
19 #include "hellowindow.h"
20 
21 // Comment line options.
22 
23 static KCmdLineOptions options[] =
24 {
25   { 0, 0, 0 } // End of options.
26 };
27 
28 int
29 main (int argc, char *argv[])
30 {
31   // Initializations.
32 
33   {
34     // Add our installation directory to KDE's search list for message
35     // catalogs.  By default it looks only in $KDEHOME/share/locale and
36     // $KDEDIR/share/locale.
37     QString kdedirs = getenv ("KDEDIRS");
38     if (kdedirs.isEmpty ())
39       kdedirs = PREFIX;
40     else
41       kdedirs = kdedirs + ":" + PREFIX;
42     setenv ("KDEDIRS", (const char *) kdedirs.local8Bit(), true);
43   }
44 
45   KAboutData aboutData ("hello-c++-kde",
46                         I18N_NOOP ("Hello example"),
47                         VERSION,
48                         I18N_NOOP ("Hello world example"),
49                         KAboutData::License_GPL,
50                         "(C) 2003 Free Software Foundation",
51                         NULL,
52                         NULL,
53                         "bug-gnu-gettext@gnu.org");
54   KCmdLineArgs::init (argc, argv, &aboutData);
55   KCmdLineArgs::addCmdLineOptions (options);
56   KApplication application;
57 
58   // Create the GUI elements.
59 
60   HelloMainWindow *window = new HelloMainWindow ();
61   QObject::connect (window->button, SIGNAL (clicked ()),
62                     &application, SLOT (quit ()));
63 
64   application.setMainWidget (window);
65 
66   // Make the GUI elements visible.
67 
68   window->show ();
69 
70   // Start the event loop.
71 
72   return application.exec ();
73 }
74