diff options
-rw-r--r-- | README.MacOS | 41 | ||||
-rw-r--r-- | quacker/quacker.pro | 33 | ||||
-rw-r--r-- | quacker/settings.cpp | 28 |
3 files changed, 51 insertions, 51 deletions
diff --git a/README.MacOS b/README.MacOS index ac6f604..2640cea 100644 --- a/README.MacOS +++ b/README.MacOS @@ -2,49 +2,32 @@ Requirements: ------------- 1. Xcode (for the compiler and build tools) -2. A recent version of Qt with carbon support (this allows building Intel and -PPC versions - I'm using qt-mac-carbon-opensource-4.7.1.dmg) +2. A version of Qt 4. I use HomeBrew to grab the latest version, + presently Qt 4.8.6. Installing in HomeBrew is as easy as + brew install qt Building Quackle: ----------------- -Unpack the source code. Edit these 3 files: +Clone the repo. Use qmake to build quackle.pro and quackleio/quackleio.pro: -1. quackle.pro -2. quackleio/quackleio.pro -3. quacker/quacker.pro + qmake quackle.pro && make + cd quackleio && qmake && make && cd .. -In each of these files, find the CONFIG variable, and append the string "x86 -ppc" to it. This instructs the compiler to create binaries for both -architectures. Also make sure that CONFIG contains "release" and not "debug". -You don't want to distribute a binary which still has debug symbols in it. +Then make an Xcode project for quacker using qmake. -rename the file "quacker.pro" to "Quackle.pro". This is a cosmetic change. It -results in the application being called "Quackle" rather than "quacker". + cd quacker && qmake -spec macx-xcode && cd .. + +You can now open the project in Xcode, build and run as usual. -Now start with the top-level directory. Run "qmake -spec macx-g++" in it, -followed by "make". Repeat these steps in the "quackleio" and then the -"quacker" directories. Now you will have an OSX application bundle called -"Quackle.app" in the "quacker" directory. This bundle contains a fat binary, -with code for both architectures. Creating a self-contained bundle: --------------------------------- -First, copy the "data" directory from the top-level directory into the bundle: - -cp -pR ../data Quackle.app/Contents - -Next, copy the icon from an existing Quackle.app bundle into this new one: -select the old Quackle application, press CMD-I, click on the icon and press -CMD-C to copy it. Then select the new application bundle, press CMD-I to open -its properties, click on the blank icon area on the top, and press CMD-V to -paste the icon. - -Finally, you need to insert the Qt frameworks into this bundle, so that it can +You need to insert the Qt frameworks into this bundle, so that it can run stand-alone, without any dependencies. You do that by running: /Developer/Tools/Qt/macdeployqt Quackle.app -dmg This will create a file, Quackle.dmg, containing the application bundle. You -can now distribute this. It should run on OSX 10.4, 10.5 and 10.6. +can now distribute this. It should run on OSX 10.8 and later. diff --git a/quacker/quacker.pro b/quacker/quacker.pro index 2ee8cc2..246a261 100644 --- a/quacker/quacker.pro +++ b/quacker/quacker.pro @@ -1,18 +1,9 @@ TEMPLATE = app -VERSION = 0.98 +VERSION = 0.99 TARGET = Quackle DEPENDPATH += .. ../quackleio INCLUDEPATH += . .. -APP_ALPHABETS_FILES.files = $$files(../data/alphabets/*) -APP_LEXICA_FILES.files = $$files(../data/lexica/*) -APP_STRATEGY_FILEScswapr07.files = $$files(../data/strategy/cswapr07/*) -APP_STRATEGY_FILEScsw12.files = $$files(../data/strategy/csw12/*) -APP_STRATEGY_FILESods5.files = $$files(../data/strategy/ods5/*) -APP_STRATEGY_FILEStwl06.files = $$files(../data/strategy/twl06/*) -APP_STRATEGY_FILEStwl98.files = $$files(../data/strategy/twl98/*) -APP_THEME_FILES.files = $$files(../data/themes/*) - MOC_DIR = moc # enable/disable debug symbols @@ -31,6 +22,7 @@ QMAKE_LFLAGS_RELEASE += -L../lib/release -L../quackleio/lib/release QMAKE_LFLAGS_DEBUG += -L../lib/debug -L../quackleio/lib/debug LIBS += -lquackleio -lquackle +macx:LIBS += -framework CoreFoundation # Input HEADERS += *.h @@ -55,16 +47,17 @@ macx { QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.8 # copy data/ directory into app bundle - APP_ALPHABETS_FILES.path = Contents/MacOS/data/alphabets - APP_LEXICA_FILES.path = Contents/MacOS/data/lexica - APP_STRATEGY_FILEScswapr07.path = Contents/MacOS/data/strategy/cswapr07 - APP_STRATEGY_FILEScsw12.path = Contents/MacOS/data/strategy/csw12 - APP_STRATEGY_FILESods5.path = Contents/MacOS/data/strategy/ods5 - APP_STRATEGY_FILEStwl06.path = Contents/MacOS/data/strategy/twl06 - APP_STRATEGY_FILEStwl98.path = Contents/MacOS/data/strategy/twl98 - APP_THEME_FILES.path = Contents/MacOS/data/themes - - QMAKE_BUNDLE_DATA += APP_ALPHABETS_FILES APP_LEXICA_FILES APP_STRATEGY_FILEScswapr07 APP_STRATEGY_FILEScsw12 APP_STRATEGY_FILESods5 APP_STRATEGY_FILEStwl06 APP_STRATEGY_FILEStwl98 APP_THEME_FILES + APP_ALPHABETS_FILES.files = ../data/alphabets + APP_LEXICA_FILES.files = ../data/lexica + APP_STRATEGY_FILES.files = ../data/strategy + APP_THEME_FILES.files = ../data/themes + + APP_ALPHABETS_FILES.path = Contents/Resources/data + APP_LEXICA_FILES.path = Contents/Resources/data + APP_STRATEGY_FILES.path = Contents/Resources/data + APP_THEME_FILES.path = Contents/Resources/data + + QMAKE_BUNDLE_DATA += APP_ALPHABETS_FILES APP_LEXICA_FILES APP_STRATEGY_FILES APP_THEME_FILES # plist gymnastics QMAKE_POST_LINK += ;cp -n $$PWD/quacker.plist $${OUT_PWD}/$${TARGET}.app/Contents diff --git a/quacker/settings.cpp b/quacker/settings.cpp index 7c3d6bd..301608e 100644 --- a/quacker/settings.cpp +++ b/quacker/settings.cpp @@ -24,6 +24,10 @@ #include <QtGui> #include <QMessageBox> +#ifdef Q_WS_MAC +#include <CoreFoundation/CoreFoundation.h> +#endif // Q_WS_MAC + #include "alphabetparameters.h" #include "board.h" #include "boardparameters.h" @@ -52,6 +56,28 @@ Settings::Settings(QWidget *parent) : QWidget(parent), m_lexiconNameCombo(0), m_alphabetNameCombo(0), m_themeNameCombo(0) { m_self = this; + QDir directory = QFileInfo(qApp->arguments().at(0)).absoluteDir(); + + #ifdef Q_WS_MAC + if (CFBundleGetMainBundle()) + { + CFURLRef dataUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("data"), NULL, NULL); + if (dataUrlRef) + { + CFStringRef macPath = CFURLCopyFileSystemPath(dataUrlRef, kCFURLPOSIXPathStyle); + size_t sizeOfBuf = CFStringGetMaximumSizeOfFileSystemRepresentation(macPath); + char* buf = (char*) malloc(sizeOfBuf); + + CFStringGetFileSystemRepresentation(macPath, buf, sizeOfBuf); + directory = QDir(buf); + directory.cdUp(); + + free(buf); + CFRelease(dataUrlRef); + CFRelease(macPath); + } + } + #endif if (QFile::exists("data")) m_dataDir = "data"; @@ -59,10 +85,8 @@ Settings::Settings(QWidget *parent) m_dataDir = "../data"; else if (QFile::exists("Quackle.app/Contents/data")) m_dataDir = "Quackle.app/Contents/data"; - else { - QDir directory = QFileInfo(qApp->arguments().at(0)).absoluteDir(); if (!directory.cd("data") || !directory.cd("../data")) QMessageBox::critical(0, tr("Error Initializing Data Files - Quacker"), tr("<p>Could not open data directory. Quackle will be useless. Try running the quacker executable with quackle/quacker/ as the current directory.</p>")); m_dataDir = directory.absolutePath(); |