Merge remote-tracking branch 'upstream/master' into cmake_qt5

This commit is contained in:
Fabio Bas 2014-06-25 15:46:50 +02:00
commit 809f390e2f
13 changed files with 155 additions and 101 deletions

View file

@ -14,6 +14,7 @@ enum GraphicsItemType {
class AbstractGraphicsItem : public QObject, public QGraphicsItem {
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
protected:
void paintNumberEllipse(int number, int radius, const QColor &color, int position, int count, QPainter *painter);
public:

View file

@ -105,15 +105,6 @@ int main(int argc, char *argv[])
qInstallMessageHandler(myMessageOutput);
#endif
}
#ifdef Q_OS_MAC
QDir baseDir(app.applicationDirPath());
baseDir.cdUp();
baseDir.cdUp();
baseDir.cdUp();
QDir pluginsDir = baseDir;
pluginsDir.cd("PlugIns");
app.addLibraryPath(pluginsDir.absolutePath());
#endif
#ifdef Q_OS_WIN
app.addLibraryPath(app.applicationDirPath() + "/plugins");
#endif
@ -129,11 +120,8 @@ int main(int argc, char *argv[])
if (translationPath.isEmpty()) {
#ifdef Q_OS_MAC
QDir translationsDir = baseDir;
translationsDir.cd("translations");
translationPath = translationsDir.absolutePath();
#endif
#ifdef Q_OS_WIN
translationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#elif Q_OS_WIN
translationPath = app.applicationDirPath() + "/translations";
#endif
}
@ -171,6 +159,43 @@ int main(int argc, char *argv[])
QDir().mkpath(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");
}
}
if(settingsCache->getSoundPath().isEmpty())
{
QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath);
QString destDir = dataDir + "/sounds";
QDir tmpDir(destDir);
if(!tmpDir.exists())
{
// try to install the default sounds for the current user and set the settigs value
settingsCache->copyPath(srcDir + "/sounds", destDir);
settingsCache->setSoundPath(destDir);
}
}
#endif
if (!settingsValid() || db->getLoadStatus() != Ok) {
qDebug("main(): invalid settings or load status");
DlgSettings dlgSettings;

View file

@ -1,5 +1,7 @@
#include "settingscache.h"
#include <QSettings>
#include <QDebug>
#include <QDir>
SettingsCache::SettingsCache()
{
@ -257,3 +259,31 @@ 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());
if (!tmpDir.mkdir(dst) && !tmpDir.exists()) {
// TODO: this is probably not good.
qDebug() << "copyPath(): Failed to create dir: " << 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);
}
}

View file

@ -90,6 +90,7 @@ public:
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
QString getPicUrl() const { return picUrl; }
QString getPicUrlHq() const { return picUrlHq; }
void copyPath(const QString &src, const QString &dst);
public slots:
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
void setLang(const QString &_lang);