mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
osx/win: add sync folders to favorite folders
This commit is contained in:
parent
1eabdee253
commit
ddecca47fd
3 changed files with 41 additions and 0 deletions
|
@ -120,6 +120,11 @@ set_target_properties( owncloudsync PROPERTIES COMPILE_DEFINITIONS OWNCLOUD_CLIE
|
|||
target_link_libraries(mirallsync ${libsync_LINK_TARGETS} )
|
||||
target_link_libraries(owncloudsync ${libsync_LINK_TARGETS} )
|
||||
|
||||
if ( APPLE )
|
||||
target_link_libraries(mirallsync /System/Library/Frameworks/CoreServices.framework)
|
||||
target_link_libraries(owncloudsync /System/Library/Frameworks/CoreServices.framework)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
|
||||
install(TARGETS mirallsync owncloudsync
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "mirall/inotify.h"
|
||||
#include "mirall/theme.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QtCore>
|
||||
|
||||
|
@ -145,6 +149,36 @@ QString FolderMan::unescapeAlias( const QString& alias ) const
|
|||
return a;
|
||||
}
|
||||
|
||||
void FolderMan::setupFavLink(const QString &folder)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
// Windows Explorer: Place under "Favorites" (Links)
|
||||
wchar_t path[MAX_PATH];
|
||||
SHGetSpecialFolderPath(0, path, CSIDL_PROFILE, FALSE);
|
||||
QString profile = QString::fromWCharArray(path);
|
||||
QString folderName = QDir::fromNativeSeparators(profile.left(profile.lastIndexOf('/')));
|
||||
QFile::link(folder, profile+QLatin1String("/Links/") + folderName + QLatin1String(".lnk"));
|
||||
#elif defined (Q_OS_MAC)
|
||||
// Finder: Place under "Places"
|
||||
QString folderUrl = QUrl::fromLocalFile(folder).toString();
|
||||
CFStringRef folderCFStr = CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(folderUrl.unicode()),
|
||||
folder.length());
|
||||
CFURLRef urlRef = CFURLCreateWithString(NULL, folderCFStr, 0);
|
||||
LSSharedFileListRef placesItems = LSSharedFileListCreate(0, kLSSharedFileListFavoriteItems, 0);
|
||||
if (placesItems) {
|
||||
//Insert an item to the list.
|
||||
LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(placesItems,
|
||||
kLSSharedFileListItemBeforeFirst, 0, 0,
|
||||
urlRef, 0, 0);
|
||||
if (item)
|
||||
CFRelease(item);
|
||||
}
|
||||
CFRelease(placesItems);
|
||||
CFRelease(folderCFStr);
|
||||
CFRelease(urlRef);
|
||||
#endif
|
||||
}
|
||||
|
||||
// filename is the name of the file only, it does not include
|
||||
// the configuration directory path
|
||||
Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
|
||||
|
@ -389,6 +423,7 @@ void FolderMan::addFolderDefinition( const QString& backend, const QString& alia
|
|||
settings.setValue(QString::fromLatin1("%1/onlyThisLAN").arg(escapedAlias), onlyThisLAN );
|
||||
settings.sync();
|
||||
|
||||
setupFavLink(sourceFolder);
|
||||
}
|
||||
|
||||
void FolderMan::removeAllFolderDefinitions()
|
||||
|
|
|
@ -101,6 +101,7 @@ private:
|
|||
// finds all folder configuration files
|
||||
// and create the folders
|
||||
int setupKnownFolders();
|
||||
void setupFavLink(const QString& folder);
|
||||
|
||||
// Escaping of the alias which is used in QSettings AND the file
|
||||
// system, thus need to be escaped.
|
||||
|
|
Loading…
Reference in a new issue