mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
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
|
|
@ -1,5 +1,6 @@
|
|||
#include "settingscache.h"
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
|
||||
SettingsCache::SettingsCache()
|
||||
{
|
||||
|
|
@ -256,3 +257,28 @@ void SettingsCache::setMainWindowGeometry(const QByteArray &_mainWindowGeometry)
|
|||
mainWindowGeometry = _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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue