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