maybe fixed utf8 upload and windows file upload
This commit is contained in:
parent
b5b54cefd8
commit
1924d00f88
@ -26,13 +26,17 @@ void clipboardcopy::copyClipboard() {
|
|||||||
if(mimeData->hasImage()) {
|
if(mimeData->hasImage()) {
|
||||||
QPixmap map = qvariant_cast<QPixmap>(mimeData->imageData());
|
QPixmap map = qvariant_cast<QPixmap>(mimeData->imageData());
|
||||||
} else if(mimeData->hasText()) {
|
} else if(mimeData->hasText()) {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QUrl fileUrl(mimeData->text());
|
||||||
|
QFileInfo fileInfo(fileUrl.toLocalFile());
|
||||||
|
#else
|
||||||
QFileInfo fileInfo(mimeData->text());
|
QFileInfo fileInfo(mimeData->text());
|
||||||
|
#endif
|
||||||
if(fileInfo.exists() && fileInfo.isReadable() && fileInfo.isFile()) {
|
if(fileInfo.exists() && fileInfo.isReadable() && fileInfo.isFile()) {
|
||||||
QMimeDatabase db;
|
QMimeDatabase db;
|
||||||
QMimeType mimeType = db.mimeTypeForFile(fileInfo);
|
QMimeType mimeType = db.mimeTypeForFile(fileInfo);
|
||||||
QString type = mimeType.name();
|
QString type = mimeType.name();
|
||||||
QFile file(fileInfo.absoluteFilePath());
|
QFile file(fileInfo.absoluteFilePath());
|
||||||
logger::info(type);
|
|
||||||
UploaderSingleton::inst().upload(file);
|
UploaderSingleton::inst().upload(file);
|
||||||
} else if (fileInfo.exists() && fileInfo.isReadable() && fileInfo.isDir()) {
|
} else if (fileInfo.exists() && fileInfo.isReadable() && fileInfo.isDir()) {
|
||||||
notifications::notify("KShare - Directory is not uploadable", fileInfo.absolutePath(), QSystemTrayIcon::Warning);
|
notifications::notify("KShare - Directory is not uploadable", fileInfo.absolutePath(), QSystemTrayIcon::Warning);
|
||||||
@ -42,6 +46,7 @@ void clipboardcopy::copyClipboard() {
|
|||||||
tmpFile.setAutoRemove(true);
|
tmpFile.setAutoRemove(true);
|
||||||
if(tmpFile.open()) {
|
if(tmpFile.open()) {
|
||||||
QTextStream stream(&tmpFile);
|
QTextStream stream(&tmpFile);
|
||||||
|
stream.setCodec("UTF-8");
|
||||||
stream << mimeData->text();
|
stream << mimeData->text();
|
||||||
stream.flush();
|
stream.flush();
|
||||||
tmpFile.seek(0);
|
tmpFile.seek(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user