]> git.sur5r.net Git - minitube/commitdiff
Qt5 fixes
authorFlavio Tordini <flavio.tordini@gmail.com>
Mon, 8 Sep 2014 13:29:47 +0000 (15:29 +0200)
committerFlavio <flavio.tordini@gmail.com>
Mon, 8 Sep 2014 13:29:47 +0000 (15:29 +0200)
34 files changed:
src/channelaggregator.cpp
src/channelmodel.cpp
src/channelsuggest.cpp
src/database.cpp
src/downloadmanager.cpp
src/downloadmodel.cpp
src/downloadsettings.cpp
src/global.h
src/jsfunctions.cpp
src/main.cpp
src/mainwindow.cpp
src/mainwindow.h
src/mediaview.cpp
src/mediaview.h
src/minisplitter.cpp
src/minisplitter.h
src/networkaccess.cpp
src/painterutils.cpp
src/playlistmodel.cpp
src/playlistview.cpp
src/qtsingleapplication/qtsingleapplication.cpp
src/qtsingleapplication/qtsingleapplication.h
src/searchlineedit.cpp
src/searchlineedit.h
src/temporary.cpp
src/updatechecker.cpp
src/urllineedit.cpp
src/urllineedit.h
src/video.cpp
src/videoareawidget.cpp
src/ytsearch.cpp
src/ytsinglevideosource.cpp
src/ytstandardfeed.cpp
src/ytuser.cpp

