1 /* *************************************************************************
2 * copyright: (C) 2003 Richard Lärkäng <nouseforaname@home.se> *
3 * copyright: (C) 2003 Gav Wood <gav@kde.org> *
4 *************************************************************************
7 /* *************************************************************************
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 *************************************************************************
18 #include <qcombobox.h>
19 #include <qpushbutton.h>
20 #include <qlineedit.h>
21 #include <qcheckbox.h>
22 #include <qradiobutton.h>
24 #include <kconfigbase.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
);
47 middleFrameLayout
= 0L;
49 m_protocol
= protocol
;
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
);
80 setServicePreferences(preferencesDialog
->serviceName
->currentText());
83 SMSEditAccountWidget::~SMSEditAccountWidget()
88 bool SMSEditAccountWidget::validateData()
93 Kopete::Account
* SMSEditAccountWidget::apply()
96 setAccount( new SMSAccount( m_protocol
, preferencesDialog
->accountId
->text() ) );
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());
111 void SMSEditAccountWidget::setServicePreferences(const QString
& serviceName
)
116 service
= ServiceLoader::loadService(serviceName
, account());
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"
144 * c-indentation-style: k&r
146 * indent-tabs-mode: t
149 // vim: set noet ts=4 sts=4 sw=4: