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 | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 14 | namespace chronochat { |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 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 |
Yingdi Yu | baaaec0 | 2014-09-02 22:05:32 -0700 | [diff] [blame] | 48 | SettingDialog::onLocalPrefixUpdated(const QString& prefix) |
| 49 | { |
| 50 | m_prefix = prefix; |
| 51 | ui->prefixLine->setText(m_prefix); |
| 52 | } |
| 53 | |
| 54 | void |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 55 | SettingDialog::onSaveClicked() |
| 56 | { |
| 57 | QString identity = ui->identityLine->text(); |
| 58 | QString nick = ui->nickLine->text(); |
Yingdi Yu | baaaec0 | 2014-09-02 22:05:32 -0700 | [diff] [blame] | 59 | QString prefix = ui->prefixLine->text(); |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 60 | |
Yingdi Yu | baaaec0 | 2014-09-02 22:05:32 -0700 | [diff] [blame] | 61 | if(identity != m_identity) { |
| 62 | m_identity = identity; |
| 63 | emit identityUpdated(identity); |
| 64 | } |
| 65 | if(nick != m_nick) { |
| 66 | m_nick = nick; |
| 67 | emit nickUpdated(nick); |
| 68 | } |
| 69 | if (prefix != m_prefix) { |
| 70 | m_prefix = prefix; |
| 71 | emit prefixUpdated(prefix); |
| 72 | } |
| 73 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 74 | |
| 75 | this->close(); |
| 76 | } |
| 77 | |
| 78 | void |
| 79 | SettingDialog::onCancelClicked() |
| 80 | { |
| 81 | this->close(); |
| 82 | } |
| 83 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 84 | } // namespace chronochat |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 85 | |
| 86 | #if WAF |
| 87 | #include "setting-dialog.moc" |
Yingdi Yu | 4212586 | 2014-08-07 17:04:28 -0700 | [diff] [blame] | 88 | // #include "setting-dialog.cpp.moc" |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 89 | #endif |