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  QStringList splitted = stream.readAll().split("\n",QString::SkipEmptyParts);
299 
300  int position = splitted.indexOf ( QRegExp("^vendor_id.*") );
301  if ( position != -1 ){
302  QString cpuVendor = splitted[position].section(':', -1).simplified();
303  aboutWidget_->OpenFlipperAbout->append(tr("CPU vendor:\t\t ") + cpuVendor );
304  } else {
305  aboutWidget_->OpenFlipperAbout->append(tr("CPU vendor:\t\t vendor specification not found"));
306  }
307 
308  position = splitted.indexOf ( QRegExp("^model name.*") );
309  if ( position != -1 ){
310  QString cpuModel = splitted[position].section(':', -1).simplified();
311  aboutWidget_->OpenFlipperAbout->append(tr("CPU model:\t\t ") + cpuModel );
312  } else {
313  aboutWidget_->OpenFlipperAbout->append(tr("CPU model:\t\t Model specification not found"));
314  }
315 
316  position = splitted.indexOf ( QRegExp("^cpu cores.*") );
317  if ( position != -1 ){
318  QString cpuCoresPhysical = splitted[position].section(':', -1).simplified();
319  aboutWidget_->OpenFlipperAbout->append(tr("Physical CPU cores:\t\t ") + cpuCoresPhysical );
320  } else {
321  aboutWidget_->OpenFlipperAbout->append(tr("Physical CPU cores:\t\t CPU Core specification not found"));
322  }
323 
324  position = splitted.indexOf ( QRegExp("^siblings.*") );
325  if ( position != -1 ){
326  QString cpuCoresLogical = splitted[position].section(':', -1).simplified();
327  aboutWidget_->OpenFlipperAbout->append(tr("Logical CPU cores:\t\t ") + cpuCoresLogical );
328  } else {
329  aboutWidget_->OpenFlipperAbout->append(tr("Logical CPU cores:\t\t CPU Core specification not found"));
330  }
331 
332  position = splitted.indexOf ( QRegExp("^flags.*") );
333  if ( position != -1 ){
334  QString cpuFlags = splitted[position].section(':', -1).simplified();
335  aboutWidget_->OpenFlipperAbout->append( tr("CPU capabilities:") );
336  aboutWidget_->OpenFlipperAbout->append( cpuFlags );
337  } else {
338  aboutWidget_->OpenFlipperAbout->append(tr("CPU capabilities:\t\t CPU flag specification not found"));
339  }
340 
341  #if Q_BYTE_ORDER == Q_BIG_ENDIAN
342  aboutWidget_->OpenFlipperAbout->append(tr("System is Big Endian"));
343  #endif
344 
345  #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
346  aboutWidget_->OpenFlipperAbout->append(tr("System is Little Endian"));
347  #endif
348 
349  }
350 
351  #endif
352 
353  // =====================================================================================
354  // OS info
355  // =====================================================================================
356  aboutWidget_->OpenFlipperAbout->append("\n");
357  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
358  aboutWidget_->OpenFlipperAbout->append(tr("Operating System Info:"));
359  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
360 
361  #ifdef WIN32
362  QSettings registryOS("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat);
363  aboutWidget_->OpenFlipperAbout->append(tr("Product Name:\t\t ") +
364  registryOS.value( "ProductName", "Unknown" ).toString() );
365  aboutWidget_->OpenFlipperAbout->append(tr("Current Version:\t\t ") +
366  registryOS.value( "CurrentVersion", "Unknown" ).toString() );
367  #elif defined ARCH_DARWIN
368 
369  int mib[2];
370  size_t len;
371  char *p;
372 
373  mib[0] = CTL_KERN;
374  mib[1] = KERN_VERSION;
375 
376  sysctl(mib, 2, NULL, &len, NULL, 0);
377  p = (char * )malloc(len);
378  sysctl(mib, 2, p, &len, NULL, 0);
379 
380  aboutWidget_->OpenFlipperAbout->append(tr("OS Version:\t\t ") + QString(p) );
381 
382  free(p);
383 
384  #else
385  QFile versionInfo("/proc/version");
386  if (! versionInfo.exists() )
387  aboutWidget_->OpenFlipperAbout->append(tr("Unable to retrieve Kernel information"));
388  else {
389  versionInfo.open(QFile::ReadOnly);
390  QTextStream versionStream(&versionInfo);
391  aboutWidget_->OpenFlipperAbout->append(tr("Kernel Version:\t\t ") + versionStream.readAll().simplified());
392 
393  QString program = "/usr/bin/lsb_release";
394 
395  QFile lsb(program);
396  if ( lsb.exists() ) {
397  QStringList arguments;
398  arguments << "-a";
399 
400  QProcess myProcess;
401  myProcess.start(program, arguments);
402 
403  if ( myProcess.waitForFinished ( 4000 ) ) {
404  QStringList outputLSB = QString(myProcess.readAllStandardOutput()).split('\n');
405 
406 
407  int position = outputLSB.indexOf ( QRegExp("^Distributor ID.*") );
408  if ( position != -1 ){
409  QString distributorID = outputLSB[position].section(':', -1).simplified();
410  aboutWidget_->OpenFlipperAbout->append(tr("Distributor ID:\t\t ") + distributorID );
411  } else {
412  aboutWidget_->OpenFlipperAbout->append(tr("Distributor ID:\t\t Unknown"));
413  }
414 
415  position = outputLSB.indexOf ( QRegExp("^Description.*") );
416  if ( position != -1 ){
417  QString description = outputLSB[position].section(':', -1).simplified();
418  aboutWidget_->OpenFlipperAbout->append(tr("Description:\t\t ") + description );
419  } else {
420  aboutWidget_->OpenFlipperAbout->append(tr("Description:\t\t Unknown"));
421  }
422 
423  position = outputLSB.indexOf ( QRegExp("^Release.*") );
424  if ( position != -1 ){
425  QString release = outputLSB[position].section(':', -1).simplified();
426  aboutWidget_->OpenFlipperAbout->append(tr("Release number:\t\t ") + release );
427  } else {
428  aboutWidget_->OpenFlipperAbout->append(tr("Release number:\t\t Unknown"));
429  }
430 
431  position = outputLSB.indexOf ( QRegExp("^Codename.*") );
432  if ( position != -1 ){
433  QString codename = outputLSB[position].section(':', -1).simplified();
434  aboutWidget_->OpenFlipperAbout->append(tr("Codename:\t\t ") + codename );
435  } else {
436  aboutWidget_->OpenFlipperAbout->append(tr("Codename:\t\t Unknown"));
437  }
438 
439  } else {
440  aboutWidget_->OpenFlipperAbout->append(tr("Unable to get LSB info"));
441  }
442 
443  } else {
444  aboutWidget_->OpenFlipperAbout->append(tr("No additional information. Unable to get info via LSB."));
445  }
446 
447  }
448  #endif
449 
450  QString systemPathVariable = getenv("PATH");
451  aboutWidget_->OpenFlipperAbout->append(tr("System Path:\n ") + systemPathVariable);
452 
453 #ifndef WIN32
454  QString systemLibraryPathVariable = getenv("LD_LIBRARY_PATH");
455  aboutWidget_->OpenFlipperAbout->append(tr("LD_LIBRARY_PATH:\n ") + systemLibraryPathVariable);
456 #endif
457 
458 
459 
460  // =====================================================================================
461  // OpenGL Renderer/Vendor and version info
462  // =====================================================================================
463  aboutWidget_->OpenFlipperAbout->append("\n");
464  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
465  aboutWidget_->OpenFlipperAbout->append(tr("OpenGL Specific Info:"));
466  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
467 
468  QString vendor = QString((const char*)glGetString(GL_VENDOR));
469  aboutWidget_->OpenFlipperAbout->append(tr("Qt reports Vendor:\t\t") + vendor);
470  QString renderer = QString((const char*)glGetString(GL_RENDERER));
471  aboutWidget_->OpenFlipperAbout->append(tr("Qt reports Renderer:\t\t") + renderer);
472 
473  QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
474 
475  QString openGLQtVersion = tr("Qt reports Version:\t\t");
476 
477  if ( flags.testFlag(QGLFormat::OpenGL_Version_4_0) )
478  openGLQtVersion += tr("4.0 or higher") ;
479  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_3))
480  openGLQtVersion += tr("3.3") ;
481  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_2))
482  openGLQtVersion += tr("3.2") ;
483  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_1))
484  openGLQtVersion += tr("3.1") ;
485  else if (flags.testFlag(QGLFormat::OpenGL_Version_3_0))
486  openGLQtVersion += tr("3.0") ;
487  else if (flags.testFlag(QGLFormat::OpenGL_Version_2_1))
488  openGLQtVersion += tr("2.1" );
489  else if (flags.testFlag(QGLFormat::OpenGL_Version_2_0))
490  openGLQtVersion += tr("2.0" );
491  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_5))
492  openGLQtVersion += tr("1.5" );
493  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_4))
494  openGLQtVersion += tr("1.4" );
495  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_3))
496  openGLQtVersion += tr("1.3" );
497  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_2))
498  openGLQtVersion += tr("1.2" );
499  else if (flags.testFlag(QGLFormat::OpenGL_Version_1_1))
500  openGLQtVersion += tr("1.1" );
501  else
502  openGLQtVersion += tr("Version:\tUNKNOWN!" );
503 
504  aboutWidget_->OpenFlipperAbout->append(openGLQtVersion);
505 
506  aboutWidget_->OpenFlipperAbout->append("\n");
507 
508  const QGLContext* context = QGLContext::currentContext();
509  if (context) {
510  QString openGLprofile = tr("Qt reports the OpenGL profile:\t");
511  QGLFormat::OpenGLContextProfile profile = context->format().profile();
512  if (profile == QGLFormat::NoProfile)
513  openGLprofile += tr("no profile");
514  else if (profile == QGLFormat::CoreProfile)
515  openGLprofile += tr("Core profile");
516  else if (profile == QGLFormat::CompatibilityProfile)
517  openGLprofile += tr("Compatibility profile");
518  else
519  openGLprofile += tr("unknown profile");
520 
521  aboutWidget_->OpenFlipperAbout->append(openGLprofile);
522  aboutWidget_->OpenFlipperAbout->append("\n");
523  }
524 
525 
526  QString openGLVendor = tr("GL reports Vendor:\t\t");
527  openGLVendor += QString((const char*)glGetString(GL_VENDOR));
528  aboutWidget_->OpenFlipperAbout->append(openGLVendor);
529 
530  QString openGLRenderer = tr("GL reports Renderer:\t\t");
531  openGLRenderer += QString((const char*)glGetString(GL_RENDERER));
532  aboutWidget_->OpenFlipperAbout->append(openGLRenderer);
533 
534  QString openGLGLVersion = tr("GL reports Version:\t\t");
535  openGLGLVersion += QString((const char*)glGetString(GL_VERSION));
536  aboutWidget_->OpenFlipperAbout->append(openGLGLVersion);
537 
538  QString openGLShadingLanguageVersion = tr("GL reports Shading Language Version:\t");
539  openGLShadingLanguageVersion += QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION));
540  aboutWidget_->OpenFlipperAbout->append(openGLShadingLanguageVersion);
541 
542 
543  // =====================================================================================
544  // OpenGL Extensions
545  // =====================================================================================
546  aboutWidget_->OpenFlipperAbout->append("\n");
547  aboutWidget_->OpenFlipperAbout->append(tr("Supported Extensions:"));
548  QString glExtensions = QString(ACG::getExtensionString().c_str());
549  aboutWidget_->OpenFlipperAbout->append(glExtensions);
550 
551 
552  // =====================================================================================
553  // OpenGL Properties
554  // =====================================================================================
555  aboutWidget_->OpenFlipperAbout->append("\n");
556  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
557  aboutWidget_->OpenFlipperAbout->append(tr("OpenGL Values:"));
558  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
559  GLint getBuffer[2];
560  glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &getBuffer[0] );
561  aboutWidget_->OpenFlipperAbout->append(tr("Maximal Viewport size(GL_MAX_VIEWPORT_DIMS):\t\t\t\t ") + QString::number(getBuffer[0]) + "x" + QString::number(getBuffer[1]) );
562 
563  glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &getBuffer[0] );
564  aboutWidget_->OpenFlipperAbout->append(tr("Maximum supported texture image units(GL_MAX_TEXTURE_IMAGE_UNITS):\t") + QString::number(getBuffer[0]) );
565 
566  // Check extension for NVIDIA memory information
567  if ( glExtensions.contains("GL_NVX_gpu_memory_info") ) {
568  // get total memory on gpu
569  GLint total_mem_kb = 0;
570  glGetIntegerv(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &total_mem_kb);
571 
572  aboutWidget_->OpenFlipperAbout->append(tr("GPU Memory (Total available):\t\t") + QString::number(total_mem_kb /1024) + " MB" );
573 
574  // get currently available memory on gpu
575  GLint cur_avail_mem_kb = 0;
576  glGetIntegerv(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb);
577 
578  aboutWidget_->OpenFlipperAbout->append(tr("GPU Memory (Currently available):\t") + QString::number(cur_avail_mem_kb / 1024) + " MB" );
579  }
580 
581 
582 
583  aboutWidget_->OpenFlipperAbout->moveCursor(QTextCursor::Start);
584 
585  // =====================================================================================
586  // glew Information
587  // =====================================================================================
588  #ifndef __APPLE__
589  aboutWidget_->OpenFlipperAbout->append("\n");
590  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
591  aboutWidget_->OpenFlipperAbout->append(tr("GLEW Specific Info:"));
592  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
593 
594  QString glewVersion = QString(getGlewVersion());
595  aboutWidget_->OpenFlipperAbout->append(tr("GLEW Version:\t") + glewVersion);
596  #endif
597 
598  // =====================================================================================
599  // Qt information
600  // =====================================================================================
601 
602  aboutWidget_->OpenFlipperAbout->append("\n");
603  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
604  aboutWidget_->OpenFlipperAbout->append(tr("Qt Version Info:"));
605  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
606  aboutWidget_->OpenFlipperAbout->append(tr("Currently used Version:\t") + qVersion() );
607  aboutWidget_->OpenFlipperAbout->append(tr("Link time Version:\t\t") + QT_VERSION_STR );
608 
609  QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
610  QString formatsString = "";
611  for ( int i = 0 ; i < imageFormats.size() ; ++i) {
612  formatsString += imageFormats[i] + " ";
613 
614  if ( (i != 0) && (i % 15) == 0 )
615  formatsString+= "\n";
616  }
617 
618  aboutWidget_->OpenFlipperAbout->append(tr("Supported image read formats:") );
619  aboutWidget_->OpenFlipperAbout->append(formatsString);
620 
621  aboutWidget_->OpenFlipperAbout->append("\n");
622 
623  aboutWidget_->OpenFlipperAbout->append(tr("Currently used Library paths:") );
624  QStringList libPaths = QCoreApplication::libraryPaths();
625  for(int i = 0 ; i < libPaths.size() ; ++i)
626  aboutWidget_->OpenFlipperAbout->append(" " + libPaths[i]);
627 
628 
629  // =========================================================
630  // Qt Documentation files
631  // =========================================================
632 /*
633  aboutWidget_->OpenFlipperAbout->append("\n");
634  aboutWidget_->OpenFlipperAbout->append(tr("Currently Loaded documentations:") );
635 
636  QStringList registeredDocumentations = helpEngine_->registeredDocumentations ();
637 
638  for ( int i = 0 ; i < registeredDocumentations.size(); ++i) {
639  QString documentationInfo = registeredDocumentations[i];
640  documentationInfo += " ";
641  documentationInfo += helpEngine_->documentationFileName(registeredDocumentations[i]);
642  aboutWidget_->OpenFlipperAbout->append(documentationInfo);
643  }
644 */
645  // =====================================================================================
646  // Compiler information
647  // =====================================================================================
648  aboutWidget_->OpenFlipperAbout->append("\n");
649  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
650  aboutWidget_->OpenFlipperAbout->append(tr("Compiler Info:"));
651  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
652  aboutWidget_->OpenFlipperAbout->append( OpenFlipper::Options::compilerInfo() );
653 
654  QString definitions;
655 
656  // Trying to check some defines:
657  #ifdef WIN32
658  definitions += "WIN32 ";
659  #endif
660 
661  #ifdef WIN64
662  definitions += "WIN64 ";
663  #endif
664 
665  #ifdef DLL
666  definitions += "DLL ";
667  #endif
668 
669 
670  #ifdef APPLE
671  definitions += "APPLE ";
672  #endif
673 
674  #ifdef ARCH_DARWIN
675  definitions += "ARCH_DARWIN ";
676  #endif
677 
678  #ifdef INCLUDE_TEMPLATES
679  definitions += "INCLUDE_TEMPLATES ";
680  #endif
681 
682  #ifdef DEBUG
683  definitions += "DEBUG ";
684  #endif
685 
686  #ifdef NDEBUG
687  definitions += "NDEBUG ";
688  #endif
689 
690  #ifdef QT_NO_OPENGL
691  definitions += "QT_NO_OPENGL ";
692  #endif
693 
694  #ifdef OPENMP
695  definitions += "OPENMP ";
696  #endif
697 
698  #ifdef USE_OPENMP
699  definitions += "USE_OPENMP ";
700  #endif
701 
702  aboutWidget_->OpenFlipperAbout->append( tr("Definitions (incomplete):\n") + definitions );
703 
704  // =====================================================================================
705  // List the currently registered data types
706  // =====================================================================================
707  aboutWidget_->OpenFlipperAbout->append("\n");
708  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
709  aboutWidget_->OpenFlipperAbout->append(tr("Registered data types:"));
710  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
711 
712  QString types;
713 
714  // Iterate over all Types known to the core
715  // Start at 1:
716  // 0 type is defined as DATA_UNKNOWN
717  DataType currentType = 1;
718  for ( uint i = 0 ; i < typeCount() - 2 ; ++i) {
719  types += typeName( currentType ) + "\t\t typeId: " + QString::number(currentType.value()) + "\n";
720 
721  // Advance to next type ( Indices are bits so multiply by to to get next bit)
722  ++currentType;
723  }
724 
725  aboutWidget_->OpenFlipperAbout->append( types );
726 
727  // =====================================================================================
728  // List The File Plugins with their filters
729  // =====================================================================================
730  aboutWidget_->OpenFlipperAbout->append("\n");
731  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
732  aboutWidget_->OpenFlipperAbout->append(tr("Registered File Plugins:"));
733  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
734 
735  for ( uint i = 0 ; i < supportedTypes().size() ; ++i ) {
736  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
737  aboutWidget_->OpenFlipperAbout->append( "\t" + supportedTypes()[i].name );
738  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
739  aboutWidget_->OpenFlipperAbout->append( "\t\t Load: " + supportedTypes()[i].loadFilters );
740  aboutWidget_->OpenFlipperAbout->append( "\t\t Save: " + supportedTypes()[i].saveFilters );
741  }
742 
743 
744  // =====================================================================================
745  // List all Plugins
746  // =====================================================================================
747  aboutWidget_->OpenFlipperAbout->append("\n");
748  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
749  aboutWidget_->OpenFlipperAbout->append(tr("Loaded Plugins:"));
750  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
751 
752  for ( uint i = 0 ; i < plugins().size() ; ++i ) {
753  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
754  aboutWidget_->OpenFlipperAbout->append( "\t" + plugins()[i].name );
755  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
756  aboutWidget_->OpenFlipperAbout->append( "\t\t Version: \t\t" + plugins()[i].version );
757  aboutWidget_->OpenFlipperAbout->append( "\t\t Description: \t" + plugins()[i].description );
758  aboutWidget_->OpenFlipperAbout->append( "\t\t Path \t\t" + plugins()[i].path );
759 
760  if ( !plugins()[i].warnings.isEmpty() ) {
761  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkYellow);
762  aboutWidget_->OpenFlipperAbout->append( "\t\t Warnings: \t\t" + plugins()[i].warnings );
763  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
764  }
765 
766  if ( !plugins()[i].errors.isEmpty() ) {
767  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkRed);
768  aboutWidget_->OpenFlipperAbout->append( "\t\t Errors: \t\t" + plugins()[i].errors );
769  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
770  }
771 
772  }
773 
774  // =====================================================================================
775  // List failed Plugins
776  // =====================================================================================
777  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
778  aboutWidget_->OpenFlipperAbout->append(tr("Failed Plugins:"));
779  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
780 
781  for ( unsigned i = 0 ; i < PluginStorage::pluginsFailed().size() ; ++i ) {
782  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
783  aboutWidget_->OpenFlipperAbout->append( "\t" + PluginStorage::pluginsFailed()[i].name );
784  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
785  aboutWidget_->OpenFlipperAbout->append( "\t\t Version: \t\t" + PluginStorage::pluginsFailed()[i].version );
786  aboutWidget_->OpenFlipperAbout->append( "\t\t Description: \t" + PluginStorage::pluginsFailed()[i].description );
787  aboutWidget_->OpenFlipperAbout->append( "\t\t Path \t\t" + PluginStorage::pluginsFailed()[i].path );
788 
789  if ( !PluginStorage::pluginsFailed()[i].warnings.isEmpty() ) {
790  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkYellow);
791  aboutWidget_->OpenFlipperAbout->append( "\t\t Warnings: \t\t" + PluginStorage::pluginsFailed()[i].warnings );
792  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
793  }
794 
795  if ( !PluginStorage::pluginsFailed()[i].errors.isEmpty() ) {
796  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkRed);
797  aboutWidget_->OpenFlipperAbout->append( "\t\t Errors: \t\t" + PluginStorage::pluginsFailed()[i].errors );
798  aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black);
799  }
800 
801  }
802 
803 
804 
805 
806  // =====================================================================================
807  // List of build-in resources
808  // =====================================================================================
809 
810  aboutWidget_->OpenFlipperAbout->append("\n");
811  aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
812  aboutWidget_->OpenFlipperAbout->append(tr("Currently loaded Resources (e.g. by qrc files):"));
813  aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
814 
815  QDir toplevelResources(":/");
816  for ( auto str : toplevelResources.entryList() ) {
817  aboutWidget_->OpenFlipperAbout->append(str);
818 
819  QDir firstLevel(":/" + str);
820  for ( auto firstLevelStr : firstLevel.entryList() ) {
821  aboutWidget_->OpenFlipperAbout->append(" \t" + firstLevelStr);
822 
823  QDir secondLevel(":/" + str + "/" + firstLevelStr);
824 
825  for ( auto secondLevelStr : secondLevel.entryList() ) {
826  aboutWidget_->OpenFlipperAbout->append(" \t\t" + secondLevelStr);
827  }
828 
829  }
830 
831  aboutWidget_->OpenFlipperAbout->append("\n");
832  }
833 
834  aboutWidget_->show();
835 
836 }
837 //=============================================================================
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:412
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