Commit 1896af7a5574151ec8915dbcd0286041c8ae7026
1 parent
9b4ea37f
Exists in
master
Método coletaNomeOs de OperatingSystem modificado para retornar o nome da distro corretamente.
Showing
1 changed file
with
17 additions
and
2 deletions
Show diff stats
src/operatingsystem.cpp
@@ -44,18 +44,33 @@ int OperatingSystem::coletaIdOs(){ | @@ -44,18 +44,33 @@ int OperatingSystem::coletaIdOs(){ | ||
44 | 44 | ||
45 | QString OperatingSystem::coletaNomeOs() | 45 | QString OperatingSystem::coletaNomeOs() |
46 | { | 46 | { |
47 | +#if defined(Q_OS_WIN) | ||
47 | QString text; | 48 | QString text; |
48 | QStringList environment = QProcessEnvironment::systemEnvironment().toStringList(); | 49 | QStringList environment = QProcessEnvironment::systemEnvironment().toStringList(); |
49 | foreach (text, environment) { | 50 | foreach (text, environment) { |
50 | // qDebug() << text; | 51 | // qDebug() << text; |
51 | - if (text.contains("OS=" , Qt::CaseInsensitive) || | ||
52 | - text.contains("SESSION=", Qt::CaseInsensitive) ){ | 52 | + if (text.contains("OS=" , Qt::CaseInsensitive) ){ |
53 | QStringList split = text.split("="); | 53 | QStringList split = text.split("="); |
54 | // qDebug() << split[1]; | 54 | // qDebug() << split[1]; |
55 | return split[1]; | 55 | return split[1]; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | +#elif defined(Q_OS_LINUX) | ||
59 | + ConsoleObject console; | ||
60 | + QStringList catOutput = console("cat /etc/*release").split("\n"); | ||
61 | + | ||
62 | + QString line; | ||
63 | + foreach(line, catOutput) { | ||
64 | + if(line.contains("PRETTY_NAME")) { | ||
65 | + QStringList split = line.split("="); | ||
66 | + | ||
67 | + QString nomeDistro = split[1].mid(1, split[1].size()-2 ); | ||
68 | + return nomeDistro; | ||
69 | + } | ||
70 | + } | ||
71 | +#endif | ||
58 | return ""; | 72 | return ""; |
73 | + | ||
59 | } | 74 | } |
60 | 75 | ||
61 | QJsonObject OperatingSystem::toJsonObject() | 76 | QJsonObject OperatingSystem::toJsonObject() |