~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/file/CFileSender.cpp

  • Committer: Nathan Osman
  • Date: 2012-06-28 04:02:39 UTC
  • Revision ID: admin@quickmediasolutions.com-20120628040239-t3u82j64vo2aym6c
Added warning for files over 30 MB in size when compression is enabled.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <QDebug>
18
18
#include <QFile>
19
19
#include <QFileInfo>
 
20
#include <QMessageBox>
20
21
#include <QVariantList>
21
22
#include <qjson/qobjecthelper.h>
22
23
 
137
138
    bool compress = Settings::Get("General/CompressFiles").toBool();
138
139
    bool checksum = Settings::Get("General/CalculateChecksum").toBool();
139
140
 
 
141
    /* If one of the files is larger than 30 MB and compression is turned on, ask
 
142
       the user if they want to disable compression for the current transfer. */
 
143
    bool displayed_prompt = false;
 
144
 
140
145
    foreach(QString filename, filenames)
141
146
    {
142
147
        QFileInfo info(filename);
143
148
 
 
149
        /* Check to see if we need to warn the user. */
 
150
        if(info.size() > 30000000 && compress && !displayed_prompt)
 
151
        {
 
152
            if(QMessageBox::warning(NULL, "Warning:", "Transferring files larger than 30 MB with compression enabled can significantly slow down your computer.\n\nWould you like to temporarily disable compression for these files?",
 
153
                                    QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
 
154
                compress = false;
 
155
 
 
156
            displayed_prompt = true;
 
157
        }
 
158
 
144
159
        CFileHeader * header = new CFileHeader(filename);
145
160
        header->SetFilename(info.fileName());
146
161
        header->SetUncompressedSize(info.size());