Bladeren bron

hardware detection under gcc working now, also splashscreen

Nicolas Winkler 5 jaren geleden
bovenliggende
commit
98305e1967
4 gewijzigde bestanden met toevoegingen van 87 en 10 verwijderingen
  1. 2 0
      Almond.cpp
  2. 1 1
      BackgroundTask.cpp
  3. 5 5
      libmandel/src/Hardware.cpp
  4. 79 4
      main.cpp

+ 2 - 0
Almond.cpp

@@ -72,7 +72,9 @@ void Almond::backgroundTaskProgress(float percentage)
         ui.backgroundProgress->setValue(percentage);
     }
     else {
+        ui.backgroundProgress->reset();
         ui.backgroundProgress->setRange(0, 0);
+        ui.backgroundProgress->setValue(-1);
     }
 }
 

+ 1 - 1
BackgroundTask.cpp

@@ -41,6 +41,6 @@ void VideoExportTask::run(void)
     emit finished(true);
     QMessageBox* msgBox = new QMessageBox;
     msgBox->setText("Video successfully exported.");
-    msgBox->exec();
+    emit msgBox->exec();
 }
 

+ 5 - 5
libmandel/src/Hardware.cpp

@@ -41,9 +41,9 @@ CpuInfo::CpuInfo(void) :
     unsigned int nExtData;
 
 #ifdef __GNUC__
-    __cpuid(0, dat[0], dat[1], dat[2], dat[3]);
+    __get_cpuid(0, &dat[0], &dat[1], &dat[2], &dat[3]);
     nData = dat[0];
-    __cpuid(0x80000000, dat[0], dat[1], dat[2], dat[3]);
+    __get_cpuid(0x80000000, &dat[0], &dat[1], &dat[2], &dat[3]);
     nExtData = dat[0];
 #else
     __cpuid((int*) dat.data(), 0);
@@ -54,7 +54,7 @@ CpuInfo::CpuInfo(void) :
 
     for (unsigned int i = 0; i <= nData; i++) {
 #ifdef __GNUC__
-        __get_cpuid(i, &dat[0], &dat[1], &dat[2], &dat[3]);
+        __get_cpuid_count(i, 0, &dat[0], &dat[1], &dat[2], &dat[3]);
 #else
         __cpuidex((int*) dat.data(), i, 0);
 #endif
@@ -63,7 +63,7 @@ CpuInfo::CpuInfo(void) :
 
     for (unsigned int i = 0x80000000; i <= nExtData; i++) {
 #ifdef __GNUC__
-        __get_cpuid(i, &dat[0], &dat[1], &dat[2], &dat[3]);
+        __get_cpuid_count(i, 0, &dat[0], &dat[1], &dat[2], &dat[3]);
 #else
         __cpuidex((int*) dat.data(), i, 0);
 #endif
@@ -108,8 +108,8 @@ CpuInfo::CpuInfo(void) :
 
     sse2 = edx1[26];
     avx = ecx1[28];
-    avx2 = ebx7[5];
     fma = ecx1[12];
+    avx2 = ebx7[5];
     avx512 = ebx7[16];
 }
 

+ 79 - 4
main.cpp

@@ -3,6 +3,78 @@
 #include <QPixmap>
 #include <QDesktopWidget>
 #include <QSplashScreen>
+#include <QMovie>
+#include <QTimer>
+#include <cmath>
+
+class AlmondSplashScreen : public QSplashScreen
+{
+private:
+    float animOff = 0.0f;
+    QTimer animUpdate;
+    volatile bool updated = true;
+public:
+    AlmondSplashScreen(QPixmap splash) :
+        QSplashScreen{ splash },
+        animUpdate{ this }
+    {
+        animUpdate.start(10);
+        //loading.start();
+        //this->add(loading);
+        //connect(&loading, &QMovie::updated, this, &AlmondSplashScreen::nextFrame);
+        connect(&animUpdate, &QTimer::timeout, this, &AlmondSplashScreen::nextFrame);
+    }
+
+    ~AlmondSplashScreen(void)
+    {
+        animUpdate.stop();
+    }
+
+    void drawContents(QPainter* painter) override
+    {
+        QSplashScreen::drawContents(painter);
+        drawAnimation(painter);
+        updated = true;
+    }
+
+    void drawAnimation(QPainter* painter)
+    {
+        const auto minimum = [] (auto a, auto b, auto c) {
+            return a < b ? (a < c ? a : c) : (b < c ? b : c);
+        };
+        int width = this->width();
+        int height = this->height();
+        int pieces = 7;
+        float off = ::fmod(animOff, width / pieces);
+        for (int i = 0; i < pieces; i++) {
+            float x = off + i * width / pieces;
+            float accelOff = 0;
+
+            if (x < 160)
+                accelOff = (160 - x) * (160 - x) / 160 ;
+            else if (x > width - 160)
+                accelOff = -(width - 160 - x) * (width - 160 - x) / 160 ;
+            
+            x -= accelOff;
+
+            if (x < 0 || x > width)
+                continue;
+
+            float opacity = minimum(x, width - x, 130);
+            QPen pen(QColor(255, 255, 255, int(opacity)));
+            pen.setWidth(4);
+            painter->setPen(pen);
+            painter->drawEllipse(QRectF{ x, height - 40, 16, 16 });
+        }
+    }
+
+public slots:
+    void nextFrame() //(const QRect& rect)
+    {
+        emit this->repaint();
+        animOff += 7;
+    }
+};
 
 int main(int argc, char *argv[])
 {
@@ -13,13 +85,16 @@ int main(int argc, char *argv[])
 
     QPixmap splashImg(":/splash/splash");
     QPixmap splashScaled = splashImg.scaled(splashW, splashW * splashImg.height() / splashImg.width());
-    QSplashScreen splash{ splashScaled };
+    AlmondSplashScreen splash{ splashScaled };
     splash.show();
-    a.processEvents();
-
+    /*for (int i = 0; i < 100; i++) {
+        a.processEvents();
+        system("sleep 0.03");
+    }*/
     Almond w;
-    w.show();
+    a.processEvents();
     splash.finish(&w);
+    w.show();
     return a.exec();
 }