int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("SRFGames"); QCoreApplication::setOrganizationDomain("sol-online.org"), QCoreApplication::setApplicationName("TrackYourTime"); #ifdef Q_OS_MAC QDir dir(argv[0]); dir.cdUp(); QString currentDir = dir.absolutePath(); dir.cdUp(); dir.cd("PlugIns"); QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath())); #endif QApplication a(argc, argv); QApplication::setQuitOnLastWindowClosed(false); #ifdef Q_OS_MAC QDir::setCurrent(currentDir); #endif qDebug() << "application start\n"; cSettings settings; QString Language = QLocale::system().name(); Language.truncate(Language.lastIndexOf('_')); Language = settings.db()->value(cDataManager::CONF_LANGUAGE_ID,Language).toString(); if (settings.db()->value(cDataManager::CONF_FIRST_LAUNCH_ID,true).toBool()){ settings.db()->setValue(cDataManager::CONF_FIRST_LAUNCH_ID,false); settings.db()->setValue(cDataManager::CONF_LANGUAGE_ID,Language); settings.db()->setValue(cDataManager::CONF_AUTORUN_ID,true); setAutorun(); settings.db()->sync(); } qDebug() << "laod translation\n"; QTranslator translator; translator.load("lang_" + Language,QDir::currentPath()+"/data/languages"); QApplication::installTranslator(&translator); qDebug() << "init datamanager\n"; cDataManager datamanager; qDebug() << "init schedule\n"; cSchedule schedule(&datamanager); qDebug() << "init updater\n"; cUpdater updater; QObject::connect(&schedule,SIGNAL(checkUpdates()),&updater,SLOT(checkUpdates())); qDebug() << "init tray icon\n"; cTrayIcon trIcon(&datamanager); QObject::connect(&datamanager, SIGNAL(trayActive()), &trIcon, SLOT(setActive())); QObject::connect(&datamanager, SIGNAL(traySleep()), &trIcon, SLOT(setInactive())); QObject::connect(&datamanager, SIGNAL(trayShowHint(QString)), &trIcon, SLOT(showHint(QString))); QObject::connect(&datamanager, SIGNAL(profilesChanged()), &trIcon, SLOT(onProfilesChange())); qDebug() << "init applications window\n"; ApplicationsWindow applicationsWindow(&datamanager); QObject::connect(&trIcon, SIGNAL(showApplications()), &applicationsWindow, SLOT(showNormal())); QObject::connect(&datamanager, SIGNAL(profilesChanged()), &applicationsWindow, SLOT(onProfilesChange())); QObject::connect(&datamanager, SIGNAL(applicationsChanged()), &applicationsWindow, SLOT(onApplicationsChange())); qDebug() << "init profiles window\n"; ProfilesWindow profilesWindow(&datamanager); QObject::connect(&applicationsWindow, SIGNAL(showProfiles()), &profilesWindow, SLOT(showNormal())); qDebug() << "init app settings window\n"; App_SettingsWindow app_settingsWindow(&datamanager); QObject::connect(&applicationsWindow, SIGNAL(showAppSettings(int)), &app_settingsWindow, SLOT(showApp(int))); QObject::connect(&datamanager, SIGNAL(debugScriptResult(QString,sSysInfo)), &app_settingsWindow, SLOT(onScriptResult(QString,sSysInfo))); qDebug() << "init settings window\n"; SettingsWindow settingsWindow(&datamanager); QObject::connect(&trIcon, SIGNAL(showSettings()), &settingsWindow, SLOT(showNormal())); QObject::connect(&settingsWindow, SIGNAL(preferencesChange()), &datamanager, SLOT(onPreferencesChanged())); qDebug() << "init schedule window\n"; ScheduleWindow scheduleWindow(&datamanager,&schedule); QObject::connect(&datamanager, SIGNAL(profilesChanged()), &scheduleWindow, SLOT(rebuild())); QObject::connect(&trIcon, SIGNAL(showSchedule()), &scheduleWindow, SLOT(showNormal())); qDebug() << "init statistic window\n"; StatisticWindow statisticWindow(&datamanager); QObject::connect(&trIcon, SIGNAL(showStatistic()), &statisticWindow, SLOT(showNormal())); qDebug() << "init about window\n"; AboutWindow aboutWindow; QObject::connect(&trIcon, SIGNAL(showAbout()), &aboutWindow, SLOT(showNormal())); qDebug() << "init update window\n"; UpdateAvailableWindow updateAvailableWindow; QObject::connect(&updater, SIGNAL(newVersionAvailable(QString)), &updateAvailableWindow, SLOT(showUpdate(QString))); QObject::connect(&updateAvailableWindow, SIGNAL(ignoreUpdate()), &updater, SLOT(ignoreNewVersion())); qDebug() << "init notification window\n"; NotificationWindow notificationWindow(&datamanager); QObject::connect(&settingsWindow, SIGNAL(preferencesChange()), ¬ificationWindow, SLOT(onPreferencesChanged())); QObject::connect(&datamanager, SIGNAL(showNotification()), ¬ificationWindow, SLOT(onShow())); qDebug() << "start schedule\n"; schedule.start(); qDebug() << "start app loop\n"; int result = a.exec(); qDebug() << "application close\n"; return result; }
int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("SRFGames"); QCoreApplication::setOrganizationDomain("sol-online.org"), QCoreApplication::setApplicationName("TrackYourTime"); #ifdef Q_OS_MAC QDir dir(argv[0]); dir.cdUp(); QString currentDir = dir.absolutePath(); dir.cdUp(); dir.cd("PlugIns"); QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath())); #endif QApplication a(argc, argv); QApplication::setQuitOnLastWindowClosed(false); #ifdef Q_OS_MAC QDir::setCurrent(currentDir); #endif QSettings settings; QString Language = QLocale::system().name(); Language.truncate(Language.lastIndexOf('_')); Language = settings.value(cDataManager::CONF_LANGUAGE_ID,Language).toString(); if (settings.value(cDataManager::CONF_FIRST_LAUNCH_ID,true).toBool()){ settings.setValue(cDataManager::CONF_FIRST_LAUNCH_ID,false); settings.setValue(cDataManager::CONF_LANGUAGE_ID,Language); settings.setValue(cDataManager::CONF_AUTORUN_ID,true); setAutorun(); settings.sync(); } QTranslator translator; translator.load("lang_" + Language,QDir::currentPath()+"/data/languages"); QApplication::installTranslator(&translator); cDataManager datamanager; cTrayIcon trIcon(&datamanager); QObject::connect(&datamanager, SIGNAL(trayActive()), &trIcon, SLOT(setActive())); QObject::connect(&datamanager, SIGNAL(traySleep()), &trIcon, SLOT(setInactive())); QObject::connect(&datamanager, SIGNAL(trayShowHint(QString)), &trIcon, SLOT(showHint(QString))); QObject::connect(&datamanager, SIGNAL(profilesChanged()), &trIcon, SLOT(onProfilesChange())); ApplicationsWindow applicationsWindow(&datamanager); QObject::connect(&trIcon, SIGNAL(showApplications()), &applicationsWindow, SLOT(show())); QObject::connect(&datamanager, SIGNAL(profilesChanged()), &applicationsWindow, SLOT(onProfilesChange())); QObject::connect(&datamanager, SIGNAL(applicationsChanged()), &applicationsWindow, SLOT(onApplicationsChange())); ProfilesWindow profilesWindow(&datamanager); QObject::connect(&applicationsWindow, SIGNAL(showProfiles()), &profilesWindow, SLOT(show())); App_SettingsWindow app_settingsWindow(&datamanager); QObject::connect(&applicationsWindow, SIGNAL(showAppSettings(int)), &app_settingsWindow, SLOT(showApp(int))); QObject::connect(&datamanager, SIGNAL(debugScriptResult(QString,sSysInfo)), &app_settingsWindow, SLOT(onScriptResult(QString,sSysInfo))); SettingsWindow settingsWindow(&datamanager); QObject::connect(&trIcon, SIGNAL(showSettings()), &settingsWindow, SLOT(show())); QObject::connect(&settingsWindow, SIGNAL(preferencesChange()), &datamanager, SLOT(onPreferencesChanged())); StatisticWindow statisticWindow(&datamanager); QObject::connect(&trIcon, SIGNAL(showStatistic()), &statisticWindow, SLOT(show())); AboutWindow aboutWindow; QObject::connect(&trIcon, SIGNAL(showAbout()), &aboutWindow, SLOT(show())); int result = a.exec(); return result; }
bool MyApp::OnInit() { gAppHandler = this; wxString sFullModleName = ::wxGetFullModuleName(); wxString sAppName = this->GetAppName(); size_t nFind = sFullModleName.rfind(sAppName); gAppPath = sFullModleName.substr(0, nFind-1).c_str(); setAutorun(BIWOO_NAME.c_str(), sFullModleName.c_str()); wxString xmlFile(gAppPath); xmlFile.Append(wxT("/default/setting.xml")); gSetting.load(xmlFile.c_str()); setlocale(LC_ALL, gSetting.locale().c_str()); //setlocale(LC_ALL,"Chinese-simplified"); //std::locale::global(std::locale("Chinese-simplified")); CCgcAddress serverAddress(gSetting.address(), CCgcAddress::ST_UDP); if (!m_biwoo.start(serverAddress, (CbiwooHandler*)this)) { //m_biwoo.stop(); //return false; } xmlFile = gAppPath.c_str(); xmlFile.Append(wxT("/default/")); xmlFile.Append(gSetting.langtext()); gLangText.load(xmlFile.c_str()); ///////////////////////////////////// // test //CDlgSetting dlgSetting(NULL); //dlgSetting.ShowModal(); if ( !wxApp::OnInit() ) { m_biwoo.stop(); return false; } CDlglogin dlgLogin(NULL, false); int ret = dlgLogin.ShowModal(); if (ret != wxID_OK) { m_biwoo.stop(); wxApp::OnExit(); return false; } gMyAccount = dlgLogin.accountInfo(); BOOST_ASSERT (gMyAccount.get() != 0); // create the main application window MyFrame * frame = new MyFrame(_T("BIWOO App"), wxSize(700, 450)); m_biwoo.setHandler(gAppHandler); m_biwoo.accountLoad(); wxString title = wxString::Format("%s - %s(%s)", BIWOO_NAME.c_str(), gMyAccount->getUserinfo()->getUserName().c_str(), gMyAccount->getUserinfo()->getAccount().c_str()); frame->SetTitle(title); frame->setTaskBarIcon(wxT("mainframe.ico"), title); #if defined(__WXMOTIF__) int width, height; frame->GetSize(& width, & height); frame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height); #endif // and show it (the frames, unlike simple controls, are not shown when // created initially) frame->SetMinSize(wxSize(700, 450)); frame->Show(true); //SetTopWindow(frame); // success: wxApp::OnRun() will be called which will enter the main message // loop and the application will run. If we returned false here, the // application would exit immediately. return true; }