Merge pull request #2613 from jonasschnelli/prefsFix
MaxOSX: settings fixes (#2371)
This commit is contained in:
commit
c83d4d2170
4 changed files with 60 additions and 5 deletions
|
@ -398,7 +398,7 @@ win32:!contains(MINGW_THREAD_BUGFIX, 0) {
|
||||||
|
|
||||||
macx:HEADERS += src/qt/macdockiconhandler.h src/qt/macnotificationhandler.h
|
macx:HEADERS += src/qt/macdockiconhandler.h src/qt/macnotificationhandler.h
|
||||||
macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm src/qt/macnotificationhandler.mm
|
macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm src/qt/macnotificationhandler.mm
|
||||||
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
|
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit -framework CoreServices
|
||||||
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
|
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
|
||||||
macx:ICON = src/qt/res/icons/bitcoin.icns
|
macx:ICON = src/qt/res/icons/bitcoin.icns
|
||||||
macx:QMAKE_CFLAGS_THREAD += -pthread
|
macx:QMAKE_CFLAGS_THREAD += -pthread
|
||||||
|
|
|
@ -215,9 +215,12 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
// Regenerate startup link, to fix links to old versions
|
// Regenerate startup link, to fix links to old versions
|
||||||
|
// OSX: makes no sense on mac and might also scan/mount external (and sleeping) volumes (can take up some secs)
|
||||||
if (GUIUtil::GetStartOnSystemStartup())
|
if (GUIUtil::GetStartOnSystemStartup())
|
||||||
GUIUtil::SetStartOnSystemStartup(true);
|
GUIUtil::SetStartOnSystemStartup(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
boost::thread_group threadGroup;
|
boost::thread_group threadGroup;
|
||||||
|
|
||||||
|
|
|
@ -426,10 +426,61 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
// TODO: OSX startup stuff; see:
|
|
||||||
// https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Articles/CustomLogin.html
|
#elif defined(Q_OS_MAC)
|
||||||
|
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
|
||||||
|
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <CoreServices/CoreServices.h>
|
||||||
|
|
||||||
|
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl);
|
||||||
|
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
|
||||||
|
{
|
||||||
|
// loop through the list of startup items and try to find the bitcoin app
|
||||||
|
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, NULL);
|
||||||
|
for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) {
|
||||||
|
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i);
|
||||||
|
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
|
||||||
|
CFURLRef currentItemURL = NULL;
|
||||||
|
LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, NULL);
|
||||||
|
if(currentItemURL && CFEqual(currentItemURL, findUrl)) {
|
||||||
|
// found
|
||||||
|
CFRelease(currentItemURL);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
if(currentItemURL) {
|
||||||
|
CFRelease(currentItemURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetStartOnSystemStartup()
|
||||||
|
{
|
||||||
|
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
|
||||||
|
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
|
||||||
|
return !!foundItem; // return boolified object
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
|
{
|
||||||
|
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
|
||||||
|
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
|
||||||
|
|
||||||
|
if(fAutoStart && !foundItem) {
|
||||||
|
// add bitcoin app to startup item list
|
||||||
|
LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst, NULL, NULL, bitcoinAppUrl, NULL, NULL);
|
||||||
|
}
|
||||||
|
else if(!fAutoStart && foundItem) {
|
||||||
|
// remove item
|
||||||
|
LSSharedFileListItemRemove(loginItems, foundItem);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
bool GetStartOnSystemStartup() { return false; }
|
bool GetStartOnSystemStartup() { return false; }
|
||||||
bool SetStartOnSystemStartup(bool fAutoStart) { return false; }
|
bool SetStartOnSystemStartup(bool fAutoStart) { return false; }
|
||||||
|
|
|
@ -45,7 +45,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
|
||||||
|
|
||||||
/* Window elements init */
|
/* Window elements init */
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
ui->tabWindow->setVisible(false);
|
/* remove Window tab on Mac */
|
||||||
|
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Display elements init */
|
/* Display elements init */
|
||||||
|
|
Loading…
Reference in a new issue