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();
}
void ChannelModel::setQuery(const QString &query, const QSqlDatabase &db) {
+ beginResetModel();
channels.clear();
sqlError = QSqlError();
connect(user, SIGNAL(destroyed(QObject *)), SLOT(removeChannel(QObject *)), Qt::UniqueConnection);
channels << user;
}
-
- reset();
+ endResetModel();
}
QSqlError ChannelModel::lastError() const {
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)));
}
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;
}
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;
}
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
}
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;
}
void DownloadModel::sendReset() {
- reset();
+ beginResetModel();
+ endResetModel();
}
void DownloadModel::setHoveredRow(int row) {
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
}
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));
}
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);
}
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;
}
#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");
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();
#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"
aboutView(0),
downloadView(0),
regionsView(0),
+ #ifdef APP_PHONON
mediaObject(0),
audioOutput(0),
+ #endif
m_fullscreen(false),
m_compact(false) {
}
void MainWindow::lazyInit() {
+#ifdef APP_PHONON
initPhonon();
+#endif
mediaView->initialize();
+#ifdef APP_PHONON
mediaView->setMediaObject(mediaObject);
+#endif
qApp->processEvents();
// CLI
// 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()));
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
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
#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() {
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);
mainToolBar->addAction(volumeMuteAct);
+#ifdef APP_PHONON
volumeSlider = new Phonon::VolumeSlider(this);
volumeSlider->setMuteVisible(false);
// qDebug() << volumeSlider->children();
// this makes the volume slider smaller
volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
mainToolBar->addWidget(volumeSlider);
+#endif
mainToolBar->addWidget(new Spacer());
mainToolBar->addWidget(searchWrapper);
#else
mainToolBar->addWidget(toolbarSearch);
- Spacer* spacer = new Spacer();
- // spacer->setWidth(4);
- mainToolBar->addWidget(spacer);
+ mainToolBar->addWidget(new Spacer());
#endif
addToolBar(mainToolBar);
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());
}
mediaView->setVideoSource(videoSource);
}
+#ifdef APP_PHONON
void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */) {
// qDebug() << "Phonon state: " << newState;
;
}
}
+#endif
void MainWindow::stop() {
mediaView->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) {
if (compactViewAct->isChecked())
compactViewAct->toggle();
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
WId handle = winId();
if (mac::CanGoFullScreen(handle)) {
mainToolBar->setVisible(true);
// geometry won't be saved
writeSettings();
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
MacSupport::enterFullScreen(this, views);
#else
mainToolBar->hide();
} else {
// Exit full screen
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
MacSupport::exitFullScreen(this, views);
#else
mainToolBar->show();
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
}
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();
if (enable) {
setMinimumSize(320, 180);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
mac::RemoveFullScreenWindow(winId());
#endif
writeSettings();
} else {
// unset minimum size
setMinimumSize(0, 0);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
mac::SetupFullScreenWindow(winId());
#endif
settings.setValue(key, saveGeometry());
// auto float on top
floatOnTop(enable);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
mac::compactMode(winId(), enable);
#endif
}
toolbarSearch->setFocus();
}
+#ifdef APP_PHONON
void MainWindow::initPhonon() {
// Phonon initialization
if (mediaObject) delete mediaObject;
audioOutput->setVolume(settings.value("volume", 1).toDouble());
// audioOutput->setMuted(settings.value("volumeMute").toBool());
}
+#endif
void MainWindow::tick(qint64 time) {
if (time <= 0) {
currentTime->setText(formatTime(time));
// remaining time
+#ifdef APP_PHONON
const qint64 remainingTime = mediaObject->remainingTime();
currentTime->setStatusTip(tr("Remaining time: %1").arg(formatTime(remainingTime)));
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) {
}
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)));
}
#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";
#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;
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);
void hideMouse();
+#ifdef APP_MAC_STORE
+ void rateOnAppStore();
+#endif
+
private:
+#ifdef APP_PHONON
void initPhonon();
+#endif
void createActions();
void createMenus();
void createToolBars();
// 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;
#include "loadingwidget.h"
#include "videoareawidget.h"
#include "networkaccess.h"
-#include "videowidget.h"
#include "minisplitter.h"
#include "constants.h"
#include "downloadmanager.h"
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);
connect(slider, SIGNAL(valueChanged(int)), SLOT(sliderMoved(int)));
}
+#ifdef APP_PHONON
void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
this->mediaObject = mediaObject;
Phonon::createPath(mediaObject, videoWidget);
SLOT(stateChanged(Phonon::State, Phonon::State)));
connect(mediaObject, SIGNAL(aboutToFinish()), SLOT(aboutToFinish()));
}
+#endif
SearchParams* MediaView::getSearchParams() {
VideoSource *videoSource = playlistModel->getVideoSource();
QTimer::singleShot(500, this, SLOT(startPlaying()));
}
+#ifdef APP_PHONON
void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/) {
if (newState == Phonon::PlayingState)
videoAreaWidget->showVideo();
handleError(mediaObject->errorString());
}
}
+#endif
void MediaView::pause() {
+#ifdef APP_PHONON
switch( mediaObject->state() ) {
case Phonon::PlayingState:
mediaObject->pause();
mediaObject->play();
break;
}
+#endif
}
QRegExp MediaView::wordRE(QString s) {
a->setEnabled(false);
a->setVisible(false);
+#ifdef APP_PHONON
mediaObject->stop();
+#endif
currentVideoId.clear();
QSlider *slider = MainWindow::instance()->getSlider();
errorTimer->stop();
+#ifdef APP_PHONON
mediaObject->stop();
+#endif
if (downloadItem) {
downloadItem->stop();
delete downloadItem;
currentVideoId = video->id();
-#ifdef Q_WS_X11_NO
+#ifdef Q_OS_LINUX_NO
mediaObject->setCurrentSource(streamUrl);
mediaObject->play();
#else
// 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:
break;
case Finished:
// qDebug() << "Finished" << mediaObject->state();
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
// MainWindow::instance()->getSeekSlider()->setEnabled(mediaObject->isSeekable());
#endif
break;
// 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
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
}
void MediaView::aboutToFinish() {
+#ifdef APP_PHONON
qint64 currentTime = mediaObject->currentTime();
qint64 totalTime = mediaObject->totalTime();
qDebug() << __PRETTY_FUNCTION__ << currentTime << totalTime;
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;
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());
}
void MediaView::openInBrowser() {
Video* video = playlistModel->activeVideo();
if (!video) return;
+#ifdef APP_PHONON
mediaObject->pause();
+#endif
QDesktopServices::openUrl(video->getStreamUrl());
}
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));
if (msgBox.clickedButton() == buyButton) {
MainWindow::instance()->showActivationView();
} else {
+#ifdef APP_PHONON
mediaObject->play();
+#endif
demoTimer->start(600000);
}
}
void MediaView::sliderMoved(int value) {
+#ifdef APP_PHONON
if (currentVideoSize <= 0 || !downloadItem || !mediaObject->isSeekable())
return;
// 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() {
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);
}
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);
}
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);
}
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);
}
subscribeAction->setStatusTip(subscribeTip);
if (subscribed) {
-#ifdef Q_WS_X11
+#ifdef Q_OS_LINUX
static QIcon tintedIcon;
if (tintedIcon.isNull()) {
QList<QSize> sizes;
#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;
class VideoSource;
namespace The {
- QHash<QString, QAction*>* globalActions();
+QHash<QString, QAction*>* globalActions();
}
class MediaView : public QWidget, public View {
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; }
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();
VideoAreaWidget *videoAreaWidget;
LoadingWidget *loadingWidget;
- // phonon
+#ifdef APP_PHONON
Phonon::MediaObject *mediaObject;
Phonon::VideoWidget *videoWidget;
+#endif
bool stopped;
QTimer *errorTimer;
#include "minisplitter.h"
-#include <QtGui/QPaintEvent>
-#include <QtGui/QPainter>
-#include <QtGui/QSplitterHandle>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QSplitterHandle>
class MiniSplitterHandle : public QSplitterHandle
{
#ifndef MINISPLITTER_H
#define MINISPLITTER_H
-#include <QtGui/QSplitter>
+#include <QSplitter>
QT_BEGIN_NAMESPACE
class QSplitterHandle;
+ " (" + 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),
#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();
}
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*>)),
}
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) {
void PlaylistView::paintEvent(QPaintEvent *event) {
QListView::paintEvent(event);
-#ifndef Q_WS_X11
+#ifndef Q_OS_LINUX
PainterUtils::topShadow(viewport());
#endif
}
#include "qtsingleapplication.h"
#include "qtlocalpeer.h"
-#include <QtGui/QWidget>
+#include <QWidget>
/*!
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
****************************************************************************/
-#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)
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);
#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"
#include "urllineedit.h"
#include "autocomplete.h"
-#include <QtGui/QLineEdit>
-#include <QtGui/QAbstractButton>
+#include <QLineEdit>
+#include <QAbstractButton>
QT_BEGIN_NAMESPACE
class QMenu;
#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())
#endif
namespace The {
- NetworkAccess* http();
+NetworkAccess* http();
}
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() {
#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>
#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;
}
namespace {
- static const QString jsNameChars = "a-zA-Z0-9\\$_";
+static const QString jsNameChars = "a-zA-Z0-9\\$_";
}
Video::Video() : m_duration(0),
// 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;
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;
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*)));
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++;
QString videoToken = re.cap(1);
while (videoToken.contains('%'))
- videoToken = QByteArray::fromPercentEncoding(videoToken.toAscii());
+ videoToken = QByteArray::fromPercentEncoding(videoToken.toLatin1());
// qDebug() << "videoToken" << videoToken;
this->videoToken = videoToken;
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++;
} 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*)));
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;
#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);
}
void VideoAreaWidget::showVideo() {
- stackedLayout->setCurrentWidget(videoWidget);
+ if (videoWidget)
+ stackedLayout->setCurrentWidget(videoWidget);
loadingWidget->clear();
}
!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);
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));
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*)));
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) {
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*)));
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") {
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*)));
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*)));
if (thumbnailUrl.isEmpty()) return;
loadingThumbnail = true;
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
thumbnailUrl.replace(QLatin1String("https://"), QLatin1String("http://"));
#endif
}
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;
}