void SettingsWindow::onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos) { if (getSettingType(scroller) == "Slider") { std::string valueStr; if (getSettingValueType(scroller) == "Float") { float value = pos / float(scroller->getScrollRange()-1); float min,max; getSettingMinMax(scroller, min, max); value = min + (max-min) * value; Settings::Manager::setFloat(getSettingName(scroller), getSettingCategory(scroller), value); valueStr = MyGUI::utility::toString(int(value)); } else { Settings::Manager::setInt(getSettingName(scroller), getSettingCategory(scroller), pos); valueStr = MyGUI::utility::toString(pos); } updateSliderLabel(scroller, valueStr); apply(); } }
void MirandaSkinnedDialog::setSettting(const char *name, const char *val, bool global) { char setting[SETTING_NAME_SIZE]; getSettingName(setting, name, global); DBWriteContactSettingString(NULL, getModule(), setting, val); }
int MirandaSkinnedDialog::getSettting(const char *name, int defVal, bool global) { char setting[SETTING_NAME_SIZE]; getSettingName(setting, name, global); return DBGetContactSettingDword(NULL, getModule(), setting, defVal); }
bool MirandaSkinnedDialog::getSettting(const char *name, bool defVal, bool global) { char setting[SETTING_NAME_SIZE]; getSettingName(setting, name, global); return DBGetContactSettingByte(NULL, getModule(), setting, defVal ? 1 : 0) != 0; }
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender) { std::string on = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On"); std::string off = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOff", "On"); bool newState; if (_sender->castType<MyGUI::Button>()->getCaption() == on) { _sender->castType<MyGUI::Button>()->setCaption(off); newState = false; } else { _sender->castType<MyGUI::Button>()->setCaption(on); newState = true; } if (_sender == mFullscreenButton) { // check if this resolution is supported in fullscreen if (mResolutionList->getIndexSelected() != MyGUI::ITEM_NONE) { std::string resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected()); int resX, resY; parseResolution (resX, resY, resStr); Settings::Manager::setInt("resolution x", "Video", resX); Settings::Manager::setInt("resolution y", "Video", resY); } bool supported = false; for (unsigned int i=0; i<mResolutionList->getItemCount(); ++i) { std::string resStr = mResolutionList->getItemNameAt(i); int resX, resY; parseResolution (resX, resY, resStr); if (resX == Settings::Manager::getInt("resolution x", "Video") && resY == Settings::Manager::getInt("resolution y", "Video")) supported = true; } if (!supported) { std::string msg = "This resolution is not supported in Fullscreen mode. Please select a resolution from the list."; MWBase::Environment::get().getWindowManager()-> messageBox(msg); _sender->castType<MyGUI::Button>()->setCaption(off); return; } mWindowBorderButton->setEnabled(!newState); } if (getSettingType(_sender) == checkButtonType) { Settings::Manager::setBool(getSettingName(_sender), getSettingCategory(_sender), newState); apply(); return; } }
void SettingsWidget::on_doubleSpinBox_changed(double value) { QString name = sender()->objectName(); options[name] = value; Settings::saveSetting(getSettingCategory(name),getSettingName(name), value); emit settingChanged(); }
void SettingsWidget::on_checkBox_changed(bool checked) { QString name = sender()->objectName(); options[name] = checked; Settings::saveSetting(getSettingCategory(name),getSettingName(name),checked); emit settingChanged(); }
void SettingsWidget::on_lineEdit_changed(const QString &text) { QString name = sender()->objectName(); options[name] = text; Settings::saveSetting(getSettingCategory(name),getSettingName(name),text); emit settingChanged(); }
void SettingsWindow::configureWidgets(MyGUI::Widget* widget) { MyGUI::EnumeratorWidgetPtr widgets = widget->getEnumerator(); while (widgets.next()) { MyGUI::Widget* current = widgets.current(); std::string type = getSettingType(current); if (type == checkButtonType) { std::string initialValue = Settings::Manager::getBool(getSettingName(current), getSettingCategory(current)) ? "#{sOn}" : "#{sOff}"; current->castType<MyGUI::Button>()->setCaptionWithReplacing(initialValue); current->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled); } if (type == sliderType) { MyGUI::ScrollBar* scroll = current->castType<MyGUI::ScrollBar>(); std::string valueStr; if (getSettingValueType(current) == "Float") { // TODO: ScrollBar isn't meant for this. should probably use a dedicated FloatSlider widget float min,max; getSettingMinMax(scroll, min, max); float value = Settings::Manager::getFloat(getSettingName(current), getSettingCategory(current)); valueStr = MyGUI::utility::toString((int)value); value = std::max(min, std::min(value, max)); value = (value-min)/(max-min); scroll->setScrollPosition(static_cast<size_t>(value * (scroll->getScrollRange() - 1))); } else { int value = Settings::Manager::getInt(getSettingName(current), getSettingCategory(current)); valueStr = MyGUI::utility::toString(value); scroll->setScrollPosition(value); } scroll->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); updateSliderLabel(scroll, valueStr); } configureWidgets(current); } }
void MirandaSkinnedDialog::getSettting(const char *name, const char *defVal, std::string &ret, bool global) { char setting[SETTING_NAME_SIZE]; getSettingName(setting, name, global); DBVARIANT dbv = {0}; if (DBGetContactSettingString(NULL, getModule(), setting, &dbv)) { ret = defVal; return; } ret = dbv.pszVal; DBFreeVariant(&dbv); }
void SettingsWidget::loadSettings(void) { //go through all line edits for(QLineEdit *x: findChildren<QLineEdit*>()) { QString category = getSettingCategory(x->objectName()); QString name = getSettingName(x->objectName()); if(category != "qt" && Settings::hasSetting(category,name)) { x->setText(Settings::getSetting(category,name).toString()); options[x->objectName()] = Settings::getSetting(category,name); } else { options[x->objectName()] = x->text(); } } //go through all combo boxes for(QComboBox *x: findChildren<QComboBox*>()) { QString category = getSettingCategory(x->objectName()); QString name = getSettingName(x->objectName()); if(category != "qt" && Settings::hasSetting(category,name)) { x->setCurrentText(Settings::getSetting(category,name).toString()); options[x->objectName()] = Settings::getSetting(category,name); } else { options[x->objectName()] = x->currentText(); } } //go through all checkboxes for(QRadioButton *x: findChildren<QRadioButton*>()) { QString category = getSettingCategory(x->objectName()); QString name = getSettingName(x->objectName()); if(Settings::hasSetting(category,name)) { x->setChecked(Settings::getSetting(category,name).toBool()); options[x->objectName()] = Settings::getSetting(category,name); } else { options[x->objectName()] = x->isChecked(); } } //go through all radio buttons for(QCheckBox *x: findChildren<QCheckBox*>()) { QString category = getSettingCategory(x->objectName()); QString name = getSettingName(x->objectName()); if(Settings::hasSetting(category,name)) { x->setChecked(Settings::getSetting(category,name).toBool()); options[x->objectName()] = Settings::getSetting(category,name); } else { options[x->objectName()] = x->isChecked(); } } //go through all spin boxes for(QSlider *x: findChildren<QSlider*>()) { QString category = getSettingCategory(x->objectName()); QString name = getSettingName(x->objectName()); if(Settings::hasSetting(category,name)) { x->setValue(Settings::getSetting(category,name).toInt()); options[x->objectName()] = Settings::getSetting(category,name); } else { options[x->objectName()] = x->value(); } } //go through all spin boxes for(QSpinBox *x: findChildren<QSpinBox*>()) { QString category = getSettingCategory(x->objectName()); QString name = getSettingName(x->objectName()); if(Settings::hasSetting(category,name)) { x->setValue(Settings::getSetting(category,name).toInt()); options[x->objectName()] = Settings::getSetting(category,name); } else { options[x->objectName()] = x->value(); } } //go through all double spin boxes for(QDoubleSpinBox *x: findChildren<QDoubleSpinBox*>()) { QString category = getSettingCategory(x->objectName()); QString name = getSettingName(x->objectName()); if(Settings::hasSetting(category,name)) { x->setValue(Settings::getSetting(category,name).toDouble()); options[x->objectName()] = Settings::getSetting(category,name); } else { options[x->objectName()] = x->value(); } } }