1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'pr2822'

This commit is contained in:
tux3 2016-01-20 14:33:17 +01:00
commit 529299c7ba
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
9 changed files with 205 additions and 109 deletions

18
OSX-Migrater.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# A qTox profile migrater for OSX
now=$(date +"%m_%d_%Y-%H.%M.%S")
bak="~/.Tox-Backup-$now"
echo "Figuring out if action is required ..."
if [ -d ~/Library/Preferences/tox ]; then
echo "Moving profile(s) ..."
cp -r ~/Library/Preferences/tox ~/Library/Application\ Support/
mv ~/Library/Application\ Support/tox/ ~/Library/Application\ Support/Tox
mv ~/Library/Preferences/tox ~/.Tox-Backup-$now
echo "Done! You profile(s) have been moved! A back up coppy still exists at:"
echo "$bak"
else
echo "Cannot locate old profile directory, profile migration not performed"
fi
exit 0

View File

@ -1,102 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIconFile</key>
<string>qtox.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleExecutable</key>
<string>qtox</string>
<key>CFBundleDisplayName</key>
<string>qTox</string>
<key>CFBundleName</key>
<string>qTox</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0-EXPERIMENTIAL</string>
<key>CFBundleIdentifier</key>
<string>chat.tox.qtox</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Tox URL</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tox</string>
</array>
<key>CFBundleURLIconFile</key>
<string>qtox_profile.icns</string>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>tox</string>
</array>
<key>CFBundleTypeName</key>
<string>Tox profile</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeIconFile</key>
<string>qtox_profile.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-tox.profile</string>
</array>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>public.tox</string>
</array>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeIdentifier</key>
<string>public.tox</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<string>TOX</string>
<key>public.filename-extension</key>
<array>
<string>tox</string>
</array>
<key>public.mime-type</key>
<string>tox/x-profile</string>
</dict>
</dict>
</array>
<key>CFBundleLocalizations</key>
<array>
<string>en_US</string>
<string>en</string>
<string>bg_BG</string>
<string>de_DE</string>
<string>fi_FI</string>
<string>fr_FR</string>
<string>it_IT</string>
<string>pl_PL</string>
<string>ru_RU</string>
<string>uk_UA</string>
<string>sv</string>
</array>
</dict>
<dict>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIconFile</key>
<string>qtox.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>toxq</string>
<key>CFBundleExecutable</key>
<string>qtox</string>
<key>CFBundleDisplayName</key>
<string>qTox</string>
<key>CFBundleName</key>
<string>qTox</string>
<key>CFBundleVersion</key>
<string>1.2.2</string>
<key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string>
<key>CFBundleIdentifier</key>
<string>chat.tox.qtox</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Tox URL</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tox</string>
</array>
<key>CFBundleURLIconFile</key>
<string>qtox_profile</string>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>tox</string>
</array>
<key>CFBundleTypeName</key>
<string>Tox profile</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeIconFile</key>
<string>qtox_profile</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-tox.profile</string>
</array>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>public.tox</string>
</array>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeIdentifier</key>
<string>public.tox</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<string>TOX</string>
<key>public.filename-extension</key>
<array>
<string>tox</string>
</array>
<key>public.mime-type</key>
<string>tox/x-profile</string>
</dict>
</dict>
</array>
<key>CFBundleLocalizations</key>
<array>
<string>en_US</string>
<string>bg_BG</string>
<string>cs</string>
<string>de_DE</string>
<string>el</string>
<string>es_MX</string>
<string>fi_FI</string>
<string>fr_FR</string>
<string>hr_HR</string>
<string>hu_HU</string>
<string>it_IT</string>
<string>lt_LT</string>
<string>nl_NL</string>
<string>nb_NO</string>
<string>pl_PL</string>
<string>pt_BR</string>
<string>ru_RU</string>
<string>sl</string>
<string>sv</string>
<string>tr_TR</string>
<string>uk_UA</string>
<string>zh_CH</string>
</array>
</dict>
</plist>

View File

@ -164,6 +164,14 @@ win32 {
LIBS += -lqrencode -lsqlcipher
contains(DEFINES, QTOX_PLATFORM_EXT) { LIBS += -framework IOKit -framework CoreFoundation }
contains(DEFINES, QTOX_FILTER_AUDIO) { LIBS += -lfilteraudio }
#Files to be includes into the qTox.app/Contents/Resources folder
#OSX-Migrater.sh part of migrateProfiles() compatabilty code
APP_RESOURCE.files = img/icons/qtox_profile.icns OSX-Migrater.sh
APP_RESOURCE.path = Contents/Resources
QMAKE_BUNDLE_DATA += APP_RESOURCE
#Dynamic versioning for Info.plist
INFO_PLIST_PATH = $$shell_quote($${OUT_PWD}/$${TARGET}.app/Contents/Info.plist)
QMAKE_POST_LINK += /usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $${GIT_DESCRIBE}\" $${INFO_PLIST_PATH}
} else {
android {
LIBS += -ltoxcore -ltoxav -ltoxencryptsave -ltoxdns

View File

@ -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");

View File

@ -537,6 +537,9 @@ QString Settings::getSettingsDirPath()
#ifdef Q_OS_WIN
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator();
#elif defined(Q_OS_OSX)
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox")+QDir::separator();
#else
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
+ QDir::separator() + "tox")+QDir::separator();

View File

@ -19,16 +19,38 @@
#if defined(__APPLE__) && defined(__MACH__)
#include "src/platform/autorun.h"
#include <QSettings>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QCoreApplication>
int state ;
bool Platform::setAutorun(bool on)
{
return false;
QString qtoxPlist = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() +
"Library" + QDir::separator() + "LaunchAgents" + QDir::separator() + "chat.tox.qtox.autorun.plist");
QString qtoxDir = QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + "qtox");
QSettings autoRun(qtoxPlist, QSettings::NativeFormat);
autoRun.setValue("Label","chat.tox.qtox.autorun");
autoRun.setValue("Program", qtoxDir);
if (on)
{
autoRun.setValue("RunAtLoad",true);
state = true;
}
else
{
autoRun.setValue("RunAtLoad",false);
state = false;
}
}
bool Platform::getAutorun()
{
return false;
return state;
}
#endif // defined(__APPLE__) && defined(__MACH__)

View File

@ -24,6 +24,8 @@
#include <QDebug>
#include <QProcess>
#include <QDir>
#include <QFileInfo>
#include <QStandardPaths>
#include <unistd.h>
@ -82,3 +84,36 @@ void osx::moveToAppFolder()
}
}
}
// migrateProfiles() is compatabilty code that can be removed down the line when the time seems right.
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. Using alternate migration method.";
QString OSXMigrater = "../Resources/OSX-Migrater.sh" ;
QProcess::execute(OSXMigrater);
QMessageBox MigrateProfile;
MigrateProfile.setIcon(QMessageBox::Information);
MigrateProfile.setWindowModality(Qt::ApplicationModal);
MigrateProfile.setText("Alternate profile migration method used.");
MigrateProfile.setInformativeText("It has been detected that your profiles \nwhere migrated to the new settings directory; \nusing the alternate migration method. \n\nA backup can be found in your: \n/Users/[USER]/.Tox-Backup[DATE-TIME] \n\nJust in case. \r\n");
MigrateProfile.exec();
}
}
else
{
qDebug() << "OS X: Old settings directory not detected";
}
}
// End migrateProfiles() compatibility code

View File

@ -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

View File

@ -104,9 +104,6 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
bodyUI->cbAutorun->setChecked(Settings::getInstance().getAutorun());
#if defined(__APPLE__) && defined(__MACH__)
bodyUI->cbAutorun->setEnabled(false);
#endif
bool showSystemTray = Settings::getInstance().getShowSystemTray();