1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
/* This file is part of the KDE project
Copyright (C) 2005 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
(C) 2002-2004 Ariya Hidayat <ariya@kde.org>
(C) 2002-2003 Norbert Andres <nandres@web.de>
(C) 2000-2005 Laurent Montel <montel@kde.org>
(C) 2002 John Dailey <dailey@vt.edu>
(C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
(C) 2001-2002 David Faure <faure@kde.org>
(C) 2001 Werner Trobin <trobin@kde.org>
(C) 2000 Bernd Johannes Wuebben <wuebben@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// Local
#include "DocumentSettingsDialog.h"
#include <QCheckBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include <QScrollBar>
#include <kcombobox.h>
#include <kconfig.h>
#include <kicon.h>
#include <kstatusbar.h>
#include <knuminput.h>
#include <kmessagebox.h>
#include <ksharedconfig.h>
#include <KStandardDirs>
#include <sonnet/configwidget.h>
#include "CalculationSettings.h"
#include "Localization.h"
#include "Map.h"
#include "ui/Selection.h"
#include "Sheet.h"
using namespace Calligra::Sheets;
class DocumentSettingsDialog::Private
{
public:
KPageWidgetItem* page1;
// Locale Options
parameterLocale* localePage;
};
DocumentSettingsDialog::DocumentSettingsDialog(Selection* selection, QWidget* parent)
: KPageDialog(parent)
, d(new Private)
{
setObjectName(QLatin1String("DocumentSettingsDialog"));
setCaption(i18n("Document Settings"));
// setFaceType(List);
setButtons(Ok | Cancel/* | Default | Reset*/);
setDefaultButton(Ok);
connect(this, SIGNAL(okClicked()), this, SLOT(slotApply()));
// connect(this, SIGNAL(defaultClicked()), this,SLOT(slotDefault()));
// connect(this, SIGNAL(resetClicked()), this, SLOT(slotReset()));
KVBox *page2 = new KVBox();
d->page1 = addPage(page2, i18n("Locale Settings"));
d->page1->setHeader(i18n("Document's Locale Settings"));
d->page1->setIcon(KIcon("preferences-desktop-locale"));
d->localePage = new parameterLocale(selection, page2);
}
DocumentSettingsDialog::~DocumentSettingsDialog()
{
delete d;
}
void DocumentSettingsDialog::slotApply()
{
d->localePage->apply();
}
void DocumentSettingsDialog::slotDefault()
{
}
void DocumentSettingsDialog::slotReset()
{
}
parameterLocale::parameterLocale(Selection* selection, KVBox *box , char * /*name*/)
: QObject(box->parent())
{
m_selection = selection;
m_bUpdateLocale = false;
// QGroupBox* tmpQGroupBox = new QGroupBox( i18n("Settings"), box );
KVBox* tmpQGroupBox = box;
KLocale* locale = selection->activeSheet()->map()->calculationSettings()->locale();
m_language = new QLabel(tmpQGroupBox);
m_number = new QLabel(tmpQGroupBox);
m_date = new QLabel(tmpQGroupBox);
m_shortDate = new QLabel(tmpQGroupBox);
m_time = new QLabel(tmpQGroupBox);
m_money = new QLabel(tmpQGroupBox);
updateToMatchLocale(locale);
m_updateButton = new QPushButton(i18n("&Use System's Locale Settings"), tmpQGroupBox);
connect(m_updateButton, SIGNAL(clicked()), this, SLOT(updateDefaultSystemConfig()));
box->layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
void parameterLocale::apply()
{
if (m_bUpdateLocale) {
const QList<Sheet*> sheets = m_selection->activeSheet()->map()->sheetList();
foreach(Sheet* sheet, sheets) {
sheet->updateLocale();
}
}
}
void parameterLocale::updateDefaultSystemConfig()
{
m_bUpdateLocale = true;
KLocale* const locale = m_selection->activeSheet()->map()->calculationSettings()->locale();
static_cast<Localization*>(locale)->defaultSystemConfig();
updateToMatchLocale(locale);
}
void parameterLocale::updateToMatchLocale(KLocale* locale)
{
m_language->setText(i18n("Language: %1", locale->language()));
m_number->setText(i18n("Default number format: %1", locale->formatNumber(12.55))); // krazy:exclude=i18ncheckarg
m_date->setText(i18n("Long date format: %1", locale->formatDate(QDate::currentDate())));
m_shortDate->setText(i18n("Short date format: %1", locale->formatDate(QDate::currentDate() , KLocale::ShortDate)));
m_time->setText(i18n("Time format: %1", locale->formatTime(QTime::currentTime())));
m_money->setText(i18n("Currency format: %1", locale->formatMoney(12.55)));
}
#include "DocumentSettingsDialog.moc"
|