make webinterface translatable. there are around 20 short strings, all with context...
[kdenetwork.git] / kopete / protocols / sms / smseditaccountwidget.cpp
blob14e666407bd298210d0615bcaa511699fcefccdc
1 /* *************************************************************************
2 * copyright: (C) 2003 Richard Lärkäng <nouseforaname@home.se> *
3 * copyright: (C) 2003 Gav Wood <gav@kde.org> *
4 *************************************************************************
5 */
7 /* *************************************************************************
8 * *
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. *
13 * *
14 *************************************************************************
17 #include <qlayout.h>
18 #include <qcombobox.h>
19 #include <qpushbutton.h>
20 #include <qlineedit.h>
21 #include <qcheckbox.h>
22 #include <qradiobutton.h>
24 #include <kconfigbase.h>
25 #include <klocale.h>
26 #include <kmessagebox.h>
27 #include <krestrictedline.h>
28 #include <kconfiggroup.h>
30 #include "kopeteuiglobal.h"
32 #include "smseditaccountwidget.h"
33 #include "smsactprefs.h"
34 #include "serviceloader.h"
35 #include "smsprotocol.h"
36 #include "smsaccount.h"
38 SMSEditAccountWidget::SMSEditAccountWidget(SMSProtocol *protocol, Kopete::Account *account, QWidget *parent)
39 : QWidget(parent), KopeteEditAccountWidget(account)
41 QVBoxLayout *l = new QVBoxLayout(this);
42 preferencesDialog = new smsActPrefsUI(this);
43 l->addWidget(preferencesDialog);
45 service = 0L;
46 configWidget = 0L;
47 middleFrameLayout = 0L;
49 m_protocol = protocol;
51 QString sName;
52 if (account)
54 preferencesDialog->accountId->setText(account->accountId());
55 //Disable changing the account ID for now
56 //FIXME: Remove this when we can safely change the account ID (Matt)
57 preferencesDialog->accountId->setReadOnly(true);
58 sName = account->configGroup()->readEntry("ServiceName", QString());
59 preferencesDialog->subEnable->setChecked(account->configGroup()->readEntry("SubEnable", false));
60 preferencesDialog->subCode->setText(account->configGroup()->readEntry("SubCode", QString()));
61 preferencesDialog->ifMessageTooLong->setCurrentIndex(SMSMsgAction(account->configGroup()->readEntry("MsgAction", 0)));
64 preferencesDialog->serviceName->addItems(ServiceLoader::services());
66 connect (preferencesDialog->serviceName, SIGNAL(activated(const QString &)),
67 this, SLOT(setServicePreferences(const QString &)));
68 connect (preferencesDialog->descButton, SIGNAL(clicked()),
69 this, SLOT(showDescription()));
72 for (int i=0; i < preferencesDialog->serviceName->count(); i++)
74 if (preferencesDialog->serviceName->itemText(i) == sName)
76 preferencesDialog->serviceName->setCurrentIndex(i);
77 break;
80 setServicePreferences(preferencesDialog->serviceName->currentText());
83 SMSEditAccountWidget::~SMSEditAccountWidget()
85 delete service;
88 bool SMSEditAccountWidget::validateData()
90 return true;
93 Kopete::Account* SMSEditAccountWidget::apply()
95 if (!account())
96 setAccount( new SMSAccount( m_protocol, preferencesDialog->accountId->text() ) );
98 if (service)
99 service->setAccount(account());
101 KConfigGroup *c = account()->configGroup();
102 c->writeEntry("ServiceName", preferencesDialog->serviceName->currentText());
103 c->writeEntry("SubEnable", preferencesDialog->subEnable->isChecked() ? "true" : "false");
104 c->writeEntry("SubCode", preferencesDialog->subCode->text());
105 c->writeEntry("MsgAction", preferencesDialog->ifMessageTooLong->currentIndex());
107 emit saved();
108 return account();
111 void SMSEditAccountWidget::setServicePreferences(const QString& serviceName)
113 delete service;
114 delete configWidget;
116 service = ServiceLoader::loadService(serviceName, account());
118 if (service == 0L)
119 return;
121 connect (this, SIGNAL(saved()), service, SLOT(savePreferences()));
123 delete middleFrameLayout;
124 middleFrameLayout = new QGridLayout(preferencesDialog->middleFrame);
125 middleFrameLayout->setObjectName("middleFrameLayout");
126 middleFrameLayout->setSpacing(6);
127 middleFrameLayout->setMargin(0);
128 service->setWidgetContainer(preferencesDialog->middleFrame, middleFrameLayout);
131 void SMSEditAccountWidget::showDescription()
133 SMSService* s = ServiceLoader::loadService(preferencesDialog->serviceName->currentText(), 0L);
135 QString d = s->description();
137 KMessageBox::information(Kopete::UI::Global::mainWidget(), d, i18n("Description"));
140 #include "smseditaccountwidget.moc"
143 * Local variables:
144 * c-indentation-style: k&r
145 * c-basic-offset: 8
146 * indent-tabs-mode: t
147 * End:
149 // vim: set noet ts=4 sts=4 sw=4: