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

Merge branch 'pr1331'

This commit is contained in:
tux3 2015-03-04 21:31:25 +01:00
commit 96d39f6565
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -29,11 +29,16 @@
#include <QFile>
#include <QFontDatabase>
#include <QMutexLocker>
#include <QProcess>
#include <sodium.h>
#include "toxme.h"
#include <unistd.h>
#define EXIT_UPDATE_MACX 218 //We track our state using unique exit codes when debugging
#ifdef LOG_TO_FILE
static QtMessageHandler dflt;
static QTextStream* logFile {nullptr};
@ -110,7 +115,7 @@ int main(int argc, char *argv[])
}
else
{
fprintf(stderr, "Couldn't open log file!!!\n");
fprintf(stderr, "Couldn't open log file!\n");
delete logFile;
logFile = nullptr;
}
@ -123,6 +128,44 @@ int main(int argc, char *argv[])
qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")";
qDebug() << "commit: " << GIT_VERSION << "\n";
#ifdef Q_OS_MACX
if (qApp->applicationDirPath() != "/Applications/qtox.app/Contents/MacOS") {
qDebug() << "OS X: Not in Applications folder";
QMessageBox AskInstall;
AskInstall.setIcon(QMessageBox::Question);
AskInstall.setWindowModality(Qt::ApplicationModal);
AskInstall.setText("Move to Applications folder?");
AskInstall.setInformativeText("I can move myself to the Applications folder, keeping your downloads folder less cluttered.\r\n");
AskInstall.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
AskInstall.setDefaultButton(QMessageBox::Yes);
int AskInstallAttempt = AskInstall.exec(); //Actually ask the user
if (AskInstallAttempt == QMessageBox::Yes) {
qDebug() << "Installing";
QProcess *sudoprocess = new QProcess;
QProcess *qtoxprocess = new QProcess;
QString bindir = qApp->applicationDirPath();
QString appdir = bindir;
appdir.chop(15);
QString sudo = bindir + "/qtox_sudo rsync -avzh --remove-source-file " + appdir + " /Applications/qtox.app";
QString qtox = "open /Applications/qtox.app";
if (fork() != 0) { //cheap hack
return EXIT_UPDATE_MACX; //Note that if we don't do this the update process will get killed. Also, errors just crash it
}
sudoprocess->start(sudo);
sudoprocess->waitForFinished();
qtoxprocess->start(qtox);
return 0; //Actually kills it
}
}
#endif
// Install Unicode 6.1 supporting font
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");