blob: 9f38cacbba75e6e930233a4966eae1fc3b4e459b [file] [log] [blame]
Yingdi Yu348f5ea2014-03-01 14:47:25 -08001/* -*- 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 Yu0b0a7362014-08-05 16:31:30 -070011#include "setting-dialog.hpp"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080012#include "ui_setting-dialog.h"
13
Yingdi Yueb692ac2015-02-10 18:46:18 -080014namespace chronochat {
Yingdi Yu0b0a7362014-08-05 16:31:30 -070015
16SettingDialog::SettingDialog(QWidget* parent)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080017 : QDialog(parent)
18 , ui(new Ui::SettingDialog)
19{
20 ui->setupUi(this);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070021
Yingdi Yu348f5ea2014-03-01 14:47:25 -080022 connect(ui->saveButton, SIGNAL(clicked()),
23 this, SLOT(onSaveClicked()));
24 connect(ui->cancelButton, SIGNAL(clicked()),
25 this, SLOT(onCancelClicked()));
26}
27
28SettingDialog::~SettingDialog()
29{
30 delete ui;
31}
32
33void
34SettingDialog::setNick(const QString& nick)
35{
36 m_nick = nick;
37 ui->nickLine->setText(m_nick);
38}
39
40void
41SettingDialog::onIdentityUpdated(const QString& identity)
42{
43 m_identity = identity;
44 ui->identityLine->setText(m_identity);
45}
46
47void
Yingdi Yubaaaec02014-09-02 22:05:32 -070048SettingDialog::onLocalPrefixUpdated(const QString& prefix)
49{
50 m_prefix = prefix;
51 ui->prefixLine->setText(m_prefix);
52}
53
54void
Yingdi Yu348f5ea2014-03-01 14:47:25 -080055SettingDialog::onSaveClicked()
56{
57 QString identity = ui->identityLine->text();
58 QString nick = ui->nickLine->text();
Yingdi Yubaaaec02014-09-02 22:05:32 -070059 QString prefix = ui->prefixLine->text();
Yingdi Yu348f5ea2014-03-01 14:47:25 -080060
Yingdi Yubaaaec02014-09-02 22:05:32 -070061 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 Yu348f5ea2014-03-01 14:47:25 -080074
75 this->close();
76}
77
78void
79SettingDialog::onCancelClicked()
80{
81 this->close();
82}
83
Yingdi Yueb692ac2015-02-10 18:46:18 -080084} // namespace chronochat
Yingdi Yu348f5ea2014-03-01 14:47:25 -080085
86#if WAF
87#include "setting-dialog.moc"
Yingdi Yu42125862014-08-07 17:04:28 -070088// #include "setting-dialog.cpp.moc"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080089#endif