mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Added basic migration compatibility code.
This code works if the ~/Library/Application Support/Tox directory does not already exist.
This commit is contained in:
parent
e05e736d33
commit
27fda2e579
11
src/main.cpp
11
src/main.cpp
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sodium.h>
|
||||
|
||||
#if defined(Q_OS_MACX) && defined(QT_RELEASE)
|
||||
#if defined(Q_OS_OSX)
|
||||
#include "platform/install_osx.h"
|
||||
#endif
|
||||
|
||||
|
@ -98,6 +98,11 @@ int main(int argc, char *argv[])
|
|||
a.setOrganizationName("Tox");
|
||||
a.setApplicationVersion("\nGit commit: " + QString(GIT_VERSION));
|
||||
|
||||
#if defined(Q_OS_OSX)
|
||||
//osx::moveToAppFolder(); TODO: Add setting to enable this feature.
|
||||
osx::migrateProfiles();
|
||||
#endif
|
||||
|
||||
#ifdef HIGH_DPI
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
#endif
|
||||
|
@ -143,10 +148,6 @@ int main(int argc, char *argv[])
|
|||
qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")";
|
||||
qDebug() << "commit: " << GIT_VERSION << "\n";
|
||||
|
||||
#if defined(Q_OS_MACX) && defined(QT_RELEASE)
|
||||
osx::moveToAppFolder();
|
||||
#endif
|
||||
|
||||
// Install Unicode 6.1 supporting font
|
||||
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -82,3 +84,27 @@ void osx::moveToAppFolder()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void osx::migrateProfiles()
|
||||
{
|
||||
QString oldPath = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() +
|
||||
"Library" + QDir::separator() + "Preferences" + QDir::separator() + "tox");
|
||||
QFileInfo checkDir(oldPath);
|
||||
|
||||
QString newPath = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
||||
+ "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox");
|
||||
QDir dir;
|
||||
|
||||
if (checkDir.exists() && checkDir.isDir())
|
||||
{
|
||||
qDebug() << "OS X: Old settings directory detected migrating to default";
|
||||
if( !dir.rename(oldPath, newPath) )
|
||||
{
|
||||
qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "OS X: Old settings directory not detected";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <QtCore/qsystemdetection.h>
|
||||
|
||||
#ifndef Q_OS_MACX
|
||||
#ifndef Q_OS_OSX
|
||||
#error "This file is only meant to be compiled for Mac OSX targets"
|
||||
#endif
|
||||
|
||||
|
@ -31,6 +31,7 @@ namespace osx
|
|||
static constexpr int EXIT_UPDATE_MACX_FAIL = 216;
|
||||
|
||||
void moveToAppFolder();
|
||||
void migrateProfiles();
|
||||
}
|
||||
|
||||
#endif // INSTALLOSX_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user