| 173 | } |
| 174 | |
| 175 | void ConnectionOptionPage::insertFromConfigFile(bool forceFileSelection) |
| 176 | { |
| 177 | auto configFile(forceFileSelection ? QString() : SyncthingConfig::locateConfigFile()); |
| 178 | if (configFile.isEmpty()) { |
| 179 | // allow user to select config file manually if it could not be located |
| 180 | configFile = QFileDialog::getOpenFileName( |
| 181 | widget(), QCoreApplication::translate("QtGui::ConnectionOptionPage", "Select Syncthing config file") + QStringLiteral(" - " APP_NAME)); |
| 182 | } |
| 183 | if (configFile.isEmpty()) { |
| 184 | return; |
| 185 | } |
| 186 | SyncthingConfig config; |
| 187 | if (!config.restore(configFile)) { |
| 188 | QMessageBox::critical(widget(), widget()->windowTitle() + QStringLiteral(" - " APP_NAME), |
| 189 | QCoreApplication::translate("QtGui::ConnectionOptionPage", "Unable to parse the Syncthing config file.")); |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | if (!config.guiAddress.isEmpty()) { |
| 194 | const auto connectInfo = config.syncthingConnectInfo(); |
| 195 | ui()->urlLineEdit->selectAll(); |
| 196 | ui()->urlLineEdit->insert(connectInfo.url); |
| 197 | ui()->localPathLineEdit->selectAll(); |
| 198 | ui()->localPathLineEdit->insert(connectInfo.path); |
| 199 | } |
| 200 | if (!config.guiUser.isEmpty() || !config.guiPasswordHash.isEmpty()) { |
| 201 | ui()->authCheckBox->setChecked(true); |
| 202 | ui()->userNameLineEdit->selectAll(); |
| 203 | ui()->userNameLineEdit->insert(config.guiUser); |
| 204 | } else { |
| 205 | ui()->authCheckBox->setChecked(false); |
| 206 | } |
| 207 | if (!config.guiApiKey.isEmpty()) { |
| 208 | ui()->apiKeyLineEdit->selectAll(); |
| 209 | ui()->apiKeyLineEdit->insert(config.guiApiKey); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | void ConnectionOptionPage::updateConnectionStatus() |
| 214 | { |
nothing calls this directly
no test coverage detected