-
Notifications
You must be signed in to change notification settings - Fork 0
/
slideshareuploaddialog.cpp
102 lines (90 loc) · 3.56 KB
/
slideshareuploaddialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright (c) 2010 Kaushal M <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "slideshareuploaddialog.h"
#include "ui_uploaddialog.h"
#include "slideshare.h"
#include <QFileDialog>
#include <QDesktopServices>
#include <QMaemo5InformationBox>
slideshareUploadDialog::slideshareUploadDialog(SlideShare *service, QWidget *parent) :
QDialog(parent),
ui(new Ui::uploadDialog)
{
this->service = service;
ui->setupUi(this);
connect(service, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgressSlot(qint64, qint64)));
connect(ui->fileSelectButton, SIGNAL(clicked()), this, SLOT(showFileDialog()));
connect(ui->uploadButton, SIGNAL(clicked()), this, SLOT(uploadButtonClickedSlot()));
connect(service, SIGNAL(uploadDone()), this, SLOT(uploadDoneSlot()));
}
slideshareUploadDialog::~slideshareUploadDialog()
{
delete ui;
}
void slideshareUploadDialog::setOpenDoc(const QString & openDocPath)
{
ui->fileSelectEdit->setText(openDocPath);
}
void slideshareUploadDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch(e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void slideshareUploadDialog::uploadProgressSlot(qint64 sent, qint64 total)
{
qint64 value = (sent * 100 / total) ;
ui->uploadProgress->setValue(value);
}
void slideshareUploadDialog::showFileDialog()
{
QString currentFile = ("" == ui->fileSelectEdit->text()) ? QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) : ui->fileSelectEdit->text();
QString filter = "Supported Files (*.odt *.doc *.odp *.ppt *.ods *.xls)";
QString filename = QFileDialog::getOpenFileName(this, QString("Select File"), currentFile, filter, &filter);
if("" != filename)
ui->fileSelectEdit->setText(filename);
}
void slideshareUploadDialog::uploadButtonClickedSlot()
{
if(ui->fileSelectEdit->text() == "" || ui->titleEdit->text() == "") {
QMaemo5InformationBox::information(this, "Please enter atleast filename and title");
return;
} else {
ui->fileSelectButton->setEnabled(false);
ui->titleEdit->setEnabled(false);
ui->descriptionBox->setEnabled(false);
ui->tagsEdit->setEnabled(false);
ui->uploadButton->setEnabled(false);
service->setSourceFile(&ui->fileSelectEdit->text());
service->setSlideTitle(&ui->titleEdit->text());
service->setDescription(&ui->descriptionBox->text());
service->setTags(&ui->tagsEdit->text());
service->setFormat(new QString(QFileInfo(ui->fileSelectEdit->text()).suffix()));
service->upload();
}
}
void slideshareUploadDialog::uploadDoneSlot()
{
QMaemo5InformationBox::information(this, "<p><b>Upload done</b></p> It'll take some time for the file to appear in the list. Please be patient.");
ui->doneButton->setEnabled(true);
}