History

Get graphics card type works on Mac laptop

NissimHadar committed 7 years ago

Commit c0a784f1 parent a3dde611 file · +22 −0Browse files

Showing the changes to interface/src/scripting/PlatformInfoScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/scripting/PlatformInfoScriptingInterface.cpp+22−0
@@ -95,5 +95,27 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { · 94 unmodified lines
9595 }
9696
9797 QString PlatformInfoScriptingInterface::getGraphicsCardType() {
98+#ifdef Q_OS_WIN
9899 return qApp->getGraphicsCardType();
100+#elif defined Q_OS_MAC
101+ FILE* stream = popen("system_profiler SPDisplaysDataType | grep Chipset", "r");
102+
103+ std::ostringstream hostStream;
104+ while (!feof(stream) && !ferror(stream)) {
105+ char buf[128];
106+ int bytesRead = fread(buf, 1, 128, stream);
107+ hostStream.write(buf, bytesRead);
108+ }
109+
110+ QString result = QString::fromStdString(hostStream.str());
111+ QStringList parts = result.split('\n');
112+ for (int i = 0; i < parts.size(); ++i) {
113+ if (parts[i].toLower().contains("radeon") || parts[i].toLower().contains("nvidia")) {
114+ return parts[i];
115+ }
116+ }
117+
118+ return "UNKNOWN";
119+#endif
120+
99121 }