mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
Fixed DragOverlayWindow file icon and name (#4428)
* Fixed DragOverlayWindow file icon and name * Fixed dragging for BitComet torrents
This commit is contained in:
parent
07a5e560b7
commit
8a5260f24c
6 changed files with 38 additions and 17 deletions
|
@ -399,6 +399,7 @@
|
|||
C3D9062A27B7EAC600EF2386 /* libpsl.h in Headers */ = {isa = PBXBuildFile; fileRef = C3D9061B27B7E31100EF2386 /* libpsl.h */; };
|
||||
C3D9062F27B7F7E200EF2386 /* libpsl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C3D9062127B7E3C900EF2386 /* libpsl.a */; };
|
||||
C809AEE7291ECFD000BFDBE1 /* NSDataAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = C809AEE6291ECFD000BFDBE1 /* NSDataAdditions.mm */; };
|
||||
C82B30312953337B0001BD6E /* NSDataAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = C809AEE6291ECFD000BFDBE1 /* NSDataAdditions.mm */; };
|
||||
C841A28129197724009F18E8 /* NSKeyedUnarchiverAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = C841A28029197724009F18E8 /* NSKeyedUnarchiverAdditions.mm */; };
|
||||
C86BCD9928228A9600F45599 /* SparkleProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = C86BCD9828228A9600F45599 /* SparkleProxy.mm */; };
|
||||
C87369652809984200573C90 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C87369642809984200573C90 /* UserNotifications.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||
|
@ -3201,6 +3202,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C82B30312953337B0001BD6E /* NSDataAdditions.mm in Sources */,
|
||||
A29304EE15D7497C00B1F726 /* main.cc in Sources */,
|
||||
A2D8CFBB15F82E030056E93D /* NSStringAdditions.mm in Sources */,
|
||||
A2F35BCA15C5A0A100EBF632 /* GenerateThumbnailForURL.mm in Sources */,
|
||||
|
|
|
@ -77,9 +77,17 @@
|
|||
|
||||
auto const n_files = metainfo.fileCount();
|
||||
fileCount += n_files;
|
||||
if (n_files == 1)
|
||||
// only useful when one torrent
|
||||
if (count == 1)
|
||||
{
|
||||
name = @(metainfo.name().c_str());
|
||||
if (n_files == 1)
|
||||
{
|
||||
name = [NSString convertedStringFromCString:metainfo.fileSubpath(0).c_str()];
|
||||
}
|
||||
else
|
||||
{
|
||||
name = @(metainfo.name().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +117,8 @@
|
|||
NSImage* icon;
|
||||
if (count == 1)
|
||||
{
|
||||
icon = [NSWorkspace.sharedWorkspace iconForFileType:name ? name.pathExtension : NSFileTypeForHFSTypeCode(kGenericFolderIcon)];
|
||||
icon = [NSWorkspace.sharedWorkspace
|
||||
iconForFileType:fileCount <= 1 ? name.pathExtension : NSFileTypeForHFSTypeCode(kGenericFolderIcon)];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
// like componentsSeparatedByCharactersInSet:, but excludes blank values
|
||||
- (NSArray<NSString*>*)nonEmptyComponentsSeparatedByCharactersInSet:(NSCharacterSet*)separators;
|
||||
|
||||
+ (NSString*)convertedStringFromCString:(char const*)bytes;
|
||||
|
||||
@end
|
||||
|
||||
__attribute__((annotate("returns_localized_nsstring"))) static inline NSString* LocalizationNotNeeded(NSString* s)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <libtransmission/utils.h>
|
||||
|
||||
#import "NSStringAdditions.h"
|
||||
#import "NSDataAdditions.h"
|
||||
|
||||
@interface NSString (Private)
|
||||
|
||||
|
@ -134,6 +135,25 @@
|
|||
return components;
|
||||
}
|
||||
|
||||
+ (NSString*)convertedStringFromCString:(nonnull char const*)bytes
|
||||
{
|
||||
// UTF-8 encoding
|
||||
NSString* fullPath = @(bytes);
|
||||
if (fullPath)
|
||||
{
|
||||
return fullPath;
|
||||
}
|
||||
// autodetection of the encoding (#3434)
|
||||
NSData* data = [NSData dataWithBytes:(void const*)bytes length:sizeof(unsigned char) * strlen(bytes)];
|
||||
[NSString stringEncodingForData:data encodingOptions:nil convertedString:&fullPath usedLossyConversion:nil];
|
||||
if (fullPath)
|
||||
{
|
||||
return fullPath;
|
||||
}
|
||||
// hexa encoding
|
||||
return data.hexString;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSString (Private)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
project(trmacql)
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
../NSDataAdditions.mm
|
||||
../NSStringAdditions.mm
|
||||
GeneratePreviewForURL.mm
|
||||
GenerateThumbnailForURL.mm
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#import "Torrent.h"
|
||||
#import "GroupsController.h"
|
||||
#import "FileListNode.h"
|
||||
#import "NSDataAdditions.h"
|
||||
#import "NSStringAdditions.h"
|
||||
#import "TrackerNode.h"
|
||||
|
||||
|
@ -1786,19 +1785,7 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
|
|||
{
|
||||
auto const file = tr_torrentFile(self.fHandle, i);
|
||||
|
||||
// UTF-8 encoding
|
||||
NSString* fullPath = @(file.name);
|
||||
if (!fullPath)
|
||||
{
|
||||
// autodetection of the encoding (#3434)
|
||||
NSData* data = [NSData dataWithBytes:(void const*)file.name length:sizeof(unsigned char) * strlen(file.name)];
|
||||
[NSString stringEncodingForData:data encodingOptions:nil convertedString:&fullPath usedLossyConversion:nil];
|
||||
if (!fullPath)
|
||||
{
|
||||
// hexa encoding
|
||||
fullPath = data.hexString;
|
||||
}
|
||||
}
|
||||
NSString* fullPath = [NSString convertedStringFromCString:file.name];
|
||||
NSArray* pathComponents = fullPath.pathComponents;
|
||||
while (pathComponents.count <= 1)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue