| 370 | } |
| 371 | |
| 372 | QWidget *DevicePropertiesDialog::buildDriverTab() { |
| 373 | auto *w = new QWidget; |
| 374 | auto *v = new QVBoxLayout(w); |
| 375 | v->setContentsMargins(8, 8, 8, 8); |
| 376 | v->setSpacing(0); |
| 377 | |
| 378 | v->addWidget(deviceHeader(m_info.name, m_info.iconName)); |
| 379 | v->addSpacing(8); |
| 380 | |
| 381 | const int lw = propertyLabelWidth(w); |
| 382 | |
| 383 | auto *form = new QGridLayout; |
| 384 | form->setContentsMargins(48, 0, 0, 0); |
| 385 | form->setHorizontalSpacing(16); |
| 386 | form->setVerticalSpacing(6); |
| 387 | form->setColumnMinimumWidth(0, lw); |
| 388 | form->setColumnStretch(1, 1); |
| 389 | int fRow = 0; |
| 390 | auto makeWrappingKey = [&](const QString &text) { |
| 391 | auto *k = formKey(text, lw); |
| 392 | k->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
| 393 | return k; |
| 394 | }; |
| 395 | auto makeWrappingValue = [](const QString &text) { |
| 396 | auto *l = plainLabel(text); |
| 397 | l->setWordWrap(true); |
| 398 | return l; |
| 399 | }; |
| 400 | auto addFormRow = [&](QLabel *key, QLabel *val) { |
| 401 | form->addWidget(key, fRow, 0, Qt::AlignTop | Qt::AlignLeft); |
| 402 | form->addWidget(val, fRow, 1); |
| 403 | ++fRow; |
| 404 | }; |
| 405 | |
| 406 | if (m_info.noDriverNeeded || m_info.disabled) { |
| 407 | addFormRow(makeWrappingKey("Driver Provider:"), makeWrappingValue("Unknown")); |
| 408 | addFormRow(makeWrappingKey("Driver Date:"), makeWrappingValue("Not available")); |
| 409 | addFormRow(makeWrappingKey("Driver Version:"), makeWrappingValue("Not available")); |
| 410 | addFormRow(makeWrappingKey("Digital Signer:"), makeWrappingValue("Not digitally signed")); |
| 411 | } else { |
| 412 | auto stripAuthorAnnotations = [](QString s) { |
| 413 | static const QRegularExpression kAnnotation(R"(\s*[<({\[].*?[>)}\]])", QRegularExpression::DotMatchesEverythingOption); |
| 414 | s.remove(kAnnotation); |
| 415 | return s.trimmed(); |
| 416 | }; |
| 417 | QString providerName; |
| 418 | if (!m_info.driverAuthor.isEmpty()) { |
| 419 | providerName = stripAuthorAnnotations(m_info.driverAuthor); |
| 420 | static const QSet<QString> kMinorWords = { |
| 421 | "a", "an", "the", "and", "but", "or", "nor", "for", "so", "yet", |
| 422 | "at", "by", "in", "of", "on", "to", "up", "as", "is", |
| 423 | // name particles (Dutch, German, French, Italian, Spanish, Portuguese) |
| 424 | "van", "von", "de", "den", "der", "del", "della", "di", "du", "le", "la", "las", "los" |
| 425 | }; |
| 426 | QStringList words = providerName.split(' ', Qt::SkipEmptyParts); |
| 427 | for (int i = 0; i < words.size(); ++i) { |
| 428 | QString &w = words[i]; |
| 429 | if (i == 0 || !kMinorWords.contains(w.toLower())) |
nothing calls this directly
no test coverage detected