1
0
forked from blue/squawk
squawk/main.cpp

56 lines
3.2 KiB
C++
Raw Normal View History

2019-03-29 14:54:34 +00:00
#include "ui/squawk.h"
#include "core/squawk.h"
#include "signalcatcher.h"
2019-03-29 14:54:34 +00:00
#include <QtWidgets/QApplication>
#include <QtCore/QThread>
#include <QtCore/QObject>
#include <QSettings>
2019-03-29 14:54:34 +00:00
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
SignalCatcher sc(&app);
QCoreApplication::setOrganizationName("Macaw");
QCoreApplication::setOrganizationDomain("macaw.me");
QCoreApplication::setApplicationName("Squawk");
QCoreApplication::setApplicationVersion("0.0.1");
2019-03-29 14:54:34 +00:00
Squawk w;
w.show();
Core::Squawk* squawk = new Core::Squawk();
QThread* coreThread = new QThread();
squawk->moveToThread(coreThread);
2019-03-30 20:13:13 +00:00
QObject::connect(coreThread, SIGNAL(started()), squawk, SLOT(start()));
QObject::connect(&app, SIGNAL(aboutToQuit()), squawk, SLOT(stop()));
QObject::connect(squawk, SIGNAL(quit()), coreThread, SLOT(quit()));
QObject::connect(coreThread, SIGNAL(finished()), squawk, SLOT(deleteLater()));
2019-03-30 20:13:13 +00:00
QObject::connect(&w, SIGNAL(newAccountRequest(const QMap<QString, QVariant>&)), squawk, SLOT(newAccountRequest(const QMap<QString, QVariant>&)));
QObject::connect(&w, SIGNAL(connectAccount(const QString&)), squawk, SLOT(connectAccount(const QString&)));
QObject::connect(&w, SIGNAL(disconnectAccount(const QString&)), squawk, SLOT(disconnectAccount(const QString&)));
2019-03-30 20:13:13 +00:00
QObject::connect(squawk, SIGNAL(newAccount(const QMap<QString, QVariant>&)), &w, SLOT(newAccount(const QMap<QString, QVariant>&)));
QObject::connect(squawk, SIGNAL(accountConnectionStateChanged(const QString&, int)), &w, SLOT(accountConnectionStateChanged(const QString&, int)));
2019-04-03 21:23:51 +00:00
QObject::connect(squawk, SIGNAL(addContact(const QString&, const QString&, const QString&, const QString&)),
&w, SLOT(addContact(const QString&, const QString&, const QString&, const QString&)));
QObject::connect(squawk, SIGNAL(addGroup(const QString&, const QString&)), &w, SLOT(addGroup(const QString&, const QString&)));
QObject::connect(squawk, SIGNAL(removeGroup(const QString&, const QString&)), &w, SLOT(removeGroup(const QString&, const QString&)));
2019-04-06 10:14:32 +00:00
QObject::connect(squawk, SIGNAL(removeContact(const QString&, const QString&)), &w, SLOT(removeContact(const QString&, const QString&)));
QObject::connect(squawk, SIGNAL(removeContact(const QString&, const QString&, const QString&)), &w, SLOT(removeContact(const QString&, const QString&, const QString&)));
QObject::connect(squawk, SIGNAL(changeContact(const QString&, const QString&, const QString&)), &w, SLOT(changeContact(const QString&, const QString&, const QString&)));
2019-04-07 14:02:41 +00:00
QObject::connect(squawk, SIGNAL(addPresence(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
&w, SLOT(addPresence(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
QObject::connect(squawk, SIGNAL(removePresence(const QString&, const QString&, const QString&)), &w, SLOT(removePresence(const QString&, const QString&, const QString&)));
2019-03-30 20:13:13 +00:00
2019-03-29 14:54:34 +00:00
coreThread->start();
int result = app.exec();
coreThread->wait(500); //TODO hate doing that but settings for some reason don't get saved to the disk
return result;
2019-03-29 14:54:34 +00:00
}