blob: 38665a8dddb6c7584fadc9e824334309e9402152 [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 "invitation-dialog.hpp"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080012#include "ui_invitation-dialog.h"
13
Yingdi Yu0b0a7362014-08-05 16:31:30 -070014namespace chronos {
Yingdi Yu348f5ea2014-03-01 14:47:25 -080015
Yingdi Yu0b0a7362014-08-05 16:31:30 -070016InvitationDialog::InvitationDialog(QWidget* parent)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080017 : QDialog(parent)
18 , ui(new Ui::InvitationDialog)
19{
20 ui->setupUi(this);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070021
Yingdi Yu348f5ea2014-03-01 14:47:25 -080022 connect(ui->okButton, SIGNAL(clicked()),
23 this, SLOT(onOkClicked()));
24 connect(ui->cancelButton, SIGNAL(clicked()),
25 this, SLOT(onCancelClicked()));
26}
27
28InvitationDialog::~InvitationDialog()
29{
30 delete ui;
31}
32
33void
Yingdi Yu17032f82014-03-25 15:48:23 -070034InvitationDialog::setInvitation(const std::string& alias,
35 const std::string& chatroom,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080036 const Name& interestName)
37{
Yingdi Yu17032f82014-03-25 15:48:23 -070038 std::string msg = alias;
Yingdi Yu233a9722014-03-07 15:47:09 -080039 m_invitationInterest = interestName;
Yingdi Yu348f5ea2014-03-01 14:47:25 -080040 msg.append(" invites you to: ").append(chatroom);
41 ui->msgLabel->setText(QString::fromStdString(msg));
42}
43
44void
45InvitationDialog::onOkClicked()
Yingdi Yufa0b6a02014-04-30 14:26:42 -070046{
47 emit invitationResponded(m_invitationInterest, true);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080048 this->close();
49
50 ui->msgLabel->clear();
51 m_invitationInterest.clear();
52}
Yingdi Yufa0b6a02014-04-30 14:26:42 -070053
Yingdi Yu348f5ea2014-03-01 14:47:25 -080054void
55InvitationDialog::onCancelClicked()
Yingdi Yufa0b6a02014-04-30 14:26:42 -070056{
Yingdi Yu348f5ea2014-03-01 14:47:25 -080057 emit invitationResponded(m_invitationInterest, false);
58 this->close();
59
60 ui->msgLabel->clear();
61 m_invitationInterest.clear();
62}
63
Yingdi Yu0b0a7362014-08-05 16:31:30 -070064} // namespace chronos
65
Yingdi Yu348f5ea2014-03-01 14:47:25 -080066#if WAF
67#include "invitation-dialog.moc"
Yingdi Yu42125862014-08-07 17:04:28 -070068// #include "invitation-dialog.cpp.moc"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080069#endif