]> git.sur5r.net Git - minitube/blobdiff - src/downloadmanager.cpp
Imported Upstream version 2.0
[minitube] / src / downloadmanager.cpp
index ee597d899f3ba46ed44f510d17081edaf6a0590e..21115d3ceab2fd759b344e10080ad7366a67696d 100644 (file)
@@ -3,7 +3,13 @@
 #include "downloadmodel.h"
 #include "video.h"
 #include "constants.h"
-#include "MainWindow.h"
+#include "mainwindow.h"
+#ifdef APP_ACTIVATION
+#include "activation.h"
+#endif
+#ifdef Q_WS_MAC
+#include "macutils.h"
+#endif
 
 static DownloadManager *downloadManagerInstance = 0;
 
@@ -41,28 +47,30 @@ DownloadItem* DownloadManager::itemForVideo(Video* video) {
 void DownloadManager::addItem(Video *video) {
     // qDebug() << __FUNCTION__ << video->title();
 
-#ifdef APP_DEMO
-    if (video->duration() >= 60*4) {
-        QMessageBox msgBox(MainWindow::instance());
-        msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
-        msgBox.setText(tr("This is just the demo version of %1.").arg(Constants::NAME));
-        msgBox.setInformativeText(
-                    tr("It can only download videos shorter than %1 minutes so you can test the download functionality.")
-                    .arg(4));
-        msgBox.setModal(true);
-        // make it a "sheet" on the Mac
-        msgBox.setWindowModality(Qt::WindowModal);
-
-        msgBox.addButton(tr("Continue"), QMessageBox::RejectRole);
-        QPushButton *buyButton = msgBox.addButton(tr("Get the full version"), QMessageBox::ActionRole);
-
-        msgBox.exec();
-
-        if (msgBox.clickedButton() == buyButton) {
-            QDesktopServices::openUrl(QUrl(QString(Constants::WEBSITE) + "#download"));
-        }
+#ifdef APP_ACTIVATION
+    if (!Activation::instance().isActivated()) {
+        if (video->duration() >= 60*4) {
+            QMessageBox msgBox(MainWindow::instance());
+            msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+            msgBox.setText(tr("This is just the demo version of %1.").arg(Constants::NAME));
+            msgBox.setInformativeText(
+                        tr("It can only download videos shorter than %1 minutes so you can test the download functionality.")
+                        .arg(4));
+            msgBox.setModal(true);
+            // make it a "sheet" on the Mac
+            msgBox.setWindowModality(Qt::WindowModal);
 
-        return;
+            msgBox.addButton(tr("Continue"), QMessageBox::RejectRole);
+            QPushButton *buyButton = msgBox.addButton(tr("Get the full version"), QMessageBox::ActionRole);
+
+            msgBox.exec();
+
+            if (msgBox.clickedButton() == buyButton) {
+                MainWindow::instance()->showActivationView();
+            }
+
+            return;
+        }
     }
 #endif
 
@@ -148,7 +156,7 @@ void DownloadManager::itemFinished() {
 }
 
 void DownloadManager::updateStatusMessage() {
-    QString message = tr("%n Download(s)", "", items.size());
+    QString message = tr("%n Download(s)", "", activeItems());
     emit statusMessageChanged(message);
 }