folders not allowed to be dropped / pasted

This commit is contained in:
John Preston 2015-11-02 17:36:26 -05:00
parent 83a542713a
commit 3f8d7944c1
3 changed files with 17 additions and 5 deletions

View File

@ -351,7 +351,7 @@ enum {
};
inline const QRegularExpression &cWordSplit() {
static QRegularExpression regexp(qsl("[\\@\\s\\-\\+\\)\\(\\,\\.\\:\\!\\_\\;\\\"\\'\\x0]"));
static QRegularExpression regexp(qsl("[\\@\\s\\-\\+\\(\\)\\[\\]\\{\\}\\<\\>\\,\\.\\:\\!\\_\\;\\\"\\'\\x0]"));
return regexp;
}

View File

@ -4378,7 +4378,10 @@ DragState HistoryWidget::getDragState(const QMimeData *d) {
QString file(i->toLocalFile());
if (file.startsWith(qsl("/.file/id="))) file = psConvertFileUrl(file);
quint64 s = QFileInfo(file).size();
QFileInfo info(file);
if (info.isDir()) return DragStateNone;
quint64 s = info.size();
if (s >= MaxUploadDocumentSize) {
return DragStateNone;
}
@ -4527,10 +4530,10 @@ void HistoryWidget::onFilesDrop(const QMimeData *data) {
return;
}
if (files.size() == 1) {
if (files.size() == 1 && !QFileInfo(files.at(0)).isDir()) {
uploadFile(files.at(0), PrepareAuto);
}
// uploadFiles(files, PrepareAuto); // multiple confirm with "compressed" checkbox
// uploadFiles(files, PrepareAuto); // multiple confirm with "compressed" checkbox
}
void HistoryWidget::onKbToggle(bool manual) {
@ -4816,7 +4819,7 @@ void HistoryWidget::uploadFile(const QString &file, PrepareMediaType type, FileL
void HistoryWidget::uploadFiles(const QStringList &files, PrepareMediaType type) {
if (!_history || files.isEmpty()) return;
if (files.size() == 1) return uploadFile(files.at(0), type);
if (files.size() == 1 && !QFileInfo(files.at(0)).isDir()) return uploadFile(files.at(0), type);
App::wnd()->activateWindow();

View File

@ -216,6 +216,10 @@ void FileLoadTask::process() {
if (!_filepath.isEmpty()) {
QFileInfo info(_filepath);
if (info.isDir()) {
_result->filesize = -1;
return;
}
filesize = info.size();
filemime = mimeTypeForFile(info).name();
filename = info.fileName();
@ -399,6 +403,11 @@ void FileLoadTask::finish() {
App::wnd()->replaceLayer(new InformBox(lang(lng_send_image_empty)));
return;
}
if (_result->filesize == -1) { // dir
App::main()->onSendFileCancel(_result);
App::wnd()->replaceLayer(new InformBox(lng_send_folder(lt_name, QFileInfo(_filepath).fileName())));
return;
}
if (_result->filesize > MaxUploadDocumentSize) {
App::main()->onSendFileCancel(_result);
App::wnd()->replaceLayer(new InformBox(lang(lng_send_image_too_large)));