| 176 | } |
| 177 | |
| 178 | QWidget *DevicePropertiesDialog::buildGeneralTab() { |
| 179 | auto *w = new QWidget; |
| 180 | auto *v = new QVBoxLayout(w); |
| 181 | v->setContentsMargins(8, 8, 8, 8); |
| 182 | v->setSpacing(0); |
| 183 | |
| 184 | v->addWidget(deviceHeader(m_info.name, m_info.iconName)); |
| 185 | v->addSpacing(8); |
| 186 | |
| 187 | const int lw = propertyLabelWidth(w); |
| 188 | |
| 189 | auto *form = new QGridLayout; |
| 190 | form->setContentsMargins(48, 0, 0, 0); |
| 191 | form->setHorizontalSpacing(16); |
| 192 | form->setVerticalSpacing(6); |
| 193 | form->setColumnMinimumWidth(0, lw); |
| 194 | form->setColumnStretch(1, 1); |
| 195 | int fRow = 0; |
| 196 | auto makeWrappingKey = [&](const QString &text) { |
| 197 | auto *k = formKey(text, lw); |
| 198 | k->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
| 199 | return k; |
| 200 | }; |
| 201 | auto makeWrappingValue = [](const QString &text) { |
| 202 | auto *l = plainLabel(text); |
| 203 | l->setWordWrap(true); |
| 204 | return l; |
| 205 | }; |
| 206 | auto addRow = [&](QLabel *key, QLabel *val) { |
| 207 | form->addWidget(key, fRow, 0, Qt::AlignTop | Qt::AlignLeft); |
| 208 | form->addWidget(val, fRow, 1); |
| 209 | ++fRow; |
| 210 | }; |
| 211 | |
| 212 | addRow(makeWrappingKey("Device type:"), makeWrappingValue( |
| 213 | m_info.deviceType.isEmpty() ? "Hardware device" : m_info.deviceType)); |
| 214 | addRow(makeWrappingKey("Manufacturer:"), makeWrappingValue(m_info.manufacturer)); |
| 215 | auto *locationLabel = makeWrappingValue( |
| 216 | m_info.location.isEmpty() ? "Unknown" : m_info.location); |
| 217 | if (!m_info.rawLocation.isEmpty() |
| 218 | && m_info.rawLocation != m_info.location) |
| 219 | locationLabel->setToolTip(m_info.rawLocation); |
| 220 | addRow(makeWrappingKey("Location:"), locationLabel); |
| 221 | v->addLayout(form); |
| 222 | |
| 223 | v->addSpacing(18); |
| 224 | |
| 225 | QString statusText; |
| 226 | if (m_info.disabled) |
| 227 | statusText = "This device is disabled."; |
| 228 | else if (m_info.noDriverNeeded) |
| 229 | statusText = "This device is working properly and does not require a driver because it is completely managed by the kernel."; |
| 230 | else if (m_info.status == "Working properly") |
| 231 | statusText = "This device is working properly."; |
| 232 | else if (m_info.status == "No driver loaded") |
| 233 | statusText = "The drivers for this device are not installed. " |
| 234 | "(Code 28)"; |
| 235 | else if (m_info.status == "No battery level") |
nothing calls this directly
no test coverage detected