1 /*
2 * This file is part of telepathy-accounts-kcm
3 *
4 * Copyright (C) 2011 Lasse Liehu <lliehu@kolumbus.fi>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "main-options-widget.h"
22
MainOptionsWidget(ParameterEditModel * model,QWidget * parent)23 MainOptionsWidget::MainOptionsWidget(
24 ParameterEditModel *model,
25 QWidget *parent)
26 : AbstractAccountParametersWidget(model, parent)
27 {
28 // Set up the UI.
29 m_ui = new Ui::MainOptionsWidget;
30 m_ui->setupUi(this);
31
32 handleParameter(QLatin1String("account"), QVariant::String, m_ui->accountLineEdit, m_ui->accountLabel);
33 handleParameter(QLatin1String("server"), QVariant::String, m_ui->serverLineEdit, m_ui->serverLabel);
34 handleParameter(QLatin1String("fullname"), QVariant::String, m_ui->fullnameLineEdit, m_ui->fullnameLabel);
35 QTimer::singleShot(0, m_ui->accountLineEdit, SLOT(setFocus()));
36 }
37
~MainOptionsWidget()38 MainOptionsWidget::~MainOptionsWidget()
39 {
40 delete m_ui;
41 }
42
defaultDisplayName() const43 QString MainOptionsWidget::defaultDisplayName() const
44 {
45 const QString &account = m_ui->accountLineEdit->text();
46 const QString &server = m_ui->serverLineEdit->text();
47 QString displayName;
48
49 if (!account.isEmpty()) {
50 displayName = account;
51 if (!server.isEmpty()) {
52 displayName.append(QString::fromLatin1(" on %1").arg(server));
53 }
54 }
55 return displayName;
56 }
57
58 #include "main-options-widget.moc"
59