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