DataDisplayEditorForm::DataDisplayEditorForm(QWidget *parent) :
		QWidget(parent),
		ui(new Ui::DataDisplayEditorForm),
		current(NULL)
{
	ui->setupUi(this);


	connect(ui->displayTable, SIGNAL(clicked(QModelIndex)), this, SLOT(displayTableClicked(QModelIndex)));
	connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveCurrent()));
	connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addNewDataDisplay()));
	connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(deleteCurrent()));
	connect(ui->testButton, SIGNAL(clicked()), this, SLOT(testCurrent()));
        connect(&GnosticApp::getInstance(), SIGNAL(configUpdated(GnosticApp::ConfigType)), this, SLOT(externalUpdate(GnosticApp::ConfigType)));

	model.setHorizontalHeaderLabels(QStringList() << "Section" << "Display Description");
	ui->displayTable->setModel(&model);
	ui->displayTable->horizontalHeader()->setStretchLastSection(true);
	populateTable();

	ui->saveButton->setEnabled(false);
}
Esempio n. 2
0
void ZConfDlg::saveConfig() {
    printf("Entered the saveConfig function.\n");
    int retval;

    // Here I handle the storing of the value of Zaurus IP LineEdit.
    QString zaurusIp;
    zaurusIp = pZIpLineEdit->text();
    retval = confManager.SetValue("zaurus_ip", (char *)zaurusIp.ascii());
    if (retval != 0) {
        /*
	    QMessageBox::critical(0, "zync-gui",
			      QString("Failed to set zaurus_ip value. "));
        */
        printf("Foo BARRRRRRRR, failed to set the zaurus ip.\n");    
    }

    // Here I handle the storing of the value of the Conflict Winner ComboBox.
    QString confWin;
    // A variable used to store the proper value to save in the config file.
    QString saveConfWin;
    confWin = pConfWinComboBox->currentText();
    if (confWin == QString("Both")) {
	    saveConfWin = "both";
    } else if (confWin == QString("Zaurus")) {
	    saveConfWin = "zaurus";
    } else if (confWin == QString("Desktop")) {
	    saveConfWin = "desktop";
    }
    retval = confManager.SetValue("conflict_winner",
				  (char *)saveConfWin.ascii());
    if (retval != 0) {
	    QMessageBox::critical(0, "zync-gui",
			      QString("Failed to set conflict_winner value."));
    }


    // Here I handle the saving of the passcode status and value.
    if (pPasswdCheckBox->isChecked()) {
	    // Save the passcode
	    QString passcode;
	    passcode = pPasswdLineEdit->text();
	    retval = confManager.SetValue("passcode", (char *)passcode.ascii());
	    if (retval != 0) {
	        QMessageBox::critical(0, "zync-gui",
				  QString("Failed to set passcod value."));
	    }
    } else {
	    if (origConfigHasPass) {
	        // Delete the passcode from the config.
	        retval = confManager.DeleteItem("passcode");
	        if (retval != 0) {
		        QMessageBox::critical(0, "zync-gui",
				    QString("Failed to delete passcode item."));
		
	        }
	    }
    }

    // Here I handle the saving of the To-Do plugin ComboBox
    QString curPluginName;
    QString curPluginFileName;
    QString curPluginPath;
    curPluginName = pTodoPluginComboBox->currentText();
    curPluginFileName = todoPluginMap[curPluginName];
    curPluginPath = todoPluginPath + curPluginFileName;
    retval = confManager.SetValue("todo_plugin_path",
				  (char *)curPluginPath.ascii());
    if (retval != 0) {
	    QMessageBox::critical(0, "zync-gui",
			      QString("Failed to set todo_plugin_path value."));
    }
    
    retval = confManager.Save((char *)confPath.ascii());
    if (retval != 0) {
	    QMessageBox::critical(0, "zync-gui",
			      QString("Failed to save ") + confPath + ".");
	    reject();
    } else {
	    emit configUpdated();
	    accept();
    }

    printf("Exiting the saveConfig() function.\n");
}
Esempio n. 3
0
bool Application::initialize()
{
  int attempt = 0;
  bool retry;
  std::string path = config_->path().toLocal8Bit().data();
  
  do {
    retry = false;
    
    // try to load LDraw part library
    try {
      if (path.empty())
        library_ = new ldraw::part_library;
      else
        library_ = new ldraw::part_library(path);
    } catch (const ldraw::exception &) {
      QMessageBox *alert =
          new QMessageBox(QMessageBox::Critical,
                          tr("Error"),
                          tr("<qt>Unable to find LDraw part library. "
                             "If you have installed LDraw, please specify "
                             "your installation path.  If you have not "
                             "installed it, you can download it from "
                             "<a href=\"" LDRAW_DL_URL "\">" LDRAW_DL_URL "</a>.</qt>"),
                          QMessageBox::Ok);

      alert->exec();
      delete alert;
      
      QString newpath = QFileDialog::getExistingDirectory(0L, tr("Choose LDraw installation directory"));
      if (newpath.isEmpty()) {
        // Last attempt
        if (!config_->path().isEmpty()) {
          try {
            library_ = new ldraw::part_library;
          } catch (...) {
            return false;
          }
          
          config_->setPath("");
          config_->writeConfig();
        } else {
          return false;
        }
      } else {
        retry = true;
        path = newpath.toLocal8Bit().data();
        ++attempt;
      }
    }
  } while (retry);
  
  if (attempt) {
    config_->setPath(path.data());
    config_->writeConfig();
  }
  
  params_ = new ldraw_renderer::parameters();
  params_->set_shading(true);
  params_->set_shader(false);
  params_->set_vbuffer_criteria(ldraw_renderer::parameters::vbuffer_parts);
  
  configUpdated();
  
  testPovRay(true);

  DBUpdaterDialog dialog;
  dialog.start(forceRescan_);
  
  if (dialog.exec() == QDialog::Rejected)
    return false;

  db_->initialize(saveLocation("")+"parts.db");
  
  return true;
}
AREXPORT void ArServerHandlerConfig::reloadConfig(ArServerClient *client, 
                                                  ArNetPacket *packet)
{
  myConfig->parseFile(myConfig->getFileName(), true);
  configUpdated();
}
bool ArServerHandlerConfig::internalSetConfig(ArServerClient *client, 
					      ArNetPacket *packet)
{
  char param[1024];
  char argument[1024];
  char errorBuffer[1024];
  char firstError[1024];
  ArNetPacket retPacket;
  ArConfig *config;
  bool ret = true;

  if (client != NULL)
    config = myConfig;
  else
    config = myDefault;

  if (client != NULL)
    lockConfig();
  ArArgumentBuilder *builder = NULL;
  if (client != NULL)
    ArLog::log(ArLog::Normal, "Got new config from client %s", client->getIPString());
  else
    ArLog::log(ArLog::Verbose, "New default config");
  errorBuffer[0] = '\0';
  firstError[0] = '\0';

  while (packet->getDataReadLength() < packet->getDataLength())
  {
    packet->bufToStr(param, sizeof(param));  
    packet->bufToStr(argument, sizeof(argument));  

    builder = new ArArgumentBuilder;
    builder->setExtraString(param);
    builder->add(argument);
    ArLog::log(ArLog::Verbose, "Config: %s %s", param, argument);
    // if the param name here is "Section" we need to parse sections,
    // otherwise we parse the argument
    if ((strcasecmp(param, "Section") == 0 && 
        !config->parseSection(builder, errorBuffer, sizeof(errorBuffer))) ||
        (strcasecmp(param, "Section") != 0 &&
        !config->parseArgument(builder, errorBuffer, sizeof(errorBuffer))))
    {
      if (firstError[0] == '\0')
        strcpy(firstError, errorBuffer);
    }
    delete builder;
    builder = NULL;
  }
  if (firstError[0] == '\0')
  {
    if (config->callProcessFileCallBacks(true, 
                                           errorBuffer, 
                                           sizeof(errorBuffer)))
    {
      if (client != NULL)
	ArLog::log(ArLog::Normal, "New config from client %s was fine.",
		   client->getIPString());
      else
	ArLog::log(ArLog::Verbose, "New default config was fine.");
      retPacket.strToBuf("");
      writeConfig();
    }
    else // error processing config callbacks
    {
      ret = false;
      if (firstError[0] == '\0')
        strcpy(firstError, errorBuffer);
      // if its still empty it means we didn't have anything good in the errorBuffer
      if (firstError[0] == '\0')
        strcpy(firstError, "Error processing");

      if (client != NULL)
	ArLog::log(ArLog::Normal, 
		   "New config from client %s had errors processing ('%s').",
		   client->getIPString(), firstError);
      else
	ArLog::log(ArLog::Normal, 
		   "New default config had errors processing ('%s').",
		   firstError);
      retPacket.strToBuf(firstError);
    }
  }
  else
  {
    ret = false;
    if (client != NULL)
      ArLog::log(ArLog::Normal, 
		 "New config from client %s had at least this problem: %s", 
		 client->getIPString(), firstError);
    else
      ArLog::log(ArLog::Normal, 
		 "New default config had at least this problem: %s", 
		 firstError);
    retPacket.strToBuf(firstError);
  }
  //printf("Sending ");
  //retPacket.log();
  if (client != NULL)
    client->sendPacketTcp(&retPacket);
  if (client != NULL)
    unlockConfig();
  if (client != NULL)
    configUpdated(client);

  return ret;
}
Esempio n. 6
0
void Config::setKey(GameKeys gameKey, Qt::Key key)
{
	removeKey(key);
	config_[gameKey] = key;
	emit configUpdated();
}