Developer Documentation
About.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 
44 
45 
46 
47 //=============================================================================
48 //
49 // CLASS Core - IMPLEMENTATION
50 //
51 //=============================================================================
52 
53 
54 //== INCLUDES =================================================================
55 
56 #include <common/glew_wrappers.hh>
57 #include "CoreWidget.hh"
60 
61 
62 #include <QGLFormat>
63 
64 #ifndef WIN32
65  #ifndef ARCH_DARWIN
66  #include <malloc.h>
67  #include <unistd.h>
68  #endif
69 #endif
70 
71 #ifdef ARCH_DARWIN
72  #include <sys/types.h>
73  #include <sys/sysctl.h>
74 #endif
75 
76 //== Defines =================================================================
77 
78 #define GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
79 #define GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
80 
81 //== IMPLEMENTATION ==========================================================
82 
83 void CoreWidget::addAboutInfo(QString _text, QString _tabName ) {
84  additionalAboutTabs_[_tabName] = _text;
85 }
86 
88 
89  if ( OpenFlipper::Options::nogui() )
90  return;
91 
92  if ( aboutWidget_ == 0 ) {
93  aboutWidget_ = new AboutWidget( this );
94 
95 
96  // Add all additional tabs
97  QMap<QString, QString>::const_iterator it = additionalAboutTabs_.constBegin();
98  while (it != additionalAboutTabs_.constEnd()) {
99  QTextEdit* tmp = new QTextEdit();
100  tmp->insertHtml( it.value() );
101  tmp->setReadOnly(true);
102  aboutWidget_->About->addTab( tmp, it.key() );
103  ++it;
104  }
105 
106  } else {
107  aboutWidget_->OpenFlipperAbout->clear();
108  }
109 
110  QFont standardFont = aboutWidget_->OpenFlipperAbout->currentFont();
111  QFont boldFont = standardFont;
112  boldFont.setBold(true);
113 
114  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
115  aboutWidget_->OpenFlipperAbout->append(tr("%1 Core Version: %2", "PRODUCT_NAME Core Version:").arg(TOSTRING(PRODUCT_NAME)).arg(OpenFlipper::Options::coreVersion()) ) ;
116  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
117 
118  // =====================================================================================
119  // Directory info
120  // =====================================================================================
121  aboutWidget_->OpenFlipperAbout->append("\n");
122  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
123  aboutWidget_->OpenFlipperAbout->append(tr("%1 Directories:").arg(TOSTRING(PRODUCT_NAME)));
124  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
125 
126  // Get the dataDir
127  QDir tempDir = QDir(OpenFlipper::Options::applicationDir());
128  #ifdef OPENFLIPPER_DATADIR
129  tempDir.cd(OPENFLIPPER_DATADIR);
130  #endif
131  aboutWidget_->OpenFlipperAbout->append("Data:\t " + tempDir.absolutePath() );
132  aboutWidget_->OpenFlipperAbout->append("Shaders:\t " + OpenFlipper::Options::shaderDirStr() );
133  aboutWidget_->OpenFlipperAbout->append("Textures:\t " + OpenFlipper::Options::textureDirStr() );
134  aboutWidget_->OpenFlipperAbout->append("Scripts:\t " + OpenFlipper::Options::scriptDirStr() );
135  aboutWidget_->OpenFlipperAbout->append("Icons:\t " + OpenFlipper::Options::iconDirStr() );
136  aboutWidget_->OpenFlipperAbout->append("Fonts:\t" + OpenFlipper::Options::fontsDirStr() );
137  aboutWidget_->OpenFlipperAbout->append("Help:\t" + OpenFlipper::Options::helpDirStr() );
138  aboutWidget_->OpenFlipperAbout->append("\n");
139 
140  // =====================================================================================
141  // Config files
142  // =====================================================================================
143  aboutWidget_->OpenFlipperAbout->append("\n");
144  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
145  aboutWidget_->OpenFlipperAbout->append(tr("%1 configuration files:").arg(TOSTRING(PRODUCT_NAME)));
146  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
147 
148  aboutWidget_->OpenFlipperAbout->append(tr("ConfigDir:\t\t\t") + OpenFlipper::Options::configDirStr() );
149  aboutWidget_->OpenFlipperAbout->append(tr("Window states:\t\t") + OpenFlipper::Options::configDirStr() + OpenFlipper::Options::dirSeparator() + "WindowStates.dat");
150 
151  aboutWidget_->OpenFlipperAbout->append(tr("Main option file:\t\t") + OpenFlipperSettings().fileName());
152  aboutWidget_->OpenFlipperAbout->append(tr("Additional option files:"));
153  for ( int i = 0 ; i < OpenFlipper::Options::optionFiles().size() ; ++i)
154  aboutWidget_->OpenFlipperAbout->append(OpenFlipper::Options::optionFiles()[i]);
155 
156 
157 
158 
159  // =====================================================================================
160  // Memory infos
161  // =====================================================================================
162  aboutWidget_->OpenFlipperAbout->append("\n");
163  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
164  aboutWidget_->OpenFlipperAbout->append(tr("Memory Information:"));
165  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
166 
167 
168  #ifdef WIN32
169 
170  // Define memory structure
171  MEMORYSTATUSEX ms;
172  // Set the size ( required according to spec ... why???? )
173  ms.dwLength = sizeof (ms);
174 
175  // Get the info
176  GlobalMemoryStatusEx(&ms);
177 
178  // Output to widget
179  aboutWidget_->OpenFlipperAbout->append(tr("Physical Memory:\t")+ QString::number(ms.ullAvailPhys/1024/1024) + "MB/"+
180  QString::number(ms.ullTotalPhys/1024/1024) + "MB free ("+
181  QString::number(ms.dwMemoryLoad) + "%)");
182  aboutWidget_->OpenFlipperAbout->append(tr("Pagefile Memory:\t")+ QString::number(ms.ullAvailPageFile/1024/1024) + "MB/"
183  + QString::number(ms.ullTotalPageFile/1024/1024) + "MB free");
184 
185 
186  #elif defined ARCH_DARWIN
187 
188  aboutWidget_->OpenFlipperAbout->append(tr("Not available for this platform (MacOS)"));
189 
190 
191  #else
192  unsigned long memory = 0;
193 
194  struct mallinfo info;
195  info = mallinfo();
196 
197  // add mmap-allocated memory
198  memory += info.hblkhd;
199 
200  // add sbrk-allocated memory
201  memory += info.uordblks;
202 
203  double mmapAllocated = double(info.hblkhd ) / 1024 / 1024;
204  double sbrkAllocated = double(info.uordblks) / 1024 / 1024;
205  double totalAllocated = double(memory) / 1024 / 1024;
206 
207  double pageSize = double(getpagesize()) /1024 ;
208  double availablePages = double( sysconf (_SC_AVPHYS_PAGES) );
209  double freeMem = availablePages * pageSize / 1024;
210 
211  aboutWidget_->OpenFlipperAbout->append(tr("Total Memory allocated:\t ") + QString::number(totalAllocated,'f' ,2 ) + tr("MB ")
212  + tr("( mmap: ") + QString::number(mmapAllocated ,'f' ,2 ) + tr("MB")
213  + tr(", sbrk: ") + QString::number(sbrkAllocated ,'f' ,2 ) + tr("MB )") );
214 
215  aboutWidget_->OpenFlipperAbout->append(tr("Free Memory:\t\t ") + QString::number(freeMem,'f' ,2 ) + tr("MB ")
216  + tr("(") + QString::number(availablePages,'f' ,0 ) + tr(" pages of ")
217  + QString::number(pageSize,'f' ,2 ) + tr("KB size)"));
218 
219  #endif
220 
221  // =====================================================================================
222  // Memory infos
223  // =====================================================================================
224  aboutWidget_->OpenFlipperAbout->append("\n");
225  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
226  aboutWidget_->OpenFlipperAbout->append(tr("CPU Information:"));
227  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
228 
229  #ifdef WIN32
230 
231  QSettings registryCPU("HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor", QSettings::NativeFormat);
232 
233  QStringList cpus = registryCPU.childGroups();
234  if ( cpus.size() != 0 ) {
235 
236  aboutWidget_->OpenFlipperAbout->append(tr("CPU vendor:\t\t ") +
237  registryCPU.value( cpus[0]+"/VendorIdentifier", "Unknown" ).toString() );
238  aboutWidget_->OpenFlipperAbout->append(tr("CPU model:\t\t ") +
239  registryCPU.value( cpus[0]+"/ProcessorNameString", "Unknown" ).toString() );
240  aboutWidget_->OpenFlipperAbout->append(tr("CPU identifier:\t\t ") +
241  registryCPU.value( cpus[0]+"/Identifier", "Unknown" ).toString() );
242  aboutWidget_->OpenFlipperAbout->append(tr("CPU Speed:\t\t ") +
243  registryCPU.value( cpus[0]+"/~MHz", "Unknown" ).toString()+ " MHz" );
244 
245  aboutWidget_->OpenFlipperAbout->append("CPU Cores:\t\t " + QString::number(cpus.size()));
246 
247  } else {
248  aboutWidget_->OpenFlipperAbout->append(tr("Unable to retrieve CPU information"));
249  }
250 
251  #elif defined ARCH_DARWIN
252 
253 
254  size_t lenCPU;
255  char *pCPU;
256 
257  // First call to get required size
258  sysctlbyname("machdep.cpu.brand_string", NULL, &lenCPU, NULL, 0);
259 
260  // allocate
261  pCPU = (char * )malloc(lenCPU);
262 
263  // Second call to get data
264  sysctlbyname("machdep.cpu.brand_string", pCPU, &lenCPU, NULL, 0);
265 
266  // Output
267  aboutWidget_->OpenFlipperAbout->append(tr("CPU Brand:\t\t ") + QString(pCPU) );
268 
269  // free memory
270  free(pCPU);
271 
272  int physicalCPUS = 0;
273 
274  // Get data
275  lenCPU = sizeof(int);
276  sysctlbyname("hw.physicalcpu", &physicalCPUS, &lenCPU , NULL, 0);
277 
278  // Output
279  aboutWidget_->OpenFlipperAbout->append(tr("Physical Cores:\t\t ") + QString::number(physicalCPUS) );
280 
281  int logicalCPUS = 0;
282 
283  // Get data
284  lenCPU = sizeof(int);
285  sysctlbyname("hw.logicalcpu", &logicalCPUS, &lenCPU, NULL, 0);
286 
287  // Output
288  aboutWidget_->OpenFlipperAbout->append(tr("LogicalCores:\t\t ") + QString::number(logicalCPUS) );
289 
290  #else
291  QFile cpuinfo("/proc/cpuinfo");
292  if (! cpuinfo.exists() )
293  aboutWidget_->OpenFlipperAbout->append(tr("Unable to retrieve CPU information"));
294  else {
295 
296  cpuinfo.open(QFile::ReadOnly);
297  QTextStream stream(&cpuinfo);
298 
299  #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
300  QStringList splitted = stream.readAll().split("\n",QString::SkipEmptyParts);
301  #else
302  QStringList splitted = stream.readAll().split("\n",Qt::SkipEmptyParts);
303  #endif
304 
305 
306  int position = splitted.indexOf ( QRegExp("^vendor_id.*") );
307  if ( position != -1 ){
308  QString cpuVendor = splitted[position].section(':', -1).simplified();
309  aboutWidget_->OpenFlipperAbout->append(tr("CPU vendor:\t\t ") + cpuVendor );
310  } else {
311  aboutWidget_->OpenFlipperAbout->append(tr("CPU vendor:\t\t vendor specification not found"));
312  }
313 
314  position = splitted.indexOf ( QRegExp("^model name.*") );
315  if ( position != -1 ){
316  QString cpuModel = splitted[position].section(':', -1).simplified();
317  aboutWidget_->OpenFlipperAbout->append(tr("CPU model:\t\t ") + cpuModel );
318  } else {
319  aboutWidget_->OpenFlipperAbout->append(tr("CPU model:\t\t Model specification not found"));
320  }
321 
322  position = splitted.indexOf ( QRegExp("^cpu cores.*") );
323  if ( position != -1 ){
324  QString cpuCoresPhysical = splitted[position].section(':', -1).simplified();
325  aboutWidget_->OpenFlipperAbout->append(tr("Physical CPU cores:\t\t ") + cpuCoresPhysical );
326  } else {
327  aboutWidget_->OpenFlipperAbout->append(tr("Physical CPU cores:\t\t CPU Core specification not found"));
328  }
329 
330  position = splitted.indexOf ( QRegExp("^siblings.*") );
331  if ( position != -1 ){
332  QString cpuCoresLogical = splitted[position].section(':', -1).simplified();
333  aboutWidget_->OpenFlipperAbout->append(tr("Logical CPU cores:\t\t ") + cpuCoresLogical );
334  } else {
335  aboutWidget_->OpenFlipperAbout->append(tr("Logical CPU cores:\t\t CPU Core specification not found"));
336  }
337 
338  position = splitted.indexOf ( QRegExp("^flags.*") );
339  if ( position != -1 ){
340  QString cpuFlags = splitted[position].section(':', -1).simplified();
341  aboutWidget_->OpenFlipperAbout->append( tr("CPU capabilities:") );
342  aboutWidget_->OpenFlipperAbout->append( cpuFlags );
343  } else {
344  aboutWidget_->OpenFlipperAbout->append(tr("CPU capabilities:\t\t CPU flag specification not found"));
345  }
346 
347  #if Q_BYTE_ORDER == Q_BIG_ENDIAN
348  aboutWidget_->OpenFlipperAbout->append(tr("System is Big Endian"));
349  #endif
350 
351  #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
352  aboutWidget_->OpenFlipperAbout->append(tr("System is Little Endian"));
353  #endif
354 
355  }
356 
357  #endif
358 
359  // =====================================================================================
360  // OS info
361  // =====================================================================================
362  aboutWidget_->OpenFlipperAbout->append("\n");
363  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
364  aboutWidget_->OpenFlipperAbout->append(tr("Operating System Info:"));
365  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
366 
367  #ifdef WIN32
368  QSettings registryOS("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat);
369  aboutWidget_->OpenFlipperAbout->append(tr("Product Name:\t\t ") +
370  registryOS.value( "ProductName", "Unknown" ).toString() );
371  aboutWidget_->OpenFlipperAbout->append(tr("Current Version:\t\t ") +
372  registryOS.value( "CurrentVersion", "Unknown" ).toString() );
373  #elif defined ARCH_DARWIN
374 
375  int mib[2];
376  size_t len;
377  char *p;
378 
379  mib[0] = CTL_KERN;
380  mib[1] = KERN_VERSION;
381 
382  sysctl(mib, 2, NULL, &len, NULL, 0);
383  p = (char * )malloc(len);
384  sysctl(mib, 2, p, &len, NULL, 0);
385 
386  aboutWidget_->OpenFlipperAbout->append(tr("OS Version:\t\t ") + QString(p) );
387 
388  free(p);
389 
390  #else
391  QFile versionInfo("/proc/version");
392  if (! versionInfo.exists() )
393  aboutWidget_->OpenFlipperAbout->append(tr("Unable to retrieve Kernel information"));
394  else {
395  versionInfo.open(QFile::ReadOnly);
396  QTextStream versionStream(&versionInfo);
397  aboutWidget_->OpenFlipperAbout->append(tr("Kernel Version:\t\t ") + versionStream.readAll().simplified());
398 
399  QString program = "/usr/bin/lsb_release";
400 
401  QFile lsb(program);
402  if ( lsb.exists() ) {
403  QStringList arguments;
404  arguments << "-a";
405 
406  QProcess myProcess;
407  myProcess.start(program, arguments);
408 
409  if ( myProcess.waitForFinished ( 4000 ) ) {
410  QStringList outputLSB = QString(myProcess.readAllStandardOutput()).split('\n');
411 
412 
413  int position = outputLSB.indexOf ( QRegExp("^Distributor ID.*") );
414  if ( position != -1 ){
415  QString distributorID = outputLSB[position].section(':', -1).simplified();
416  aboutWidget_->OpenFlipperAbout->append(tr("Distributor ID:\t\t ") + distributorID );
417  } else {
418  aboutWidget_->OpenFlipperAbout->append(tr("Distributor ID:\t\t Unknown"));
419  }
420 
421  position = outputLSB.indexOf ( QRegExp("^Description.*") );
422  if ( position != -1 ){
423  QString description = outputLSB[position].section(':', -1).simplified();
424  aboutWidget_->OpenFlipperAbout->append(tr("Description:\t\t ") + description );
425  } else {
426  aboutWidget_->OpenFlipperAbout->append(tr("Description:\t\t Unknown"));
427  }
428 
429  position = outputLSB.indexOf ( QRegExp("^Release.*") );
430  if ( position != -1 ){
431  QString release = outputLSB[position].section(':', -1).simplified();
432  aboutWidget_->OpenFlipperAbout->append(tr("Release number:\t\t ") + release );
433  } else {
434  aboutWidget_->OpenFlipperAbout->append(tr("Release number:\t\t Unknown"));
435  }
436 
437  position = outputLSB.indexOf ( QRegExp("^Codename.*") );
438  if ( position != -1 ){
439  QString codename = outputLSB[position].section(':', -1).simplified();
440  aboutWidget_->OpenFlipperAbout->append(tr("Codename:\t\t ") + codename );
441  } else {
442  aboutWidget_->OpenFlipperAbout->append(tr("Codename:\t\t Unknown"));
443  }
444 
445  } else {
446  aboutWidget_->OpenFlipperAbout->append(tr("Unable to get LSB info"));
447  }
448 
449  } else {
450  aboutWidget_->OpenFlipperAbout->append(tr("No additional information. Unable to get info via LSB."));
451  }
452 
453  }
454  #endif
455 
456  QString systemPathVariable = getenv("PATH");
457  aboutWidget_->OpenFlipperAbout->append(tr("System Path:\n ") + systemPathVariable);
458 
459 #ifndef WIN32
460  QString systemLibraryPathVariable = getenv("LD_LIBRARY_PATH");
461  aboutWidget_->OpenFlipperAbout->append(tr("LD_LIBRARY_PATH:\n ") + systemLibraryPathVariable);
462 #endif
463 
464 
465 
466  // =====================================================================================
467  // OpenGL Renderer/Vendor and version info
468  // =====================================================================================
469  aboutWidget_->OpenFlipperAbout->append("\n");
470  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
471  aboutWidget_->OpenFlipperAbout->append(tr("OpenGL Specific Info:"));
472  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
473 
474  QString vendor = QString((const char*)glGetString(GL_VENDOR));
475  aboutWidget_->OpenFlipperAbout->append(tr("Qt reports Vendor:\t\t") + vendor);
476  QString renderer = QString((const char*)glGetString(GL_RENDERER));
477  aboutWidget_->OpenFlipperAbout->append(tr("Qt reports Renderer:\t\t") + renderer);
478 
479  QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
480 
481  QString openGLQtVersion = tr("Qt reports Version:\t\t");
482 
483  if ( flags.testFlag(QGLFormat::OpenGL_Version_4_0) )
484  openGLQtVersion += tr("4.0 or higher") ;
485  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_3))
486  openGLQtVersion += tr("3.3") ;
487  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_2))
488  openGLQtVersion += tr("3.2") ;
489  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_1))
490  openGLQtVersion += tr("3.1") ;
491  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_0))
492  openGLQtVersion += tr("3.0") ;
493  else if (flags.testFlag(QGLFormat::OpenGL_Version_2_1))
494  openGLQtVersion += tr("2.1" );
495  else if (flags.testFlag(QGLFormat::OpenGL_Version_2_0))
496  openGLQtVersion += tr("2.0" );
497  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_5))
498  openGLQtVersion += tr("1.5" );
499  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_4))
500  openGLQtVersion += tr("1.4" );
501  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_3))
502  openGLQtVersion += tr("1.3" );
503  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_2))
504  openGLQtVersion += tr("1.2" );
505  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_1))
506  openGLQtVersion += tr("1.1" );
507  else
508  openGLQtVersion += tr("Version:\tUNKNOWN!" );
509 
510  aboutWidget_->OpenFlipperAbout->append(openGLQtVersion);
511 
512  aboutWidget_->OpenFlipperAbout->append("\n");
513 
514  const QGLContext* context = QGLContext::currentContext();
515  if (context) {
516  QString openGLprofile = tr("Qt reports the OpenGL profile:\t");
517  QGLFormat::OpenGLContextProfile profile = context->format().profile();
518  if (profile == QGLFormat::NoProfile)
519  openGLprofile += tr("no profile");
520  else if (profile == QGLFormat::CoreProfile)
521  openGLprofile += tr("Core profile");
522  else if (profile == QGLFormat::CompatibilityProfile)
523  openGLprofile += tr("Compatibility profile");
524  else
525  openGLprofile += tr("unknown profile");
526 
527  aboutWidget_->OpenFlipperAbout->append(openGLprofile);
528  aboutWidget_->OpenFlipperAbout->append("\n");
529  }
530 
531 
532  QString openGLVendor = tr("GL reports Vendor:\t\t");
533  openGLVendor += QString((const char*)glGetString(GL_VENDOR));
534  aboutWidget_->OpenFlipperAbout->append(openGLVendor);
535 
536  QString openGLRenderer = tr("GL reports Renderer:\t\t");
537  openGLRenderer += QString((const char*)glGetString(GL_RENDERER));
538  aboutWidget_->OpenFlipperAbout->append(openGLRenderer);
539 
540  QString openGLGLVersion = tr("GL reports Version:\t\t");
541  openGLGLVersion += QString((const char*)glGetString(GL_VERSION));
542  aboutWidget_->OpenFlipperAbout->append(openGLGLVersion);
543 
544  QString openGLShadingLanguageVersion = tr("GL reports Shading Language Version:\t");
545  openGLShadingLanguageVersion += QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION));
546  aboutWidget_->OpenFlipperAbout->append(openGLShadingLanguageVersion);
547 
548 
549  // =====================================================================================
550  // OpenGL Extensions
551  // =====================================================================================
552  aboutWidget_->OpenFlipperAbout->append("\n");
553  aboutWidget_->OpenFlipperAbout->append(tr("Supported Extensions:"));
554  QString glExtensions = QString(ACG::getExtensionString().c_str());
555  aboutWidget_->OpenFlipperAbout->append(glExtensions);
556 
557 
558  // =====================================================================================
559  // OpenGL Properties
560  // =====================================================================================
561  aboutWidget_->OpenFlipperAbout->append("\n");
562  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
563  aboutWidget_->OpenFlipperAbout->append(tr("OpenGL Values:"));
564  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
565  GLint getBuffer[2];
566  glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &getBuffer[0] );
567  aboutWidget_->OpenFlipperAbout->append(tr("Maximal Viewport size(GL_MAX_VIEWPORT_DIMS):\t\t\t\t ") + QString::number(getBuffer[0]) + "x" + QString::number(getBuffer[1]) );
568 
569  glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &getBuffer[0] );
570  aboutWidget_->OpenFlipperAbout->append(tr("Maximum supported texture image units(GL_MAX_TEXTURE_IMAGE_UNITS):\t") + QString::number(getBuffer[0]) );
571 
572  // Check extension for NVIDIA memory information
573  if ( glExtensions.contains("GL_NVX_gpu_memory_info") ) {
574  // get total memory on gpu
575  GLint total_mem_kb = 0;
576  glGetIntegerv(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &total_mem_kb);
577 
578  aboutWidget_->OpenFlipperAbout->append(tr("GPU Memory (Total available):\t\t") + QString::number(total_mem_kb /1024) + " MB" );
579 
580  // get currently available memory on gpu
581  GLint cur_avail_mem_kb = 0;
582  glGetIntegerv(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb);
583 
584  aboutWidget_->OpenFlipperAbout->append(tr("GPU Memory (Currently available):\t") + QString::number(cur_avail_mem_kb / 1024) + " MB" );
585  }
586 
587 
588 
589  aboutWidget_->OpenFlipperAbout->moveCursor(QTextCursor::Start);
590 
591  // =====================================================================================
592  // glew Information
593  // =====================================================================================
594  #ifndef __APPLE__
595  aboutWidget_->OpenFlipperAbout->append("\n");
596  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
597  aboutWidget_->OpenFlipperAbout->append(tr("GLEW Specific Info:"));
598  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
599 
600  QString glewVersion = QString(getGlewVersion());
601  aboutWidget_->OpenFlipperAbout->append(tr("GLEW Version:\t") + glewVersion);
602  #endif
603 
604  // =====================================================================================
605  // Qt information
606  // =====================================================================================
607 
608  aboutWidget_->OpenFlipperAbout->append("\n");
609  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
610  aboutWidget_->OpenFlipperAbout->append(tr("Qt Version Info:"));
611  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
612  aboutWidget_->OpenFlipperAbout->append(tr("Currently used Version:\t") + qVersion() );
613  aboutWidget_->OpenFlipperAbout->append(tr("Link time Version:\t\t") + QT_VERSION_STR );
614 
615  QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
616  QString formatsString = "";
617  for ( int i = 0 ; i < imageFormats.size() ; ++i) {
618  formatsString += imageFormats[i] + " ";
619 
620  if ( (i != 0) && (i % 15) == 0 )
621  formatsString+= "\n";
622  }
623 
624  aboutWidget_->OpenFlipperAbout->append(tr("Supported image read formats:") );
625  aboutWidget_->OpenFlipperAbout->append(formatsString);
626 
627  aboutWidget_->OpenFlipperAbout->append("\n");
628 
629  aboutWidget_->OpenFlipperAbout->append(tr("Currently used Library paths:") );
630  QStringList libPaths = QCoreApplication::libraryPaths();
631  for(int i = 0 ; i < libPaths.size() ; ++i)
632  aboutWidget_->OpenFlipperAbout->append(" " + libPaths[i]);
633 
634 
635  // =========================================================
636  // Qt Documentation files
637  // =========================================================
638 /*
639  aboutWidget_->OpenFlipperAbout->append("\n");
640  aboutWidget_->OpenFlipperAbout->append(tr("Currently Loaded documentations:") );
641 
642  QStringList registeredDocumentations = helpEngine_->registeredDocumentations ();
643 
644  for ( int i = 0 ; i < registeredDocumentations.size(); ++i) {
645  QString documentationInfo = registeredDocumentations[i];
646  documentationInfo += " ";
647  documentationInfo += helpEngine_->documentationFileName(registeredDocumentations[i]);
648  aboutWidget_->OpenFlipperAbout->append(documentationInfo);
649  }
650 */
651  // =====================================================================================
652  // Compiler information
653  // =====================================================================================
654  aboutWidget_->OpenFlipperAbout->append("\n");
655  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
656  aboutWidget_->OpenFlipperAbout->append(tr("Compiler Info:"));
657  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
658  aboutWidget_->OpenFlipperAbout->append( OpenFlipper::Options::compilerInfo() );
659 
660  QString definitions;
661 
662  // Trying to check some defines:
663  #ifdef WIN32
664  definitions += "WIN32 ";
665  #endif
666 
667  #ifdef WIN64
668  definitions += "WIN64 ";
669  #endif
670 
671  #ifdef DLL
672  definitions += "DLL ";
673  #endif
674 
675 
676  #ifdef APPLE
677  definitions += "APPLE ";
678  #endif
679 
680  #ifdef ARCH_DARWIN
681  definitions += "ARCH_DARWIN ";
682  #endif
683 
684  #ifdef INCLUDE_TEMPLATES
685  definitions += "INCLUDE_TEMPLATES ";
686  #endif
687 
688  #ifdef DEBUG
689  definitions += "DEBUG ";
690  #endif
691 
692  #ifdef NDEBUG
693  definitions += "NDEBUG ";
694  #endif
695 
696  #ifdef QT_NO_OPENGL
697  definitions += "QT_NO_OPENGL ";
698  #endif
699 
700  #ifdef OPENMP
701  definitions += "OPENMP ";
702  #endif
703 
704  #ifdef USE_OPENMP
705  definitions += "USE_OPENMP ";
706  #endif
707 
708  aboutWidget_->OpenFlipperAbout->append( tr("Definitions (incomplete):\n") + definitions );
709 
710  // =====================================================================================
711  // List the currently registered data types
712  // =====================================================================================
713  aboutWidget_->OpenFlipperAbout->append("\n");
714  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
715  aboutWidget_->OpenFlipperAbout->append(tr("Registered data types:"));
716  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
717 
718  QString types;
719 
720  // Iterate over all Types known to the core
721  // Start at 1:
722  // 0 type is defined as DATA_UNKNOWN
723  DataType currentType = 1;
724  for ( uint i = 0 ; i < typeCount() - 2 ; ++i) {
725  types += typeName( currentType ) + "\t\t typeId: " + QString::number(currentType.value()) + "\n";
726 
727  // Advance to next type ( Indices are bits so multiply by to to get next bit)
728  ++currentType;
729  }
730 
731  aboutWidget_->OpenFlipperAbout->append( types );
732 
733  // =====================================================================================
734  // List The File Plugins with their filters
735  // =====================================================================================
736  aboutWidget_->OpenFlipperAbout->append("\n");
737  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
738  aboutWidget_->OpenFlipperAbout->append(tr("Registered File Plugins:"));
739  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
740 
741  for ( uint i = 0 ; i < supportedTypes().size() ; ++i ) {
742  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
743  aboutWidget_->OpenFlipperAbout->append( "\t" + supportedTypes()[i].name );
744  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
745  aboutWidget_->OpenFlipperAbout->append( "\t\t Load: " + supportedTypes()[i].loadFilters );
746  aboutWidget_->OpenFlipperAbout->append( "\t\t Save: " + supportedTypes()[i].saveFilters );
747  }
748 
749 
750  // =====================================================================================
751  // List all Plugins
752  // =====================================================================================
753  aboutWidget_->OpenFlipperAbout->append("\n");
754  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
755  aboutWidget_->OpenFlipperAbout->append(tr("Loaded Plugins:"));
756  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
757 
758  for ( uint i = 0 ; i < plugins().size() ; ++i ) {
759  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
760  aboutWidget_->OpenFlipperAbout->append( "\t" + plugins()[i].name );
761  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
762  aboutWidget_->OpenFlipperAbout->append( "\t\t Version: \t\t" + plugins()[i].version );
763  aboutWidget_->OpenFlipperAbout->append( "\t\t Description: \t" + plugins()[i].description );
764  aboutWidget_->OpenFlipperAbout->append( "\t\t Path \t\t" + plugins()[i].path );
765 
766  if ( !plugins()[i].warnings.isEmpty() ) {
767  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkYellow);
768  aboutWidget_->OpenFlipperAbout->append( "\t\t Warnings: \t\t" + plugins()[i].warnings );
769  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
770  }
771 
772  if ( !plugins()[i].errors.isEmpty() ) {
773  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkRed);
774  aboutWidget_->OpenFlipperAbout->append( "\t\t Errors: \t\t" + plugins()[i].errors );
775  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
776  }
777 
778  }
779 
780  // =====================================================================================
781  // List failed Plugins
782  // =====================================================================================
783  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
784  aboutWidget_->OpenFlipperAbout->append(tr("Failed Plugins:"));
785  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
786 
787  for ( unsigned i = 0 ; i < PluginStorage::pluginsFailed().size() ; ++i ) {
788  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
789  aboutWidget_->OpenFlipperAbout->append( "\t" + PluginStorage::pluginsFailed()[i].name );
790  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
791  aboutWidget_->OpenFlipperAbout->append( "\t\t Version: \t\t" + PluginStorage::pluginsFailed()[i].version );
792  aboutWidget_->OpenFlipperAbout->append( "\t\t Description: \t" + PluginStorage::pluginsFailed()[i].description );
793  aboutWidget_->OpenFlipperAbout->append( "\t\t Path \t\t" + PluginStorage::pluginsFailed()[i].path );
794 
795  if ( !PluginStorage::pluginsFailed()[i].warnings.isEmpty() ) {
796  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkYellow);
797  aboutWidget_->OpenFlipperAbout->append( "\t\t Warnings: \t\t" + PluginStorage::pluginsFailed()[i].warnings );
798  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
799  }
800 
801  if ( !PluginStorage::pluginsFailed()[i].errors.isEmpty() ) {
802  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkRed);
803  aboutWidget_->OpenFlipperAbout->append( "\t\t Errors: \t\t" + PluginStorage::pluginsFailed()[i].errors );
804  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
805  }
806 
807  }
808 
809 
810 
811 
812  // =====================================================================================
813  // List of build-in resources
814  // =====================================================================================
815 
816  aboutWidget_->OpenFlipperAbout->append("\n");
817  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
818  aboutWidget_->OpenFlipperAbout->append(tr("Currently loaded Resources (e.g. by qrc files):"));
819  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
820 
821  QDir toplevelResources(":/");
822  for ( auto str : toplevelResources.entryList() ) {
823  aboutWidget_->OpenFlipperAbout->append(str);
824 
825  QDir firstLevel(":/" + str);
826  for ( auto firstLevelStr : firstLevel.entryList() ) {
827  aboutWidget_->OpenFlipperAbout->append(" \t" + firstLevelStr);
828 
829  QDir secondLevel(":/" + str + "/" + firstLevelStr);
830 
831  for ( auto secondLevelStr : secondLevel.entryList() ) {
832  aboutWidget_->OpenFlipperAbout->append(" \t\t" + secondLevelStr);
833  }
834 
835  }
836 
837  aboutWidget_->OpenFlipperAbout->append("\n");
838  }
839 
840  aboutWidget_->show();
841 
842 }
843 //=============================================================================
void showAboutWidget()
Display the about widget.
Definition: About.cc:87
QMap< QString, QString > additionalAboutTabs_
Additional tab information, that could be provided by plugins.
Definition: CoreWidget.hh:1205
AboutWidget * aboutWidget_
Pointer to the about widget.
Definition: CoreWidget.hh:1202
std::vector< PluginInfo > & plugins()
Convenient way to access plugin list.
Definition: CoreWidget.cc:661
void addAboutInfo(QString _text, QString _tabName)
Adds an entry to the about dialog.
Definition: About.cc:83
Predefined datatypes.
Definition: DataTypes.hh:83
DLLEXPORT size_t typeCount()
Get the number of registered types.
Definition: Types.cc:175
unsigned int value() const
Definition: Types.cc:407
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
Definition: Types.cc:154
#define TOSTRING(x)
QSettings object containing all program settings of OpenFlipper.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
std::string getExtensionString()
getExtensionString returns a string containing all supported OpenGL extensions this function uses the...
Definition: gl.cc:100