Exemple #1
0
eQEP::eQEP(int eQEP_address):
eQEP_address_(eQEP_address)
{
  if (eQEP_address_ < 3) {
    switch (eQEP_address_) {
    case 0:
      eQEP_address_ = eQEP0;
      break;
    case 1:
      eQEP_address_ = eQEP1;
      break;
    case 2:
      eQEP_address_ = eQEP2;
      break;
    }
  }
  active = false;
  eQEPFd = open("/dev/mem", O_RDWR | O_SYNC);
  if (eQEPFd < 0)
  {
    debug(0, "eQEP class: Can't open /dev/mem\n");
    return;
  }
  
  // Map the PWM memory range
  map_pwm_register();
  eqep_addr = pwm_addr + (eQEP_address_ & (getpagesize()-1));
  position_p = (uint32_t *) (eqep_addr + EQEP_QPOSCNT);
  
  debug(2, "eQEP successfully activated\n");
  defaultSettings();
  active = true;
}
// seteaza pozitie, rotatie, translatie
Object3D::Object3D(Vector3D *_translation, Vector3D *_rotation, Vector3D *_scale)
{
	defaultSettings();
	this->SetPosition(_translation);
	this->SetRotation(_rotation);
	this->SetScale(_scale);	
}
Exemple #3
0
void FilmGrainSettings::readSettings(KConfigGroup& group)
{
    FilmGrainContainer prm;
    FilmGrainContainer defaultPrm = defaultSettings();

    prm.grainSize               = group.readEntry(d->configGrainSizeEntry,                      defaultPrm.grainSize);
    prm.photoDistribution       = group.readEntry(d->configPhotoDistributionEntry,              defaultPrm.photoDistribution);
    prm.addLuminanceNoise       = group.readEntry(d->configAddLumNoiseEntry,                    defaultPrm.addLuminanceNoise);
    prm.lumaIntensity           = group.readEntry(d->configIntensityLumAdjustmentEntry,         defaultPrm.lumaIntensity);
    prm.lumaShadows             = group.readEntry(d->configShadowsLumAdjustmentEntry,           defaultPrm.lumaShadows);
    prm.lumaMidtones            = group.readEntry(d->configMidtonesLumAdjustmentEntry,          defaultPrm.lumaMidtones);
    prm.lumaHighlights          = group.readEntry(d->configHighlightsLumAdjustmentEntry,        defaultPrm.lumaHighlights);
    prm.addChrominanceBlueNoise = group.readEntry(d->configAddChromaBlueNoiseEntry,             defaultPrm.addChrominanceBlueNoise);
    prm.chromaBlueIntensity     = group.readEntry(d->configIntensityChromaBlueAdjustmentEntry,  defaultPrm.chromaBlueIntensity);
    prm.chromaBlueShadows       = group.readEntry(d->configShadowsChromaBlueAdjustmentEntry,    defaultPrm.chromaBlueShadows);
    prm.chromaBlueMidtones      = group.readEntry(d->configMidtonesChromaBlueAdjustmentEntry,   defaultPrm.chromaBlueMidtones);
    prm.chromaBlueHighlights    = group.readEntry(d->configHighlightsChromaBlueAdjustmentEntry, defaultPrm.chromaBlueHighlights);
    prm.addChrominanceRedNoise  = group.readEntry(d->configAddChromaRedNoiseEntry,              defaultPrm.addChrominanceRedNoise);
    prm.chromaRedIntensity      = group.readEntry(d->configIntensityChromaRedAdjustmentEntry,   defaultPrm.chromaRedIntensity);
    prm.chromaRedShadows        = group.readEntry(d->configShadowsChromaRedAdjustmentEntry,     defaultPrm.chromaRedShadows);
    prm.chromaRedMidtones       = group.readEntry(d->configMidtonesChromaRedAdjustmentEntry,    defaultPrm.chromaRedMidtones);
    prm.chromaRedHighlights     = group.readEntry(d->configHighlightsChromaRedAdjustmentEntry,  defaultPrm.chromaRedHighlights);

    setSettings(prm);
}
Exemple #4
0
void MixerSettings::readSettings(KConfigGroup& group)
{
    MixerContainer prm;
    MixerContainer defaultPrm = defaultSettings();

    prm.bMonochrome    = group.readEntry(d->configMonochromeEntry,         defaultPrm.bMonochrome);
    prm.bPreserveLum   = group.readEntry(d->configPreserveLuminosityEntry, defaultPrm.bPreserveLum);

    prm.redRedGain     = group.readEntry(d->configRedRedGainEntry,         defaultPrm.redRedGain);
    prm.redGreenGain   = group.readEntry(d->configRedGreenGainEntry,       defaultPrm.redGreenGain);
    prm.redBlueGain    = group.readEntry(d->configRedBlueGainEntry,        defaultPrm.redBlueGain);

    prm.greenRedGain   = group.readEntry(d->configGreenRedGainEntry,       defaultPrm.greenRedGain);
    prm.greenGreenGain = group.readEntry(d->configGreenGreenGainEntry,     defaultPrm.greenGreenGain);
    prm.greenBlueGain  = group.readEntry(d->configGreenBlueGainEntry,      defaultPrm.greenBlueGain);

    prm.blueRedGain    = group.readEntry(d->configBlueRedGainEntry,        defaultPrm.blueRedGain);
    prm.blueGreenGain  = group.readEntry(d->configBlueGreenGainEntry,      defaultPrm.blueGreenGain);
    prm.blueBlueGain   = group.readEntry(d->configBlueBlueGainEntry,       defaultPrm.blueBlueGain);

    prm.blackRedGain   = group.readEntry(d->configBlackRedGainEntry,       defaultPrm.blackRedGain);
    prm.blackGreenGain = group.readEntry(d->configBlackGreenGainEntry,     defaultPrm.blackGreenGain);
    prm.blackBlueGain  = group.readEntry(d->configBlackBlueGainEntry,      defaultPrm.blackBlueGain);

    setSettings(prm);
}
Exemple #5
0
Firewall::Firewall() : flood_messages(0), right_after_connection(false)
{
	kdebugf();
	
	loadSecuredList();

	lastMsg.start();
	lastNotify.start();

	pattern.setCaseSensitive(false);
	pattern.setPattern(unicode2std(config_file.readEntry("Firewall", "answer", tr("I want something"))));

	Protocol *gadu = AccountManager::instance()->defaultAccount()->protocol();
	connect(gadu, SIGNAL(rawGaduReceivedMessageFilter(Protocol *, UserListElements, QString&, QByteArray&, bool&)), this, SLOT(messageFiltering(Protocol *, UserListElements, QString&, QByteArray&, bool&)));
	connect(gadu, SIGNAL(sendMessageFiltering(const UserListElements, QByteArray &, bool &)), this, SLOT(sendMessageFilter(const UserListElements, QByteArray &, bool &)));
 	connect(chat_manager, SIGNAL(chatWidgetDestroying(ChatWidget *)), this, SLOT(chatDestroyed(ChatWidget *)));

	connect(userlist, SIGNAL(userDataChanged(UserListElement, QString, QVariant, QVariant, bool, bool)), this, SLOT(userDataChanged(UserListElement, QString, QVariant, QVariant, bool, bool)));
	connect(userlist, SIGNAL(userAdded(UserListElement, bool, bool)), this, SLOT(userAdded(UserListElement, bool, bool)));
	connect(userlist, SIGNAL(userRemoved(UserListElement, bool, bool)), this, SLOT(userRemoved(UserListElement, bool, bool)));

	
	connect(gadu, SIGNAL(connecting()), this, SLOT(connecting()));
	connect(gadu, SIGNAL(connected()), this, SLOT(connected()));

	defaultSettings();
	
	kdebugf2();
	
}
Exemple #6
0
void SettingsTest::testUpgrade_data(){
  // Read recipe
  QFile recipe(":/testdata/upgrade/recipe");
  QVERIFY(recipe.open(QIODevice::ReadOnly));
  QList<UpgradeTestHelper::TestCase> testCases = UpgradeTestHelper::readRecipe(&recipe);

  // Generate settings file according to recipe
  QTemporaryFile settingsFile;
  QVERIFY(settingsFile.open() == true);

  QSettings settings(settingsFile.fileName(), QSettings::IniFormat);

  UpgradeTestHelper::fillSettings(&settings, testCases);

  // Generate defaults file according to recipe
  QTemporaryFile defaultSettingsFile;
  QVERIFY(defaultSettingsFile.open() == true);

  QSettings defaultSettings(defaultSettingsFile.fileName(), QSettings::IniFormat);

  UpgradeTestHelper::fillDefaultSettings(&defaultSettings, testCases);

  // Parse settings -- do upgrade
#if 0
  settingsFile.seek(0);
  defaultSettingsFile.seek(0);
  qDebug() << "SETTINGS {{{\n" << settingsFile.readAll() << "\n}}}";
  qDebug() << "DEFAULT SETTINGS {{{\n" << defaultSettingsFile.readAll() << "\n}}}";
#endif

  SsuSettings ssuSettings(settingsFile.fileName(), QSettings::IniFormat,
      defaultSettingsFile.fileName());

#if 0
  settingsFile.seek(0);
  qDebug() << "SETTINGS UPGRADED {{{\n" << settingsFile.readAll() << "\n}}}";
#endif

  // Record data for verification phase
  QTest::addColumn<bool>("keyIsSet");
  QTest::addColumn<bool>("keyShouldBeSet");
  QTest::addColumn<QString>("actualValue");
  QTest::addColumn<QString>("expectedValue");

  foreach (const UpgradeTestHelper::TestCase &testCase, testCases){
    foreach (const QString &group, UpgradeTestHelper::groups()){
      const QString key = group.isEmpty() ? testCase.key() : group + '/' + testCase.key();
      QTest::newRow(qPrintable(QString("%1%2:%3:%4")
          .arg(group.isEmpty() ? "" : group + "/")
          .arg(testCase.history())
          .arg(testCase.current())
          .arg(testCase.expected())))
        << ssuSettings.contains(key)
        << testCase.keyShouldBeSet()
        << ssuSettings.value(key).toString()
        << testCase.expected();
    }
  }
Exemple #7
0
void NoiseGen::reloadDefaultSettings()
{
    defaultSettings();
    std::cout << "loaded default settings\n";
    initTerrainSlider(); // memory leak?
    std::cout << "initialized terrain slider\n";
    updateSliders(NULL);
    std::cout << "updated sliders\n";
    //refresh = true;
}
Exemple #8
0
NoiseGen::NoiseGen()
{

    //init seed
    srand( time(NULL) );

    IMAGE_SIZE = 256;
    IMAGE_SCALE = 2;

    terrainmode = false;
    //paramvalues.resize(9);
    terSlider = NULL;

    //load settings
    defaultSettings(); // load hardcoded defaults first
    loadSettings(); // load settings file, if one is not found, create one

    //init screen
    screen = new sf::RenderWindow( sf::VideoMode(IMAGE_SIZE*IMAGE_SCALE+RIGHT_MARGIN_WIDTH,IMAGE_SIZE*IMAGE_SCALE+BOTTOM_MARGIN_HEIGHT,32), "Simplex Noise");
    screen->setIcon(sfml_icon.width, sfml_icon.height, sfml_icon.pixel_data);
    mapTexture = new sf::RenderTexture;
    mapTexture->create(IMAGE_SCALE*IMAGE_SIZE, IMAGE_SCALE*IMAGE_SIZE);
    mapTexture->display();

    //load font
    font.loadFromFile("font.ttf");



    //init terrain colors
    /*
    terraincolors.push_back(sf::Color(0,0,120)); // deep water
    terraincolors.push_back(sf::Color(0,0,220)); // shallow water
    terraincolors.push_back(sf::Color(200,200,0)); // sand
    terraincolors.push_back(sf::Color(200,120,50)); // dirt
    terraincolors.push_back(sf::Color(0,220,0)); // low grass
    terraincolors.push_back(sf::Color(0,120,0)); // high grass
    terraincolors.push_back(sf::Color(120,120,120)); // low mtn
    terraincolors.push_back(sf::Color(200,200,200)); // high mtn
    terraincolors.push_back(sf::Color(245,245,245)); // mtn tops
    */

    //other object inits
    initSliders();
    initTerrainSlider();
    initButtons();

    //start main loop
    mainLoop();
}
StripToolVariable::StripToolVariable(StripToolVariableInfo *info, QObject *parent) :
    QObject(parent)
{
    info_ = 0;
    data_ = 0;
    series_ = 0;

    setInfo(info);

    buildComponents();
    makeConnections();
    defaultSettings();

    qDebug() << "StripToolVariable object created.";
}
/*-----------------------------------------------------------------------------
name        :getCoutStatement
description :return string representing a converted printf into cout
parameters  :/
return      :string
exceptions  :/
algorithm   :
-----------------------------------------------------------------------------*/
string PrintConverter::getCoutStatement(){
  string retStr="cout<<";
  
  if( format.size() < 3 ){ //special case for empty format string
    retStr = "cout << \"\"";
    for( unsigned int i = 0; i<args.size();i++){
      retStr+="<<"+args[i].getArg();
    }  
    retStr += ";";
    
    return retStr;  
  }
  
  string outStr="";
  format=string(format,1,format.size()-2); //strip leading and trailing "
  string coutFormatSpec="";
  while(pos<format.size()){
    if(isFormatSpec(coutFormatSpec)){
      //copy the string and an argument after it
      retStr+="\""+outStr+"\"<<";
      outStr="";
      if(argpos<args.size()){
        if((coutFormatSpec.size()>0)||(flags.size()>0)){
          retStr+=customFlags();
          retStr+=coutFormatSpec; //stream formatting string
          retStr+=args[argpos].getArg()+
                  ";\n"+defaultSettings();
        }
        else{
          retStr+=args[argpos].getArg()+"<<";
        }
      }
      else{
        cerr<<"not enough arguments corresponding to format string of cout"<<endl;
        return retStr;
      }
      argpos++;
    }//if(isFormatSpec...
    if(pos<format.size()) outStr+=format[pos];
    pos++;
  }
  retStr+="\""+outStr+"\";"; //output the remaining text in outStr and flush
  
  return retStr;
}
Exemple #11
0
void NRSettings::readSettings(KConfigGroup& group)
{
    NRContainer prm;
    NRContainer defaultPrm = defaultSettings();
    prm.thresholds[0]      = group.readEntry(d->configThrLumInputAdjustmentEntry,  defaultPrm.thresholds[0]);
    prm.thresholds[1]      = group.readEntry(d->configThrCbInputAdjustmentEntry,   defaultPrm.thresholds[1]);
    prm.thresholds[2]      = group.readEntry(d->configThrCrInputAdjustmentEntry,   defaultPrm.thresholds[2]);
    prm.softness[0]        = group.readEntry(d->configSoftLumInputAdjustmentEntry, defaultPrm.softness[0]);
    prm.softness[1]        = group.readEntry(d->configSoftCbInputAdjustmentEntry,  defaultPrm.softness[1]);
    prm.softness[2]        = group.readEntry(d->configSoftCrInputAdjustmentEntry,  defaultPrm.softness[2]);

    bool b                 = group.readEntry(d->configCheckAutoEstimationEntry,    false);
    d->checkAutoEst->setChecked(b);
    slotDisableParameters(b);

    if (!b)
        setSettings(prm);
}
Exemple #12
0
void XSettingsModel::read_default_ini()
{
	QString defaultSettings("");
	switch (mainObject->runningOs()) {
		case OS_MAC:
			defaultSettings = ":/default/osx_default.ini";
			break;
		case OS_WINDOWS:
			defaultSettings = ":/default/win_default.ini";
			break;
		case OS_LINUX:
			defaultSettings = ":/default/x_default.ini";
			break;
		default:
			outLog("*** FGx shout: No default settings for this system");
			break;
	}
	
	QSettings settings(defaultSettings,QSettings::IniFormat);

	bool ena;
	for(int row_idx=0; row_idx < rowCount(); row_idx++){
		//= loop rows and load each "option" as an [ini section] with enabled, value as values
		settings.beginGroup(item(row_idx, C_OPTION)->text());
			ena = settings.value("enabled").toBool() ;
			item(row_idx, C_ENABLED)->setText( ena ? "1" : "0");
			QString val = settings.value("value").toString();
			if(val == ""){
				val = item(row_idx, C_DEFAULT)->text();
			}
			item(row_idx, C_VALUE)->setText(val );
			set_row_bg(row_idx, ena ? QColor(200,255,200) : QColor(240,240,240));
			//= Broadcast changes
			emit upx(item(row_idx, C_OPTION)->text(),
					 item(row_idx, C_ENABLED)->text() == "1",
					 item(row_idx, C_VALUE)->text()
					 );
		settings.endGroup();
	}
	//qDebug() << "Read ini";
	emit updated(get_fgfs_list());
	
}
ShutterToolMainWindow::ShutterToolMainWindow(QWidget *parent)
	: QWidget(parent)
{
	setAttribute(Qt::WA_ShowWithoutActivating);

	model_ = 0;
	mainLayout_ = 0;

	appStatusLabel_ = 0;
	enableAutomaticShuttersOpenButton_ = 0;
	enableAutomaticShuttersOpenButton_ = 0;

	shuttersStatusLabel_ = 0;
	openShuttersButton_ = 0;
	closeShuttersButton_ = 0;

	createComponents();
	defaultSettings();
	makeConnections();
}
// Constructor
ViewerWindow::ViewerWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::ViewerWindow)
{
    // Set the user interface from Qt Designer
    ui->setupUi(this);
    ui->centralWidget->setVisible(false);



    // Default Value for Settings
    defaultSettings();

    // Settings
    readSettings();



    myCloudList = new CloudListModel();
    ui->myCloudList->setModel(myCloudList);
    ui->myCloudViewer->setModel(myCloudList);

}
Exemple #15
0
void MysqLoader::on_defaultButton_clicked()
{
	QMessageBox msgBox;

        msgBox.setWindowTitle(trUtf8("Vorgang bestätigen"));
	msgBox.setText(trUtf8("<b>Alle Werte werden auf die "
						  "Standardeinstellungen zurück gesetzt!</b>"));

	msgBox.setIcon(QMessageBox::Question);
	msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
	msgBox.setDefaultButton(QMessageBox::Yes);
	int ret = msgBox.exec();
	switch (ret) {
	case QMessageBox::Yes:
		defaultSettings();
		break;
	case QMessageBox::No:
		msgBox.close();
		break;
	default:
		break;
	}
}
Exemple #16
0
StripTool::StripTool(QWidget *parent) : QWidget(parent)
{
	appDirectory_ = 0;

	model_ = 0;
	mainView_ = 0;
	importer_ = 0;
	exporter_ = 0;
	editor_ = 0;

	setAppDirectory(QDir(QDir::homePath()).filePath("StripTool"));

	buildComponents();
	makeConnections();
	defaultSettings();

	QVBoxLayout *windowLayout = new QVBoxLayout();
	windowLayout->addWidget(mainView_);

	setLayout(windowLayout);
	resize(800, 500);

	qDebug() << "StripTool object created.";
}
Exemple #17
0
Vehicle::Vehicle(char *cullorder):Primitiva(data,cullorder)
{
	vector<float> defaultSettings(4,0.5);
	m = new Material(NULL,  defaultSettings, defaultSettings, defaultSettings, defaultSettings, 1, 1, 1, GL_FRONT_AND_BACK);
	m2 = new Material(NULL,  defaultSettings, defaultSettings, defaultSettings, defaultSettings, 1, 1, 1, GL_FRONT_AND_BACK);

	vector<float> data;
	data.push_back(-BALLOON_SIDE/2.0);
	data.push_back(-BALLOON_SIDE/2.0);
	data.push_back(BALLOON_SIDE/2.0);
	data.push_back(BALLOON_SIDE/2.0);

	f1 = new Rectangle(data, cullorder, "flat");
	f2 = new Rectangle(data, cullorder, "flat");
	f3 = new Rectangle(data, cullorder, "flat");
	f4 = new Rectangle(data, cullorder, "flat");
	f5 = new Rectangle(data, cullorder, "flat");






}
Exemple #18
0
int Calculator::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: decSystem(); break;
        case 1: binSystem(); break;
        case 2: octSystem(); break;
        case 3: hexSystem(); break;
        case 4: realSystem(); break;
        case 5: complexSystem(); break;
        case 6: hyperbolicSystem(); break;
        case 7: changeLanguage((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: changePrecision(); break;
        case 9: inputNumOne(); break;
        case 10: inputNumTwo(); break;
        case 11: inputNumThree(); break;
        case 12: inputNumFour(); break;
        case 13: inputNumFive(); break;
        case 14: inputNumSix(); break;
        case 15: inputNumSeven(); break;
        case 16: inputNumEight(); break;
        case 17: inputNumNine(); break;
        case 18: inputNumZero(); break;
        case 19: inputNumA(); break;
        case 20: inputNumB(); break;
        case 21: inputNumC(); break;
        case 22: inputNumD(); break;
        case 23: inputNumE(); break;
        case 24: inputNumF(); break;
        case 25: inputNumI(); break;
        case 26: inputNumEi(); break;
        case 27: inputPoint(); break;
        case 28: inputOperAdd(); break;
        case 29: inputOperSubtract(); break;
        case 30: inputOperMultiply(); break;
        case 31: inputOperDivide(); break;
        case 32: inputOperMod(); break;
        case 33: inputOperDiv(); break;
        case 34: inputOperPercent(); break;
        case 35: inputOperFact(); break;
        case 36: inputOperComb(); break;
        case 37: inputOperPower(); break;
        case 38: inputOperSqr(); break;
        case 39: inputOperCub(); break;
        case 40: inputOperExpE(); break;
        case 41: inputOperExp10(); break;
        case 42: inputOperSqrt(); break;
        case 43: inputOperCur(); break;
        case 44: inputOperXYsqrt(); break;
        case 45: inputFunSin(); break;
        case 46: inputFunCos(); break;
        case 47: inputFunTan(); break;
        case 48: inputFunCot(); break;
        case 49: inputFunArcSin(); break;
        case 50: inputFunArcCos(); break;
        case 51: inputFunArcTan(); break;
        case 52: inputFunArcCot(); break;
        case 53: inputFunLg(); break;
        case 54: inputFunLn(); break;
        case 55: inputFunLog(); break;
        case 56: inputFunAbs(); break;
        case 57: inputFunPow(); break;
        case 58: inputFunGcd(); break;
        case 59: inputFunLcm(); break;
        case 60: inputLeftBack(); break;
        case 61: inputRightBack(); break;
        case 62: inputConst_e(); break;
        case 63: inputConst_g(); break;
        case 64: inputConst_pi(); break;
        case 65: inputConstant(); break;
        case 66: clearExpress(); break;
        case 67: backspace(); break;
        case 68: redo(); break;
        case 69: undo(); break;
        case 70: fold(); break;
        case 71: insertNewResult(); break;
        case 72: insertMemorySystem(); break;
        case 73: insertMemoryResult(); break;
        case 74: getResult(); break;
        case 75: showHistory(); break;
        case 76: showVariable(); break;
        case 77: showConstant(); break;
        case 78: setTopHint(); break;
        case 79: windowColorChange((*reinterpret_cast< QColor(*)>(_a[1]))); break;
        case 80: textviewColorChange((*reinterpret_cast< QColor(*)>(_a[1]))); break;
        case 81: expressionFontChange((*reinterpret_cast< QFont(*)>(_a[1]))); break;
        case 82: defaultSettings(); break;
        case 83: showFontDialog(); break;
        case 84: showWindowColorDialog(); break;
        case 85: showTextViewColorDialog(); break;
        case 86: setData(); break;
        case 87: setHistoryIndex(); break;
        case 88: getHugeCalcWidget(); break;
        case 89: getLinearAlgebraWidget(); break;
        case 90: getnonLinearAlgebraWidget(); break;
        case 91: help(); break;
        case 92: about(); break;
        case 93: giveSuggestions(); break;
        case 94: ElseTools(); break;
        default: ;
        }
        _id -= 95;
    }
    return _id;
}
Exemple #19
0
void MenuStateMachine(void){
    uint8_t u8ExitWithoutSavingFlag = TRUE;
    uint8_t u8MemCommand;
    static uint32_t u32defaultSettingsInitialValue;
    static uint8_t u8checkForDefaultSettings = FALSE;
    uint32_t u32TickCount;

    //Check to see if the encoder moved
    if(i8MenuChangeFlag != 0 && i8SubMenuState == SUBMENU_NOT_SELECTED){
        changeMainMenuState();
        resetBlink();
    }

    //Check to see if the encoder switch is held down for 3 seconds. This is
    //the mechanism for defaulting the menu.
    if(u8MenuKeyPressFlag == TRUE){
        //Start the timer.
        u32TickCount = xTaskGetTickCount();
        u32defaultSettingsInitialValue = u32TickCount;
        u8checkForDefaultSettings = TRUE;
    }else{
        //If the switch continues to be held down for 3 seconds, default the settings and exit the menu.
        if(u8checkForDefaultSettings == TRUE){
            if(!READ_ENC_SWITCH){//Switch is held down.
                //Increment the timer
                u32TickCount = xTaskGetTickCount();
                if((u32TickCount - u32defaultSettingsInitialValue) > DEFAULT_SETTINGS_TIME_LENGTH){
                    defaultSettings();
                    u8ExitWithoutSavingFlag = FALSE;
                    u8MenuExitFlag = TRUE;
                    u8checkForDefaultSettings = FALSE;
                }
            }else{
                u8checkForDefaultSettings = FALSE;
            }
        }
    }

    switch(i8MainMenuState){
        case X_MENU:
        case Y_MENU:
        case Z_MENU:
            //Handle the encoder switch press
            if(u8MenuKeyPressFlag == TRUE){
                u8MenuKeyPressFlag = FALSE;
                //If no submenu has been selected, enter submenu mode
                if(i8SubMenuState == SUBMENU_NOT_SELECTED){
                    i8SubMenuState = RANGE;
                    setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON);
                    setLEDState(u8XYZSubMenuMapping[i8SubMenuState-1], BLINK);
                }
                else if(u8ParameterEditModeFlag == FALSE){
                    //Enter the submenu and modify the parameter
                    u8ParameterEditModeFlag = TRUE;
                    setLEDState(u8XYZSubMenuMapping[i8SubMenuState-1], ON);
                    initializeXYZParameterMode();
                }
                else{
                    //Lock in the selection and exit the menu.
                    u8ExitWithoutSavingFlag = FALSE;
                    u8MenuExitFlag = TRUE;
                }
            }

            //If it made it this far, then it's changing submenus
            if(i8MenuChangeFlag != 0){
                //If we're not in parameter edit mode
                if(u8ParameterEditModeFlag == FALSE){
                    changeXYZSubMenuState();
                    resetBlink();
                }
                else{
                    editXYZParameter(i8SubMenuState);
                }
            }  
            break;
        case RECORD_MENU:
        case OVERDUB_MENU:
        case PLAYBACK_MENU:
            //Handle the encoder switch press
            if(u8MenuKeyPressFlag == TRUE){
                u8MenuKeyPressFlag = FALSE;
                //If no submenu has been selected, enter submenu mode
                if(i8SubMenuState == SUBMENU_NOT_SELECTED){
                    i8SubMenuState = SOURCE;
                    setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON);
                    setLEDState(u8PlaySubMenuMapping[i8SubMenuState-1], BLINK);
                }
                else if(u8ParameterEditModeFlag == FALSE){
                    //Enter the submenu and modify the parameter
                    u8ParameterEditModeFlag = TRUE;
                    setLEDState(u8PlaySubMenuMapping[i8SubMenuState-1], ON);
                    initializeRecParameterMode(i8MainMenuState-RECORD_MENU);
                }
                else{
                    //Locking in the change and exiting the menu.
                    u8ExitWithoutSavingFlag = FALSE;
                    u8MenuExitFlag = TRUE;
                }
            }

            //If it made it this far, then it's changing submenus
            if(i8MenuChangeFlag != 0){
                //If we're not in parameter edit mode
                if(u8ParameterEditModeFlag == FALSE){
                    changeRecSubMenuState();
                    resetBlink();
                }
                else{
                    editRecParameter(i8MainMenuState-RECORD_MENU);
                }
            }
            break;
        case LOAD_MENU:
        case STORE_MENU:
            //Store a sequence
            /*The first key press enters the mode. The next one issues a store
             * command*/
            if(u8MenuKeyPressFlag == TRUE){
                u8MenuKeyPressFlag = FALSE;
                if(i8MainMenuState == LOAD_MENU){
                    if(u8LoadModeFlag == FALSE){
                        //u8LoadModeFlag = TRUE;
                        /*Set the LEDs on for locations which have a stored sequence. Flash 
                         the currently selected LED.*/
                        u8LoadModeFlag = initializeLoadStoreMode();
                        if(u8LoadModeFlag == 1){
                            i8SubMenuState = 1;
                        }
                    }
                    else{
                        //Load the sequence
                        flashLoadSequence(u8LoadStoreParameter);
                        u8LoadModeFlag = FALSE;
                        u8MenuExitFlag = TRUE;
                    }
                }else{
                    if(u8StoreModeFlag == FALSE){
                        //u8StoreModeFlag = TRUE;
                        u8StoreModeFlag = initializeLoadStoreMode();
                        if(u8StoreModeFlag == 1){
                            i8SubMenuState = 1;
                        }
                    }
                    else{
                        //Store the sequence
                        flashStoreSequence(u8LoadStoreParameter, getLengthOfRecording());
                        u8StoreModeFlag = FALSE;
                        u8MenuExitFlag = TRUE;
                    }
                }
            }

            //Handle the encoder
            if(u8StoreModeFlag == TRUE || u8LoadModeFlag == TRUE){
                if(i8MenuChangeFlag != 0){
                    editLoadStoreParameter();
                }
            }
            else{
                i8MenuChangeFlag = 0;
            }

            break;
        case EFFECT_MENU:
            if(u8MenuKeyPressFlag == TRUE){
                u8MenuKeyPressFlag = FALSE;

                if(u8EffectModeFlag == FALSE){
                    i8SubMenuState = 1;
                    u8EffectModeFlag = TRUE;
                    setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON);
                    initializeEffectMode();
                }
                else{
                    //Set the effect mode
                    u8EffectModeFlag = FALSE;
                    //Locking in the change and exiting the menu.
                    u8ExitWithoutSavingFlag = FALSE;
                    u8MenuExitFlag = TRUE;
                }

            }

            //Handle the encoder
            if(u8EffectModeFlag == TRUE){
                if(i8MenuChangeFlag != 0){
                    editEffectParameter();
                }
            }
            else{
                i8MenuChangeFlag = 0;
            }
            break;
        case CLOCK_MENU:
            if(u8MenuKeyPressFlag == TRUE){
                u8MenuKeyPressFlag = FALSE;

                if(i8SubMenuState == SUBMENU_NOT_SELECTED){
                    u8ClockModeFlag = TRUE;
                    i8SubMenuState = SYNC;
                    setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON);
                    setLEDState(u8LEDMainMenuMapping[i8SubMenuState-1], BLINK);
                }
                else if(u8ParameterEditModeFlag == FALSE){
                    //Enter the submenu and modify the parameter
                    u8ParameterEditModeFlag = TRUE;
                    setLEDState(u8LEDMainMenuMapping[i8SubMenuState-1], ON);
                    initializeClockMode();
                }
                else{
                    //Set the effect mode
                    u8ClockModeFlag = FALSE;
                    //Locking in the change and exiting the menu.
                    u8ExitWithoutSavingFlag = FALSE;
                    u8MenuExitFlag = TRUE;
                }

            }

            //If it made it this far, then it's changing submenus
            if(i8MenuChangeFlag != 0){
                //If we're not in parameter edit mode
                if(u8ParameterEditModeFlag == FALSE){
                    changeClockSubMenuState();
                    resetBlink();
                }
                else{
                    editClockParameter();
                }
            }
            break;
        default:
            break;   
    }


    /*When we exit the menu, we have to reset the LIVE PLAY INTERACTION stuff or
     we could end up in a weird state.*/

    if(u8MenuExitFlag == TRUE){
        /*If the main switch is pressed, then we exit without saving the change and
         need to reset the parameter.*/
        if(u8ExitWithoutSavingFlag == TRUE){
            resetMenuParameter();
        }
        else{
            //Write the file table with the stored settings.
            copyCurrentSettingsToFileTable(0);
            u8MemCommand = WRITE_FLASH_FILE_TABLE;
            xQueueSend(xMemInstructionQueue, &u8MemCommand, 0);
        }
        resetEncoderLiveInteraction();//Encoder turning needs to be reset to not get spurious changes.
        i8SubMenuState = SUBMENU_NOT_SELECTED;
        u8MenuExitFlag = FALSE;
        setLEDAlternateFuncFlag(FALSE);//LEDs back to indicating position
        turnOffAllLEDs();//Reset the LEDs state
        setRedLEDs(HALF_BRIGHTNESS);
        setMenuModeFlag(FALSE);//Master control knows menu is over
        u8ParameterEditModeFlag = FALSE;
        u8LoadModeFlag = FALSE;
        u8StoreModeFlag = FALSE;
    }
}
Exemple #20
0
// GlobalSettings --------------------------------------------------------------------
GlobalSettings::GlobalSettings() {

    mName = "GlobalSettings";
    defaultSettings();
}
void UBPreferencesController::wire()
{
    UBSettings* settings = UBSettings::settings();

    // main tab
    mPreferencesUI->mainTabWidget->setCurrentWidget(mPreferencesUI->displayTab);
    mPreferencesUI->versionLabel->setText(tr("version: ") + UBApplication::applicationVersion());

    connect(mPreferencesUI->closeButton, SIGNAL(released()), this, SLOT(close()));
    connect(mPreferencesUI->defaultSettingsButton, SIGNAL(released()), this, SLOT(defaultSettings()));

    connect(mPreferencesUI->startupTipsCheckBox,SIGNAL(clicked(bool)),this,SLOT(onStartupTipsClicked(bool)));


    // OSK preferences

    for(int i = 0; i < settings->supportedKeyboardSizes->size(); i++)
        mPreferencesUI->keyboardPaletteKeyButtonSize->addItem(settings->supportedKeyboardSizes->at(i));


    connect(mPreferencesUI->keyboardPaletteKeyButtonSize, SIGNAL(currentIndexChanged(const QString &)), settings->boardKeyboardPaletteKeyBtnSize, SLOT(setString(const QString &)));
    connect(mPreferencesUI->startModeComboBox, SIGNAL(currentIndexChanged(int)), settings->appStartMode, SLOT(setInt(int)));


    connect(mPreferencesUI->useExternalBrowserCheckBox, SIGNAL(clicked(bool)), settings->webUseExternalBrowser, SLOT(setBool(bool)));
    connect(mPreferencesUI->displayBrowserPageCheckBox, SIGNAL(clicked(bool)), settings->webShowPageImmediatelyOnMirroredScreen, SLOT(setBool(bool)));
    connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), settings->swapControlAndDisplayScreens, SLOT(setBool(bool)));
    connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), UBApplication::applicationController->displayManager(), SLOT(reinitScreens(bool)));

    connect(mPreferencesUI->toolbarAtTopRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool)));
    connect(mPreferencesUI->toolbarAtBottomRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool)));
    connect(mPreferencesUI->horizontalChoice, SIGNAL(clicked(bool)), this, SLOT(toolbarOrientationHorizontal(bool)));
    connect(mPreferencesUI->verticalChoice, SIGNAL(clicked(bool)), this, SLOT(toolbarOrientationVertical(bool)));
    connect(mPreferencesUI->toolbarDisplayTextCheckBox, SIGNAL(clicked(bool)), settings->appToolBarDisplayText, SLOT(setBool(bool)));

    // pen
    QList<QColor> penLightBackgroundColors = settings->boardPenLightBackgroundColors->colors();
    QList<QColor> penDarkBackgroundColors = settings->boardPenDarkBackgroundColors->colors();
    QList<QColor> penLightBackgroundSelectedColors = settings->boardPenLightBackgroundSelectedColors->colors();
    QList<QColor> penDarkBackgroundSelectedColors = settings->boardPenDarkBackgroundSelectedColors->colors();

    mPenProperties = new UBBrushPropertiesFrame(mPreferencesUI->penFrame,
                                                penLightBackgroundColors, penDarkBackgroundColors, penLightBackgroundSelectedColors,
                                                penDarkBackgroundSelectedColors, this);

    mPenProperties->opacityFrame->hide();

    connect(mPenProperties->fineSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mPenProperties->mediumSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mPenProperties->strongSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mPenProperties->pressureSensitiveCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setPenPressureSensitive(bool)));

    // marker
    QList<QColor> markerLightBackgroundColors = settings->boardMarkerLightBackgroundColors->colors();
    QList<QColor> markerDarkBackgroundColors = settings->boardMarkerDarkBackgroundColors->colors();
    QList<QColor> markerLightBackgroundSelectedColors = settings->boardMarkerLightBackgroundSelectedColors->colors();
    QList<QColor> markerDarkBackgroundSelectedColors = settings->boardMarkerDarkBackgroundSelectedColors->colors();

    mMarkerProperties = new UBBrushPropertiesFrame(mPreferencesUI->markerFrame, markerLightBackgroundColors,
                                                   markerDarkBackgroundColors, markerLightBackgroundSelectedColors,
                                                   markerDarkBackgroundSelectedColors, this);

    mMarkerProperties->pressureSensitiveCheckBox->setText(tr("Marker is pressure sensitive"));

    connect(mMarkerProperties->fineSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mMarkerProperties->mediumSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mMarkerProperties->strongSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mMarkerProperties->pressureSensitiveCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setMarkerPressureSensitive(bool)));
    connect(mMarkerProperties->opacitySlider, SIGNAL(valueChanged(int)), this, SLOT(opacitySliderChanged(int)));


    //network
    connect(mPreferencesUI->Username_textBox, SIGNAL(editingFinished()), this, SLOT(onCommunityUsernameChanged()));
    connect(mPreferencesUI->Password_textEdit, SIGNAL(editingFinished()), this, SLOT(onCommunityPasswordChanged()));
    connect(mPreferencesUI->PSCredentialsPersistenceCheckBox,SIGNAL(clicked()),this, SLOT(onCommunityPersistenceChanged()));

    // about tab
    connect(mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox, SIGNAL(clicked(bool)), settings->appEnableAutomaticSoftwareUpdates, SLOT(setBool(bool)));
}
Exemple #22
0
void FilmGrainSettings::resetToDefault()
{
    setSettings(defaultSettings());
}
Exemple #23
0
void MixerSettings::resetToDefault()
{
    setSettings(defaultSettings());
}
void UBPreferencesController::wire()
{
    UBSettings* settings = UBSettings::settings();

    // main tab
    mPreferencesUI->mainTabWidget->setCurrentWidget(mPreferencesUI->displayTab);
    mPreferencesUI->versionLabel->setText(tr("version: ") + UBApplication::applicationVersion());

    connect(mPreferencesUI->closeButton, SIGNAL(released()), this, SLOT(close()));
    connect(mPreferencesUI->defaultSettingsButton, SIGNAL(released()), this, SLOT(defaultSettings()));


    // OSK preferences
    mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("16x16");
    mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("24x24");
    mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("32x32");
    connect(mPreferencesUI->keyboardPaletteAutoMinimize, SIGNAL(clicked(bool)), settings->boardKeyboardPaletteAutoMinimize, SLOT(setBool(bool)));
    connect(mPreferencesUI->keyboardPaletteKeyButtonSize, SIGNAL(currentIndexChanged(const QString &)), settings->boardKeyboardPaletteKeyBtnSize, SLOT(setString(const QString &)));


    connect(mPreferencesUI->useExternalBrowserCheckBox, SIGNAL(clicked(bool)), settings->webUseExternalBrowser, SLOT(setBool(bool)));
    connect(mPreferencesUI->displayBrowserPageCheckBox, SIGNAL(clicked(bool)), settings->webShowPageImmediatelyOnMirroredScreen, SLOT(setBool(bool)));

    connect(mPreferencesUI->toolbarAtTopRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool)));
    connect(mPreferencesUI->toolbarAtBottomRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool)));
    connect(mPreferencesUI->horizontalChoice, SIGNAL(clicked(bool)), this, SLOT(toolbarOrientationHorizontal(bool)));
    connect(mPreferencesUI->verticalChoice, SIGNAL(clicked(bool)), this, SLOT(toolbarOrientationVertical(bool)));
    connect(mPreferencesUI->toolbarDisplayTextCheckBox, SIGNAL(clicked(bool)), settings->appToolBarDisplayText, SLOT(setBool(bool)));

    // pen
    QList<QColor> penLightBackgroundColors = settings->boardPenLightBackgroundColors->colors();
    QList<QColor> penDarkBackgroundColors = settings->boardPenDarkBackgroundColors->colors();
    QList<QColor> penLightBackgroundSelectedColors = settings->boardPenLightBackgroundSelectedColors->colors();
    QList<QColor> penDarkBackgroundSelectedColors = settings->boardPenDarkBackgroundSelectedColors->colors();

    mPenProperties = new UBBrushPropertiesFrame(mPreferencesUI->penFrame,
            penLightBackgroundColors, penDarkBackgroundColors, penLightBackgroundSelectedColors,
            penDarkBackgroundSelectedColors, this);

    mPenProperties->opacityFrame->hide();

    connect(mPenProperties->fineSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mPenProperties->mediumSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mPenProperties->strongSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mPenProperties->pressureSensitiveCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setPenPressureSensitive(bool)));

    // marker
    QList<QColor> markerLightBackgroundColors = settings->boardMarkerLightBackgroundColors->colors();
    QList<QColor> markerDarkBackgroundColors = settings->boardMarkerDarkBackgroundColors->colors();
    QList<QColor> markerLightBackgroundSelectedColors = settings->boardMarkerLightBackgroundSelectedColors->colors();
    QList<QColor> markerDarkBackgroundSelectedColors = settings->boardMarkerDarkBackgroundSelectedColors->colors();

    mMarkerProperties = new UBBrushPropertiesFrame(mPreferencesUI->markerFrame, markerLightBackgroundColors,
            markerDarkBackgroundColors, markerLightBackgroundSelectedColors,
            markerDarkBackgroundSelectedColors, this);

    mMarkerProperties->pressureSensitiveCheckBox->setText(tr("Marker is pressure sensitive"));

    connect(mMarkerProperties->fineSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mMarkerProperties->mediumSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mMarkerProperties->strongSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSliderChanged(int)));
    connect(mMarkerProperties->pressureSensitiveCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setMarkerPressureSensitive(bool)));
    connect(mMarkerProperties->opacitySlider, SIGNAL(valueChanged(int)), this, SLOT(opacitySliderChanged(int)));

    // about tab
    connect(mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox, SIGNAL(clicked(bool)), settings->appEnableAutomaticSoftwareUpdates, SLOT(setBool(bool)));
}
Exemple #25
0
//--------------------------------------------------------------------------
// Loads all the editor settings from file.  True and false settings are saved
//  as 1 and 0.
//  If the contents of settings.dat to not match expected then default values
//  are used.
void __fastcall TOptions::LoadSettings()
{
  try {
    const int SIZE = 256;
    AnsiString str;
    str = ExtractFilePath(Application->ExeName) + "settings.dat";
    char fileName[SIZE];
    strcpy(fileName, str.c_str());        // fileName is path + settings.dat

    defaultSettings();          // start with default settings

    if(FileExists(fileName))    //check if settings file exists
    {                           //if it did then load all the settings
      char buffer[SIZE+1];
      char temp[SIZE+1];        //temp storage
      unsigned int index;       //looping index
      ifstream File(fileName);  //open settings file

      // read and set flags from file
      File.getline(buffer, SIZE); //first line contains version number

      File.getline(buffer, SIZE); // 'generate list' setting
      if (!strcmp(&buffer[1],"$generate list")) {   // if expected setting
        if(buffer[0] == '1') {
          listFlag = true;
          chkGenList->Checked = true;
        } else {
          listFlag   = false;
          chkGenList->Checked = false;
        }
      }

      File.getline(buffer, SIZE); // 'generate s-record' setting
      if (!strcmp(&buffer[1],"$generate s-record")) {   // if expected setting
        if(buffer[0] == '1') {
          objFlag = true;
          chkGenSRec->Checked = true;
        } else {
          objFlag    = false;
          chkGenSRec->Checked = false;
        }
      }

      File.getline(buffer, SIZE); // 'save before assemble' setting
      if (!strcmp(&buffer[1],"$save then assemble")) {  // if expected setting
        if(buffer[0] == '1') {
          bSave = true;
          chkSave->Checked = true;
        } else {
          bSave      = false;
          chkSave->Checked = false;
        }
      }

      File.getline(buffer, SIZE); // 'Show Warnings' setting
      if (!strcmp(&buffer[1],"$show warnings")) {  // if expected setting
        if(buffer[0] == '1') {
          WARflag = true;
          chkShowWarnings->Checked = true;
        } else {
          WARflag    = false;
          chkShowWarnings->Checked = false;
        }
      }

      File.getline(buffer, SIZE); // 'cross reference' setting
      if (!strcmp(&buffer[1],"$cross reference")) {  // if expected setting
        if(buffer[0] == '1') {
          CREflag = true;
          chkCrossRef->Checked = true;
        } else {
          CREflag    = false;
          chkCrossRef->Checked = false;
        }
      }

      File.getline(buffer, SIZE); // 'macro expanded setting' setting
      if (!strcmp(&buffer[1],"$macros expanded")) {  // if expected setting
        if(buffer[0] == '1') {
          MEXflag = true;
          chkMacEx->Checked = true;
        } else {
          MEXflag    = false;
          chkMacEx->Checked = false;
        }
      }

      File.getline(buffer, SIZE); // 'structured assembly expanded setting' setting
      if (!strcmp(&buffer[1],"$structured expand")) {  // if expected setting
        if(buffer[0] == '1') {
          SEXflag = true;
          chkStrucEx->Checked = true;
        } else {
          SEXflag    = false;
          chkStrucEx->Checked = false;
        }
      }

      File.getline(buffer, SIZE); // 'constants expanded setting' setting
      if (!strcmp(&buffer[1],"$constants expand")) {  // if expected setting
        if(buffer[0] == '1') {
          CEXflag = true;
          chkConstantsEx->Checked = true;
        } else {
          CEXflag    = false;
          chkConstantsEx->Checked = false;
        }
      }

      index = 0;
      File.getline(buffer, SIZE);        // 'font name' setting
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$font name")) {  // if expected setting
        EditorOptionsForm->cbFont->Text = temp;
      }

      File.getline(buffer, SIZE);        // 'font size' setting
      index = 0;                       //reset looping index
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$font size")) {  // if expected setting
        EditorOptionsForm->cbSize->Text = temp;
      }

      File.getline(buffer, SIZE);        // Tab Type setting
      if (!strcmp(&buffer[1],"$tab type")) {  // if expected setting
        if(buffer[0] == '0') {
          EditorOptionsForm->AssemblyTabs->Checked = true;
          EditorOptionsForm->FixedTabs->Checked = false;
          tabType = Assembly;
        } else {
          EditorOptionsForm->AssemblyTabs->Checked = false;
          EditorOptionsForm->FixedTabs->Checked = true;
          tabType = Fixed;
        }
      }

      File.getline(buffer, SIZE);         // Fixed Tab Size
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$fixed tab size")) {  // if expected setting
        EditorOptionsForm->FixedTabSize->Value = atoi(temp);
      }

      File.getline(buffer, SIZE);        // maximizedEdit setting
      if (!strcmp(&buffer[1],"$maximized edit")) {  // if expected setting
        if(buffer[0] == '1') {
          maximizedEdit = true;
        } else {
          maximizedEdit = false;
        }
      }

      File.getline(buffer, SIZE);        // autoIndent setting
      if (!strcmp(&buffer[1],"$auto indent")) {  // if expected setting
        if(buffer[0] == '1') {
          autoIndent = true;
          EditorOptionsForm->AutoIndent->Checked = true;
        } else {
          autoIndent = false;
          EditorOptionsForm->AutoIndent->Checked = false;
        }
      }

      File.getline(buffer, SIZE);        // realTabs setting
      if (!strcmp(&buffer[1],"$real tabs")) {  // if expected setting
        if(buffer[0] == '1') {
          realTabs = true;
          EditorOptionsForm->RealTabs->Checked = true;
        } else {
          realTabs = false;
          EditorOptionsForm->RealTabs->Checked = false;
        }
      }

      File.getline(buffer, SIZE);        // Bitfield setting
      if (!strcmp(&buffer[1],"$assemble bit field")) {  // if expected setting
        if(buffer[0] == '1') {
          BITflag = true;
          chkBitfield->Checked = true;
        } else {
          BITflag    = false;
          chkBitfield->Checked = false;
        }
      }

      File.getline(buffer, SIZE);         // 'Main Form Top' setting
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$main top")) {  // if expected setting
        Main->Top = atoi(temp);
      }

      File.getline(buffer, SIZE);         // 'Main Form Left' setting
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$main left")) {  // if expected setting
        Main->Left = atoi(temp);
      }

      File.getline(buffer, SIZE);         // 'Main Form Height' setting
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$main height")) {  // if expected setting
        Main->Height = atoi(temp);
      }

      File.getline(buffer, SIZE);         // 'Main Form Width' setting
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$main width")) {  // if expected setting
        Main->Width = atoi(temp);
      }

      // Syntax Highlight stuff
      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$code color")) {  // if expected setting
        codeStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$code bold")) {  // if expected setting
        codeStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$code italic")) {  // if expected setting
        codeStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$code underline")) {  // if expected setting
        codeStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$unknown color")) {  // if expected setting
        unknownStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$unknown bold")) {  // if expected setting
        unknownStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$unknown italic")) {  // if expected setting
        unknownStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$unknown underline")) {  // if expected setting
        unknownStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$directive color")) {  // if expected setting
        directiveStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$directive bold")) {  // if expected setting
        directiveStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$directive italic")) {  // if expected setting
        directiveStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$directive underline")) {  // if expected setting
        directiveStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$comment color")) {  // if expected setting
        commentStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$comment bold")) {  // if expected setting
        commentStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$comment italic")) {  // if expected setting
        commentStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$comment underline")) {  // if expected setting
        commentStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$label color")) {  // if expected setting
        labelStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$label bold")) {  // if expected setting
        labelStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$label italic")) {  // if expected setting
        labelStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$label underline")) {  // if expected setting
        labelStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$structure color")) {  // if expected setting
        structureStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$structure bold")) {  // if expected setting
        structureStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$structure italic")) {  // if expected setting
        structureStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$structure underline")) {  // if expected setting
        structureStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$error color")) {  // if expected setting
        errorStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$error bold")) {  // if expected setting
        errorStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$error italic")) {  // if expected setting
        errorStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$error underline")) {  // if expected setting
        errorStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$text color")) {  // if expected setting
        textStyle.color = (TColor)atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$text bold")) {  // if expected setting
        textStyle.bold = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$text italic")) {  // if expected setting
        textStyle.italic = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$text underline")) {  // if expected setting
        textStyle.underline = atoi(temp);
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$highlight disabled")) {  // if expected setting
        highlightDisabled = atoi(temp);
      }

      File.getline(buffer, SIZE);        // Print w/Black
      if (!strcmp(&buffer[1],"$print w/black")) {  // if expected setting
        if(buffer[0] == '1')
          EditorOptionsForm->PrintBlack->Checked = true;
        else
          EditorOptionsForm->PrintBlack->Checked = false;
      }

      File.getline(buffer,SIZE);
      index = 0;
      while(buffer[index] != '$' && index < SIZE)
      {
        temp[index] = buffer[index];
        index++;
      }
      temp[index] = '\0';
      if (!strcmp(&buffer[index],"$background color")) {  // if expected setting
        backColor = (TColor)atoi(temp);
      }

      File.close();
    } // endif
  }
  catch( ... ) {
    MessageDlg("Error loading editor settings",mtInformation, TMsgDlgButtons() << mbOK,0);
    return;
  }
}
// constructor de baza
Object3D::Object3D()
{
	defaultSettings();
}
// seteaza si tipul obiectului
Object3D::Object3D(ObjectType _Type)
{
	defaultSettings();
	Type = _Type;
}
// seteaza si pozitia
Object3D::Object3D(Vector3D *_translation)
{
	defaultSettings();
	this->SetPosition(_translation);
}
void readInputData(Simulation *sim, Grid *g, Settings *sett){
	FILE *inParticles, *inCells;
	int i, j;

	defaultSettings(sett);
	set(g, sett->gridCellsX, sett->gridCellsY, sett->simulationWidth, sett->simulationHeight);

	sim->particles = malloc(sett->numOfParticles * sizeof(struct particle));
	g->cells 	= malloc(g->numCellsXTotal * sizeof(struct cell*));
	for(i = 0; i < g->numCellsXTotal; i++){
		g->cells[i] = malloc(g->numCellsYTotal * sizeof(struct cell));
	}

	inParticles = fopen("particles.txt", "r");
	for(i = 0; i < sett->numOfParticles; i++){
		fscanf(inParticles, "%lg", &sim->particles[i].x);
		//printf("%lg\n", sim->particles[i].x);
		fscanf(inParticles, "%lg", &sim->particles[i].y);
		//printf("%lg\n", sim->particles[i].y);
		fscanf(inParticles, "%lg", &sim->particles[i].radius);
		//printf("%lg\n", sim->particles[i].radius);
		fscanf(inParticles, "%lg", &sim->particles[i].vx);
		//printf("%lg\n", sim->particles[i].vx);
		fscanf(inParticles, "%lg", &sim->particles[i].vy);
		//printf("%lg\n", sim->particles[i].vy);
		fscanf(inParticles, "%lg", &sim->particles[i].ax);
		//printf("%lg\n", sim->particles[i].ax);
		fscanf(inParticles, "%lg", &sim->particles[i].ay);
		//printf("%lg\n", sim->particles[i].ay);
		fscanf(inParticles, "%lg", &sim->particles[i].mass);
		//printf("%lg\n", sim->particles[i].mass);
		fscanf(inParticles, "%lg", &sim->particles[i].charge);
		//printf("%lg\n", sim->particles[i].charge);
		fscanf(inParticles, "%lg", &sim->particles[i].prevX);
		//printf("%lg\n", sim->particles[i].prevX);
		fscanf(inParticles, "%lg", &sim->particles[i].prevY);
		//printf("%lg\n", sim->particles[i].prevY);
		fscanf(inParticles, "%lg", &sim->particles[i].Ex);
		//printf("%lg\n", sim->particles[i].Ex);
		fscanf(inParticles, "%lg", &sim->particles[i].Ey);
		//printf("%lg\n", sim->particles[i].Ey);
		fscanf(inParticles, "%lg", &sim->particles[i].Bz);
		//printf("%lg\n", sim->particles[i].Bz);
		fscanf(inParticles, "%lg", &sim->particles[i].prevpositionComponentForceX);
		//printf("%lg\n", sim->particles[i].prevpositionComponentForceX);
		fscanf(inParticles, "%lg", &sim->particles[i].prevpositionComponentForceY);
		//printf("%lg\n", sim->particles[i].prevpositionComponentForceY);
		fscanf(inParticles, "%lg", &sim->particles[i].prevtangentVelocityComponentOfForceX);
		//printf("%lg\n", sim->particles[i].prevtangentVelocityComponentOfForceX);
		fscanf(inParticles, "%lg", &sim->particles[i].prevtangentVelocityComponentOfForceY);
		//printf("%lg\n", sim->particles[i].prevtangentVelocityComponentOfForceY);
		fscanf(inParticles, "%lg", &sim->particles[i].prevnormalVelocityComponentOfForceX);
		//printf("%lg\n", sim->particles[i].prevnormalVelocityComponentOfForceX);
		fscanf(inParticles, "%lg", &sim->particles[i].prevnormalVelocityComponentOfForceY);
		//printf("%lg\n", sim->particles[i].prevnormalVelocityComponentOfForceY);
		fscanf(inParticles, "%lg", &sim->particles[i].prevBz);
		//printf("%lg\n", sim->particles[i].prevBz);
		fscanf(inParticles, "%lg", &sim->particles[i].prevLinearDragCoefficient);
		//printf("%lg\n", sim->particles[i].prevLinearDragCoefficient);
	}
	fclose(inParticles);

	inCells = fopen("cells.txt", "r");
	for(i = 0; i < g->numCellsXTotal; i++){
		for(j = 0; j < g->numCellsYTotal; j++){
			fscanf(inCells, "%lg", &g->cells[i][j].jx);
			// printf("%lg\n", g->cells[i][j].jx);
			fscanf(inCells, "%lg", &g->cells[i][j].jy);
			// printf("%lg\n", g->cells[i][j].jy);
			fscanf(inCells, "%lg", &g->cells[i][j].rho);
			// printf("%lg\n", g->cells[i][j].rho);
			fscanf(inCells, "%lg", &g->cells[i][j].phi);
			// printf("%lg\n", g->cells[i][j].phi);
			fscanf(inCells, "%lg", &g->cells[i][j].ex);
			// printf("%lg\n", g->cells[i][j].ex);
			fscanf(inCells, "%lg", &g->cells[i][j].ey);
			// printf("%lg\n", g->cells[i][j].ey);
			fscanf(inCells, "%lg", &g->cells[i][j].bz);
			// printf("%lg\n", g->cells[i][j].bz);
			fscanf(inCells, "%lg", &g->cells[i][j].bzo);
			// printf("%lg\n", g->cells[i][j].bzo);
		}
	}
	fclose(inCells);

}
Exemple #30
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QSettings *settings = new QSettings(QDir::homePath()+"/.config/thumbterm/settings.ini", QSettings::IniFormat);
    defaultSettings(settings);

    QCoreApplication::setApplicationName("Thumbterm");

    // fork the child process before creating QGuiApplication
    int socketM;
    int pid = forkpty(&socketM,NULL,NULL,NULL);
    if( pid==-1 ) {
        qFatal("forkpty failed");
        exit(1);
    } else if( pid==0 ) {
        setenv("TERM", settings->value("terminal/envVarTERM").toByteArray(), 1);

        QString execCmd;
        for(int i=0; i<argc-1; i++) {
            if( QString(argv[i]) == "-e" )
                execCmd = QString(argv[i+1]);
        }
        if(execCmd.isEmpty()) {
            execCmd = settings->value("gen/execCmd").toString();
        }
        if(execCmd.isEmpty()) {
            // Unset POSIXLY_CORRECT as having it set causes bash to start in POSIX mode (http://www.delorie.com/gnu/docs/bash/bashref_62.html#IDX214)
            // which causes it to not read the .bashrc on startup (http://lists.gnu.org/archive/html/bug-bash/2001-10/msg00117.html)
            unsetenv("POSIXLY_CORRECT");

            // execute the user's default shell
            passwd *pwdstruct = getpwuid(getuid());
            execCmd = QString(pwdstruct->pw_shell);
            execCmd.append(" --login");
        }

        if(settings)
            delete settings; // don't need 'em here

        QStringList execParts = execCmd.split(' ', QString::SkipEmptyParts);
        if(execParts.length()==0)
            exit(0);
        char *ptrs[execParts.length()+1];
        for(int i=0; i<execParts.length(); i++) {
            ptrs[i] = new char[execParts.at(i).toLatin1().length()+1];
            memcpy(ptrs[i], execParts.at(i).toLatin1().data(), execParts.at(i).toLatin1().length());
            ptrs[i][execParts.at(i).toLatin1().length()] = 0;
        }
        ptrs[execParts.length()] = 0;

        execvp(execParts.first().toLatin1(), ptrs);
        exit(0);
    }

    QGuiApplication app(argc, argv);
    QQuickWindow::setDefaultAlphaBuffer(true);

    QScreen* sc = app.primaryScreen();
    if(sc){
    sc->setOrientationUpdateMask(Qt::PrimaryOrientation
                                 | Qt::LandscapeOrientation
                                 | Qt::PortraitOrientation
                                 | Qt::InvertedLandscapeOrientation
                                 | Qt::InvertedPortraitOrientation);
    }

    qmlRegisterType<TextRender>("TextRender",1,0,"TextRender");
    MainWindow view;

    Terminal term;
    Util util(settings);
    term.setUtil(&util);
    QString startupErrorMsg;

    // copy the default config files to the config dir if they don't already exist
    copyFileFromResources(":/data/menu.xml", util.configPath()+"/menu.xml");
    copyFileFromResources(":/data/english.layout", util.configPath()+"/english.layout");
    copyFileFromResources(":/data/finnish.layout", util.configPath()+"/finnish.layout");
    copyFileFromResources(":/data/french.layout", util.configPath()+"/french.layout");
    copyFileFromResources(":/data/german.layout", util.configPath()+"/german.layout");
    copyFileFromResources(":/data/qwertz.layout", util.configPath()+"/qwertz.layout");

    KeyLoader keyLoader;
    keyLoader.setUtil(&util);
    bool ret = keyLoader.loadLayout( settings->value("ui/keyboardLayout").toString() );
    if(!ret) {
        // on failure, try to load the default one (english) directly from resources
        startupErrorMsg = "There was an error loading the keyboard layout.<br>\nUsing the default one instead.";
        settings->setValue("ui/keyboardLayout", "english");
        ret = keyLoader.loadLayout(":/data/english.layout");
        if(!ret)
            qFatal("failure loading keyboard layout");
    }

    QQmlContext *context = view.rootContext();
    context->setContextProperty( "term", &term );
    context->setContextProperty( "util", &util );
    context->setContextProperty( "keyLoader", &keyLoader );

    view.setSource(QUrl("qrc:/qml/Main.qml"));

    QObject *root = view.rootObject();
    if(!root)
        qFatal("no root object - qml error");

    QObject* win = root->findChild<QObject*>("window");

    if(!startupErrorMsg.isEmpty())
        QMetaObject::invokeMethod(win, "showErrorMessage", Qt::QueuedConnection, Q_ARG(QVariant, startupErrorMsg));

    TextRender *tr = root->findChild<TextRender*>("textrender");
    tr->setUtil(&util);
    tr->setTerminal(&term);
    term.setRenderer(tr);
    term.setWindow(&view);
    util.setWindow(&view);
    util.setTerm(&term);
    util.setRenderer(tr);

    QObject::connect(&term,SIGNAL(displayBufferChanged()),win,SLOT(displayBufferChanged()));
    QObject::connect(view.engine(),SIGNAL(quit()),&app,SLOT(quit()));

    QSize screenSize = QGuiApplication::primaryScreen()->size();
    if ((screenSize.width() < 1024 || screenSize.height() < 768 || app.arguments().contains("-fs"))
            && !app.arguments().contains("-nofs"))
    {
        view.showFullScreen();
    } else
        view.show();

    PtyIFace ptyiface(pid, socketM, &term,
                       settings->value("terminal/charset").toString());

    if( ptyiface.failed() )
        qFatal("pty failure");

    return app.exec();
}