From c372c07128555e5d1175d7c13b5274476b5b8004 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Mon, 26 Jul 2010 23:09:47 +0200 Subject: [PATCH] Demo stuff --- src/MediaView.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/MediaView.h | 5 +++++ 2 files changed, 46 insertions(+) diff --git a/src/MediaView.cpp b/src/MediaView.cpp index d8d6775..f0137ac 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -4,6 +4,7 @@ #include "videowidget.h" #include "minisplitter.h" #include "flickcharm.h" +#include "constants.h" namespace The { QMap* 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 diff --git a/src/MediaView.h b/src/MediaView.h index 26775b6..f3bd3dd 100644 --- a/src/MediaView.h +++ b/src/MediaView.h @@ -100,6 +100,11 @@ private: QTimer *workaroundTimer; Video *skippedVideo; +#ifdef APP_DEMO + void demoExpired(); + int tracksPlayed; +#endif + }; #endif // __MEDIAVIEW_H__ -- 2.39.5