* @brief Checks whether the current QtPass configuration is valid. * @example * bool result = Util::configIsValid(); * std::cout << std::boolalpha << result << std::endl; // Expected output: true * or false * * @return bool - True if the configuration file exists and the required * executable is available; otherwise false. */
| 189 | * executable is available; otherwise false. |
| 190 | */ |
| 191 | auto Util::configIsValid() -> bool { |
| 192 | const QString configFilePath = |
| 193 | QDir(QtPassSettings::getPassStore()).filePath(".gpg-id"); |
| 194 | if (!QFile(configFilePath).exists()) { |
| 195 | return false; |
| 196 | } |
| 197 | |
| 198 | const QString executable = QtPassSettings::isUsePass() |
| 199 | ? QtPassSettings::getPassExecutable() |
| 200 | : QtPassSettings::getGpgExecutable(); |
| 201 | |
| 202 | if (executable.startsWith(QStringLiteral("wsl "))) { |
| 203 | QString out; |
| 204 | QString err; |
| 205 | if (Executor::executeBlocking(QStringLiteral("wsl"), |
| 206 | {QStringLiteral("--version")}, &out, |
| 207 | &err) == 0 && |
| 208 | !out.isEmpty() && err.isEmpty()) { |
| 209 | return true; |
| 210 | } |
| 211 | } |
| 212 | return QFile(executable).exists(); |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * @brief Returns a directory path derived from a model index, optionally |
nothing calls this directly
no outgoing calls
no test coverage detected