summaryrefslogtreecommitdiff
path: root/gettext-tools/examples/hello-c++-kde/hello.cc
blob: e8cdf746f6bedc14a46d5ab0f2c8c30007fb5f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Example for use of GNU gettext.
// Copyright (C) 2003, 2015 Free Software Foundation, Inc.
// This file is published under the GNU General Public License.

// Source code of the C++ program.

#if HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdlib.h>
/* Declare KCmdLineArgs, KCmdLineOptions.  */
#include <kcmdlineargs.h>
/* Declare KApplication.  */
#include <kapplication.h>
/* Declare KAboutData.  */
#include <kaboutdata.h>
/* Declare main window widget.  */
#include "hellowindow.h"

// Comment line options.

static KCmdLineOptions options[] =
{
  { 0, 0, 0 } // End of options.
};

int
main (int argc, char *argv[])
{
  // Initializations.

  {
    // Add our installation directory to KDE's search list for message
    // catalogs.  By default it looks only in $KDEHOME/share/locale and
    // $KDEDIR/share/locale.
    QString kdedirs = getenv ("KDEDIRS");
    if (kdedirs.isEmpty ())
      kdedirs = PREFIX;
    else
      kdedirs = kdedirs + ":" + PREFIX;
    setenv ("KDEDIRS", (const char *) kdedirs.local8Bit(), true);
  }

  KAboutData aboutData ("hello-c++-kde",
                        I18N_NOOP ("Hello example"),
                        VERSION,
                        I18N_NOOP ("Hello world example"),
                        KAboutData::License_GPL,
                        "(C) 2003 Free Software Foundation",
                        NULL,
                        NULL,
                        "bug-gnu-gettext@gnu.org");
  KCmdLineArgs::init (argc, argv, &aboutData);
  KCmdLineArgs::addCmdLineOptions (options);
  KApplication application;

  // Create the GUI elements.

  HelloMainWindow *window = new HelloMainWindow ();
  QObject::connect (window->button, SIGNAL (clicked ()),
                    &application, SLOT (quit ()));

  application.setMainWidget (window);

  // Make the GUI elements visible.

  window->show ();

  // Start the event loop.

  return application.exec ();
}