2 * Copyright (c) 2010 Kaushal M <kshlmster@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "slideshareuploaddialog.h"
20 #include "ui_uploaddialog.h"
22 #include "slideshare.h"
24 #include <QFileDialog>
25 #include <QMessageBox>
27 slideshareUploadDialog::slideshareUploadDialog(SlideShare *service, QWidget *parent) :
29 ui(new Ui::uploadDialog)
31 this->service = service;
33 connect(service, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(uploadProgressSlot(qint64,qint64)));
34 connect(ui->fileSelectButton, SIGNAL(clicked()), this, SLOT(showFileDialog()));
35 connect(ui->uploadButton, SIGNAL(clicked()), this, SLOT(uploadButtonClickedSlot()));
36 connect(service, SIGNAL(uploadDone()), this, SLOT(uploadDoneSlot()));
39 slideshareUploadDialog::~slideshareUploadDialog()
44 void slideshareUploadDialog::changeEvent(QEvent *e)
46 QDialog::changeEvent(e);
48 case QEvent::LanguageChange:
49 ui->retranslateUi(this);
57 void slideshareUploadDialog::uploadProgressSlot(qint64 sent, qint64 total)
59 qint64 value = (sent * 100 / total) ;
60 ui->uploadProgress->setValue(value);
63 void slideshareUploadDialog::showFileDialog()
65 QString filter = "Supported Files (odt doc odp ppt ods xls)(*.odt *.doc *.odp *.ppt *.ods *.xls);; Documents (odt doc)(*.odt *.doc);; Presentations (odp ppt)(*.odp *.ppt) ;; Spreadsheets(ods xls)(*.ods *.xls)";
66 QString filename = QFileDialog::getOpenFileName(this,QString("Select File"),tr(""),filter);
67 ui->fileSelectEdit->setText(filename);
70 void slideshareUploadDialog::uploadButtonClickedSlot()
72 if(ui->fileSelectEdit->text() == "" || ui->titleEdit->text() == "")
74 QMessageBox::information(this,"Incomplete parameters","Please enter atleast filename and title");
79 ui->fileSelectButton->setEnabled(false);
80 ui->titleEdit->setEnabled(false);
81 ui->descriptionBox->setEnabled(false);
82 ui->tagsEdit->setEnabled(false);
83 ui->uploadButton->setEnabled(false);
84 ui->uploadLabel->setText(tr("Uploading file..."));
85 service->setSourceFile(&ui->fileSelectEdit->text());
86 service->setSlideTitle(&ui->titleEdit->text());
87 service->setDescription(&ui->descriptionBox->toPlainText());
88 service->setTags(&ui->tagsEdit->text());
89 service->setFormat(new QString(QFileInfo(ui->fileSelectEdit->text()).suffix()));
94 void slideshareUploadDialog::uploadDoneSlot()
96 ui->uploadLabel->setText(tr("Upload done"));
97 ui->doneButton->setEnabled(true);