index f27f23e5e062c423e11cc5d651a88e62b7ea5399..092a9937fb9c4c0d67f67704c7345da853bf8225 100644 (file)
@@ -119,7 +119,7 @@ void ChannelAggregator::finish() {
     if (t != s[0]) return;
     */
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     if (newVideoCount > 0 && unwatchedCount > 0 && mac::canNotify()) {
         QString channelNames;
         const int total = updatedChannels.size();
index fb8cbdb577736e3c516b7b1a4e2968381b3ce3c0..e51e4dc2701102715b9ef8723f94f863014b84d6 100644 (file)
@@ -73,6 +73,7 @@ ChannelModel::ItemTypes ChannelModel::typeForIndex(const QModelIndex &index) con
 }
 
 void ChannelModel::setQuery(const QString &query, const QSqlDatabase &db) {
+    beginResetModel();
     channels.clear();
     sqlError = QSqlError();
 
@@ -90,8 +91,7 @@ void ChannelModel::setQuery(const QString &query, const QSqlDatabase &db) {
         connect(user, SIGNAL(destroyed(QObject *)), SLOT(removeChannel(QObject *)), Qt::UniqueConnection);
         channels << user;
     }
-
-    reset();
+    endResetModel();
 }
 
 QSqlError ChannelModel::lastError() const {
index 6d0d1ff265ba3afa311f33e66f1f8b0c1b20985b..00f6e901a3672043e00984b1f4d08192179275cc 100644 (file)
@@ -31,8 +31,17 @@ ChannelSuggest::ChannelSuggest(QObject *parent) : Suggester(parent) {
 
 void ChannelSuggest::suggest(QString query) {
     QUrl url("http://www.youtube.com/results");
+#if QT_VERSION >= 0x050000
+        {
+            QUrl &u = url;
+            QUrlQuery url;
+#endif
     url.addQueryItem("search_type", "search_users");
     url.addQueryItem("search_query", query);
+#if QT_VERSION >= 0x050000
+            u.setQuery(url);
+        }
+#endif
     QObject *reply = The::http()->get(url);
     connect(reply, SIGNAL(data(QByteArray)), SLOT(handleNetworkData(QByteArray)));
 }
index 37e84336044234bec852cfdf1d294e29661d1e9a..5d8a482d93a30c82ba8eb891c2a58ed814042b9c 100644 (file)
@@ -27,8 +27,12 @@ static const QString dbName = QLatin1String(Constants::UNIX_NAME) + ".db";
 static Database *databaseInstance = 0;
 
 Database::Database() {
-
+#if QT_VERSION >= 0x050000
+    QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+#else
     QString dataLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#endif
+
     QDir().mkpath(dataLocation);
     dbLocation = dataLocation + "/" + dbName;
 
@@ -94,8 +98,11 @@ void Database::createDatabase() {
 }
 
 QString Database::getDbLocation() {
-    static QString dataLocation = QDesktopServices::storageLocation(
-                QDesktopServices::DataLocation);
+#if QT_VERSION >= 0x050000
+    static const QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+#else
+    static const QString dataLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#endif
     return dataLocation + "/" + dbName;
 }
 
index 33d2adacf66371feae05b5679614da3ef7eec4de..c42b0746c7029ed1ccbd2ce0249dbb09985a349c 100644 (file)
@@ -161,17 +161,17 @@ void DownloadManager::gotStreamUrl(QUrl url) {
 void DownloadManager::itemFinished() {
     if (activeItems() == 0) emit finished();
 #ifdef APP_EXTRA
-        DownloadItem *item = static_cast<DownloadItem*>(sender());
-        if (!item) {
-            qDebug() << "Cannot get item in" << __FUNCTION__;
-            return;
-        }
-        Video *video = item->getVideo();
-        if (!video) return;
-        QString stats = tr("%1 downloaded in %2").arg(
-                    DownloadItem::formattedFilesize(item->bytesTotal()),
-                    DownloadItem::formattedTime(item->totalTime(), false));
-        Extra::notify(tr("Download finished"), video->title(), stats);
+    DownloadItem *item = static_cast<DownloadItem*>(sender());
+    if (!item) {
+        qDebug() << "Cannot get item in" << __FUNCTION__;
+        return;
+    }
+    Video *video = item->getVideo();
+    if (!video) return;
+    QString stats = tr("%1 downloaded in %2").arg(
+                DownloadItem::formattedFilesize(item->bytesTotal()),
+                DownloadItem::formattedTime(item->totalTime(), false));
+    Extra::notify(tr("Download finished"), video->title(), stats);
 #endif
 }
 
@@ -182,16 +182,29 @@ void DownloadManager::updateStatusMessage() {
 
 QString DownloadManager::defaultDownloadFolder() {
     // download in the Movies system folder
+#if QT_VERSION >= 0x050000
+    QString path = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
+#else
     QString path = QDesktopServices::storageLocation(QDesktopServices::MoviesLocation);
+#endif
+
     QDir moviesDir(path);
     if (!moviesDir.exists()) {
         // fallback to Desktop
+#if QT_VERSION >= 0x050000
+        path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
+#else
         path = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
+#endif
 
         QDir desktopDir(path);
         if (!desktopDir.exists()) {
             // fallback to Home
+#if QT_VERSION >= 0x050000
+            path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#else
             path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
         }
     }
     return path;
index d5d36e930269563ec8dba27da657743d74c65b27..89a5eb035246e1e402eb8abedcd98e6712d6896a 100644 (file)
@@ -65,7 +65,8 @@ QVariant DownloadModel::data(const QModelIndex &index, int role) const {
 }
 
 void DownloadModel::sendReset() {
-    reset();
+    beginResetModel();
+    endResetModel();
 }
 
 void DownloadModel::setHoveredRow(int row) {
index 1afb2d5b1317b89d6435580361789f3e16dfe758..333f8e196b093be78e756ee04c034371a561d669 100644 (file)
@@ -61,12 +61,18 @@ void DownloadSettings::changeFolder() {
     QFileDialog* dialog = new QFileDialog(this);
     dialog->setFileMode(QFileDialog::Directory);
     dialog->setOptions(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly);
-    dialog->setDirectory(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+    QString path;
+#if QT_VERSION >= 0x050000
+    path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#else
+    path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
+    dialog->setDirectory(path);
     dialog->open(this, SLOT(folderChosen(const QString &)));
 #else
     QString folder = QFileDialog::getExistingDirectory(window(), tr("Choose the download location"),
-                                                    QDesktopServices::storageLocation(QDesktopServices::HomeLocation),
-                                                    QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly);
+                                                       QDesktopServices::storageLocation(QDesktopServices::HomeLocation),
+                                                       QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly);
     folderChosen(folder);
 #endif
 }
@@ -85,11 +91,15 @@ void DownloadSettings::folderChosen(const QString &dir) {
 
 void DownloadSettings::updateMessage() {
     QString path = DownloadManager::instance()->currentDownloadFolder();
-    QString home = QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/";
+#if QT_VERSION >= 0x050000
+    QString home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#else
+    QString home = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
     QString displayPath = path;
-    displayPath = displayPath.remove(home);
+    displayPath = displayPath.remove(home + "/");
     message->setText(
-            tr("Downloading to: %1")
-            .arg("<a href='file://%1' style='text-decoration:none; color:palette(text); font-weight:bold'>%2</a>")
-            .arg(path, displayPath));
+                tr("Downloading to: %1")
+                .arg("<a href='file://%1' style='text-decoration:none; color:palette(text); font-weight:bold'>%2</a>")
+                .arg(path, displayPath));
 }
index 5bac445df6845ca8ae104299ce4aeb570e4665ad..e54b5d5e3e784735be6690b4ee08094d83a1509d 100644 (file)
@@ -148,8 +148,11 @@ namespace The {
             maybeSetSystemProxy();
             nam = new QNetworkAccessManager();
             QNetworkDiskCache *cache = new DiskCache();
-            QString cacheLocation = QDesktopServices::storageLocation(
-                        QDesktopServices::DataLocation);
+#if QT_VERSION >= 0x050000
+            QString cacheLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/qt5";
+#else
+            QString cacheLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#endif
             cache->setCacheDirectory(cacheLocation);
             nam->setCache(cache);
         }
index 45070f1e2497c466a42563c0213c1db2cafb0a04..961d3f6a5d8e8183bf4fae862b1db49cc037d6db 100644 (file)
@@ -64,7 +64,11 @@ const QLatin1String & JsFunctions::jsFilename() {
 
 const QString & JsFunctions::jsPath() {
     static const QString path(
+            #if QT_VERSION >= 0x050000
+                QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+            #else
                 QDesktopServices::storageLocation(QDesktopServices::DataLocation)
+            #endif
                 + "/" + jsFilename());
     return path;
 }
index a9717afeb4b9163a0c415b7a80ed9b0bc5a29e4a..a1232c921b94411cc27e511179b78254853d1f9e 100644 (file)
@@ -30,13 +30,13 @@ $END_LICENSE */
 #ifdef APP_EXTRA
 #include "extra.h"
 #endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
 #include "mac_startup.h"
 #endif
 
 int main(int argc, char **argv) {
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     mac::MacMain();
     // https://bugreports.qt-project.org/browse/QTBUG-32789
     QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
@@ -92,7 +92,9 @@ int main(int argc, char **argv) {
     QTranslator translator;
     translator.load(QLocale::system(), QString(), QString(), localeDir);
     app.installTranslator(&translator);
+#if QT_VERSION < 0x050000
     QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
+#endif
 
     MainWindow mainWin;
     mainWin.show();
index df6426171805e241c1376b1723d72cc948b48f86..e0a0fb8fcb91a367c45b1ed8b37812feeda77024 100644 (file)
@@ -34,10 +34,10 @@ $END_LICENSE */
 #include "searchparams.h"
 #include "videosource.h"
 #include "ytsearch.h"
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
 #include "gnomeglobalshortcutbackend.h"
 #endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
 #include "mac_startup.h"
 #include "macfullscreen.h"
 #include "macsupport.h"
@@ -83,8 +83,10 @@ MainWindow::MainWindow() :
     aboutView(0),
     downloadView(0),
     regionsView(0),
+    #ifdef APP_PHONON
     mediaObject(0),
     audioOutput(0),
+    #endif
     m_fullscreen(false),
     m_compact(false) {
 
@@ -150,9 +152,13 @@ MainWindow::~MainWindow() {
 }
 
 void MainWindow::lazyInit() {
+#ifdef APP_PHONON
     initPhonon();
+#endif
     mediaView->initialize();
+#ifdef APP_PHONON
     mediaView->setMediaObject(mediaObject);
+#endif
     qApp->processEvents();
 
     // CLI
@@ -170,11 +176,11 @@ void MainWindow::lazyInit() {
 
     // Global shortcuts
     GlobalShortcuts &shortcuts = GlobalShortcuts::instance();
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
     if (GnomeGlobalShortcutBackend::IsGsdAvailable())
         shortcuts.setBackend(new GnomeGlobalShortcutBackend(&shortcuts));
 #endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     mac::MacSetup();
 #endif
     connect(&shortcuts, SIGNAL(PlayPause()), pauseAct, SLOT(trigger()));
@@ -430,7 +436,7 @@ void MainWindow::createActions() {
     addAction(volumeMuteAct);
 
     QAction *definitionAct = new QAction(this);
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
     definitionAct->setIcon(Utils::tintedIcon("video-display", QColor(0, 0, 0),
                                              QList<QSize>() << QSize(16, 16)));
 #else
@@ -571,6 +577,12 @@ void MainWindow::createActions() {
     actions->insert("open-in-browser", action);
     connect(action, SIGNAL(triggered()), mediaView, SLOT(openInBrowser()));
 
+#ifdef APP_MAC_STORE
+    action = new QAction(tr("&Love %1? Rate it!").arg(Constants::NAME), this);
+    actions->insert("app-store", action);
+    connect(action, SIGNAL(triggered()), SLOT(rateOnAppStore()));
+#endif
+
 #ifdef APP_ACTIVATION
     Extra::createActivationAction(tr("Buy %1...").arg(Constants::NAME));
 #endif
@@ -667,6 +679,11 @@ void MainWindow::createMenus() {
 #endif
     helpMenu->addAction(The::globalActions()->value("report-issue"));
     helpMenu->addAction(aboutAct);
+
+#ifdef APP_MAC_STORE
+    helpMenu->addSeparator();
+    helpMenu->addAction(The::globalActions()->value("app-store"));
+#endif
 }
 
 void MainWindow::createToolBars() {
@@ -690,7 +707,7 @@ void MainWindow::createToolBars() {
     mainToolBar->addAction(The::globalActions()->value("download"));
 
     bool addFullScreenAct = true;
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     addFullScreenAct = !mac::CanGoFullScreen(winId());
 #endif
     if (addFullScreenAct) mainToolBar->addAction(fullscreenAct);
@@ -730,6 +747,7 @@ void MainWindow::createToolBars() {
 
     mainToolBar->addAction(volumeMuteAct);
 
+#ifdef APP_PHONON
     volumeSlider = new Phonon::VolumeSlider(this);
     volumeSlider->setMuteVisible(false);
     // qDebug() << volumeSlider->children();
@@ -741,6 +759,7 @@ void MainWindow::createToolBars() {
     // this makes the volume slider smaller
     volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     mainToolBar->addWidget(volumeSlider);
+#endif
 
     mainToolBar->addWidget(new Spacer());
 
@@ -759,9 +778,7 @@ void MainWindow::createToolBars() {
     mainToolBar->addWidget(searchWrapper);
 #else
     mainToolBar->addWidget(toolbarSearch);
-    Spacer* spacer = new Spacer();
-    // spacer->setWidth(4);
-    mainToolBar->addWidget(spacer);
+    mainToolBar->addWidget(new Spacer());
 #endif
 
     addToolBar(mainToolBar);
@@ -842,8 +859,12 @@ void MainWindow::writeSettings() {
     settings.setValue("geometry", saveGeometry());
     mediaView->saveSplitterState();
 
-    settings.setValue("volume", audioOutput->volume());
-    settings.setValue("volumeMute", audioOutput->isMuted());
+#ifdef APP_PHONON
+    if (audioOutput->volume() > 0.1)
+        settings.setValue("volume", audioOutput->volume());
+    // settings.setValue("volumeMute", audioOutput->isMuted());
+#endif
+
     settings.setValue("manualplay", The::globalActions()->value("manualplay")->isChecked());
 }
 
@@ -1013,6 +1034,7 @@ void MainWindow::showMedia(VideoSource *videoSource) {
     mediaView->setVideoSource(videoSource);
 }
 
+#ifdef APP_PHONON
 void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */) {
 
     // qDebug() << "Phonon state: " << newState;
@@ -1062,6 +1084,7 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState
         ;
     }
 }
+#endif
 
 void MainWindow::stop() {
     mediaView->stop();
@@ -1069,7 +1092,7 @@ void MainWindow::stop() {
 }
 
 void MainWindow::resizeEvent(QResizeEvent*) {
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     if (mac::CanGoFullScreen(winId())) {
         bool isFullscreen = mac::IsFullScreen(winId());
         if (isFullscreen != m_fullscreen) {
@@ -1089,7 +1112,7 @@ void MainWindow::fullscreen() {
     if (compactViewAct->isChecked())
         compactViewAct->toggle();
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     WId handle = winId();
     if (mac::CanGoFullScreen(handle)) {
         mainToolBar->setVisible(true);
@@ -1109,7 +1132,7 @@ void MainWindow::fullscreen() {
         // geometry won't be saved
         writeSettings();
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         MacSupport::enterFullScreen(this, views);
 #else
         mainToolBar->hide();
@@ -1119,7 +1142,7 @@ void MainWindow::fullscreen() {
     } else {
         // Exit full screen
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         MacSupport::exitFullScreen(this, views);
 #else
         mainToolBar->show();
@@ -1171,7 +1194,7 @@ void MainWindow::updateUIForFullscreen() {
         stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop));
     }
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     MacSupport::fullScreenActions(The::globalActions()->values(), m_fullscreen);
 #endif
 
@@ -1187,7 +1210,7 @@ void MainWindow::updateUIForFullscreen() {
 }
 
 bool MainWindow::isReallyFullScreen() {
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     WId handle = winId();
     if (mac::CanGoFullScreen(handle)) return mac::IsFullScreen(handle);
     else return isFullScreen();
@@ -1211,7 +1234,7 @@ void MainWindow::compactView(bool enable) {
 
     if (enable) {
         setMinimumSize(320, 180);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         mac::RemoveFullScreenWindow(winId());
 #endif
         writeSettings();
@@ -1240,7 +1263,7 @@ void MainWindow::compactView(bool enable) {
     } else {
         // unset minimum size
         setMinimumSize(0, 0);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         mac::SetupFullScreenWindow(winId());
 #endif
         settings.setValue(key, saveGeometry());
@@ -1256,7 +1279,7 @@ void MainWindow::compactView(bool enable) {
     // auto float on top
     floatOnTop(enable);
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     mac::compactMode(winId(), enable);
 #endif
 }
@@ -1266,6 +1289,7 @@ void MainWindow::searchFocus() {
     toolbarSearch->setFocus();
 }
 
+#ifdef APP_PHONON
 void MainWindow::initPhonon() {
     // Phonon initialization
     if (mediaObject) delete mediaObject;
@@ -1288,6 +1312,7 @@ void MainWindow::initPhonon() {
     audioOutput->setVolume(settings.value("volume", 1).toDouble());
     // audioOutput->setMuted(settings.value("volumeMute").toBool());
 }
+#endif
 
 void MainWindow::tick(qint64 time) {
     if (time <= 0) {
@@ -1300,6 +1325,7 @@ void MainWindow::tick(qint64 time) {
     currentTime->setText(formatTime(time));
 
     // remaining time
+#ifdef APP_PHONON
     const qint64 remainingTime = mediaObject->remainingTime();
     currentTime->setStatusTip(tr("Remaining time: %1").arg(formatTime(remainingTime)));
 
@@ -1309,6 +1335,7 @@ void MainWindow::tick(qint64 time) {
     if (totalTime > 0 && time > 0 && !slider->isSliderDown() && mediaObject->state() == Phonon::PlayingState)
         slider->setValue(time * slider->maximum() / totalTime);
     slider->blockSignals(false);
+#endif
 }
 
 void MainWindow::totalTimeChanged(qint64 time) {
@@ -1339,27 +1366,35 @@ QString MainWindow::formatTime(qint64 time) {
 }
 
 void MainWindow::volumeUp() {
+#ifdef APP_PHONON
     qreal newVolume = volumeSlider->audioOutput()->volume() + .1;
     if (newVolume > volumeSlider->maximumVolume())
         newVolume = volumeSlider->maximumVolume();
     volumeSlider->audioOutput()->setVolume(newVolume);
+#endif
 }
 
 void MainWindow::volumeDown() {
+#ifdef APP_PHONON
     qreal newVolume = volumeSlider->audioOutput()->volume() - .1;
     if (newVolume < 0)
         newVolume = 0;
     volumeSlider->audioOutput()->setVolume(newVolume);
+#endif
 }
 
 void MainWindow::volumeMute() {
+#ifdef APP_PHONON
     volumeSlider->audioOutput()->setMuted(!volumeSlider->audioOutput()->isMuted());
+#endif
 }
 
 void MainWindow::volumeChanged(qreal newVolume) {
+#ifdef APP_PHONON
     // automatically unmute when volume changes
     if (volumeSlider->audioOutput()->isMuted())
         volumeSlider->audioOutput()->setMuted(false);
+#endif
     statusBar()->showMessage(tr("Volume at %1%").arg((int)(newVolume*100)));
 }
 
@@ -1603,6 +1638,14 @@ void MainWindow::hideMouse() {
 #endif
 }
 
+#ifdef APP_MAC_STORE
+void MainWindow::rateOnAppStore() {
+    QDesktopServices::openUrl(QUrl("macappstore://userpub.itunes.apple.com"
+                                   "/WebObjects/MZUserPublishing.woa/wa/addUserReview"
+                                   "?id=422006190&type=Purple+Software"));
+}
+#endif
+
 void MainWindow::printHelp() {
     QString msg = QString("%1 %2\n\n").arg(Constants::NAME, Constants::VERSION);
     msg += "Usage: minitube [options]\n";
index e20bae0187e8c32afe3f3b45329d1ca633d58e53..67bb0c4cfef9749c329cd34c21e98825e47000da 100644 (file)
@@ -25,10 +25,12 @@ $END_LICENSE */
 #if QT_VERSION >= 0x050000
 #include <QtWidgets>
 #endif
+#ifdef APP_PHONON
 #include <phonon/audiooutput.h>
 #include <phonon/volumeslider.h>
 #include <phonon/mediaobject.h>
 #include <phonon/seekslider.h>
+#endif
 #include "view.h"
 
 class HomeView;
@@ -99,7 +101,9 @@ private slots:
     void updateUIForFullscreen();
     void compactView(bool enable);
     void stop();
+#ifdef APP_PHONON
     void stateChanged(Phonon::State newState, Phonon::State oldState);
+#endif
     void searchFocus();
     void tick(qint64 time);
     void totalTimeChanged(qint64 time);
@@ -128,8 +132,14 @@ private slots:
 
     void hideMouse();
 
+#ifdef APP_MAC_STORE
+    void rateOnAppStore();
+#endif
+
 private:
+#ifdef APP_PHONON
     void initPhonon();
+#endif
     void createActions();
     void createMenus();
     void createToolBars();
@@ -198,12 +208,14 @@ private:
 
     // phonon
     QSlider *slider;
+#ifdef APP_PHONON
 #ifdef APP_PHONON_SEEK
     Phonon::SeekSlider *seekSlider;
 #endif
     Phonon::VolumeSlider *volumeSlider;
     Phonon::MediaObject *mediaObject;
     Phonon::AudioOutput *audioOutput;
+#endif
     QLabel *currentTime;
     QLabel *totalTime;
 
index c1a08468c065ec7f909372f319eb6259df7615d0..5287af0051f70800e59537d33cc6afbeed3e2f98 100644 (file)
@@ -24,7 +24,6 @@ $END_LICENSE */
 #include "loadingwidget.h"
 #include "videoareawidget.h"
 #include "networkaccess.h"
-#include "videowidget.h"
 #include "minisplitter.h"
 #include "constants.h"
 #include "downloadmanager.h"
@@ -101,8 +100,11 @@ void MediaView::initialize() {
 
     videoAreaWidget = new VideoAreaWidget(this);
     // videoAreaWidget->setMinimumSize(320,240);
+
+#ifdef APP_PHONON
     videoWidget = new Phonon::VideoWidget(this);
     videoAreaWidget->setVideoWidget(videoWidget);
+#endif
     videoAreaWidget->setListModel(playlistModel);
 
     loadingWidget = new LoadingWidget(this);
@@ -158,6 +160,7 @@ void MediaView::initialize() {
     connect(slider, SIGNAL(valueChanged(int)), SLOT(sliderMoved(int)));
 }
 
+#ifdef APP_PHONON
 void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
     this->mediaObject = mediaObject;
     Phonon::createPath(mediaObject, videoWidget);
@@ -166,6 +169,7 @@ void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
             SLOT(stateChanged(Phonon::State, Phonon::State)));
     connect(mediaObject, SIGNAL(aboutToFinish()), SLOT(aboutToFinish()));
 }
+#endif
 
 SearchParams* MediaView::getSearchParams() {
     VideoSource *videoSource = playlistModel->getVideoSource();
@@ -282,6 +286,7 @@ void MediaView::handleError(QString /* message */) {
     QTimer::singleShot(500, this, SLOT(startPlaying()));
 }
 
+#ifdef APP_PHONON
 void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/) {
     if (newState == Phonon::PlayingState)
         videoAreaWidget->showVideo();
@@ -291,8 +296,10 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/)
             handleError(mediaObject->errorString());
     }
 }
+#endif
 
 void MediaView::pause() {
+#ifdef APP_PHONON
     switch( mediaObject->state() ) {
     case Phonon::PlayingState:
         mediaObject->pause();
@@ -301,6 +308,7 @@ void MediaView::pause() {
         mediaObject->play();
         break;
     }
+#endif
 }
 
 QRegExp MediaView::wordRE(QString s) {
@@ -339,7 +347,9 @@ void MediaView::stop() {
     a->setEnabled(false);
     a->setVisible(false);
 
+#ifdef APP_PHONON
     mediaObject->stop();
+#endif
     currentVideoId.clear();
 
     QSlider *slider = MainWindow::instance()->getSlider();
@@ -356,7 +366,9 @@ void MediaView::activeRowChanged(int row) {
 
     errorTimer->stop();
 
+#ifdef APP_PHONON
     mediaObject->stop();
+#endif
     if (downloadItem) {
         downloadItem->stop();
         delete downloadItem;
@@ -433,7 +445,7 @@ void MediaView::gotStreamUrl(QUrl streamUrl) {
 
     currentVideoId = video->id();
 
-#ifdef Q_WS_X11_NO
+#ifdef Q_OS_LINUX_NO
     mediaObject->setCurrentSource(streamUrl);
     mediaObject->play();
 #else
@@ -469,9 +481,11 @@ void MediaView::downloadStatusChanged() {
         // qDebug() << "Downloading";
         if (downloadItem->offset() == 0) startPlaying();
         else {
+#ifdef APP_PHONON
             // qDebug() << "Seeking to" << downloadItem->offset();
             mediaObject->seek(offsetToTime(downloadItem->offset()));
             mediaObject->play();
+#endif
         }
         break;
     case Starting:
@@ -479,7 +493,7 @@ void MediaView::downloadStatusChanged() {
         break;
     case Finished:
         // qDebug() << "Finished" << mediaObject->state();
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
         // MainWindow::instance()->getSeekSlider()->setEnabled(mediaObject->isSeekable());
 #endif
         break;
@@ -509,9 +523,11 @@ void MediaView::startPlaying() {
     // go!
     QString source = downloadItem->currentFilename();
     qDebug() << "Playing" << source << QFile::exists(source);
+#ifdef APP_PHONON
     mediaObject->setCurrentSource(source);
     mediaObject->play();
-#ifdef Q_WS_X11
+#endif
+#ifdef Q_OS_LINUX
     // MainWindow::instance()->getSeekSlider()->setEnabled(false);
 #endif
 
@@ -528,7 +544,9 @@ void MediaView::itemActivated(const QModelIndex &index) {
         if (activeVideo && video && activeVideo == video) {
             // mediaObject->seek(0);
             sliderMoved(0);
+#ifdef APP_PHONON
             mediaObject->play();
+#endif
         } else playlistModel->setActiveRow(index.row());
 
         // the user doubleclicked on the "Search More" item
@@ -567,6 +585,7 @@ void MediaView::skipBackward() {
 }
 
 void MediaView::aboutToFinish() {
+#ifdef APP_PHONON
     qint64 currentTime = mediaObject->currentTime();
     qint64 totalTime = mediaObject->totalTime();
     qDebug() << __PRETTY_FUNCTION__ << currentTime << totalTime;
@@ -575,10 +594,13 @@ void MediaView::aboutToFinish() {
         mediaObject->seek(currentTime);
         mediaObject->play();
     }
+#endif
 }
 
 void MediaView::playbackFinished() {
     if (stopped) return;
+
+#ifdef APP_PHONON
     const qint64 totalTime = mediaObject->totalTime();
     const qint64 currentTime = mediaObject->currentTime();
     qDebug() << __PRETTY_FUNCTION__ << mediaObject->currentTime() << totalTime;
@@ -592,21 +614,26 @@ void MediaView::playbackFinished() {
             stopAfterThisAction->setChecked(false);
         } else skip();
     }
+#endif
 }
 
 void MediaView::playbackResume() {
     if (stopped) return;
+#ifdef APP_PHONON
     const qint64 currentTime = mediaObject->currentTime();
     qDebug() << __PRETTY_FUNCTION__ << currentTime;
     if (currentTime > 0)
         mediaObject->seek(currentTime);
     mediaObject->play();
+#endif
 }
 
 void MediaView::openWebPage() {
     Video* video = playlistModel->activeVideo();
     if (!video) return;
+#ifdef APP_PHONON
     mediaObject->pause();
+#endif
     QDesktopServices::openUrl(video->webpage());
 }
 
@@ -631,7 +658,9 @@ void MediaView::copyVideoLink() {
 void MediaView::openInBrowser() {
     Video* video = playlistModel->activeVideo();
     if (!video) return;
+#ifdef APP_PHONON
     mediaObject->pause();
+#endif
     QDesktopServices::openUrl(video->getStreamUrl());
 }
 
@@ -704,8 +733,10 @@ void MediaView::saveSplitterState() {
 static QPushButton *continueButton;
 
 void MediaView::demoMessage() {
+#ifdef APP_PHONON
     if (mediaObject->state() != Phonon::PlayingState) return;
     mediaObject->pause();
+#endif
 
     QMessageBox msgBox(this);
     msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
@@ -730,7 +761,9 @@ void MediaView::demoMessage() {
     if (msgBox.clickedButton() == buyButton) {
         MainWindow::instance()->showActivationView();
     } else {
+#ifdef APP_PHONON
         mediaObject->play();
+#endif
         demoTimer->start(600000);
     }
 
@@ -797,6 +830,7 @@ void MediaView::startDownloading() {
 }
 
 void MediaView::sliderMoved(int value) {
+#ifdef APP_PHONON
     if (currentVideoSize <= 0 || !downloadItem || !mediaObject->isSeekable())
         return;
 
@@ -820,11 +854,14 @@ void MediaView::sliderMoved(int value) {
         // qDebug() << "simple seek";
         mediaObject->seek(offsetToTime(offset));
     }
+#endif
 }
 
 qint64 MediaView::offsetToTime(qint64 offset) {
+#ifdef APP_PHONON
     const qint64 totalTime = mediaObject->totalTime();
     return ((offset * totalTime) / currentVideoSize);
+#endif
 }
 
 void MediaView::findVideoParts() {
@@ -901,9 +938,18 @@ void MediaView::shareViaTwitter() {
     Video* video = playlistModel->activeVideo();
     if (!video) return;
     QUrl url("https://twitter.com/intent/tweet");
-    url.addQueryItem("via", "minitubeapp");
-    url.addQueryItem("text", video->title());
-    url.addQueryItem("url", video->webpage().toString());
+#if QT_VERSION >= 0x050000
+    {
+        QUrl &u = url;
+        QUrlQuery url;
+#endif
+        url.addQueryItem("via", "minitubeapp");
+        url.addQueryItem("text", video->title());
+        url.addQueryItem("url", video->webpage().toString());
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QDesktopServices::openUrl(url);
 }
 
@@ -911,8 +957,17 @@ void MediaView::shareViaFacebook() {
     Video* video = playlistModel->activeVideo();
     if (!video) return;
     QUrl url("https://www.facebook.com/sharer.php");
-    url.addQueryItem("t", video->title());
-    url.addQueryItem("u", video->webpage().toString());
+#if QT_VERSION >= 0x050000
+    {
+        QUrl &u = url;
+        QUrlQuery url;
+#endif
+        url.addQueryItem("t", video->title());
+        url.addQueryItem("u", video->webpage().toString());
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QDesktopServices::openUrl(url);
 }
 
@@ -920,10 +975,19 @@ void MediaView::shareViaBuffer() {
     Video* video = playlistModel->activeVideo();
     if (!video) return;
     QUrl url("http://bufferapp.com/add");
-    url.addQueryItem("via", "minitubeapp");
-    url.addQueryItem("text", video->title());
-    url.addQueryItem("url", video->webpage().toString());
-    url.addQueryItem("picture", video->thumbnailUrl());
+#if QT_VERSION >= 0x050000
+    {
+        QUrl &u = url;
+        QUrlQuery url;
+#endif
+        url.addQueryItem("via", "minitubeapp");
+        url.addQueryItem("text", video->title());
+        url.addQueryItem("url", video->webpage().toString());
+        url.addQueryItem("picture", video->thumbnailUrl());
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QDesktopServices::openUrl(url);
 }
 
@@ -931,12 +995,21 @@ void MediaView::shareViaEmail() {
     Video* video = playlistModel->activeVideo();
     if (!video) return;
     QUrl url("mailto:");
-    url.addQueryItem("subject", video->title());
-    QString body = video->title() + "\n" +
-            video->webpage().toString() + "\n\n" +
-            tr("Sent from %1").arg(Constants::NAME) + "\n" +
-            Constants::WEBSITE;
-    url.addQueryItem("body", body);
+#if QT_VERSION >= 0x050000
+    {
+        QUrl &u = url;
+        QUrlQuery url;
+#endif
+        url.addQueryItem("subject", video->title());
+        QString body = video->title() + "\n" +
+                video->webpage().toString() + "\n\n" +
+                tr("Sent from %1").arg(Constants::NAME) + "\n" +
+                Constants::WEBSITE;
+        url.addQueryItem("body", body);
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QDesktopServices::openUrl(url);
 }
 
@@ -977,7 +1050,7 @@ void MediaView::updateSubscriptionAction(Video *video, bool subscribed) {
     subscribeAction->setStatusTip(subscribeTip);
 
     if (subscribed) {
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
         static QIcon tintedIcon;
         if (tintedIcon.isNull()) {
             QList<QSize> sizes;
index 15e9a8d2930402beea1a4421fa84148be461f372..29dcc5b3f3f50969c6bda1de76675f918943a49d 100644 (file)
@@ -26,9 +26,11 @@ $END_LICENSE */
 #include <QtWidgets>
 #endif
 #include <QtNetwork>
+#ifdef APP_PHONON
 #include <phonon/mediaobject.h>
 #include <phonon/videowidget.h>
 #include <phonon/seekslider.h>
+#endif
 #include "view.h"
 
 class Video;
@@ -42,7 +44,7 @@ class SidebarWidget;
 class VideoSource;
 
 namespace The {
-    QHash<QString, QAction*>* globalActions();
+QHash<QString, QAction*>* globalActions();
 }
 
 class MediaView : public QWidget, public View {
@@ -56,7 +58,9 @@ public:
     void appear();
     void disappear();
 
+#ifdef APP_PHONON
     void setMediaObject(Phonon::MediaObject *mediaObject);
+#endif
     const QList<VideoSource*> & getHistory() { return history; }
     int getHistoryIndex();
     PlaylistModel* getPlaylistModel() { return playlistModel; }
@@ -106,7 +110,9 @@ private slots:
     void gotStreamUrl(QUrl streamUrl);
     void handleError(QString message);
     // phonon
+#ifdef APP_PHONON
     void stateChanged(Phonon::State newState, Phonon::State oldState);
+#endif
     void aboutToFinish();
 #ifdef APP_ACTIVATION
     void demoMessage();
@@ -135,9 +141,10 @@ private:
     VideoAreaWidget *videoAreaWidget;
     LoadingWidget *loadingWidget;
 
-    // phonon
+#ifdef APP_PHONON
     Phonon::MediaObject *mediaObject;
     Phonon::VideoWidget *videoWidget;
+#endif
 
     bool stopped;
     QTimer *errorTimer;
index 02fdacf7946c63e580a17ad8efe78c6a66500f5c..8232da8966c01f16250c08a49ab12e4be303bca2 100644 (file)
@@ -29,9 +29,9 @@
 
 #include "minisplitter.h"
 
-#include <QtGui/QPaintEvent>
-#include <QtGui/QPainter>
-#include <QtGui/QSplitterHandle>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QSplitterHandle>
 
 class MiniSplitterHandle : public QSplitterHandle
 {
index 51a1c01292c6522c118c0c1f07d05f6ca8635391..23204ae22620ceceffdc1aa889d7c62e058556c9 100644 (file)
@@ -30,7 +30,7 @@
 #ifndef MINISPLITTER_H
 #define MINISPLITTER_H
 
-#include <QtGui/QSplitter>
+#include <QSplitter>
 
 QT_BEGIN_NAMESPACE
 class QSplitterHandle;
index 98e44ca8bf75fd329bf00fbc72b44f6362b7dbf0..6ed3e7347deece00525cc7cf5fac7fdb5beeaebc 100644 (file)
@@ -35,7 +35,7 @@ const QString USER_AGENT = QString(Constants::NAME)
                            + " (" + Constants::WEBSITE + ")";
 */
 
-const QString USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36";
+const QString USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36";
 
 NetworkReply::NetworkReply(QNetworkReply *networkReply) :
     QObject(networkReply),
index 54ee39ee26d1cb6365c70691e3b6ee8240a94a6e..8dcfdf4aebbf226ab0ba898cc60add9c7e52f17c 100644 (file)
@@ -90,7 +90,7 @@ void PainterUtils::paintBadge(QPainter *painter, const QString &text, bool cente
 #ifdef APP_WIN
     rect.adjust(0, -2, 0, 0);
 #endif
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
     rect.adjust(0, -1, 0, 0);
 #endif
     painter->save();
index b3bf4cf5f27aa67e4e9296d8fa0d881e6e8e2977..a3cad088bcee9646d686264c1ab6bdd25e1cd457 100644 (file)
@@ -164,13 +164,13 @@ Video* PlaylistModel::activeVideo() const {
 }
 
 void PlaylistModel::setVideoSource(VideoSource *videoSource) {
+    beginResetModel();
     while (!videos.isEmpty())
         delete videos.takeFirst();
-
     m_activeVideo = 0;
     m_activeRow = -1;
     skip = 1;
-    reset();
+    endResetModel();
 
     this->videoSource = videoSource;
     connect(videoSource, SIGNAL(gotVideos(QList<Video*>)),
@@ -205,14 +205,15 @@ void PlaylistModel::searchNeeded() {
 }
 
 void PlaylistModel::abortSearch() {
+    beginResetModel();
     while (!videos.isEmpty())
         delete videos.takeFirst();
-    reset();
     // if (videoSource) videoSource->abort();
     searching = false;
     m_activeRow = -1;
     m_activeVideo = 0;
     skip = 1;
+    endResetModel();
 }
 
 void PlaylistModel::searchFinished(int total) {
index 83c812e23db62e6a68ff0f4405611b0bd4ffb710..2391f9fe6258f019f424d497c8846631cb6842e3 100644 (file)
@@ -136,7 +136,7 @@ bool PlaylistView::isShowMoreItem(const QModelIndex &index) {
 
 void PlaylistView::paintEvent(QPaintEvent *event) {
     QListView::paintEvent(event);
-#ifndef Q_WS_X11
+#ifndef Q_OS_LINUX
     PainterUtils::topShadow(viewport());
 #endif
 }
index 2ab0bbd9680ed5e387c2c733a347a88b6517e73d..3840ad8ebcd87699b369a4c902504eceb361e2ae 100644 (file)
@@ -47,7 +47,7 @@
 
 #include "qtsingleapplication.h"
 #include "qtlocalpeer.h"
-#include <QtGui/QWidget>
+#include <QWidget>
 
 
 /*!
@@ -182,14 +182,16 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char *
     will be QCoreApplication::applicationFilePath(). \a argc, \a
     argv, and \a type are passed on to the QAppliation constructor.
 */
+/*
 QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
     : QApplication(argc, argv, type)
 {
     sysInit();
 }
+*/
 
 
-#if defined(Q_WS_X11)
+#if defined(Q_OS_LINUX)
 /*!
   Special constructor for X11, ref. the documentation of
   QApplication's corresponding constructor. The application identifier
index b73f5d668ecae954ecb5e62bef4c262626cdc448..29a4182745a60b2b934712eb4436d5e50aa93d62 100644 (file)
 ****************************************************************************/
 
 
-#include <QtGui/QApplication>
+#include <QApplication>
 
 class QtLocalPeer;
 
-#if defined(Q_WS_WIN)
+#if defined(Q_OS_WIN)
 #  if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
 #    define QT_QTSINGLEAPPLICATION_EXPORT
 #  elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
@@ -72,8 +72,8 @@ class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
 public:
     QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
     QtSingleApplication(const QString &id, int &argc, char **argv);
-    QtSingleApplication(int &argc, char **argv, Type type);
-#if defined(Q_WS_X11)
+    // QtSingleApplication(int &argc, char **argv, Type type);
+#if defined(Q_OS_LINUX)
     QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
     QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
     QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
index abd33ad6602bc0a957a9cc09ebbdd40fa54cfd6e..93008d008f628f7e01e2e8a5c456f92a79cc1c71 100644 (file)
 
 #include "searchlineedit.h"
 
-#include <QtGui/QPainter>
-#include <QtGui/QMouseEvent>
-#include <QtGui/QMenu>
-#include <QtGui/QStyle>
-#include <QtGui/QStyleOptionFrameV2>
+#include <QPainter>
+#include <QMouseEvent>
+#include <QMenu>
+#include <QStyle>
+#include <QStyleOptionFrameV2>
 
 #include "autocomplete.h"
 
index 909443556fd2612f3e67b663faa0ba5189c5b1fa..3403df4ee60c437e919c19b4b4a066a3f85f03ef 100644 (file)
@@ -45,8 +45,8 @@
 #include "urllineedit.h"
 #include "autocomplete.h"
 
-#include <QtGui/QLineEdit>
-#include <QtGui/QAbstractButton>
+#include <QLineEdit>
+#include <QAbstractButton>
 
 QT_BEGIN_NAMESPACE
 class QMenu;
index 3f29d70acc2a230675258c9f8d668c20a60102e4..40bd5427efcd481659665ac4573f31fc4f35ff05 100644 (file)
@@ -22,19 +22,22 @@ $END_LICENSE */
 #include "constants.h"
 
 static QList<QString> paths;
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
 static QString userName;
 #endif
 
 Temporary::Temporary() { }
 
 QString Temporary::filename() {
-
+#if QT_VERSION >= 0x050000
+    static const QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
+#else
     static const QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
+#endif
 
     QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand());
 
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
     if (userName.isNull()) {
         userName = QString(getenv("USERNAME"));
         if (userName.isEmpty())
index af7c349e6d3c9522cb00e669a40e8c946b1fc0cd..247fb5346d4db4f7b699a631aab86e7ec6a103f6 100644 (file)
@@ -26,7 +26,7 @@ $END_LICENSE */
 #endif
 
 namespace The {
-    NetworkAccess* http();
+NetworkAccess* http();
 }
 
 UpdateChecker::UpdateChecker() {
@@ -34,35 +34,47 @@ UpdateChecker::UpdateChecker() {
 }
 
 void UpdateChecker::checkForUpdate() {
-    QUrl updateUrl(QLatin1String(Constants::WEBSITE) + "-ws/release.xml");
-    updateUrl.addQueryItem("v", Constants::VERSION);
+    QUrl url(QLatin1String(Constants::WEBSITE) + "-ws/release.xml");
+
+#if QT_VERSION >= 0x050000
+    {
+        QUrl &u = url;
+        QUrlQuery url;
+#endif
+
+        url.addQueryItem("v", Constants::VERSION);
 
 #ifdef APP_MAC
-    updateUrl.addQueryItem("os", "mac");
+        url.addQueryItem("os", "mac");
 #endif
 #ifdef APP_WIN
-    updateUrl.addQueryItem("os", "win");
+        url.addQueryItem("os", "win");
 #endif
 #ifdef APP_ACTIVATION
-    QString t = "demo";
-    if (Activation::instance().isActivated()) t = "active";
-    updateUrl.addQueryItem("t", t);
+        QString t = "demo";
+        if (Activation::instance().isActivated()) t = "active";
+        url.addQueryItem("t", t);
 #endif
 #ifdef APP_MAC_STORE
-    updateUrl.addQueryItem("store", "mac");
+        url.addQueryItem("store", "mac");
+#endif
+
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
 #endif
 
-    QObject *reply = The::http()->get(updateUrl);
+    QObject *reply = The::http()->get(url);
     connect(reply, SIGNAL(data(QByteArray)), SLOT(requestFinished(QByteArray)));
 
 }
 
 void UpdateChecker::requestFinished(QByteArray data) {
-        UpdateCheckerStreamReader reader;
-        reader.read(data);
-        m_needUpdate = reader.needUpdate();
-        m_remoteVersion = reader.remoteVersion();
-        if (m_needUpdate && !m_remoteVersion.isEmpty()) emit newVersion(m_remoteVersion);
+    UpdateCheckerStreamReader reader;
+    reader.read(data);
+    m_needUpdate = reader.needUpdate();
+    m_remoteVersion = reader.remoteVersion();
+    if (m_needUpdate && !m_remoteVersion.isEmpty()) emit newVersion(m_remoteVersion);
 }
 
 QString UpdateChecker::remoteVersion() {
index e7e5064e315454cd6aeca96640593e58798d65c9..1b79fd07bf619970018a3452ebfca29890f0d351 100644 (file)
 #include "urllineedit.h"
 #include "searchlineedit.h"
 
-#include <QtCore/QEvent>
-
-#include <QtGui/QApplication>
-#include <QtGui/QCompleter>
-#include <QtGui/QFocusEvent>
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QLabel>
-#include <QtGui/QLineEdit>
-#include <QtGui/QPainter>
-#include <QtGui/QStyle>
-#include <QtGui/QStyleOptionFrameV2>
+#include <QEvent>
+
+#include <QApplication>
+#include <QCompleter>
+#include <QFocusEvent>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPainter>
+#include <QStyle>
+#include <QStyleOptionFrameV2>
 
 #include <QtCore/QDebug>
 
index a8e4a12066836eeaf6be288e421329abc32a153e..3cda04c1dbe5656b7e819661ee5983ff58eec7aa 100644 (file)
@@ -62,10 +62,10 @@ $END_LICENSE */
 #ifndef URLLINEEDIT_H
 #define URLLINEEDIT_H
 
-#include <QtCore/QUrl>
-#include <QtGui/QWidget>
-#include <QtGui/QLineEdit>
-#include <QtGui/QStyleOptionFrame>
+#include <QUrl>
+#include <QWidget>
+#include <QLineEdit>
+#include <QStyleOptionFrame>
 
 QT_BEGIN_NAMESPACE
 class QLineEdit;
index ce351105601cb33c691b8ee73d281f44092d7fe7..3c15efd0411c3e771ea6d164ebbb643367dec6cc 100644 (file)
@@ -29,7 +29,7 @@ NetworkAccess* http();
 }
 
 namespace {
-    static const QString jsNameChars = "a-zA-Z0-9\\$_";
+static const QString jsNameChars = "a-zA-Z0-9\\$_";
 }
 
 Video::Video() : m_duration(0),
@@ -70,7 +70,7 @@ void Video::setWebpage(QUrl webpage) {
     // QRegExp re("^((?:http://)?(?:\\w+\\.)?youtube\\.com/(?:(?:v/)|(?:(?:watch(?:\\.php)?)?\\?(?:.+&)?v=)))?([0-9A-Za-z_-]+)(?(1).+)?$");
     QRegExp re("^https?://www\\.youtube\\.com/watch\\?v=([0-9A-Za-z_-]+).*");
     bool match = re.exactMatch(m_webpage.toString());
-    if (!match || re.numCaptures() < 1) {
+    if (!match) {
         qWarning() << QString("Cannot get video id for %1").arg(m_webpage.toString());
         // emit errorStreamUrl(QString("Cannot get video id for %1").arg(m_webpage.toString()));
         // loadingStreamUrl = false;
@@ -115,18 +115,29 @@ void Video::loadStreamUrl() {
 void  Video::getVideoInfo() {
     static const QStringList elTypes = QStringList() << "&el=embedded" << "&el=detailpage" << "&el=vevo" << "";
 
-    QUrl videoInfoUrl;
+    QUrl url;
 
     if (elIndex == elTypes.size()) {
         // qDebug() << "Trying special embedded el param";
-        videoInfoUrl = QUrl("http://www.youtube.com/get_video_info");
-        videoInfoUrl.addQueryItem("video_id", videoId);
-        videoInfoUrl.addQueryItem("el", "embedded");
-        videoInfoUrl.addQueryItem("gl", "US");
-        videoInfoUrl.addQueryItem("hl", "en");
-        videoInfoUrl.addQueryItem("eurl", "https://youtube.googleapis.com/v/" + videoId);
-        videoInfoUrl.addQueryItem("asv", "3");
-        videoInfoUrl.addQueryItem("sts", "1588");
+        url = QUrl("http://www.youtube.com/get_video_info");
+
+#if QT_VERSION >= 0x050000
+        {
+            QUrl &u = url;
+            QUrlQuery url;
+#endif
+            url.addQueryItem("video_id", videoId);
+            url.addQueryItem("el", "embedded");
+            url.addQueryItem("gl", "US");
+            url.addQueryItem("hl", "en");
+            url.addQueryItem("eurl", "https://youtube.googleapis.com/v/" + videoId);
+            url.addQueryItem("asv", "3");
+            url.addQueryItem("sts", "1588");
+#if QT_VERSION >= 0x050000
+            u.setQuery(url);
+        }
+#endif
+
     } else if (elIndex > elTypes.size() - 1) {
         qWarning() << "Cannot get video info";
         loadingStreamUrl = false;
@@ -134,12 +145,12 @@ void  Video::getVideoInfo() {
         return;
     } else {
         // qDebug() << "Trying el param:" << elTypes.at(elIndex) << elIndex;
-        videoInfoUrl = QUrl(QString(
-                                "http://www.youtube.com/get_video_info?video_id=%1%2&ps=default&eurl=&gl=US&hl=en"
-                                ).arg(videoId, elTypes.at(elIndex)));
+        url = QUrl(QString(
+                       "http://www.youtube.com/get_video_info?video_id=%1%2&ps=default&eurl=&gl=US&hl=en"
+                       ).arg(videoId, elTypes.at(elIndex)));
     }
 
-    QObject *reply = The::http()->get(videoInfoUrl);
+    QObject *reply = The::http()->get(url);
     connect(reply, SIGNAL(data(QByteArray)), SLOT(gotVideoInfo(QByteArray)));
     connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(errorVideoInfo(QNetworkReply*)));
 
@@ -154,7 +165,7 @@ void  Video::gotVideoInfo(QByteArray data) {
     QRegExp re = QRegExp("^.*&token=([^&]+).*$");
     bool match = re.exactMatch(videoInfo);
     // handle regexp failure
-    if (!match || re.numCaptures() < 1) {
+    if (!match) {
         // qDebug() << "Cannot get token. Trying next el param";
         // Don't panic! We're gonna try another magic "el" param
         elIndex++;
@@ -164,7 +175,7 @@ void  Video::gotVideoInfo(QByteArray data) {
 
     QString videoToken = re.cap(1);
     while (videoToken.contains('%'))
-        videoToken = QByteArray::fromPercentEncoding(videoToken.toAscii());
+        videoToken = QByteArray::fromPercentEncoding(videoToken.toLatin1());
     // qDebug() << "videoToken" << videoToken;
     this->videoToken = videoToken;
 
@@ -172,7 +183,7 @@ void  Video::gotVideoInfo(QByteArray data) {
     re = QRegExp("^.*&url_encoded_fmt_stream_map=([^&]+).*$");
     match = re.exactMatch(videoInfo);
     // handle regexp failure
-    if (!match || re.numCaptures() < 1) {
+    if (!match) {
         // qDebug() << "Cannot get urlMap. Trying next el param";
         // Don't panic! We're gonna try another magic "el" param
         elIndex++;
@@ -231,10 +242,20 @@ void Video::parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage) {
                 } else {
                     // qDebug() << "Loading webpage";
                     QUrl url("http://www.youtube.com/watch");
-                    url.addQueryItem("v", videoId);
-                    url.addQueryItem("gl", "US");
-                    url.addQueryItem("hl", "en");
-                    url.addQueryItem("has_verified", "1");
+
+#if QT_VERSION >= 0x050000
+                    {
+                        QUrl &u = url;
+                        QUrlQuery url;
+#endif
+                        url.addQueryItem("v", videoId);
+                        url.addQueryItem("gl", "US");
+                        url.addQueryItem("hl", "en");
+                        url.addQueryItem("has_verified", "1");
+#if QT_VERSION >= 0x050000
+                        u.setQuery(url);
+                    }
+#endif
                     QObject *reply = The::http()->get(url);
                     connect(reply, SIGNAL(data(QByteArray)), SLOT(scrapeWebPage(QByteArray)));
                     connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(errorVideoInfo(QNetworkReply*)));
@@ -320,7 +341,7 @@ void Video::scrapeWebPage(QByteArray data) {
     QRegExp re(".*\"url_encoded_fmt_stream_map\":\\s+\"([^\"]+)\".*");
     bool match = re.exactMatch(html);
     // on regexp failure, stop and report error
-    if (!match || re.numCaptures() < 1) {
+    if (!match) {
         qWarning() << "Error parsing video page";
         // emit errorStreamUrl("Error parsing video page");
         // loadingStreamUrl = false;
index 14a57187b09d2af07c2fe810d8523cfe33063304..ee64a2084df54539114e3748efc51de00f933d69 100644 (file)
@@ -24,11 +24,11 @@ $END_LICENSE */
 #ifdef APP_EXTRA
 #include "extra.h"
 #endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
 #include "macutils.h"
 #endif
 
-VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
+VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent), videoWidget(0) {
     QBoxLayout *vLayout = new QVBoxLayout(this);
     vLayout->setMargin(0);
     vLayout->setSpacing(0);
@@ -73,7 +73,8 @@ void VideoAreaWidget::setLoadingWidget(LoadingWidget *loadingWidget) {
 }
 
 void VideoAreaWidget::showVideo() {
-    stackedLayout->setCurrentWidget(videoWidget);
+    if (videoWidget)
+        stackedLayout->setCurrentWidget(videoWidget);
     loadingWidget->clear();
 }
 
@@ -140,7 +141,7 @@ void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
             !MainWindow::instance()->isReallyFullScreen();
     if (event->buttons() & Qt::LeftButton && isNormalWindow) {
         QPoint p = event->globalPos() - dragPosition;
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         mac::moveWindowTo(window()->winId(), p.x(), p.y());
 #else
         window()->move(p);
index 010cbd57d4ea0696041ed51c39a5b856f633439c..68b22c6e1854bc828b7c1460ff63c212183c9147 100644 (file)
@@ -42,8 +42,13 @@ void YTSearch::loadVideos(int max, int skip) {
     aborted = false;
 
     QUrl url("http://gdata.youtube.com/feeds/api/videos/");
-    url.addQueryItem("v", "2");
+#if QT_VERSION >= 0x050000
+{
+    QUrl &u = url;
+    QUrlQuery url;
+#endif
 
+    url.addQueryItem("v", "2");
     url.addQueryItem("max-results", QString::number(max));
     url.addQueryItem("start-index", QString::number(skip));
 
@@ -99,6 +104,10 @@ void YTSearch::loadVideos(int max, int skip) {
         break;
     }
 
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QObject *reply = The::http()->get(url);
     connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResults(QByteArray)));
     connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*)));
index b4f4d308943341e810a5862f2650b43e77134d73..05e5a327db238eae33b1654fb10c170898cfee8b 100644 (file)
@@ -42,6 +42,11 @@ void YTSingleVideoSource::loadVideos(int max, int skip) {
     if (skip == 1) s = "http://gdata.youtube.com/feeds/api/videos/" + videoId;
     else s = QString("http://gdata.youtube.com/feeds/api/videos/%1/related").arg(videoId);
     QUrl url(s);
+#if QT_VERSION >= 0x050000
+{
+    QUrl &u = url;
+    QUrlQuery url;
+#endif
     url.addQueryItem("v", "2");
 
     if (skip != 1) {
@@ -49,6 +54,10 @@ void YTSingleVideoSource::loadVideos(int max, int skip) {
         url.addQueryItem("start-index", QString::number(skip-1));
     }
 
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QObject *reply = The::http()->get(url);
     connect(reply, SIGNAL(data(QByteArray)), SLOT(parse(QByteArray)));
     connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*)));
index 50e0674318605a8d1d4c2a61a282ec8cb0308e66..ee5e0030f141a8982754fd5840eec756f7eed638 100644 (file)
@@ -41,6 +41,11 @@ void YTStandardFeed::loadVideos(int max, int skip) {
     if (!category.isEmpty()) s += "_" + category;
 
     QUrl url(s);
+#if QT_VERSION >= 0x050000
+{
+    QUrl &u = url;
+    QUrlQuery url;
+#endif
     url.addQueryItem("v", "2");
 
     if (feedId != "most_shared" && feedId != "on_the_web") {
@@ -52,6 +57,10 @@ void YTStandardFeed::loadVideos(int max, int skip) {
     url.addQueryItem("max-results", QString::number(max));
     url.addQueryItem("start-index", QString::number(skip));
 
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QObject *reply = The::http()->get(url);
     connect(reply, SIGNAL(data(QByteArray)), SLOT(parse(QByteArray)));
     connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*)));
index 5098f3f84d56196f5185f06e06447b882b828bdc..29f851dc39a6dc802124b1f95ef108a802c67bdb 100644 (file)
@@ -83,7 +83,16 @@ void YTUser::maybeLoadfromAPI() {
     loading = true;
 
     QUrl url("http://gdata.youtube.com/feeds/api/users/" + userId);
-    url.addQueryItem("v", "2");
+#if QT_VERSION >= 0x050000
+    {
+        QUrl &u = url;
+        QUrlQuery url;
+#endif
+        url.addQueryItem("v", "2");
+#if QT_VERSION >= 0x050000
+        u.setQuery(url);
+    }
+#endif
     QObject *reply = The::http()->get(url);
     connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResponse(QByteArray)));
     connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*)));
@@ -122,7 +131,7 @@ void YTUser::loadThumbnail() {
     if (thumbnailUrl.isEmpty()) return;
     loadingThumbnail = true;
 
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
     thumbnailUrl.replace(QLatin1String("https://"), QLatin1String("http://"));
 #endif
 
@@ -133,8 +142,13 @@ void YTUser::loadThumbnail() {
 }
 
 const QString & YTUser::getThumbnailDir() {
-    static const QString thumbDir = QDesktopServices::storageLocation(
-                QDesktopServices::DataLocation) + "/channels/";
+    static const QString thumbDir =
+        #if QT_VERSION >= 0x050000
+            QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+#else
+            QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#endif
+    + "/channels/";
     return thumbDir;
 }