OSX: Handle zonebg for first time installations
If none of the gameboard images is set and and the user’s data directory doesn’t contain a “zonebg” directory, create the directory, copy contents from cockatrice’s app bundle and sets the config accordingly.
This commit is contained in:
parent
55c4c464e4
commit
0b4701c42f
4 changed files with 52 additions and 1 deletions
|
@ -202,7 +202,8 @@ if(APPLE)
|
||||||
install(CODE "
|
install(CODE "
|
||||||
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
|
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
|
||||||
Plugins = Plugins
|
Plugins = Plugins
|
||||||
Translations = Resources/translations\")
|
Translations = Resources/translations
|
||||||
|
Data = Resources\")
|
||||||
" COMPONENT Runtime)
|
" COMPONENT Runtime)
|
||||||
|
|
||||||
install(CODE "
|
install(CODE "
|
||||||
|
|
|
@ -133,6 +133,29 @@ int main(int argc, char *argv[])
|
||||||
QDir().mkpath(dataDir + "/pics");
|
QDir().mkpath(dataDir + "/pics");
|
||||||
settingsCache->setPicsPath(dataDir + "/pics");
|
settingsCache->setPicsPath(dataDir + "/pics");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
if(settingsCache->getHandBgPath().isEmpty() &&
|
||||||
|
settingsCache->getStackBgPath().isEmpty() &&
|
||||||
|
settingsCache->getTableBgPath().isEmpty() &&
|
||||||
|
settingsCache->getPlayerBgPath().isEmpty())
|
||||||
|
{
|
||||||
|
QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath);
|
||||||
|
QString destDir = dataDir + "/zonebg";
|
||||||
|
QDir tmpDir(destDir);
|
||||||
|
if(!tmpDir.exists())
|
||||||
|
{
|
||||||
|
// try to install the default images for the current user and set the settigs value
|
||||||
|
settingsCache->copyPath(srcDir + "/zonebg", destDir);
|
||||||
|
|
||||||
|
settingsCache->setHandBgPath(destDir + "/fabric_green.png");
|
||||||
|
settingsCache->setStackBgPath(destDir + "/fabric_red.png");
|
||||||
|
settingsCache->setTableBgPath(destDir + "/fabric_blue.png");
|
||||||
|
settingsCache->setPlayerBgPath(destDir + "/fabric_gray.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!settingsValid() || db->getLoadStatus() != Ok) {
|
if (!settingsValid() || db->getLoadStatus() != Ok) {
|
||||||
qDebug("main(): invalid settings or load status");
|
qDebug("main(): invalid settings or load status");
|
||||||
DlgSettings dlgSettings;
|
DlgSettings dlgSettings;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
SettingsCache::SettingsCache()
|
SettingsCache::SettingsCache()
|
||||||
{
|
{
|
||||||
|
@ -256,3 +257,28 @@ void SettingsCache::setMainWindowGeometry(const QByteArray &_mainWindowGeometry)
|
||||||
mainWindowGeometry = _mainWindowGeometry;
|
mainWindowGeometry = _mainWindowGeometry;
|
||||||
settings->setValue("interface/main_window_geometry", mainWindowGeometry);
|
settings->setValue("interface/main_window_geometry", mainWindowGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::copyPath(const QString &src, const QString &dst)
|
||||||
|
{
|
||||||
|
// test source && return if inexistent
|
||||||
|
QDir dir(src);
|
||||||
|
if (! dir.exists())
|
||||||
|
return;
|
||||||
|
// test destination && create if inexistent
|
||||||
|
QDir tmpDir(dst);
|
||||||
|
if (!tmpDir.exists())
|
||||||
|
{
|
||||||
|
tmpDir.setPath(QDir::rootPath());
|
||||||
|
tmpDir.mkdir(dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||||
|
QString dst_path = dst + QDir::separator() + d;
|
||||||
|
dir.mkpath(dst_path);
|
||||||
|
copyPath(src+ QDir::separator() + d, dst_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (QString f, dir.entryList(QDir::Files)) {
|
||||||
|
QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ public:
|
||||||
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
|
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
|
||||||
QString getPicUrl() const { return picUrl; }
|
QString getPicUrl() const { return picUrl; }
|
||||||
QString getPicUrlHq() const { return picUrlHq; }
|
QString getPicUrlHq() const { return picUrlHq; }
|
||||||
|
void copyPath(const QString &src, const QString &dst);
|
||||||
public slots:
|
public slots:
|
||||||
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
||||||
void setLang(const QString &_lang);
|
void setLang(const QString &_lang);
|
||||||
|
|
Loading…
Reference in a new issue