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:
commit
96d39f6565
45
src/main.cpp
45
src/main.cpp
@ -29,11 +29,16 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
#include "toxme.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
|
#ifdef LOG_TO_FILE
|
||||||
static QtMessageHandler dflt;
|
static QtMessageHandler dflt;
|
||||||
static QTextStream* logFile {nullptr};
|
static QTextStream* logFile {nullptr};
|
||||||
@ -110,7 +115,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Couldn't open log file!!!\n");
|
fprintf(stderr, "Couldn't open log file!\n");
|
||||||
delete logFile;
|
delete logFile;
|
||||||
logFile = nullptr;
|
logFile = nullptr;
|
||||||
}
|
}
|
||||||
@ -123,6 +128,44 @@ int main(int argc, char *argv[])
|
|||||||
qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")";
|
qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")";
|
||||||
qDebug() << "commit: " << GIT_VERSION << "\n";
|
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
|
// Install Unicode 6.1 supporting font
|
||||||
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user