Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [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 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 11 | #include "setting-dialog.hpp" |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 12 | #include "ui_setting-dialog.h" |
| 13 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 14 | namespace chronos { |
| 15 | |
| 16 | SettingDialog::SettingDialog(QWidget* parent) |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 17 | : QDialog(parent) |
| 18 | , ui(new Ui::SettingDialog) |
| 19 | { |
| 20 | ui->setupUi(this); |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 21 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 22 | connect(ui->saveButton, SIGNAL(clicked()), |
| 23 | this, SLOT(onSaveClicked())); |
| 24 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 25 | this, SLOT(onCancelClicked())); |
| 26 | } |
| 27 | |
| 28 | SettingDialog::~SettingDialog() |
| 29 | { |
| 30 | delete ui; |
| 31 | } |
| 32 | |
| 33 | void |
| 34 | SettingDialog::setNick(const QString& nick) |
| 35 | { |
| 36 | m_nick = nick; |
| 37 | ui->nickLine->setText(m_nick); |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | SettingDialog::onIdentityUpdated(const QString& identity) |
| 42 | { |
| 43 | m_identity = identity; |
| 44 | ui->identityLine->setText(m_identity); |
| 45 | } |
| 46 | |
| 47 | void |
| 48 | SettingDialog::onSaveClicked() |
| 49 | { |
| 50 | QString identity = ui->identityLine->text(); |
| 51 | QString nick = ui->nickLine->text(); |
| 52 | |
| 53 | if(identity != m_identity) |
| 54 | { |
| 55 | m_identity = identity; |
| 56 | emit identityUpdated(identity); |
| 57 | } |
| 58 | if(nick != m_nick) |
| 59 | { |
| 60 | m_nick = nick; |
| 61 | emit nickUpdated(nick); |
| 62 | } |
| 63 | |
| 64 | this->close(); |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | SettingDialog::onCancelClicked() |
| 69 | { |
| 70 | this->close(); |
| 71 | } |
| 72 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 73 | } // namespace chronos |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 74 | |
| 75 | #if WAF |
| 76 | #include "setting-dialog.moc" |
Yingdi Yu | 4212586 | 2014-08-07 17:04:28 -0700 | [diff] [blame] | 77 | // #include "setting-dialog.cpp.moc" |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 78 | #endif |