예제 #1
0
//set value
void cOpt::setValue(std::string sSetIn) {
    if (sType == "string") {
        if (getItemPos(sSetIn) != -1) {
            sSet = sSetIn;
        }

    } else if (sType == "bool") {
        bSet = (sSetIn == "True" || sSetIn == "true" || sSetIn == "T" || sSetIn == "t");

    } else if (sType == "int") {
        iSet = atoi(sSetIn.c_str());

        if ( iSet < iMin || iSet > iMax ) {
            iSet = iDefault;
        }

    } else if (sType == "float") {
        std::istringstream ssTemp(sSetIn);
        ssTemp.imbue(std::locale("C"));
        float tmpFloat;
        ssTemp >> tmpFloat;
        if(ssTemp) {
            setValue(tmpFloat);
        } else {
            debugmsg("invalid floating point option: %s", sSetIn.c_str());
        }
    }
예제 #2
0
//set to next item
void cOpt::setNext() {
    if (sType == "string") {
        int iNext = getItemPos(sSet)+1;
        if (iNext >= vItems.size()) {
            iNext = 0;
        }

        sSet = vItems[iNext];

    } else if (sType == "bool") {
        bSet = !bSet;

    } else if (sType == "int") {
        iSet++;
        if (iSet > iMax) {
            iSet = iMin;
        }

    } else if (sType == "float") {
        fSet += fStep;
        if (fSet > fMax) {
            fSet = fMin;
        }
    }
}
예제 #3
0
//set to prev item
void cOpt::setPrev() {
    if (sType == "string") {
        int iPrev = getItemPos(sSet)-1;
        if (iPrev < 0) {
            iPrev = vItems.size()-1;
        }

        sSet = vItems[iPrev];

    } else if (sType == "bool") {
        bSet = !bSet;

    } else if (sType == "int") {
        iSet--;
        if (iSet < iMin) {
            iSet = iMax;
        }

    } else if (sType == "float") {
        fSet -= fStep;
        if (fSet < fMin) {
            fSet = fMax;
        }
    }
}
예제 #4
0
파일: utils.c 프로젝트: dpeddi/minisatip
int getItemSize(int64_t key)
{
	STmpinfo *s = getItemPos(key);
	if (!s)
		return 0;
	return s->max_size;
}
예제 #5
0
파일: utils.c 프로젝트: dpeddi/minisatip
unsigned char *getItem(int64_t key)
{
	STmpinfo *s = getItemPos(key);
	if (s)
		s->last_updated = getTick();
	return s ? s->data : NULL;
}
예제 #6
0
파일: utils.c 프로젝트: dpeddi/minisatip
int delItem(int64_t key)
{
	STmpinfo *s = getItemPos(key);
	s->enabled = 0;
	s->len = 0;
	s->key = 0;
	LOG("Deleted Item Pos %d", s->id);
	return 0;
}
예제 #7
0
파일: utils.c 프로젝트: dpeddi/minisatip
int setItemTimeout(int64_t key, int tmout)
{
	STmpinfo *s = getItemPos(key);
	if (!s)
		return -1;
	s->timeout = tmout;
	if (!s->data)
		return -1;
	return 0;
}
예제 #8
0
파일: utils.c 프로젝트: dpeddi/minisatip
int getItemChange(int64_t key, int *prev)
{
	int current;
	*prev = current = -1;
	STmpinfo *s = getItemPos(key);
	if (!s)
		return 0;
	*prev = s->prev_no_change;
	current = s->no_change;
	return current;
}
예제 #9
0
파일: utils.c 프로젝트: dpeddi/minisatip
int setItemSize(int64_t key, uint32_t max_size)
{
	STmpinfo *s = getItemPos(key);
	if (!s)
		return -1;
	if (s->max_size == max_size)
		return 0;
	s->max_size = max_size;
	if (s->data)
		free1(s->data);
	s->data = malloc1(s->max_size + 100);
	if (!s->data)
		return -1;
	return 0;
}
예제 #10
0
//string constructor
cOpt::cOpt(const std::string sPageIn, const std::string sMenuTextIn, const std::string sTooltipIn, const std::string sItemsIn, std::string sDefaultIn) {
    sPage = sPageIn;
    sMenuText = sMenuTextIn;
    sTooltip = sTooltipIn;
    sType = "string";

    std::stringstream ssTemp(sItemsIn);
    std::string sItem;
    while (std::getline(ssTemp, sItem, ',')) {
        vItems.push_back(sItem);
    }

    if (getItemPos(sDefaultIn) == -1) {
        sDefaultIn = vItems[0];
    }

    sDefault = sDefaultIn;
    sSet = sDefaultIn;
}
예제 #11
0
파일: utils.c 프로젝트: dpeddi/minisatip
int setItem(int64_t key, unsigned char *data, int len, int pos) // pos = -1 -> append, owerwrite the existing key
{
	int new_key = 0;
	STmpinfo *s = getItemPos(key);
	if (!s)
	{
		s = getFreeItemPos(key);
		new_key = 1;
	}
	if (!s)
		return -1;

	if (s->max_size == 0)
		s->max_size = MAX_DATA + 10;
	if (!s->data)
		s->data = malloc1(s->max_size);
	if (!s->data)
		return -1;
	s->enabled = 1;
	s->key = key;
	s->last_updated = getTick();
	if (pos == -1)
		pos = s->len;
	if (pos + len >= s->max_size) // make sure we do not overflow the data buffer
		len = s->max_size - pos;

	s->len = pos + len;
	if (pos == 0)
	{
		s->prev_no_change = s->no_change;
		s->no_change = 1;
	}
	if (new_key)
		s->no_change = 0;
	if (memcmp(s->data + pos, data, len) != 0)
		s->no_change = 0;

	memcpy(s->data + pos, data, len);
	return 0;
}
예제 #12
0
//set value
void cOpt::setValue(std::string sSetIn) {
    if (sType == "string") {
        if (getItemPos(sSetIn) != -1) {
            sSet = sSetIn;
        }

    } else if (sType == "bool") {
        bSet = (sSetIn == "True" || sSetIn == "true" || sSetIn == "T" || sSetIn == "t");

    } else if (sType == "int") {
        iSet = atoi(sSetIn.c_str());

        if ( iSet < iMin || iSet > iMax ) {
            iSet = iDefault;
        }

    } else if (sType == "float") {
        fSet = atof(sSetIn.c_str());

        if ( fSet < fMin || fSet > fMax ) {
            fSet = fDefault;
        }
    }
}
예제 #13
0
void Config::loadConfig() {
    // Si no existe configuración en $HOME la copiamos de /usr/share/flynnoswm
    QDir usrConfigDir(USR_CONFIG_DIR);
    QDir homeConfigDir(QDir::homePath() + "/" + HOME_CONFIG_DIR);

    if(!homeConfigDir.exists()) {
        qDebug() << "Home configuration not found, copying it...";

        if(!usrConfigDir.exists()) {
            qFatal("/usr/share/flynnoswm not found, reinstall the application can "
                   "solve the problem");
        }

        homeConfigDir.cdUp();
        homeConfigDir.mkdir(HOME_CONFIG_DIR);
        homeConfigDir.cd(HOME_CONFIG_DIR);

        if(!this->copyDir(usrConfigDir, homeConfigDir)) {
            qFatal("Can't copy configuration to your home");
        }
    }

    // Leemos la configuración
    qDebug() << "Reading configuration from home";
    QSettings flynnoswmSettings(QDir::homePath() + CONFIG_FILE_PATH,
            QSettings::NativeFormat);

    qDebug() << QDir::homePath() + CONFIG_FILE_PATH;

    //--------------------------------------------------------------------------

    // Abrimos el archivo de configuración del tema
    QString folderThemeName = flynnoswmSettings.value(USED_THEME, "").toString();
    QString themeConfigPath = QDir::homePath() + THEMES_PATH + folderThemeName
            + THEME_INFO;
    QSettings themeSettings(themeConfigPath, QSettings::NativeFormat);

    // Guardamos la información del tema
    showIcon            = themeSettings.value(SHOW_ICON, false).toBool();

    titlebarWidth       = themeSettings.value(TITLEBAR_WIDTH, 16).toInt();
    topBorderWidth      = themeSettings.value(TOP_BORDER_WIDTH, 4).toInt();
    bottomBorderWidth   = themeSettings.value(BOTTOM_BORDER_WIDTH, 4).toInt();
    leftBorderWidth     = themeSettings.value(LEFT_BORDER_WIDTH, 16).toInt();
    rightBorderWidth    = themeSettings.value(RIGHT_BORDER_WIDTH, 16).toInt();
    iconSize            = themeSettings.value(ICON_SIZE, 16).toInt();

    minimizeButtonPos   = getItemPos(themeSettings, MINIMIZE_BUTTON_POS);
    minimizeVisibleButtonPos   = getItemPos(themeSettings, MINIMIZE_VISIBLE_BUTTON_POS);
    maximizeButtonPos   = getItemPos(themeSettings, MAXIMIZE_BUTTON_POS);
    exitButtonPos       = getItemPos(themeSettings, EXIT_BUTTON_POS);
    iconPos             = getItemPos(themeSettings, ICON_POS);
    titlePos            = getItemPos(themeSettings, TITLE_POS);

    minimizeButtonAling = getIconAling(themeSettings, MINIMIZE_BUTTON_ALING);
    minimizeVisibleButtonAling = getIconAling(themeSettings, MINIMIZE_VISIBLE_BUTTON_ALING);
    maximizeButtonAling = getIconAling(themeSettings, MAXIMIZE_BUTTON_ALING);
    exitButtonAling     = getIconAling(themeSettings, EXIT_BUTTON_ALING);

    //--------------------------------------------------------------------------

    // Guardamos el estilo
    QString themeStylePath = QDir::homePath() + THEMES_PATH + folderThemeName
            + STYLE_QSS;
    QFile qss(themeStylePath);
    qss.open(QFile::ReadOnly);
    style = qss.readAll();
    style.replace("%theme_path%", QDir::homePath()+THEMES_PATH+folderThemeName);
    qDebug() << style;
    qss.close();
}
예제 #14
0
파일: utils.c 프로젝트: dpeddi/minisatip
int getItemLen(int64_t key)
{
	STmpinfo *s = getItemPos(key);
	return s ? s->len : 0;
}