MainWindow::~MainWindow() { RyProxyServer* server = RyProxyServer::instance(); server->close(); delete _jsBridge; delete ui; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setQuitOnLastWindowClosed(false); appPath = qApp->applicationDirPath(); QTranslator translator; bool isLoadSuccess = translator.load(appPath+"/rythem_zh_CN"); if(!isLoadSuccess)qDebug()<<"error"; QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8")); a.installTranslator(&translator); #ifdef DEBUGTOFILE qInstallMsgHandler(myMessageHandler); #endif RyRuleManager *manager = RyRuleManager::instance(); manager->loadLocalConfig(appPath+"/rythem_config.txt"); // register metatypes qRegisterMetaType<RyPipeData_ptr>("RyPipeData_ptr"); QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8")); //QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8")); //QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8")); MainWindow w; RyProxyServer* server = RyProxyServer::instance(); server->connect(server,SIGNAL(pipeBegin(RyPipeData_ptr)),&w,SLOT(onNewPipe(RyPipeData_ptr))); server->connect(server,SIGNAL(pipeComplete(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr))); server->connect(server,SIGNAL(pipeError(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr))); server->listen(QHostAddress("127.0.0.1"),8889); //w.showMaximized(); w.show(); return a.exec(); }
int main(int argc, char *argv[]) { SingleApplication a(argc, argv, "a"); if(a.isRunning()){ a.sendMessage("from other instance"); return 0; } #ifdef Q_OS_MAC ProxyAutoConfig::instance(); #endif a.setQuitOnLastWindowClosed(false); appPath = qApp->applicationDirPath(); // load app translate file QTranslator translator; bool isLoadSuccess = translator.load(appPath+"/rythem_zh_CN"); if(!isLoadSuccess)qDebug()<<" load language error"; a.installTranslator(&translator); // load system translate file QTranslator translator2; translator2.load(appPath+"/qt_zh_CN"); a.installTranslator(&translator2); #ifdef DEBUGTOFILE qInstallMsgHandler(myMessageHandler); #endif RyRuleManager *manager = RyRuleManager::instance(); manager->loadLocalConfig(appPath+"/rythem_config.txt"); // register metatypes qRegisterMetaType<RyPipeData_ptr>("RyPipeData_ptr"); MainWindow w; //a.connect(&a,SIGNAL(messageAvailable(QString)),&w,SLOT(raise())); a.connect(&a,SIGNAL(messageAvailable(QString)),&w,SLOT(onMessageFromOtherInstance())); RyProxyServer* server = RyProxyServer::instance(); server->connect(server,SIGNAL(pipeBegin(RyPipeData_ptr)),&w,SLOT(onNewPipe(RyPipeData_ptr))); server->connect(server,SIGNAL(pipeComplete(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr))); server->connect(server,SIGNAL(pipeError(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr))); bool isListenSuccess = server->listen(QHostAddress::Any,8889); if(!isListenSuccess){ return 0; } qDebug()<<"listen success"; //w.showMaximized(); w.show(); return a.exec(); }