add more spacing
[personal-kdebase.git] / runtime / kcontrol / locale / klocalesample.cpp
blob72f07284c8ec6289f555a6a8bdbd23cf7db31a5b
1 /*
2 * klocalesample.cpp
4 * Copyright (c) 1998 Matthias Hoelzer (hoelzer@physik.uni-wuerzburg.de)
5 * Copyright (c) 1999 Preston Brown <pbrown@kde.org>
6 * Copyright (c) 1999-2003 Hans Petter Bieker <bieker@kde.org>
8 * Requires the Qt widget libraries, available at no cost at
9 * http://www.troll.no/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include <QDateTime>
27 #include <QLabel>
28 #include <QLayout>
29 #include <QTimer>
31 #include <stdio.h>
33 #include <klocale.h>
35 #include "klocalesample.h"
36 #include "klocalesample.moc"
38 KLocaleSample::KLocaleSample(KLocale *locale, QWidget *parent)
39 : QWidget(parent),
40 m_locale(locale)
42 QGridLayout *lay = new QGridLayout(this);
44 m_labNumber = new QLabel(this);
45 lay->addWidget(m_labNumber, 0, 0);
46 m_labNumber->setObjectName( I18N_NOOP("Numbers:") );
47 m_labNumber->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
48 m_numberSample = new QLabel(this);
49 lay->addWidget(m_numberSample, 0, 1);
51 m_labMoney = new QLabel(this);
52 lay->addWidget(m_labMoney, 1, 0);
53 m_labMoney->setObjectName( I18N_NOOP("Money:") );
54 m_labMoney->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
55 m_moneySample = new QLabel(this);
56 lay->addWidget(m_moneySample, 1, 1);
58 m_labDate = new QLabel(this);
59 lay->addWidget(m_labDate, 2, 0);
60 m_labDate->setObjectName( I18N_NOOP("Date:") );
61 m_labDate->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
62 m_dateSample = new QLabel(this);
63 lay->addWidget(m_dateSample, 2, 1);
65 m_labDateShort = new QLabel(this);
66 lay->addWidget(m_labDateShort, 3, 0);
67 m_labDateShort->setObjectName( I18N_NOOP("Short date:") );
68 m_labDateShort->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
69 m_dateShortSample = new QLabel(this);
70 lay->addWidget(m_dateShortSample, 3, 1);
72 m_labTime = new QLabel(this);
73 lay->addWidget(m_labTime, 4, 0);
74 m_labTime->setObjectName( I18N_NOOP("Time:") );
75 m_labTime->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
76 m_timeSample = new QLabel(this);
77 lay->addWidget(m_timeSample, 4, 1);
79 lay->setColumnStretch(1, 3);
81 QTimer *timer = new QTimer(this);
82 timer->setObjectName(QLatin1String("clock_timer"));
83 connect(timer, SIGNAL(timeout()), this, SLOT(slotUpdateTime()));
84 timer->start(1000);
87 KLocaleSample::~KLocaleSample()
91 void KLocaleSample::slotUpdateTime()
93 QDateTime dt = QDateTime::currentDateTime();
95 m_dateSample->setText(m_locale->formatDate(dt.date(), KLocale::LongDate));
96 m_dateShortSample->setText(m_locale->formatDate(dt.date(), KLocale::ShortDate));
97 m_timeSample->setText(m_locale->formatTime(dt.time(), true));
100 void KLocaleSample::slotLocaleChanged()
102 m_numberSample->setText(m_locale->formatNumber(1234567.89) +
103 QLatin1String(" / ") +
104 m_locale->formatNumber(-1234567.89));
106 m_moneySample->setText(m_locale->formatMoney(123456789.00) +
107 QLatin1String(" / ") +
108 m_locale->formatMoney(-123456789.00));
110 slotUpdateTime();
112 QString str;
114 str = ki18n("This is how numbers will be displayed.").toString(m_locale);
115 m_labNumber->setWhatsThis( str );
116 m_numberSample->setWhatsThis( str );
118 str = ki18n("This is how monetary values will be displayed.").toString(m_locale);
119 m_labMoney->setWhatsThis( str );
120 m_moneySample->setWhatsThis( str );
122 str = ki18n("This is how date values will be displayed.").toString(m_locale);
123 m_labDate->setWhatsThis( str );
124 m_dateSample->setWhatsThis( str );
126 str = ki18n("This is how date values will be displayed using "
127 "a short notation.").toString(m_locale);
128 m_labDateShort->setWhatsThis( str );
129 m_dateShortSample->setWhatsThis( str );
131 str = ki18n("This is how the time will be displayed.").toString(m_locale);
132 m_labTime->setWhatsThis( str );
133 m_timeSample->setWhatsThis( str );