~ubuntu-branches/ubuntu/oneiric/kde4libs/oneiric-proposed

« back to all changes in this revision

Viewing changes to kate/plugins/timedate/timedate_config.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-07-08 00:08:34 UTC
  • mto: This revision was merged to the branch mainline in revision 247.
  • Revision ID: package-import@ubuntu.com-20110708000834-dr9a8my4iml90qe5
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
  * This file is part of the KDE libraries
3
 
  * Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org>
4
 
  *
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.
8
 
  *
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.
13
 
  *
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.
18
 
  */
19
 
 
20
 
#include "timedate_config.h"
21
 
#include "timedate.h"
22
 
 
23
 
#include <QtGui/QLabel>
24
 
#include <QtGui/QBoxLayout>
25
 
 
26
 
#include <klocale.h>
27
 
#include <kpluginfactory.h>
28
 
#include <kpluginloader.h>
29
 
#include <klineedit.h>
30
 
#include <kconfiggroup.h>
31
 
 
32
 
TimeDateConfig::TimeDateConfig(QWidget *parent, const QVariantList &args)
33
 
    : KCModule(TimeDatePluginFactory::componentData(), parent, args)
34
 
{
35
 
    QVBoxLayout *layout = new QVBoxLayout(this);
36
 
 
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"
48
 
     "\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"));
57
 
 
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())
62
 
    {
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",
70
 
                                  "%d-%m-%Y %H:%M");
71
 
    }
72
 
 
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);
78
 
 
79
 
    layout->addWidget(info);
80
 
    layout->addLayout(hlayout);
81
 
 
82
 
    setLayout(layout);
83
 
 
84
 
    load();
85
 
 
86
 
    QObject::connect(format, SIGNAL(textChanged(QString)), this, SLOT(slotChanged()));
87
 
}
88
 
 
89
 
TimeDateConfig::~TimeDateConfig()
90
 
{
91
 
}
92
 
 
93
 
void TimeDateConfig::save()
94
 
{
95
 
    if (TimeDatePlugin::self())
96
 
    {
97
 
        TimeDatePlugin::self()->setFormat(format->text());
98
 
        TimeDatePlugin::self()->writeConfig();
99
 
    }
100
 
    else
101
 
    {
102
 
        KConfigGroup cg(KGlobal::config(), "TimeDate Plugin");
103
 
        cg.writeEntry("string", format->text());
104
 
    }
105
 
 
106
 
    emit changed(false);
107
 
}
108
 
 
109
 
void TimeDateConfig::load()
110
 
{
111
 
    if (TimeDatePlugin::self())
112
 
    {
113
 
        TimeDatePlugin::self()->readConfig();
114
 
        format->setText(TimeDatePlugin::self()->format());
115
 
    }
116
 
    else
117
 
    {
118
 
        KConfigGroup cg(KGlobal::config(), "TimeDate Plugin" );
119
 
        format->setText(cg.readEntry("string", localizedTimeDate));
120
 
    }
121
 
 
122
 
    emit changed(false);
123
 
}
124
 
 
125
 
void TimeDateConfig::defaults()
126
 
{
127
 
    format->setText(localizedTimeDate);
128
 
 
129
 
    emit changed(true);
130
 
}
131
 
 
132
 
void TimeDateConfig::slotChanged()
133
 
{
134
 
    emit changed(true);
135
 
}
136
 
 
137
 
#include "timedate_config.moc"