/** * @brief CLI::CLI * @param parent * @param arguments Command line arguments */ CLI::CLI(QObject *parent, QStringList arguments) : QObject(parent) { m_useFolderName = false; m_arguments = arguments; m_downloadManager = new DownloadManager(this); m_infosToLoad << MovieScraperInfos::Title << MovieScraperInfos::Tagline << MovieScraperInfos::Rating << MovieScraperInfos::Released << MovieScraperInfos::Runtime << MovieScraperInfos::Certification << MovieScraperInfos::Trailer << MovieScraperInfos::Overview << MovieScraperInfos::Poster << MovieScraperInfos::Backdrop << MovieScraperInfos::Actors << MovieScraperInfos::Genres << MovieScraperInfos::Studios << MovieScraperInfos::Countries; connect(m_downloadManager, SIGNAL(allDownloadsFinished()), this, SLOT(onDownloadsFinished())); connect(m_downloadManager, SIGNAL(downloadFinished(DownloadManagerElement)), this, SLOT(onDownloadFinished(DownloadManagerElement))); Manager::instance(); }
video::video() { handler = new http_handler; connect(handler, SIGNAL(allDownloadsFinished()), this, SLOT(handleDownloads())); connect(handler, SIGNAL(error(QString)), this, SLOT(networkError(QString))); _treeItem = NULL; }
video::video() { handler = new http_handler; connect(handler, SIGNAL(allDownloadsFinished()), this, SLOT(handleDownloads())); connect(handler, SIGNAL(error(QString)), this, SLOT(networkError(QString))); connect(this, SIGNAL(downloadFinished()), this, SLOT(startConvert())); _treeItem = NULL; _downloadPaused = false; _isRestarted = false; }
/** * \brief The constructor */ UBDockPalette::UBDockPalette(eUBDockPaletteType paletteType, QWidget *parent, const char *name) :QWidget(parent, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint) , mCurrentMode(eUBDockPaletteWidget_BOARD) , mOrientation(eUBDockOrientation_Left) , mPreferredWidth(100) , mPreferredHeight(100) , mCanResize(false) , mResized(false) , mCollapseWidth(150) , mLastWidth(-1) , mHTab(0) , mpStackWidget(NULL) , mpLayout(NULL) , mCurrentTab(0) , mPaletteType(paletteType) , mTabPalette(new UBTabDockPalette(this, parent)) { setObjectName(name); mpLayout = new QVBoxLayout(); setLayout(mpLayout); mpStackWidget = new QStackedWidget(this); mpLayout->addWidget(mpStackWidget); // clear the tab widgets mTabWidgets.clear(); // We let 2 pixels in order to keep a small border for the resizing setMinimumWidth(0); if (parent) { setAttribute(Qt::WA_NoMousePropagation); setAttribute(Qt::WA_TranslucentBackground); } else { // standalone window setAttribute(Qt::WA_TranslucentBackground); } mBackgroundBrush = QBrush(UBSettings::paletteColor); // This is the only way to set the background as transparent! setStyleSheet("QWidget {background-color: transparent}"); // Set the position of the tab onToolbarPosUpdated(); connect(UBSettings::settings()->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(onToolbarPosUpdated())); connect(UBDownloadManager::downloadManager(), SIGNAL(allDownloadsFinished()), this, SLOT(onAllDownloadsFinished())); connect(UBApplication::boardController,SIGNAL(documentSet(UBDocumentProxy*)),this,SLOT(onDocumentSet(UBDocumentProxy*))); }
/** * @brief Aborts and clears all downloads and sets a list of new downloads * @param elements List of elements to download * @see DownloadManagerElement */ void DownloadManager::setDownloads(QList<DownloadManagerElement> elements) { qDebug() << "Entered"; if (m_downloading) m_currentReply->abort(); m_timer.stop(); m_mutex.lock(); m_queue.clear(); m_mutex.unlock(); foreach (const DownloadManagerElement &elem, elements) addDownload(elem); if (m_queue.isEmpty()) QTimer::singleShot(0, this, SIGNAL(allDownloadsFinished())); }
void video::restart() { this->_isRestarted = true; this->_finished = false; this->_downloadPaused = false; this->_step = 0; this->cachedProgress.first = 0; this->cachedProgress.second = 0; handler->disconnect(this); this->handler->cancelAllDownloads(); connect(handler, SIGNAL(allDownloadsFinished()), this, SLOT(handleDownloads())); connect(handler, SIGNAL(error(QString)), this, SLOT(networkError(QString))); this->disconnect(SIGNAL(analysingFinished())); this->analyse(); }
/** * @brief Starts the next download */ void DownloadManager::startNextDownload() { m_timer.stop(); if (m_currentDownloadElement.movie) { int numDownloadsLeft = 0; for (int i=0, n=m_queue.size() ; i<n ; ++i) { if (m_queue[i].movie == m_currentDownloadElement.movie) numDownloadsLeft++; } if (numDownloadsLeft == 0) emit allDownloadsFinished(m_currentDownloadElement.movie); } if (m_currentDownloadElement.show) { int numDownloadsLeft = 0; for (int i=0, n=m_queue.size() ; i<n ; ++i) { if (m_queue[i].show == m_currentDownloadElement.show) numDownloadsLeft++; } if (numDownloadsLeft == 0) emit allDownloadsFinished(m_currentDownloadElement.show); } if (m_currentDownloadElement.concert) { int numDownloadsLeft = 0; for (int i=0, n=m_queue.size() ; i<n ; ++i) { if (m_queue[i].concert == m_currentDownloadElement.concert) numDownloadsLeft++; } if (numDownloadsLeft == 0) emit allDownloadsFinished(m_currentDownloadElement.concert); } if (m_queue.isEmpty()) { qDebug() << "All downloads finished"; emit allDownloadsFinished(); return; } m_timer.start(5000); m_downloading = true; m_mutex.lock(); m_currentDownloadElement = m_queue.dequeue(); m_mutex.unlock(); m_currentReply = qnam()->get(QNetworkRequest(m_currentDownloadElement.url)); connect(m_currentReply, SIGNAL(finished()), this, SLOT(downloadFinished())); connect(m_currentReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); if (m_currentDownloadElement.imageType == ImageType::Actor || m_currentDownloadElement.imageType == ImageType::TvShowEpisodeThumb) { if (m_currentDownloadElement.movie) { int numDownloadsLeft = 0; m_mutex.lock(); for (int i=0, n=m_queue.size() ; i<n ; ++i) { if (m_queue[i].movie == m_currentDownloadElement.movie) numDownloadsLeft++; } m_mutex.unlock(); emit downloadsLeft(numDownloadsLeft, m_currentDownloadElement); } else if (m_currentDownloadElement.show) { int numDownloadsLeft = 0; m_mutex.lock(); for (int i=0, n=m_queue.size() ; i<n ; ++i) { if (m_queue[i].show == m_currentDownloadElement.show) numDownloadsLeft++; } m_mutex.unlock(); emit downloadsLeft(numDownloadsLeft, m_currentDownloadElement); } else { emit downloadsLeft(m_queue.size()); } } }