Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame] | 3 | * Copyright (c) 2020, Regents of the University of California |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 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 "invitation-dialog.hpp" |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 12 | #include "ui_invitation-dialog.h" |
| 13 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 14 | namespace chronochat { |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 15 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 16 | InvitationDialog::InvitationDialog(QWidget* parent) |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 17 | : QDialog(parent) |
| 18 | , ui(new Ui::InvitationDialog) |
| 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->okButton, SIGNAL(clicked()), |
| 23 | this, SLOT(onOkClicked())); |
| 24 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 25 | this, SLOT(onCancelClicked())); |
| 26 | } |
| 27 | |
| 28 | InvitationDialog::~InvitationDialog() |
| 29 | { |
| 30 | delete ui; |
| 31 | } |
| 32 | |
| 33 | void |
Yingdi Yu | 2c9e771 | 2014-10-20 11:55:05 -0700 | [diff] [blame] | 34 | InvitationDialog::onInvitationReceived(QString alias, QString chatroom, Name interestName) |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 35 | { |
Yingdi Yu | 233a972 | 2014-03-07 15:47:09 -0800 | [diff] [blame] | 36 | m_invitationInterest = interestName; |
Yingdi Yu | 2c9e771 | 2014-10-20 11:55:05 -0700 | [diff] [blame] | 37 | |
| 38 | QString msg = QString("%1 invites you to chatroom\n %2 ").arg(alias).arg(chatroom); |
| 39 | ui->msgLabel->setText(msg); |
| 40 | |
| 41 | show(); |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void |
| 45 | InvitationDialog::onOkClicked() |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 46 | { |
| 47 | emit invitationResponded(m_invitationInterest, true); |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 48 | this->close(); |
| 49 | |
| 50 | ui->msgLabel->clear(); |
| 51 | m_invitationInterest.clear(); |
| 52 | } |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 53 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 54 | void |
| 55 | InvitationDialog::onCancelClicked() |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 56 | { |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 57 | emit invitationResponded(m_invitationInterest, false); |
| 58 | this->close(); |
| 59 | |
| 60 | ui->msgLabel->clear(); |
| 61 | m_invitationInterest.clear(); |
| 62 | } |
| 63 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 64 | } // namespace chronochat |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 65 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 66 | #if WAF |
| 67 | #include "invitation-dialog.moc" |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 68 | #endif |