1 #include "mainwindow.h"
2 #include "tmeditorwidget.h"
5 #include "httpserver.h"
8 #include "tmdatabase.h"
12 #include <QApplication>
14 #include <QDesktopServices>
17 #include <QLinkedList>
23 int main(int argc, char *argv[])
25 SetDebugMemoryLeaks();
26 QApplication a(argc, argv);
28 a.setOrganizationName("Wordring");
29 a.setApplicationName("TM");
31 QString path = QStandardPaths::writableLocation(
32 QStandardPaths::ConfigLocation) + "/settings.ini";
33 Settings settings(path, QSettings::IniFormat);
34 //QString apppath = QCoreApplication::applicationDirPath();
37 if(!settings.contains("Japanese/mecabdic"))
39 QString mecabdic(PROXYSRCDIR);
40 mecabdic.append("/../third-party/lib/ipadic");
42 mecabdic = dir.absolutePath();
43 settings.setValue("Japanese/mecabdic", mecabdic);
47 if(!settings.contains("HttpServer/port")) settings.setValue("HttpServer/port", 8080);
49 if(!settings.contains("SocketServer/port")) settings.setValue("SocketServer/port", 8081);
51 if(!settings.contains("ProxyModule/prefix")) settings.setValue("ProxyModule/prefix", "/?");
53 if(!settings.contains("ProxyHandler/jscode"))
54 settings.setValue("ProxyHandler/jscode", QString(PROXYSRCDIR) + "/tm.js");
57 if(!settings.contains("Database/root"))
59 QString path = QStandardPaths::writableLocation(
60 QStandardPaths::CacheLocation);
61 settings.setValue("Database/root", path);
64 TM::Service *service = new TM::Service(&settings, &a);
65 MainWindow w(&settings, service);
66 w.setFont(QFont("Meiryo", 10.5));
67 service->load_languages(QApplication::applicationDirPath() + "/plugins");
69 HttpServer *server = new HttpServer(&settings, &w);
70 w.set_http_port(server->port());
72 TM::SocketServer *socket = new TM::SocketServer(&settings, service, w.editor_widget(), &w);
74 server->install(new TM::ProxyModule(
75 &settings, server->port(), socket->port(), server));
77 QObject::connect(&w, SIGNAL(closing()), socket, SLOT(abort()));
79 int result = a.exec();