4 * Copyright (c) 2001-2003 Hans Petter Bieker <bieker@kde.org>
6 * Requires the Qt widget libraries, available at no cost at
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 #include <KConfigGroup>
33 #include <KStandardDirs>
35 #include "localeother.h"
36 #include "localeother.moc"
39 KLocaleConfigOther::KLocaleConfigOther(KLocale
*locale
,
45 QGridLayout
*lay
= new QGridLayout(this );
46 lay
->setMargin( KDialog::marginHint() );
47 lay
->setSpacing( KDialog::spacingHint());
49 m_labPageSize
= new QLabel(this);
50 m_labPageSize
->setObjectName(I18N_NOOP("Paper format:") );
51 m_labPageSize
->setAlignment(Qt::AlignRight
| Qt::AlignVCenter
);
52 lay
->addWidget(m_labPageSize
, 0, 0);
53 m_combPageSize
= new QComboBox(this);
54 lay
->addWidget(m_combPageSize
, 0, 1);
55 connect( m_combPageSize
, SIGNAL( activated(int) ),
56 SLOT( slotPageSizeChanged(int) ) );
58 m_labMeasureSystem
= new QLabel(this);
59 m_labMeasureSystem
->setObjectName( I18N_NOOP("Measure system:") );
60 m_labMeasureSystem
->setAlignment(Qt::AlignRight
| Qt::AlignVCenter
);
61 lay
->addWidget(m_labMeasureSystem
, 1, 0);
62 m_combMeasureSystem
= new QComboBox(this);
63 lay
->addWidget(m_combMeasureSystem
, 1, 1);
64 connect( m_combMeasureSystem
, SIGNAL( activated(int) ),
65 SLOT( slotMeasureSystemChanged(int) ) );
67 m_combPageSize
->addItem(QString());
68 m_combPageSize
->addItem(QString());
69 m_combMeasureSystem
->addItem(QString());
70 m_combMeasureSystem
->addItem(QString());
72 lay
->setColumnStretch(1, 1);
73 lay
->setRowStretch(2, 1);
78 KLocaleConfigOther::~KLocaleConfigOther()
82 void KLocaleConfigOther::save()
84 KSharedConfig::Ptr config
= KGlobal::config();
85 KConfigGroup
group(config
, "Locale");
86 KConfig
ent(KStandardDirs::locate("locale",
87 QString::fromLatin1("l10n/%1/entry.desktop")
88 .arg(m_locale
->country())));
89 KConfigGroup entGrp
= ent
.group("KCM Locale");
91 // ### HPB: Add code here
93 i
= entGrp
.readEntry("PageSize", (int)QPrinter::A4
);
94 group
.deleteEntry("PageSize", KConfig::Persistent
| KConfig::Global
);
95 if (i
!= m_locale
->pageSize())
96 group
.writeEntry("PageSize",
97 m_locale
->pageSize(), KConfig::Persistent
|KConfig::Global
);
99 i
= entGrp
.readEntry("MeasureSystem", (int)KLocale::Metric
);
100 group
.deleteEntry("MeasureSystem", KConfig::Persistent
| KConfig::Global
);
101 if (i
!= m_locale
->measureSystem())
102 group
.writeEntry("MeasureSystem",
103 int(m_locale
->measureSystem()), KConfig::Persistent
|KConfig::Global
);
108 void KLocaleConfigOther::slotLocaleChanged()
110 m_combMeasureSystem
->setCurrentIndex(m_locale
->measureSystem());
112 int pageSize
= m_locale
->pageSize();
114 int i
= 0; // default to A4
115 if ( pageSize
== (int)QPrinter::Letter
)
117 m_combPageSize
->setCurrentIndex(i
);
120 void KLocaleConfigOther::slotTranslate()
122 m_combMeasureSystem
->setItemText( 0, ki18nc("The Metric System", "Metric").toString(m_locale
) );
123 m_combMeasureSystem
->setItemText( 1, ki18nc("The Imperial System", "Imperial").toString(m_locale
) );
125 m_combPageSize
->setItemText( 0, ki18n("A4").toString(m_locale
) );
126 m_combPageSize
->setItemText( 1, ki18n("US Letter").toString(m_locale
) );
129 void KLocaleConfigOther::slotPageSizeChanged(int i
)
131 QPrinter::PageSize pageSize
= QPrinter::A4
;
134 pageSize
= QPrinter::Letter
;
136 m_locale
->setPageSize((int)pageSize
);
137 emit
localeChanged();
140 void KLocaleConfigOther::slotMeasureSystemChanged(int i
)
142 m_locale
->setMeasureSystem((KLocale::MeasureSystem
)i
);
143 emit
localeChanged();