| 120 | } |
| 121 | |
| 122 | bool GeneralSettingWidget::apply() |
| 123 | { |
| 124 | auto setting = SmartUTManager::instance()->utSetting(); |
| 125 | const auto &format = nameFormatEdit->text(); |
| 126 | if (format.isEmpty() || !format.contains("${filename}")) { |
| 127 | nameFormatEdit->setAlert(true); |
| 128 | nameFormatEdit->showAlertMessage(tr("Please input a valid format, e.g.ut_${filename}.cpp")); |
| 129 | nameFormatEdit->setFocus(); |
| 130 | nameFormatEdit->lineEdit()->selectAll(); |
| 131 | return false; |
| 132 | } |
| 133 | setting->setValue(kGeneralGroup, kNameFormat, format); |
| 134 | |
| 135 | QStringList templateList; |
| 136 | for (int i = 1; i < templateCB->count(); ++i) { |
| 137 | templateList << templateCB->itemText(i); |
| 138 | } |
| 139 | |
| 140 | setting->setValue(kGeneralGroup, kTemplates, templateList); |
| 141 | setting->setValue(kActiveGroup, kActiveTemplate, templateCB->currentIndex() == 0 ? "" : templateCB->currentText()); |
| 142 | setting->setValue(kActiveGroup, kActiveTestFramework, testFrameworkCB->currentText()); |
| 143 | return true; |
| 144 | } |