From: Flavio
Date: Tue, 11 Dec 2012 08:53:33 +0000 (+0100)
Subject: Activation
X-Git-Tag: 2.0~52
X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1e2e459c6e29ce467f14c1b42be5479c42290771;p=minitube
Activation
---
diff --git a/src/AboutView.cpp b/src/AboutView.cpp
index 868c018..8cbfad7 100644
--- a/src/AboutView.cpp
+++ b/src/AboutView.cpp
@@ -3,50 +3,59 @@
#ifndef Q_WS_X11
#include "extra.h"
#endif
+#ifdef APP_ACTIVATION
+#include "activation.h"
+#endif
+#ifdef APP_MAC
+#include "macutils.h"
+#include "mac_startup.h"
+#endif
AboutView::AboutView(QWidget *parent) : QWidget(parent) {
- QBoxLayout *aboutlayout = new QHBoxLayout(this);
- aboutlayout->setAlignment(Qt::AlignCenter);
- aboutlayout->setMargin(30);
- aboutlayout->setSpacing(30);
+ QBoxLayout *hLayout = new QHBoxLayout(this);
+ hLayout->setAlignment(Qt::AlignCenter);
+ hLayout->setMargin(30);
+ hLayout->setSpacing(30);
QLabel *logo = new QLabel(this);
- QString resource = "app";
-#ifndef Q_WS_X11
- resource = Extra::resourceName(resource);
-#endif
- logo->setPixmap(QPixmap(":/images/" + resource + ".png"));
- aboutlayout->addWidget(logo, 0, Qt::AlignTop);
+ logo->setPixmap(QPixmap(":/images/app.png"));
+ hLayout->addWidget(logo, 0, Qt::AlignTop);
QBoxLayout *layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignCenter);
layout->setSpacing(30);
- aboutlayout->addLayout(layout);
+ hLayout->addLayout(layout);
- QString info = "" + QString(Constants::NAME) + "
"
+ QString info = ""
+ "" + QString(Constants::NAME) + "
"
"" + tr("There's life outside the browser!") + "
"
"" + tr("Version %1").arg(Constants::VERSION) + "
"
- + QString("%1
").arg(Constants::WEBSITE) +
+ + QString("%1
").arg(Constants::WEBSITE);
- #if !defined(APP_MAC) && !defined(APP_WIN)
- "" + tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "
"
+#ifdef APP_ACTIVATION
+ if (Activation::instance().isActivated())
+ info += "
" + tr("Licensed to: %1").arg("" + Activation::instance().getEmail() + "");
+#endif
+
+#ifdef Q_WS_X11
+ info += "
" + tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "
"
+ tr("Please donate to support the continued development of %2.")
- .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "
"
- #endif
+ .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "
";
+#endif
- "" + tr("You may want to try my other apps as well:") + "
"
- + ""
"" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
.arg("Transifex")
@@ -56,7 +65,7 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent) {
+ tr("Icon designed by %1.").arg("David Nel")
+ "
"
- #if !defined(APP_MAC) && !defined(APP_WIN)
+ #ifdef Q_WS_X11
"" + tr("Released under the GNU General Public License")
.arg("http://www.gnu.org/licenses/gpl.html") + "
"
#endif
@@ -68,6 +77,8 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent) {
layout->addWidget(infoLabel);
QLayout *buttonLayout = new QHBoxLayout();
+ buttonLayout->setMargin(0);
+ buttonLayout->setSpacing(0);
buttonLayout->setAlignment(Qt::AlignLeft);
QPushButton *closeButton = new QPushButton(tr("&Close"), this);
@@ -77,15 +88,7 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent) {
connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
buttonLayout->addWidget(closeButton);
- /*
- QPushButton *issueButton = new QPushButton(tr("&Report an issue"), this);
- issueButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
- connect(issueButton, SIGNAL(clicked()), window(), SLOT(reportIssue()));
- buttonLayout->addWidget(issueButton);
- */
-
layout->addLayout(buttonLayout);
-
}
void AboutView::paintEvent(QPaintEvent * /*event*/) {
@@ -100,3 +103,12 @@ void AboutView::paintEvent(QPaintEvent * /*event*/) {
painter.fillRect(0, 0, width(), height(), brush);
#endif
}
+
+void AboutView::appear() {
+#ifdef APP_MAC
+ mac::uncloseWindow(window()->winId());
+#ifdef APP_ACTIVATION
+ mac::CheckForUpdates();
+#endif
+#endif
+}
diff --git a/src/AboutView.h b/src/AboutView.h
index 2d3e0c4..e1977dd 100644
--- a/src/AboutView.h
+++ b/src/AboutView.h
@@ -4,9 +4,6 @@
#include
#include "View.h"
#include "constants.h"
-#ifdef APP_MAC
-#include "macutils.h"
-#endif
class AboutView : public QWidget, public View {
@@ -14,11 +11,7 @@ class AboutView : public QWidget, public View {
public:
AboutView(QWidget *parent);
- void appear() {
-#ifdef APP_MAC
- mac::uncloseWindow(window()->winId());
-#endif
- }
+ void appear();
void disappear() {}
QMap metadata() {
QMap metadata;
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index e5d78d2..b0e184e 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -15,15 +15,9 @@
#include "macsupport.h"
#include "macutils.h"
#endif
-#ifndef Q_WS_X11
-#include "extra.h"
-#endif
#include "downloadmanager.h"
#include "youtubesuggest.h"
#include "updatechecker.h"
-#ifdef APP_DEMO
-#include "demostartupview.h"
-#endif
#include "temporary.h"
#ifdef APP_MAC
#include "searchlineedit_mac.h"
@@ -31,6 +25,15 @@
#include "searchlineedit.h"
#endif
#include
+#ifndef Q_WS_X11
+#include "extra.h"
+#include "updatedialog.h"
+#endif
+#ifdef APP_ACTIVATION
+#include "activation.h"
+#include "activationview.h"
+#include "activationdialog.h"
+#endif
static MainWindow *singleton = 0;
@@ -52,7 +55,6 @@ MainWindow::MainWindow() :
// views mechanism
history = new QStack();
views = new QStackedWidget(this);
- setCentralWidget(views);
// views
searchView = new SearchView(this);
@@ -95,14 +97,15 @@ MainWindow::MainWindow() :
setMinimumWidth(0);
// show the initial view
-#ifdef APP_DEMO
- QWidget *demoStartupView = new DemoStartupView(this);
- views->addWidget(demoStartupView);
- showWidget(demoStartupView);
-#else
- showSearch();
+ showSearch(false);
+
+#ifdef APP_ACTIVATION
+ if (!Activation::instance().isActivated())
+ showActivationView(false);
#endif
+ setCentralWidget(views);
+
// Global shortcuts
GlobalShortcuts &shortcuts = GlobalShortcuts::instance();
#ifdef Q_WS_X11
@@ -473,6 +476,10 @@ void MainWindow::createActions() {
action->setCheckable(true);
actions->insert("refine-search", action);
+#ifdef APP_ACTIVATION
+ Extra::createActivationAction(tr("Buy %1...").arg(Constants::NAME));
+#endif
+
// common action properties
foreach (QAction *action, actions->values()) {
@@ -491,10 +498,6 @@ void MainWindow::createActions() {
// show keyboard shortcuts in the status bar
if (!action->shortcut().isEmpty())
action->setStatusTip(action->statusTip() + " (" + action->shortcut().toString(QKeySequence::NativeText) + ")");
-
- // no icons in menus
- action->setIconVisibleInMenu(false);
-
}
}
@@ -504,11 +507,12 @@ void MainWindow::createMenus() {
QMap *menus = The::globalMenus();
fileMenu = menuBar()->addMenu(tr("&Application"));
-#ifdef APP_DEMO
- QAction* action = new QAction(tr("Buy %1...").arg(Constants::NAME), this);
- action->setMenuRole(QAction::ApplicationSpecificRole);
- connect(action, SIGNAL(triggered()), SLOT(buy()));
- fileMenu->addAction(action);
+#ifdef APP_ACTIVATION
+ QAction *buyAction = The::globalActions()->value("buy");
+ if (buyAction) fileMenu->addAction(buyAction);
+#ifndef APP_MAC
+ fileMenu->addSeparator();
+#endif
#endif
fileMenu->addAction(clearAct);
#ifndef APP_MAC
@@ -740,7 +744,7 @@ void MainWindow::goBack() {
}
}
-void MainWindow::showWidget ( QWidget* widget ) {
+void MainWindow::showWidget(QWidget* widget, bool transition) {
if (compactViewAct->isChecked())
compactViewAct->toggle();
@@ -752,7 +756,7 @@ void MainWindow::showWidget ( QWidget* widget ) {
if (oldView) {
oldView->disappear();
views->currentWidget()->setEnabled(false);
- }
+ } else qDebug() << "Cannot cast view";
// call show method on the new view
View* newView = dynamic_cast (widget);
@@ -767,13 +771,15 @@ void MainWindow::showWidget ( QWidget* widget ) {
statusBar()->showMessage((metadata.value("description").toString()));
}
- stopAct->setEnabled(widget == mediaView);
- compactViewAct->setEnabled(widget == mediaView);
- webPageAct->setEnabled(widget == mediaView);
- copyPageAct->setEnabled(widget == mediaView);
- copyLinkAct->setEnabled(widget == mediaView);
- findVideoPartsAct->setEnabled(widget == mediaView);
- toolbarSearch->setEnabled(widget == searchView || widget == mediaView || widget == downloadView);
+ const bool isMediaView = widget == mediaView;
+
+ stopAct->setEnabled(isMediaView);
+ compactViewAct->setEnabled(isMediaView);
+ webPageAct->setEnabled(isMediaView);
+ copyPageAct->setEnabled(isMediaView);
+ copyLinkAct->setEnabled(isMediaView);
+ findVideoPartsAct->setEnabled(isMediaView);
+ toolbarSearch->setEnabled(widget == searchView || isMediaView || widget == downloadView);
if (widget == searchView) {
skipAct->setEnabled(false);
@@ -782,20 +788,14 @@ void MainWindow::showWidget ( QWidget* widget ) {
The::globalActions()->value("stopafterthis")->setEnabled(false);
}
- The::globalActions()->value("twitter")->setEnabled(widget == mediaView);
- The::globalActions()->value("facebook")->setEnabled(widget == mediaView);
- The::globalActions()->value("buffer")->setEnabled(widget == mediaView);
- The::globalActions()->value("email")->setEnabled(widget == mediaView);
+ The::globalActions()->value("twitter")->setEnabled(isMediaView);
+ The::globalActions()->value("facebook")->setEnabled(isMediaView);
+ The::globalActions()->value("buffer")->setEnabled(isMediaView);
+ The::globalActions()->value("email")->setEnabled(isMediaView);
aboutAct->setEnabled(widget != aboutView);
The::globalActions()->value("downloads")->setChecked(widget == downloadView);
- // toolbar only for the mediaView
- /* mainToolBar->setVisible(
- (widget == mediaView && !compactViewAct->isChecked())
- || widget == downloadView
- ); */
-
setUpdatesEnabled(true);
QWidget *oldWidget = views->currentWidget();
@@ -804,10 +804,9 @@ void MainWindow::showWidget ( QWidget* widget ) {
views->setCurrentWidget(widget);
widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- // adjustSize();
#ifndef Q_WS_X11
- Extra::fadeInWidget(oldWidget, widget);
+ if (transition) Extra::fadeInWidget(oldWidget, widget);
#endif
history->push(widget);
@@ -888,8 +887,8 @@ bool MainWindow::confirmQuit() {
return true;
}
-void MainWindow::showSearch() {
- showWidget(searchView);
+void MainWindow::showSearch(bool transition) {
+ showWidget(searchView, transition);
currentTime->clear();
totalTime->clear();
}
@@ -1373,7 +1372,6 @@ void MainWindow::checkForUpdate() {
this, SLOT(gotNewVersion(QString)));
updateChecker->checkForUpdate();
settings.setValue(updateCheckKey, unixTime);
-
}
void MainWindow::gotNewVersion(QString version) {
@@ -1382,47 +1380,36 @@ void MainWindow::gotNewVersion(QString version) {
updateChecker = 0;
}
-#if defined(APP_DEMO) || defined(APP_MAC_STORE) || defined(APP_USC)
- return;
-#endif
-
QSettings settings;
QString checkedVersion = settings.value("checkedVersion").toString();
if (checkedVersion == version) return;
+#ifdef APP_SIMPLEUPDATE
+ simpleUpdateDialog(version);
+#endif
+#if defined(APP_ACTIVATION) && !defined(APP_MAC)
+ UpdateDialog *dialog = new UpdateDialog(version, this);
+ dialog->show();
+#endif
+}
+
+void MainWindow::simpleUpdateDialog(QString version) {
QMessageBox msgBox(this);
- msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ msgBox.setIconPixmap(
+ QPixmap(":/images/app.png")
+ .scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
msgBox.setText(tr("%1 version %2 is now available.").arg(Constants::NAME, version));
-
msgBox.setModal(true);
- // make it a "sheet" on the Mac
msgBox.setWindowModality(Qt::WindowModal);
-
- QPushButton* laterButton = 0;
- QPushButton* updateButton = 0;
-
-#if defined(APP_MAC) || defined(APP_WIN)
- msgBox.setInformativeText(
- tr("To get the updated version, download %1 again from the link you received via email and reinstall.")
- .arg(Constants::NAME)
- );
- laterButton = msgBox.addButton(tr("Remind me later"), QMessageBox::RejectRole);
- msgBox.addButton(QMessageBox::Ok);
-#else
msgBox.addButton(QMessageBox::Close);
- updateButton = msgBox.addButton(tr("Update"), QMessageBox::AcceptRole);
-#endif
-
+ QPushButton* laterButton = msgBox.addButton(tr("Remind me later"), QMessageBox::RejectRole);
+ QPushButton* updateButton = msgBox.addButton(tr("Update"), QMessageBox::AcceptRole);
msgBox.exec();
-
if (msgBox.clickedButton() != laterButton) {
+ QSettings settings;
settings.setValue("checkedVersion", version);
}
-
- if (updateButton && msgBox.clickedButton() == updateButton) {
- QDesktopServices::openUrl(QUrl(QLatin1String(Constants::WEBSITE) + "#download"));
- }
-
+ if (msgBox.clickedButton() == updateButton) visitSite();
}
void MainWindow::floatOnTop(bool onTop) {
@@ -1482,3 +1469,33 @@ void MainWindow::printHelp() {
msg += "Go back to the previous video.\n";
std::cout << msg.toLocal8Bit().data();
}
+
+void MainWindow::showMessage(QString message) {
+ statusBar()->showMessage(message, 60000);
+}
+
+#ifdef APP_ACTIVATION
+void MainWindow::showActivationView(bool transition) {
+ QWidget *activationView = ActivationView::instance();
+ if (views->currentWidget() == activationView) {
+ buy();
+ return;
+ }
+ views->addWidget(activationView);
+ showWidget(activationView, transition);
+}
+
+void MainWindow::showActivationDialog() {
+ QTimer::singleShot(0, new ActivationDialog(this), SLOT(show()));
+}
+
+void MainWindow::buy() {
+ Extra::buy();
+}
+
+void MainWindow::hideBuyAction() {
+ QAction *action = The::globalActions()->value("buy");
+ action->setVisible(false);
+ action->setEnabled(false);
+}
+#endif
diff --git a/src/MainWindow.h b/src/MainWindow.h
index ee21703..b0b3b74 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -34,6 +34,14 @@ public slots:
void messageReceived(const QString &message);
void quit();
void startToolbarSearch(QString query);
+ void goBack();
+ void showMessage(QString message);
+#ifdef APP_ACTIVATION
+ void showActivationView(bool transition = true);
+ void showActivationDialog();
+ void buy();
+ void hideBuyAction();
+#endif
protected:
void changeEvent(QEvent *);
@@ -46,8 +54,7 @@ protected:
private slots:
void checkForUpdate();
void gotNewVersion(QString version);
- void goBack();
- void showSearch();
+ void showSearch(bool transition = true);
void visitSite();
void donate();
void reportIssue();
@@ -92,9 +99,10 @@ private:
void createMenus();
void createToolBars();
void createStatusBar();
- void showWidget(QWidget*);
+ void showWidget(QWidget*, bool transition = true);
static QString formatTime(qint64 time);
bool confirmQuit();
+ void simpleUpdateDialog(QString version);
UpdateChecker *updateChecker;
diff --git a/src/MediaView.cpp b/src/MediaView.cpp
index 012266c..1b0dce1 100644
--- a/src/MediaView.cpp
+++ b/src/MediaView.cpp
@@ -16,6 +16,9 @@
#ifdef APP_MAC
#include "macfullscreen.h"
#endif
+#ifdef APP_ACTIVATION
+#include "activation.h"
+#endif
namespace The {
NetworkAccess* http();
@@ -81,7 +84,7 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) {
splitter->addWidget(sidebar);
videoAreaWidget = new VideoAreaWidget(this);
- // videoAreaWidget->setMinimumSize(320,240);
+ videoAreaWidget->setMinimumSize(320,240);
videoWidget = new Phonon::VideoWidget(this);
videoAreaWidget->setVideoWidget(videoWidget);
videoAreaWidget->setListModel(listModel);
@@ -111,7 +114,7 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) {
workaroundTimer->setInterval(3000);
connect(workaroundTimer, SIGNAL(timeout()), SLOT(timerPlay()));
-#ifdef APP_DEMO
+#ifdef APP_ACTIVATION
demoTimer = new QTimer(this);
demoTimer->setSingleShot(true);
connect(demoTimer, SIGNAL(timeout()), SLOT(demoMessage()));
@@ -148,7 +151,7 @@ void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
void MediaView::search(SearchParams *searchParams) {
reallyStopped = false;
-#ifdef APP_DEMO
+#ifdef APP_ACTIVATION
demoTimer->stop();
#endif
workaroundTimer->stop();
@@ -313,9 +316,7 @@ void MediaView::activeRowChanged(int row) {
timerPlayFlag = false;
// video title in the statusbar
- QMainWindow* mainWindow = dynamic_cast(window());
- if (mainWindow) mainWindow->statusBar()->showMessage(video->title());
-
+ MainWindow::instance()->showMessage(video->title());
// ensure active item is visible
// int row = listModel->activeRow();
@@ -439,8 +440,9 @@ void MediaView::startPlaying() {
listView->scrollTo(index, QAbstractItemView::EnsureVisible);
}
-#ifdef APP_DEMO
- demoTimer->start(60000);
+#ifdef APP_ACTIVATION
+ if (!Activation::instance().isActivated())
+ demoTimer->start(180000);
#endif
}
@@ -539,9 +541,8 @@ void MediaView::copyWebPage() {
if (!video) return;
QString address = video->webpage().toString();
QApplication::clipboard()->setText(address);
- QMainWindow* mainWindow = dynamic_cast(window());
QString message = tr("You can now paste the YouTube link into another application");
- if (mainWindow) mainWindow->statusBar()->showMessage(message);
+ MainWindow::instance()->showMessage(message);
}
void MediaView::copyVideoLink() {
@@ -550,8 +551,7 @@ void MediaView::copyVideoLink() {
QApplication::clipboard()->setText(video->getStreamUrl().toEncoded());
QString message = tr("You can now paste the video stream URL into another application")
+ ". " + tr("The link will be valid only for a limited time.");
- QMainWindow* mainWindow = dynamic_cast(window());
- if (mainWindow) mainWindow->statusBar()->showMessage(message);
+ MainWindow::instance()->showMessage(message);
}
void MediaView::removeSelected() {
@@ -644,7 +644,7 @@ void MediaView::saveSplitterState() {
settings.setValue("splitter", splitter->saveState());
}
-#ifdef APP_DEMO
+#ifdef APP_ACTIVATION
static QPushButton *continueButton;
@@ -673,7 +673,7 @@ void MediaView::demoMessage() {
msgBox.exec();
if (msgBox.clickedButton() == buyButton) {
- QDesktopServices::openUrl(QUrl(QString(Constants::WEBSITE) + "#download"));
+ MainWindow::instance()->showActivationView();
} else {
mediaObject->play();
demoTimer->start(600000);
@@ -697,18 +697,10 @@ void MediaView::updateContinueButton(int value) {
void MediaView::downloadVideo() {
Video* video = listModel->activeVideo();
if (!video) return;
-
DownloadManager::instance()->addItem(video);
-
- // TODO animate
-
The::globalActions()->value("downloads")->setVisible(true);
-
- // The::globalActions()->value("download")->setEnabled(DownloadManager::instance()->itemForVideo(video) == 0);
-
- QMainWindow* mainWindow = dynamic_cast(window());
QString message = tr("Downloading %1").arg(video->title());
- if (mainWindow) mainWindow->statusBar()->showMessage(message);
+ MainWindow::instance()->showMessage(message);
}
void MediaView::snapshot() {
@@ -877,7 +869,8 @@ void MediaView::authorPushed(QModelIndex index) {
Video* video = listModel->videoAt(index.row());
if (!video) return;
- QString channel = video->author();
+ QString channel = video->authorUri();
+ if (channel.isEmpty()) channel = video->author();
if (channel.isEmpty()) return;
SearchParams *searchParams = new SearchParams();
diff --git a/src/MediaView.h b/src/MediaView.h
index 9d30c50..54a2803 100644
--- a/src/MediaView.h
+++ b/src/MediaView.h
@@ -87,7 +87,7 @@ private slots:
void searchMostViewed();
// timer
void timerPlay();
-#ifdef APP_DEMO
+#ifdef APP_ACTIVATION
void demoMessage();
void updateContinueButton(int);
#endif
@@ -137,7 +137,7 @@ private:
QTimer *workaroundTimer;
Video *skippedVideo;
-#ifdef APP_DEMO
+#ifdef APP_ACTIVATION
QTimer *demoTimer;
#endif
diff --git a/src/SearchView.cpp b/src/SearchView.cpp
index 723ad72..89dc98a 100644
--- a/src/SearchView.cpp
+++ b/src/SearchView.cpp
@@ -12,9 +12,13 @@
#ifndef Q_WS_X11
#include "extra.h"
#endif
+#ifdef APP_ACTIVATION
+#include "activation.h"
+#endif
+#include "MainWindow.h"
namespace The {
- QMap* globalActions();
+QMap* globalActions();
}
static const QString recentKeywordsKey = "recentKeywords";
@@ -41,24 +45,9 @@ SearchView::SearchView(QWidget *parent) : QWidget(parent) {
message->hide();
mainLayout->addWidget(message);
-#ifdef APP_DEMO
- QLabel *buy = new QLabel(this);
- buy->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
- buy->setText(QString("%2").arg(
- QString(Constants::WEBSITE) + "#download",
- tr("Get the full version").toUpper()
- ));
- buy->setOpenExternalLinks(true);
- buy->setMargin(7);
- buy->setAlignment(Qt::AlignRight);
- buy->setStyleSheet("QLabel {"
- "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #CCD6E0, stop: 1 #ADBCCC);"
- "border-bottom-left-radius: 8px;"
- "border-bottom-right-radius: 8px;"
- "font-size: 10px;"
- "margin-right: 50px;"
- "}");
- mainLayout->addWidget(buy, 0, Qt::AlignRight);
+#ifdef APP_ACTIVATION
+ if (!Activation::instance().isActivated())
+ mainLayout->addWidget(Extra::buyButton(tr("Get the full version")), 0, Qt::AlignCenter);
#endif
mainLayout->addStretch();
@@ -69,13 +58,7 @@ SearchView::SearchView(QWidget *parent) : QWidget(parent) {
mainLayout->addLayout(hLayout);
QLabel *logo = new QLabel(this);
- QString resource = "app";
-#ifndef Q_WS_X11
- resource = Extra::resourceName(resource);
- logo->setMaximumSize(128, 128);
- logo->setScaledContents(true);
-#endif
- logo->setPixmap(QPixmap(":/images/" + resource + ".png"));
+ logo->setPixmap(QPixmap(":/images/app.png"));
hLayout->addWidget(logo, 0, Qt::AlignTop);
hLayout->addSpacing(PADDING);
@@ -98,7 +81,7 @@ SearchView::SearchView(QWidget *parent) : QWidget(parent) {
QBoxLayout *tipLayout = new QHBoxLayout();
tipLayout->setSpacing(10);
- //: "Enter", as in "type". The whole frase says: "Enter a keyword to start watching videos"
+ //: "Enter", as in "type". The whole phrase says: "Enter a keyword to start watching videos"
QLabel *tipLabel = new QLabel(tr("Enter"), this);
tipLabel->setFont(biggerFont);
tipLayout->addWidget(tipLabel);
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index ee597d8..b06b3ec 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -4,6 +4,12 @@
#include "video.h"
#include "constants.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
diff --git a/src/updatechecker.cpp b/src/updatechecker.cpp
index da60d8f..c98a836 100644
--- a/src/updatechecker.cpp
+++ b/src/updatechecker.cpp
@@ -1,6 +1,9 @@
#include "updatechecker.h"
#include "networkaccess.h"
#include "constants.h"
+#ifdef APP_ACTIVATION
+#include "activation.h"
+#endif
namespace The {
NetworkAccess* http();
@@ -20,8 +23,10 @@ void UpdateChecker::checkForUpdate() {
#ifdef APP_WIN
updateUrl.addQueryItem("os", "win");
#endif
-#ifdef APP_DEMO
- updateUrl.addQueryItem("t", "demo");
+#ifdef APP_ACTIVATION
+ QString t = "demo";
+ if (Activation::instance().isActivated()) t = "active";
+ updateUrl.addQueryItem("t", t);
#endif
#ifdef APP_MAC_STORE
updateUrl.addQueryItem("store", "mac");