blob: ed9a1bd937dbc04e53f8a1432207f41b9afe1dc1 [file] [log] [blame]
Yingdi Yue50bcf92013-10-23 10:31:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Yingdi Yu
5 *
6 * BSD license, See the LICENSE file for more information
7 *
8 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
9 */
10
11#include "settingdialog.h"
12#include "ui_settingdialog.h"
13
14using namespace std;
15
16SettingDialog::SettingDialog(QWidget *parent) :
17 QDialog(parent),
18 ui(new Ui::SettingDialog)
19{
20 ui->setupUi(this);
Yingdi Yu53eb8a72013-10-23 11:50:51 -070021
22 connect(ui->okButton, SIGNAL(clicked()),
23 this, SLOT(onOkClicked()));
Yingdi Yue50bcf92013-10-23 10:31:08 -070024}
25
26SettingDialog::~SettingDialog()
27{
28 delete ui;
29}
30
31void
Yingdi Yu42372442013-11-06 18:43:31 -080032SettingDialog::setIdentity(const std::string& identity,
33 const std::string& nickName)
Yingdi Yue50bcf92013-10-23 10:31:08 -070034{
35 m_identity = identity;
Yingdi Yu42372442013-11-06 18:43:31 -080036 ui->identityLine->setText(QString::fromStdString(m_identity));
37 m_nickName = nickName;
38 ui->nickLine->setText(QString::fromStdString(m_nickName));
Yingdi Yue50bcf92013-10-23 10:31:08 -070039}
40
41void
42SettingDialog::onOkClicked()
43{
Yingdi Yu42372442013-11-06 18:43:31 -080044 QString qIdentity = ui->identityLine->text();
45 string identity = qIdentity.toStdString();
46 QString qNick = ui->nickLine->text();
47 string nick = qNick.toStdString();
48
49 if(identity != m_identity || nick != m_nickName)
Yingdi Yue50bcf92013-10-23 10:31:08 -070050 {
51 m_identity = identity;
Yingdi Yu42372442013-11-06 18:43:31 -080052 m_nickName = nick;
53 emit identitySet(qIdentity, qNick);
Yingdi Yue50bcf92013-10-23 10:31:08 -070054 }
Yingdi Yu53eb8a72013-10-23 11:50:51 -070055 this->close();
Yingdi Yue50bcf92013-10-23 10:31:08 -070056}
57
58
59#if WAF
60#include "settingdialog.moc"
61#include "settingdialog.cpp.moc"
62#endif