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
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.h>
28
#include <qwhatsthis.h>
36
#include "klocalesample.h"
37
#include "klocalesample.moc"
39
KLocaleSample::KLocaleSample(KLocale *locale,
40
QWidget *parent, const char*name)
41
: QWidget(parent, name),
44
QGridLayout *lay = new QGridLayout(this, 5, 2);
45
lay->setAutoAdd(TRUE);
47
// Whatever the color scheme is, we want black text
48
QColorGroup a = palette().active();
49
a.setColor(QColorGroup::Foreground, Qt::black);
50
QPalette pal(a, a, a);
52
m_labNumber = new QLabel(this, I18N_NOOP("Numbers:"));
53
m_labNumber->setPalette(pal);
54
m_numberSample = new QLabel(this);
55
m_numberSample->setPalette(pal);
57
m_labMoney = new QLabel(this, I18N_NOOP("Money:"));
58
m_labMoney->setPalette(pal);
59
m_moneySample = new QLabel(this);
60
m_moneySample->setPalette(pal);
62
m_labDate = new QLabel(this, I18N_NOOP("Date:"));
63
m_labDate->setPalette(pal);
64
m_dateSample = new QLabel(this);
65
m_dateSample->setPalette(pal);
67
m_labDateShort = new QLabel(this, I18N_NOOP("Short date:"));
68
m_labDateShort->setPalette(pal);
69
m_dateShortSample = new QLabel(this);
70
m_dateShortSample->setPalette(pal);
72
m_labTime = new QLabel(this, I18N_NOOP("Time:"));
73
m_labTime->setPalette(pal);
74
m_timeSample = new QLabel(this);
75
m_timeSample->setPalette(pal);
77
lay->setColStretch(0, 1);
78
lay->setColStretch(1, 3);
80
QTimer *timer = new QTimer(this, "clock_timer");
81
connect(timer, SIGNAL(timeout()), this, SLOT(slotUpdateTime()));
85
KLocaleSample::~KLocaleSample()
89
void KLocaleSample::slotUpdateTime()
91
QDateTime dt = QDateTime::currentDateTime();
93
m_dateSample->setText(m_locale->formatDate(dt.date(), false));
94
m_dateShortSample->setText(m_locale->formatDate(dt.date(), true));
95
m_timeSample->setText(m_locale->formatTime(dt.time(), true));
98
void KLocaleSample::slotLocaleChanged()
100
m_numberSample->setText(m_locale->formatNumber(1234567.89) +
101
QString::fromLatin1(" / ") +
102
m_locale->formatNumber(-1234567.89));
104
m_moneySample->setText(m_locale->formatMoney(123456789.00) +
105
QString::fromLatin1(" / ") +
106
m_locale->formatMoney(-123456789.00));
112
str = m_locale->translate("This is how numbers will be displayed.");
113
QWhatsThis::add( m_labNumber, str );
114
QWhatsThis::add( m_numberSample, str );
116
str = m_locale->translate("This is how monetary values will be displayed.");
117
QWhatsThis::add( m_labMoney, str );
118
QWhatsThis::add( m_moneySample, str );
120
str = m_locale->translate("This is how date values will be displayed.");
121
QWhatsThis::add( m_labDate, str );
122
QWhatsThis::add( m_dateSample, str );
124
str = m_locale->translate("This is how date values will be displayed using "
125
"a short notation.");
126
QWhatsThis::add( m_labDateShort, str );
127
QWhatsThis::add( m_dateShortSample, str );
129
str = m_locale->translate("This is how the time will be displayed.");
130
QWhatsThis::add( m_labTime, str );
131
QWhatsThis::add( m_timeSample, str );