~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to kcontrol/locale/klocalesample.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ana Beatriz Guerrero Lopez
  • Date: 2009-04-05 05:22:13 UTC
  • mfrom: (0.4.2 experimental) (0.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 235.
  • Revision ID: james.westby@ubuntu.com-20090405052213-39thr4l6p2ss07uj
Tags: 4:4.2.2-1
* New upstream release:
  - khtml fixes. (Closes: #290285, #359680)
  - Default konsole sessions can be deleted. (Closes: #286342)
  - Tag widget uses standard application palette. (Closes: #444800)
  - ... and surely many more but we have lost track...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * klocalesample.cpp
3
 
 *
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>
7
 
 *
8
 
 * Requires the Qt widget libraries, available at no cost at
9
 
 * http://www.troll.no/
10
 
 *
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.
15
 
 *
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.
20
 
 *
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.
24
 
 */
25
 
 
26
 
#include <qdatetime.h>
27
 
#include <qlabel.h>
28
 
#include <qwhatsthis.h>
29
 
#include <qlayout.h>
30
 
#include <qtimer.h>
31
 
 
32
 
#include <stdio.h>
33
 
 
34
 
#include <klocale.h>
35
 
 
36
 
#include "klocalesample.h"
37
 
#include "klocalesample.moc"
38
 
 
39
 
KLocaleSample::KLocaleSample(KLocale *locale,
40
 
                             QWidget *parent, const char*name)
41
 
  : QWidget(parent, name),
42
 
    m_locale(locale)
43
 
{
44
 
  QGridLayout *lay = new QGridLayout(this, 5, 2);
45
 
  lay->setAutoAdd(TRUE);
46
 
 
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);
51
 
 
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);
56
 
 
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);
61
 
 
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);
66
 
 
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);
71
 
 
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);
76
 
 
77
 
  lay->setColStretch(0, 1);
78
 
  lay->setColStretch(1, 3);
79
 
 
80
 
  QTimer *timer = new QTimer(this, "clock_timer");
81
 
  connect(timer, SIGNAL(timeout()), this, SLOT(slotUpdateTime()));
82
 
  timer->start(1000);
83
 
}
84
 
 
85
 
KLocaleSample::~KLocaleSample()
86
 
{
87
 
}
88
 
 
89
 
void KLocaleSample::slotUpdateTime()
90
 
{
91
 
  QDateTime dt = QDateTime::currentDateTime();
92
 
 
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));
96
 
}
97
 
 
98
 
void KLocaleSample::slotLocaleChanged()
99
 
{
100
 
  m_numberSample->setText(m_locale->formatNumber(1234567.89) +
101
 
                          QString::fromLatin1(" / ") +
102
 
                          m_locale->formatNumber(-1234567.89));
103
 
 
104
 
  m_moneySample->setText(m_locale->formatMoney(123456789.00) +
105
 
                         QString::fromLatin1(" / ") +
106
 
                         m_locale->formatMoney(-123456789.00));
107
 
 
108
 
  slotUpdateTime();
109
 
 
110
 
  QString str;
111
 
 
112
 
  str = m_locale->translate("This is how numbers will be displayed.");
113
 
  QWhatsThis::add( m_labNumber,  str );
114
 
  QWhatsThis::add( m_numberSample, str );
115
 
 
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 );
119
 
 
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 );
123
 
 
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 );
128
 
 
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 );
132
 
}