2
* This file is part of the KDE libraries
3
* Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License version 2 as published by the Free Software Foundation.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public License
15
* along with this library; see the file COPYING.LIB. If not, write to
16
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#include "timedate_config.h"
23
#include <QtGui/QLabel>
24
#include <QtGui/QBoxLayout>
27
#include <kpluginfactory.h>
28
#include <kpluginloader.h>
29
#include <klineedit.h>
30
#include <kconfiggroup.h>
32
TimeDateConfig::TimeDateConfig(QWidget *parent, const QVariantList &args)
33
: KCModule(TimeDatePluginFactory::componentData(), parent, args)
35
QVBoxLayout *layout = new QVBoxLayout(this);
37
QLabel *info = new QLabel(i18n(
38
"%y\t2-digit year excluding century (00 - 99)\n"
39
"%Y\tfull year number\n"
40
"%:m\tmonth number, without leading zero (1 - 12)\n"
41
"%m\tmonth number, 2 digits (01 - 12)\n"
42
"%b\tabbreviated month name\n"
43
"%B\tfull month name\n"
44
"%e\tday of the month (1 - 31)\n"
45
"%d\tday of the month, 2 digits (01 - 31)\n"
46
"%a\tabbreviated weekday name\n"
47
"%A\tfull weekday name\n"
49
"%H\thour in the 24 hour clock, 2 digits (00 - 23)\n"
50
"%k\thour in the 24 hour clock, without leading zero (0 - 23)\n"
51
"%I\thour in the 12 hour clock, 2 digits (01 - 12)\n"
52
"%l\thour in the 12 hour clock, without leading zero (1 - 12)\n"
53
"%M\tminute, 2 digits (00 - 59)\n"
54
"%S\tseconds (00 - 59)\n"
55
"%P\t\"am\" or \"pm\"\n"
56
"%p\t\"AM\" or \"PM\"\n"));
58
// It is possible that the plugin has not been loaded yet, and the
59
// configuration dialog has been asked to be shown. In that case, it is our
60
// turn to set the static string to the correct value.
61
if (localizedTimeDate.isNull())
63
localizedTimeDate = i18nc("This is a localized string for default time & date printing on kate document."
64
"%d means day in XX format."
65
"%m means month in XX format."
66
"%Y means year in XXXX format."
67
"%H means hours in XX format."
68
"%M means minutes in XX format."
69
"Please, if in your language time or date is written in a different order, change it here",
73
QHBoxLayout *hlayout = new QHBoxLayout(this);
74
QLabel *lformat = new QLabel(i18n("Format"));
75
format = new KLineEdit(this);
76
hlayout->addWidget(lformat);
77
hlayout->addWidget(format);
79
layout->addWidget(info);
80
layout->addLayout(hlayout);
86
QObject::connect(format, SIGNAL(textChanged(QString)), this, SLOT(slotChanged()));
89
TimeDateConfig::~TimeDateConfig()
93
void TimeDateConfig::save()
95
if (TimeDatePlugin::self())
97
TimeDatePlugin::self()->setFormat(format->text());
98
TimeDatePlugin::self()->writeConfig();
102
KConfigGroup cg(KGlobal::config(), "TimeDate Plugin");
103
cg.writeEntry("string", format->text());
109
void TimeDateConfig::load()
111
if (TimeDatePlugin::self())
113
TimeDatePlugin::self()->readConfig();
114
format->setText(TimeDatePlugin::self()->format());
118
KConfigGroup cg(KGlobal::config(), "TimeDate Plugin" );
119
format->setText(cg.readEntry("string", localizedTimeDate));
125
void TimeDateConfig::defaults()
127
format->setText(localizedTimeDate);
132
void TimeDateConfig::slotChanged()
137
#include "timedate_config.moc"