[users] Clean up DMI model more for hostname

Remove anything in parentheses, and also drop the "Apple" prefix for
Apple machines. This converts:

"Apple MacBook Air (13-inch, M2, 2022)"

into:

"MacBookAir"

which is a lot more reasonable.

Other vendors could be added as needed (it's inconsistent whether DT
platforms prefix the model with the vendor or not).

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2023-08-06 20:00:52 +09:00
parent 17e1027ea2
commit a899f76da2

View File

@ -321,7 +321,7 @@ Config::hostnameStatus() const
static QString
cleanupForHostname( const QString& s )
{
QRegExp dmirx( "[^a-zA-Z0-9]", Qt::CaseInsensitive );
QRegExp dmirx( "(^Apple|\\(.*\\)|[^a-zA-Z0-9])", Qt::CaseInsensitive );
return s.toLower().replace( dmirx, " " ).remove( ' ' );
}