]> git.sur5r.net Git - minitube/commitdiff
Activation
authorFlavio <flavio@odisseo.local>
Tue, 11 Dec 2012 08:53:33 +0000 (09:53 +0100)
committerFlavio <flavio@odisseo.local>
Tue, 11 Dec 2012 08:53:33 +0000 (09:53 +0100)
src/AboutView.cpp
src/AboutView.h
src/MainWindow.cpp
src/MainWindow.h
src/MediaView.cpp
src/MediaView.h
src/SearchView.cpp
src/downloadmanager.cpp
src/updatechecker.cpp

index 868c018bbadef6a29f62365345d3a2a6e57c3c5d..8cbfad7e31d250c39fe7dad0ed3b789dd3eb5b58 100644 (file)
@@ -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 = "<html><style>a { color: palette(text); text-decoration: none; font-weight: bold }</style><body><h1>" + QString(Constants::NAME) + "</h1>"
+    QString info = "<html><style>a { color: palette(text); text-decoration: none; font-weight: bold }</style><body>"
+            "<h1>" + QString(Constants::NAME) + "</h1>"
             "<p>" + tr("There's life outside the browser!") + "</p>"
             "<p>" + tr("Version %1").arg(Constants::VERSION) + "</p>"
-            + QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE) +
+            + QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
 
-        #if !defined(APP_MAC) && !defined(APP_WIN)
-            "<p>" +  tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
+#ifdef APP_ACTIVATION
+    if (Activation::instance().isActivated())
+        info += "<p>" + tr("Licensed to: %1").arg("<b>" + Activation::instance().getEmail() + "</b>");
+#endif
+
+#ifdef Q_WS_X11
+    info += "<p>" +  tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
             + tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
-            .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>"
-        #endif
+            .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>";
+#endif
 
-            "<p>" + tr("You may want to try my other apps as well:") + "</p>"
-            "<ul>"
+    info += "<p>" + tr("You may want to try my other apps as well:") + "</p>"
+            "<ul>"
 
-            "<li>" + tr("%1, a YouTube music player")
+            "<li>" + tr("%1, a YouTube music player")
             .arg("<a href='http://flavio.tordini.org/musictube'>Musictube</a>")
             + "</li>"
 
-            "<li>" + tr("%1, a music player")
+            "<li>" + tr("%1, a music player")
             .arg("<a href='http://flavio.tordini.org/musique'>Musique</a>")
             + "</li>"
 
-            "</ul>"
+            "</ul>"
 
             "<p>" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
             .arg("<a href='http://www.transifex.net/projects/p/" + QString(Constants::UNIX_NAME) + "/resource/main/'>Transifex</a>")
@@ -56,7 +65,7 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent) {
             + tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.com/'>David Nel</a>")
             + "</p>"
 
-        #if !defined(APP_MAC) && !defined(APP_WIN)
+        #ifdef Q_WS_X11
             "<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
             .arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
         #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
+}
index 2d3e0c4dc394341f1fbc1fa88f308e9b98c71dbb..e1977ddac3d1496ce917cb05f54c8b85192ffc4f 100644 (file)
@@ -4,9 +4,6 @@
 #include <QtGui>
 #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<QString, QVariant> metadata() {
         QMap<QString, QVariant> metadata;
index e5d78d22533d7df0fd5ef4b272c4795b91965f18..b0e184e4bf597eb1e0846f25b43f4b158523de07 100644 (file)
 #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"
 #include "searchlineedit.h"
 #endif
 #include <iostream>
+#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<QWidget*>();
     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<QString, QMenu*> *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<View *> (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
index ee217036ee500ed897ed67c60e3b1e3a787a98db..b0b3b74a1c0482d84e77dff29672f538c4caf24c 100644 (file)
@@ -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;
 
index 012266cc2a262853f8f8757365ad7fb33c489d4f..1b0dce181c267ccf93766cc6673938e4dda16647 100644 (file)
@@ -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<QMainWindow*>(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<QMainWindow*>(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<QMainWindow*>(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<QMainWindow*>(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();
index 9d30c5017dc7c3a7d5287e510f5de34bfcfba059..54a28031e176f3c101025950c140cf3fc09727b4 100644 (file)
@@ -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
 
index 723ad724f7e1c81545f752bbc945549e20aa2ea8..89dc98a30eb95a2154c39dbaf4df9cf4470cb7aa 100644 (file)
 #ifndef Q_WS_X11
 #include "extra.h"
 #endif
+#ifdef APP_ACTIVATION
+#include "activation.h"
+#endif
+#include "MainWindow.h"
 
 namespace The {
-    QMap<QString, QAction*>* globalActions();
+QMap<QString, QAction*>* 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("<a style='color:palette(text);text-decoration:none' href='%1'>%2</a>").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);
index ee597d899f3ba46ed44f510d17081edaf6a0590e..b06b3ec086c8edabe656c493ee9fdd9e455b851b 100644 (file)
@@ -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
 
index da60d8fb706253a4eba40b8581ba0156e2b286a2..c98a83635ea8842ffe2897f7774349573b801be0 100644 (file)
@@ -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");