Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 1 | /* -*- 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 Zhu | 85845d2 | 2012-06-01 23:10:43 -0700 | [diff] [blame] | 11 | #include "settingdialog.h" |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 12 | #include "ui_settingdialog.h" |
Zhenkai Zhu | 85845d2 | 2012-06-01 23:10:43 -0700 | [diff] [blame] | 13 | |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 14 | using namespace std; |
| 15 | |
| 16 | SettingDialog::SettingDialog(QWidget *parent) : |
| 17 | QDialog(parent), |
| 18 | ui(new Ui::SettingDialog) |
Zhenkai Zhu | 85845d2 | 2012-06-01 23:10:43 -0700 | [diff] [blame] | 19 | { |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 20 | ui->setupUi(this); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 21 | |
| 22 | connect(ui->okButton, SIGNAL(clicked()), |
| 23 | this, SLOT(onOkClicked())); |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 24 | } |
Zhenkai Zhu | 716addc | 2012-06-05 20:57:41 -0700 | [diff] [blame] | 25 | |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 26 | SettingDialog::~SettingDialog() |
| 27 | { |
| 28 | delete ui; |
Zhenkai Zhu | 7e9b06d | 2012-06-02 00:44:42 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame^] | 32 | SettingDialog::setIdentity(const std::string& identity, |
| 33 | const std::string& nickName) |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 34 | { |
| 35 | m_identity = identity; |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame^] | 36 | ui->identityLine->setText(QString::fromStdString(m_identity)); |
| 37 | m_nickName = nickName; |
| 38 | ui->nickLine->setText(QString::fromStdString(m_nickName)); |
Zhenkai Zhu | 85845d2 | 2012-06-01 23:10:43 -0700 | [diff] [blame] | 39 | } |
Zhenkai Zhu | 56a60ce | 2012-06-02 12:55:07 -0700 | [diff] [blame] | 40 | |
| 41 | void |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 42 | SettingDialog::onOkClicked() |
Zhenkai Zhu | 56a60ce | 2012-06-02 12:55:07 -0700 | [diff] [blame] | 43 | { |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame^] | 44 | 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 Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 50 | { |
| 51 | m_identity = identity; |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame^] | 52 | m_nickName = nick; |
| 53 | emit identitySet(qIdentity, qNick); |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 54 | } |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 55 | this->close(); |
Zhenkai Zhu | 56a60ce | 2012-06-02 12:55:07 -0700 | [diff] [blame] | 56 | } |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 57 | |
Yingdi Yu | c2ab62c | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 58 | |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 59 | #if WAF |
| 60 | #include "settingdialog.moc" |
| 61 | #include "settingdialog.cpp.moc" |
| 62 | #endif |