void QvisScreenPositioner::drawLines(QPainter &paint) { // Draw the lines. QPen pen(palette().color(QPalette::Text)); int cx = contentsRect().x(); int cy = contentsRect().y(); int w = contentsRect().width(); int h = contentsRect().height(); // Draw the old position double t = double(xPosition) / double(xScreenSize); int oldwx = int(t * double(w - 1)); CLAMP_VALUE(oldwx, 0, w - 1); t = 1. - double(yPosition) / double(yScreenSize); int oldwy = int(t * double(h - 1)); CLAMP_VALUE(oldwy, 0, h - 1); paint.setPen(pen); paint.drawLine(oldwx + cx, cy, oldwx + cx, cy + h); paint.drawLine(cx, cy + oldwy, cx + w, cy + oldwy); // Draw the temporary position t = double(xTempPosition) / double(xScreenSize); int twx = int(t * double(w - 1)); CLAMP_VALUE(twx, 0, w - 1); t = 1. - double(yTempPosition) / double(yScreenSize); int twy = int(t * double(h - 1)); CLAMP_VALUE(twy, 0, h - 1); pen.setStyle(Qt::DotLine); paint.setPen(pen); paint.drawLine(twx + cx, cy, twx + cx, cy + h); paint.drawLine(cx, cy + twy, cx + w, cy + twy); }
static void setup_system_sound_levels (NValue *value) { gchar **split = NULL; gchar **iter = NULL; guint i = 0; if (!value) { N_WARNING (LOG_CAT "no system-sound-levels key defined " "in profile.ini!"); return; } if (n_value_type (value) != N_VALUE_TYPE_STRING) { N_WARNING (LOG_CAT "invalid value type for system sound levels!"); return; } split = g_strsplit (n_value_get_string (value), ";", -1); for (iter = split; *iter; ++iter) ++num_system_sound_levels; system_sound_levels = (int*) g_malloc0 (sizeof (int) * num_system_sound_levels); for (iter = split, i = 0; *iter; ++iter, ++i) { system_sound_levels[i] = atoi (*iter); system_sound_levels[i] = CLAMP_VALUE (system_sound_levels[i], 0, 100); } g_strfreev (split); }
static void update_context_value (NContext *context, const char *profile, const char *key, const char *value) { gchar *context_key = NULL; NValue *context_val = NULL; gint level = 0; gchar *new_val = NULL; context_key = construct_context_key (profile, key); context_val = n_value_new (); if (g_str_has_suffix (key, TONE_SUFFIX) || g_str_has_suffix (key, PATTERN_SUFFIX)) { new_val = get_absolute_tone_path (value); new_val = new_val != NULL ? new_val : g_strdup (value); n_value_set_string (context_val, new_val); g_free (new_val); } else if (g_str_has_suffix (key, VOLUME_SUFFIX)) { n_value_set_int (context_val, profile_parse_int (value)); } else if (g_str_has_suffix (key, SYSTEM_SUFFIX)) { level = profile_parse_int (value); level = CLAMP_VALUE (level, 0, (gint) num_system_sound_levels-1); n_value_set_int (context_val, system_sound_levels[level]); } else if (g_str_equal (key, KEY_VIBRATION_ENABLED)) { n_value_set_bool (context_val, profile_parse_bool (value)); } else if (g_str_equal (key, KEY_TOUCH_VIBRA_LEVEL)) { n_value_set_int (context_val, profile_parse_int (value)); } else { n_value_set_string (context_val, value); } n_context_set_value (context, context_key, context_val); g_free (context_key); }