blob: ed9a1bd937dbc04e53f8a1432207f41b9afe1dc1 [file] [log] [blame]
Yingdi Yuc2ab62c2013-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
Zhenkai Zhu85845d22012-06-01 23:10:43 -070011#include "settingdialog.h"
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070012#include "ui_settingdialog.h"
Zhenkai Zhu85845d22012-06-01 23:10:43 -070013
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070014using namespace std;
15
16SettingDialog::SettingDialog(QWidget *parent) :
17 QDialog(parent),
18 ui(new Ui::SettingDialog)
Zhenkai Zhu85845d22012-06-01 23:10:43 -070019{
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070020 ui->setupUi(this);
Yingdi Yu978b3ae2013-10-23 11:50:51 -070021
22 connect(ui->okButton, SIGNAL(clicked()),
23 this, SLOT(onOkClicked()));
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070024}
Zhenkai Zhu716addc2012-06-05 20:57:41 -070025
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070026SettingDialog::~SettingDialog()
27{
28 delete ui;
Zhenkai Zhu7e9b06d2012-06-02 00:44:42 -070029}
30
31void
Yingdi Yu46948282013-11-06 18:43:31 -080032SettingDialog::setIdentity(const std::string& identity,
33 const std::string& nickName)
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070034{
35 m_identity = identity;
Yingdi Yu46948282013-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));
Zhenkai Zhu85845d22012-06-01 23:10:43 -070039}
Zhenkai Zhu56a60ce2012-06-02 12:55:07 -070040
41void
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070042SettingDialog::onOkClicked()
Zhenkai Zhu56a60ce2012-06-02 12:55:07 -070043{
Yingdi Yu46948282013-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 Yuc2ab62c2013-10-23 10:31:08 -070050 {
51 m_identity = identity;
Yingdi Yu46948282013-11-06 18:43:31 -080052 m_nickName = nick;
53 emit identitySet(qIdentity, qNick);
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070054 }
Yingdi Yu978b3ae2013-10-23 11:50:51 -070055 this->close();
Zhenkai Zhu56a60ce2012-06-02 12:55:07 -070056}
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070057
Yingdi Yuc2ab62c2013-10-23 10:31:08 -070058
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070059#if WAF
60#include "settingdialog.moc"
61#include "settingdialog.cpp.moc"
62#endif