mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-23 12:55:44 +03:00
Overlay Icons: Improve OS X version, improve general feedback
Now the update phase of the syncing algorithm pushes stuff the notification socket too.
This commit is contained in:
parent
a73316306d
commit
2f34b046d0
8 changed files with 56 additions and 14 deletions
|
@ -18,6 +18,7 @@
|
||||||
{
|
{
|
||||||
NSMutableDictionary* _fileNamesCache;
|
NSMutableDictionary* _fileNamesCache;
|
||||||
BOOL _fileIconsEnabled;
|
BOOL _fileIconsEnabled;
|
||||||
|
BOOL _hasChangedContent;
|
||||||
|
|
||||||
NSNumber *_icnOk;
|
NSNumber *_icnOk;
|
||||||
NSNumber *_icnSync;
|
NSNumber *_icnSync;
|
||||||
|
|
|
@ -31,6 +31,7 @@ static ContentManager* sharedInstance = nil;
|
||||||
{
|
{
|
||||||
_fileNamesCache = [[NSMutableDictionary alloc] init];
|
_fileNamesCache = [[NSMutableDictionary alloc] init];
|
||||||
_fileIconsEnabled = TRUE;
|
_fileIconsEnabled = TRUE;
|
||||||
|
_hasChangedContent = TRUE;
|
||||||
|
|
||||||
NSString *base = @"/Applications/owncloud.app/Contents/Resources/icons/";
|
NSString *base = @"/Applications/owncloud.app/Contents/Resources/icons/";
|
||||||
|
|
||||||
|
@ -107,14 +108,18 @@ static ContentManager* sharedInstance = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
|
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
|
||||||
[_fileNamesCache setObject:res forKey:normalizedPath];
|
|
||||||
// NSLog(@"SET value %d", [res intValue]);
|
if (![_fileNamesCache objectForKey:normalizedPath] || ![[_fileNamesCache objectForKey:normalizedPath] isEqualToString:res]) {
|
||||||
|
[_fileNamesCache setObject:res forKey:normalizedPath];
|
||||||
[self repaintAllWindows];
|
// NSLog(@"SET value %d", [res intValue]);
|
||||||
|
_hasChangedContent = YES;
|
||||||
|
[self performSelector:@selector(repaintAllWindowsIfNeeded) withObject:0 afterDelay:1.0]; // 1 sec
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSNumber*)iconByPath:(NSString*)path isDirectory:(BOOL)isDir
|
- (NSNumber*)iconByPath:(NSString*)path isDirectory:(BOOL)isDir
|
||||||
{
|
{
|
||||||
|
//NSLog(@"%@ %@", NSStringFromSelector(_cmd), path);
|
||||||
if (!_fileIconsEnabled)
|
if (!_fileIconsEnabled)
|
||||||
{
|
{
|
||||||
NSLog(@"Icons are NOT ENABLED!");
|
NSLog(@"Icons are NOT ENABLED!");
|
||||||
|
@ -151,6 +156,7 @@ static ContentManager* sharedInstance = nil;
|
||||||
// it clears the entries from the hash to make it call again home to mirall.
|
// it clears the entries from the hash to make it call again home to mirall.
|
||||||
- (void)clearFileNameCacheForPath:(NSString*)path
|
- (void)clearFileNameCacheForPath:(NSString*)path
|
||||||
{
|
{
|
||||||
|
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||||
NSMutableArray *keysToDelete = [NSMutableArray array];
|
NSMutableArray *keysToDelete = [NSMutableArray array];
|
||||||
|
|
||||||
if( path != nil ) {
|
if( path != nil ) {
|
||||||
|
@ -170,9 +176,6 @@ static ContentManager* sharedInstance = nil;
|
||||||
if( [keysToDelete count] > 0 ) {
|
if( [keysToDelete count] > 0 ) {
|
||||||
NSLog( @"Entries to delete: %d", [keysToDelete count]);
|
NSLog( @"Entries to delete: %d", [keysToDelete count]);
|
||||||
[_fileNamesCache removeObjectsForKeys:keysToDelete];
|
[_fileNamesCache removeObjectsForKeys:keysToDelete];
|
||||||
|
|
||||||
[self repaintAllWindows];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,8 +198,20 @@ static ContentManager* sharedInstance = nil;
|
||||||
[self repaintAllWindows];
|
[self repaintAllWindows];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)repaintAllWindowsIfNeeded
|
||||||
|
{
|
||||||
|
if (!_hasChangedContent) {
|
||||||
|
NSLog(@"%@ Repaint scheduled but not needed", NSStringFromSelector(_cmd));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hasChangedContent = NO;
|
||||||
|
[self repaintAllWindows];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)repaintAllWindows
|
- (void)repaintAllWindows
|
||||||
{
|
{
|
||||||
|
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||||
NSArray* windows = [[NSApplication sharedApplication] windows];
|
NSArray* windows = [[NSApplication sharedApplication] windows];
|
||||||
|
|
||||||
for (int i = 0; i < [windows count]; i++)
|
for (int i = 0; i < [windows count]; i++)
|
||||||
|
@ -286,7 +301,7 @@ static ContentManager* sharedInstance = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"LiferayNativityFinder: refreshing icon badges failed");
|
NSLog(@"OwnCloudFinder: refreshing icon badges failed");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -297,6 +312,7 @@ static ContentManager* sharedInstance = nil;
|
||||||
|
|
||||||
- (void)setIcons:(NSDictionary*)iconDictionary filterByFolder:(NSString*)filterFolder
|
- (void)setIcons:(NSDictionary*)iconDictionary filterByFolder:(NSString*)filterFolder
|
||||||
{
|
{
|
||||||
|
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||||
for (NSString* path in iconDictionary)
|
for (NSString* path in iconDictionary)
|
||||||
{
|
{
|
||||||
if (filterFolder && ![path hasPrefix:filterFolder])
|
if (filterFolder && ![path hasPrefix:filterFolder])
|
||||||
|
|
|
@ -136,9 +136,6 @@ static RequestManager* sharedInstance = nil;
|
||||||
[contentman setResultForPath:[chunks objectAtIndex:2] result:[chunks objectAtIndex:1]];
|
[contentman setResultForPath:[chunks objectAtIndex:2] result:[chunks objectAtIndex:1]];
|
||||||
} else if( [[chunks objectAtIndex:0] isEqualToString:@"UPDATE_VIEW"] ) {
|
} else if( [[chunks objectAtIndex:0] isEqualToString:@"UPDATE_VIEW"] ) {
|
||||||
NSString *path = [chunks objectAtIndex:1];
|
NSString *path = [chunks objectAtIndex:1];
|
||||||
[contentman clearFileNameCacheForPath:path];
|
|
||||||
|
|
||||||
[contentman repaintAllWindows];
|
|
||||||
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
|
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
|
||||||
NSNumber *one = [NSNumber numberWithInt:1];
|
NSNumber *one = [NSNumber numberWithInt:1];
|
||||||
NSString *path = [chunks objectAtIndex:1];
|
NSString *path = [chunks objectAtIndex:1];
|
||||||
|
|
|
@ -600,6 +600,7 @@ void Folder::startSync(const QStringList &pathList)
|
||||||
connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString)));
|
connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString)));
|
||||||
connect(_engine.data(), SIGNAL(transmissionProgress(Progress::Info)), this, SLOT(slotTransmissionProgress(Progress::Info)));
|
connect(_engine.data(), SIGNAL(transmissionProgress(Progress::Info)), this, SLOT(slotTransmissionProgress(Progress::Info)));
|
||||||
connect(_engine.data(), SIGNAL(jobCompleted(SyncFileItem)), this, SLOT(slotJobCompleted(SyncFileItem)));
|
connect(_engine.data(), SIGNAL(jobCompleted(SyncFileItem)), this, SLOT(slotJobCompleted(SyncFileItem)));
|
||||||
|
connect(_engine.data(), SIGNAL(syncItemDiscovered(SyncFileItem)), this, SLOT(slotSyncItemDiscovered(SyncFileItem)));
|
||||||
|
|
||||||
setDirtyNetworkLimits();
|
setDirtyNetworkLimits();
|
||||||
_engine->setSelectiveSyncBlackList(selectiveSyncBlackList());
|
_engine->setSelectiveSyncBlackList(selectiveSyncBlackList());
|
||||||
|
@ -725,6 +726,11 @@ void Folder::slotJobCompleted(const SyncFileItem &item)
|
||||||
emit ProgressDispatcher::instance()->jobCompleted(alias(), item);
|
emit ProgressDispatcher::instance()->jobCompleted(alias(), item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Folder::slotSyncItemDiscovered(const SyncFileItem & item)
|
||||||
|
{
|
||||||
|
emit ProgressDispatcher::instance()->syncItemDiscovered(alias(), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
|
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,6 +164,7 @@ private slots:
|
||||||
void slotFolderDiscovered(bool local, QString folderName);
|
void slotFolderDiscovered(bool local, QString folderName);
|
||||||
void slotTransmissionProgress(const Progress::Info& pi);
|
void slotTransmissionProgress(const Progress::Info& pi);
|
||||||
void slotJobCompleted(const SyncFileItem&);
|
void slotJobCompleted(const SyncFileItem&);
|
||||||
|
void slotSyncItemDiscovered(const SyncFileItem & item);
|
||||||
|
|
||||||
void slotPollTimerTimeout();
|
void slotPollTimerTimeout();
|
||||||
void etagRetreived(const QString &);
|
void etagRetreived(const QString &);
|
||||||
|
|
|
@ -201,6 +201,8 @@ signals:
|
||||||
*/
|
*/
|
||||||
void jobCompleted(const QString &folder, const SyncFileItem & item);
|
void jobCompleted(const QString &folder, const SyncFileItem & item);
|
||||||
|
|
||||||
|
void syncItemDiscovered(const QString &folder, const SyncFileItem & item);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setProgressInfo(const QString& folder, const Progress::Info& progress);
|
void setProgressInfo(const QString& folder, const Progress::Info& progress);
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,8 @@ SocketApi::SocketApi(QObject* parent)
|
||||||
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(QString)), this, SLOT(slotUpdateFolderView(QString)));
|
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(QString)), this, SLOT(slotUpdateFolderView(QString)));
|
||||||
connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString,SyncFileItem)),
|
connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString,SyncFileItem)),
|
||||||
SLOT(slotJobCompleted(QString,SyncFileItem)));
|
SLOT(slotJobCompleted(QString,SyncFileItem)));
|
||||||
|
connect(ProgressDispatcher::instance(), SIGNAL(syncItemDiscovered(QString,SyncFileItem)),
|
||||||
|
this, SLOT(slotSyncItemDiscovered(QString,SyncFileItem)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketApi::~SocketApi()
|
SocketApi::~SocketApi()
|
||||||
|
@ -318,8 +320,9 @@ void SocketApi::slotUpdateFolderView(const QString& alias)
|
||||||
void SocketApi::slotJobCompleted(const QString &folder, const SyncFileItem &item)
|
void SocketApi::slotJobCompleted(const QString &folder, const SyncFileItem &item)
|
||||||
{
|
{
|
||||||
Folder *f = FolderMan::instance()->folder(folder);
|
Folder *f = FolderMan::instance()->folder(folder);
|
||||||
if (!f)
|
if (!f) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const QString path = f->path() + item.destination();
|
const QString path = f->path() + item.destination();
|
||||||
|
|
||||||
|
@ -327,9 +330,24 @@ void SocketApi::slotJobCompleted(const QString &folder, const SyncFileItem &item
|
||||||
if (Progress::isWarningKind(item._status)) {
|
if (Progress::isWarningKind(item._status)) {
|
||||||
command = QLatin1String("ERROR");
|
command = QLatin1String("ERROR");
|
||||||
}
|
}
|
||||||
if( Utility::isLinux() ) {
|
broadcastMessage(QLatin1String("STATUS"), path, command);
|
||||||
broadcastMessage(QLatin1String("BROADCAST"), path, command);
|
}
|
||||||
|
|
||||||
|
void SocketApi::slotSyncItemDiscovered(const QString &folder, const SyncFileItem &item)
|
||||||
|
{
|
||||||
|
if (item._instruction == CSYNC_INSTRUCTION_NONE) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Folder *f = FolderMan::instance()->folder(folder);
|
||||||
|
if (!f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString path = f->path() + item.destination();
|
||||||
|
|
||||||
|
const QString command = QLatin1String("SYNC");
|
||||||
|
broadcastMessage(QLatin1String("STATUS"), path, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ private slots:
|
||||||
void onLostConnection();
|
void onLostConnection();
|
||||||
void slotReadSocket();
|
void slotReadSocket();
|
||||||
void slotJobCompleted(const QString &, const SyncFileItem &);
|
void slotJobCompleted(const QString &, const SyncFileItem &);
|
||||||
|
void slotSyncItemDiscovered(const QString &, const SyncFileItem &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendMessage(QTcpSocket* socket, const QString& message, bool doWait = false);
|
void sendMessage(QTcpSocket* socket, const QString& message, bool doWait = false);
|
||||||
|
|
Loading…
Reference in a new issue