summaryrefslogtreecommitdiff
path: root/gettext-tools/examples/hello-c++-kde/hellowindow.cc
blob: 60c3eb31e458187b8ebb42bfcd43881bde0b6772 (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
// Example for use of GNU gettext.
// Copyright (C) 2003, 2015-2016 Free Software Foundation, Inc.
// This file is published under the GNU General Public License.

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

/* Specification.  */
#include "hellowindow.h"

/* Declare i18n.  */
#include <klocale.h>
/* Declare KMainWindow.  */
#include <kmainwindow.h>
/* Declare QLabel.  */
#include <qlabel.h>
/* Declare QPushButton.  */
#include <qpushbutton.h>
/* Declare QString.  */
#include <qstring.h>
/* Declare QVBox.  */
#include <qvbox.h>
/* Declare QHBox.  */
#include <qhbox.h>

/* Get getpid() declaration.  */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif

// The main window widget.

HelloMainWindow::HelloMainWindow (QWidget * parent, const char * name)
  : KMainWindow (parent, name)
{
  setCaption ("Hello example");

  QVBox *panel = new QVBox (this);
  panel->setSpacing (2);

  QLabel *label1 = new QLabel (i18n ("Hello, world!"), panel);

  QString label2text;
  // NOT using QString::sprintf because it doesn't support reordering of
  // arguments.
  //label2text.sprintf (i18n ("This program is running as process number %d"),
  //                    getpid ());
  label2text = i18n ("This program is running as process number %1.").arg(getpid ());
  QLabel *label2 = new QLabel (label2text, panel);

  QHBox *buttonbar = new QHBox (panel);
  QWidget *filler = new QWidget (buttonbar); // makes the button right-aligned
  button = new QPushButton ("OK", buttonbar);
  button->setMaximumWidth (button->sizeHint().width() + 20);

  panel->resize (panel->sizeHint ());
  resize (panel->frameSize ());
}

HelloMainWindow::~HelloMainWindow ()
{
}