Add a very rudimentary UI for accepting a transfer
[quassel.git] / src / qtui / receivefiledlg.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2013 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #include <QDir>
22 #include <QFileDialog>
23
24 #include "receivefiledlg.h"
25
26 #include "transfer.h"
27
28 ReceiveFileDlg::ReceiveFileDlg(const Transfer *transfer, QWidget *parent)
29     : QDialog(parent),
30     _transfer(transfer)
31 {
32     setAttribute(Qt::WA_DeleteOnClose);
33     ui.setupUi(this);
34
35     QString label = tr("<b>%1</b> wants to send you a file:<br>%2 (%3 bytes)").arg(transfer->nick(), transfer->fileName()).arg(transfer->fileSize());
36     ui.infoText->setText(label);
37 }
38
39
40 void ReceiveFileDlg::on_buttonBox_clicked(QAbstractButton *button)
41 {
42     if (ui.buttonBox->standardButton(button) == QDialogButtonBox::Save) {
43         QString name = QFileDialog::getSaveFileName(this, QString(), QDir::currentPath() + "/" + _transfer->fileName());
44         _transfer->accept(name);
45     }
46
47 }