Beispiel #1
0
void ViewLoading::openLoginDialog()
{
  // Allow the user to attempt to login. Cancelling the login will quit the client
  DlgLogin* pLogin = new DlgLogin(this);

  int nResult = pLogin->exec();
  if ( nResult == QDialog::Accepted)
  {
    addLogItem( ResourceManager::instance().getClientString( STR_LOGIN_ATTEMPTING ) );
    emit attemptLogin( pLogin->getUsername(), pLogin->getPassword() );
  }
  else
  {
    // we need to shutdown
    FCAPP->quit();
  }
}
Beispiel #2
0
int main(int argc, char *argv[]) {

  QApplication::setApplicationName("SubutaiTray");
  QApplication::setOrganizationName("subut.ai");
  QApplication app(argc, argv);

  QCommandLineParser cmd_parser;

  cmd_parser.setApplicationDescription("This tray application should help users to work with hub");
  QCommandLineOption log_level_opt("l",
                                   "Log level can be TRACE (0), INFO (1) and ERROR (2). Trace is most detailed logs.",
                                   "log_level",
                                   "ERROR");
  QCommandLineOption version_opt("v",
                                 "Version",
                                 "Version");

  cmd_parser.addOption(log_level_opt);
  cmd_parser.addPositionalArgument("log_level", "Log level to use in this application");
  cmd_parser.addOption(version_opt);
  cmd_parser.addHelpOption();
  cmd_parser.parse(QApplication::arguments());

  CApplicationLog::Instance()->SetDirectory(QApplication::applicationDirPath().toStdString().c_str());

  QString ll = cmd_parser.value(log_level_opt).toLower().trimmed();
  if(ll == "trace" || ll == "0")
    CApplicationLog::Instance()->SetLogLevel(CApplicationLog::LT_TRACE);
  else if (ll == "info" || ll == "1")
    CApplicationLog::Instance()->SetLogLevel(CApplicationLog::LT_INFO);
  else if (ll == "error" || ll == "2")
    CApplicationLog::Instance()->SetLogLevel(CApplicationLog::LT_ERROR);

  if (cmd_parser.isSet(version_opt)) {
    std::cout << GIT_VERSION << std::endl;
    return 0;
  }
  CApplicationLog::Instance()->LogTrace("Tray application %s launched\n", GIT_VERSION);

  app.setQuitOnLastWindowClosed(false);
  qRegisterMetaType<com::Bstr>("com::Bstr");  

  QString tmp_file_path = CCommons::AppNameTmp();

  QFile tmp_file(tmp_file_path);
  if (tmp_file.exists()) {
    if (!tmp_file.remove()) {
      CApplicationLog::Instance()->LogError("Couldn't remove file %s", tmp_file_path.toStdString().c_str());
    }
  }

  DlgLogin dlg;
  dlg.setModal(true);
  dlg.exec();
  if (dlg.result() == QDialog::Rejected)
    return 0;

  CTrayServer::Instance()->Init();
  CVBoxManagerSingleton::Instance()->init_com();
  TrayControlWindow tcw;
  return app.exec();
}