]> git.sur5r.net Git - minitube/commitdiff
Demo stuff
authorFlavio Tordini <flavio.tordini@gmail.com>
Mon, 26 Jul 2010 21:09:47 +0000 (23:09 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Mon, 26 Jul 2010 21:09:47 +0000 (23:09 +0200)
src/MediaView.cpp
src/MediaView.h

index d8d67752c9a22b0f7c613cbf49d92c1f1de92424..f0137acc380a9739044b08b17fec27e6178b2457 100644 (file)
@@ -4,6 +4,7 @@
 #include "videowidget.h"
 #include "minisplitter.h"
 #include "flickcharm.h"
+#include "constants.h"
 
 namespace The {
     QMap<QString, QAction*>* globalActions();
@@ -13,6 +14,10 @@ namespace The {
 
 MediaView::MediaView(QWidget *parent) : QWidget(parent) {
 
+#ifdef APP_DEMO
+    tracksPlayed = 0;
+#endif
+
     reallyStopped = false;
 
     QBoxLayout *layout = new QHBoxLayout();
@@ -144,6 +149,10 @@ void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
 void MediaView::search(SearchParams *searchParams) {
     reallyStopped = false;
 
+#ifdef APP_DEMO
+    tracksPlayed = 0;
+#endif
+
     videoAreaWidget->clear();
     workaroundTimer->stop();
     errorTimer->stop();
@@ -290,6 +299,12 @@ void MediaView::gotStreamUrl(QUrl streamUrl) {
         QModelIndex index = listModel->index(row, 0, QModelIndex());
         listView->scrollTo(index, QAbstractItemView::EnsureVisible);
     }
+
+#ifdef APP_DEMO
+    if (tracksPlayed > 1) demoExpired();
+    else tracksPlayed++;
+#endif
+
 }
 
 void MediaView::itemActivated(const QModelIndex &index) {
@@ -424,3 +439,29 @@ void MediaView::saveSplitterState() {
     QSettings settings;
     settings.setValue("splitter", splitter->saveState());
 }
+
+#ifdef APP_DEMO
+void MediaView::demoExpired() {
+    mediaObject->pause();
+
+    QMessageBox msgBox;
+    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::APP_NAME) + " " +
+                   tr("It allows you to test the application and see if it works for you.")
+                   );
+    msgBox.setModal(true);
+
+    QPushButton *quitButton = 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(QString(Constants::WEBSITE) + "#download");
+    } else {
+        mediaObject->play();
+    }
+
+    tracksPlayed = 1;
+}
+#endif
index 26775b624ac73e241196636a81bed50e12225666..f3bd3dd33f9eca687c6db8ffb302a70a61e3b03e 100644 (file)
@@ -100,6 +100,11 @@ private:
     QTimer *workaroundTimer;
     Video *skippedVideo;
 
+#ifdef APP_DEMO
+    void demoExpired();
+    int tracksPlayed;
+#endif
+
 };
 
 #endif // __MEDIAVIEW_H__