Yingdi Yu | e50bcf9 | 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 | |
| 11 | #include "settingdialog.h" |
| 12 | #include "ui_settingdialog.h" |
| 13 | |
| 14 | using namespace std; |
| 15 | |
| 16 | SettingDialog::SettingDialog(QWidget *parent) : |
| 17 | QDialog(parent), |
| 18 | ui(new Ui::SettingDialog) |
| 19 | { |
| 20 | ui->setupUi(this); |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 21 | |
| 22 | connect(ui->okButton, SIGNAL(clicked()), |
| 23 | this, SLOT(onOkClicked())); |
Yingdi Yu | e50bcf9 | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | SettingDialog::~SettingDialog() |
| 27 | { |
| 28 | delete ui; |
| 29 | } |
| 30 | |
| 31 | void |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 32 | SettingDialog::setIdentity(const std::string& identity) |
Yingdi Yu | e50bcf9 | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 33 | { |
| 34 | m_identity = identity; |
| 35 | ui->identityLine->setText(QString::fromUtf8(m_identity.c_str())); |
| 36 | } |
| 37 | |
| 38 | void |
| 39 | SettingDialog::onOkClicked() |
| 40 | { |
| 41 | QString text = ui->identityLine->text(); |
| 42 | string identity = text.toUtf8().constData(); |
| 43 | if(identity != m_identity) |
| 44 | { |
| 45 | m_identity = identity; |
| 46 | emit identitySet(text); |
| 47 | } |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 48 | this->close(); |
Yingdi Yu | e50bcf9 | 2013-10-23 10:31:08 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | |
| 52 | #if WAF |
| 53 | #include "settingdialog.moc" |
| 54 | #include "settingdialog.cpp.moc" |
| 55 | #endif |