void FFDemux::abort() { QMutexLocker mL(&mutex); for (FormatContext *fmtCtx : asConst(formatContexts)) fmtCtx->abort(); abortFetchTracks = true; }
void EditGroupWidget::apply() { m_temporaryGroup->setName(m_mainUi->editName->text()); m_temporaryGroup->setNotes(m_mainUi->editNotes->toPlainText()); m_temporaryGroup->setExpires(m_mainUi->expireCheck->isChecked()); m_temporaryGroup->setExpiryTime(m_mainUi->expireDatePicker->dateTime().toUTC()); m_temporaryGroup->setSearchingEnabled(triStateFromIndex(m_mainUi->searchComboBox->currentIndex())); m_temporaryGroup->setAutoTypeEnabled(triStateFromIndex(m_mainUi->autotypeComboBox->currentIndex())); if (m_mainUi->autoTypeSequenceInherit->isChecked()) { m_temporaryGroup->setDefaultAutoTypeSequence(QString()); } else { m_temporaryGroup->setDefaultAutoTypeSequence(m_mainUi->autoTypeSequenceCustomEdit->text()); } IconStruct iconStruct = m_editGroupWidgetIcons->state(); if (iconStruct.number < 0) { m_temporaryGroup->setIcon(Group::DefaultIconNumber); } else if (iconStruct.uuid.isNull()) { m_temporaryGroup->setIcon(iconStruct.number); } else { m_temporaryGroup->setIcon(iconStruct.uuid); } for (const ExtraPage& page : asConst(m_extraPages)) { page.assign(); } // Icons add/remove are applied globally outside the transaction! m_group->copyDataFrom(m_temporaryGroup.data()); setModified(false); }
~VTBHwaccel() { QMutexLocker locker(&m_buffersMutex); for (quintptr buffer : asConst(m_buffers)) CVPixelBufferRelease((CVPixelBufferRef)buffer); CVPixelBufferRelease(m_pixelBufferToRelease); }
void Module::setInstances(bool &restartPlaying) { QMutexLocker locker(&mutex); for (ModuleCommon *mc : asConst(instances)) if (!mc->set()) restartPlaying = true; }
void IPSubnetWhitelistOptionsDialog::on_buttonDeleteIPSubnet_clicked() { for (const auto &i : asConst(m_ui->whitelistedIPSubnetList->selectionModel()->selectedIndexes())) m_sortFilter->removeRow(i.row()); m_modified = true; }
void FeedListWidget::fill(QTreeWidgetItem *parent, RSS::Folder *rssParent) { for (const auto rssItem : asConst(rssParent->items())) { QTreeWidgetItem *item = createItem(rssItem, parent); // Recursive call if this is a folder. if (auto folder = qobject_cast<RSS::Folder *>(rssItem)) fill(item, folder); } }
void CategoryFilterWidget::removeUnusedCategories() { auto session = BitTorrent::Session::instance(); for (const QString &category : asConst(session->categories().keys())) { if (model()->data(static_cast<CategoryFilterProxyModel *>(model())->index(category), Qt::UserRole) == 0) session->removeCategory(category); } updateGeometry(); }
void LogListWidget::copySelection() { static const QRegularExpression htmlTag("<[^>]+>"); QStringList strings; for (QListWidgetItem* it : asConst(selectedItems())) strings << static_cast<QLabel*>(itemWidget(it))->text().remove(htmlTag); QApplication::clipboard()->setText(strings.join('\n')); }
void RSSWidget::on_markReadButton_clicked() { for (const auto index : asConst(m_rssTreeView->selectionModel()->selectedRows())) { RSS::Item *rssItem = getItemPtr(index); if (rssItem) { rssItem->markAsRead(); if (rssItem->id() == 0) break; // all items was read } } }
void RSSWidget::copySelectedFeedsURL() { QStringList URLs; for (const auto index : asConst(m_rssTreeView->selectionModel()->selectedRows())) { RSS::Item *rssItem = getItemPtr(index); if (auto *feed = qobject_cast<RSS::Feed *>(rssItem)) URLs << feed->url(); } qApp->clipboard()->setText(URLs.join('\n')); }
void TagFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent) { allTagsItem()->decreaseTorrentsCount(); if (torrent->tags().isEmpty()) untaggedItem()->decreaseTorrentsCount(); for (TagModelItem *item : asConst(findItems(torrent->tags()))) item->decreaseTorrentsCount(); }
void EntryModel::severConnections() { if (m_group) { disconnect(m_group, nullptr, this, nullptr); } for (const Group* group : asConst(m_allGroups)) { disconnect(group, nullptr, this, nullptr); } }
void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer<Database>& database) { m_group = group; m_db = database; m_temporaryGroup.reset(group->clone(Entry::CloneNoFlags, Group::CloneNoFlags)); connect(m_temporaryGroup->customData(), SIGNAL(customDataModified()), SLOT(setModified())); if (create) { setHeadline(tr("Add group")); } else { setHeadline(tr("Edit group")); } if (m_group->parentGroup()) { addTriStateItems(m_mainUi->searchComboBox, m_group->parentGroup()->resolveSearchingEnabled()); addTriStateItems(m_mainUi->autotypeComboBox, m_group->parentGroup()->resolveAutoTypeEnabled()); } else { addTriStateItems(m_mainUi->searchComboBox, true); addTriStateItems(m_mainUi->autotypeComboBox, true); } m_mainUi->editName->setText(m_group->name()); m_mainUi->editNotes->setPlainText(m_group->notes()); m_mainUi->expireCheck->setChecked(group->timeInfo().expires()); m_mainUi->expireDatePicker->setDateTime(group->timeInfo().expiryTime().toLocalTime()); m_mainUi->searchComboBox->setCurrentIndex(indexFromTriState(group->searchingEnabled())); m_mainUi->autotypeComboBox->setCurrentIndex(indexFromTriState(group->autoTypeEnabled())); if (group->defaultAutoTypeSequence().isEmpty()) { m_mainUi->autoTypeSequenceInherit->setChecked(true); } else { m_mainUi->autoTypeSequenceCustomRadio->setChecked(true); } m_mainUi->autoTypeSequenceCustomEdit->setText(group->effectiveAutoTypeSequence()); IconStruct iconStruct; iconStruct.uuid = m_temporaryGroup->iconUuid(); iconStruct.number = m_temporaryGroup->iconNumber(); m_editGroupWidgetIcons->load(m_temporaryGroup->uuid(), m_db, iconStruct); m_editWidgetProperties->setFields(m_temporaryGroup->timeInfo(), m_temporaryGroup->uuid()); m_editWidgetProperties->setCustomData(m_temporaryGroup->customData()); for (const ExtraPage& page : asConst(m_extraPages)) { page.set(m_temporaryGroup.data(), m_db); } setCurrentPage(0); m_mainUi->editName->setFocus(); // Force the user to Save/Discard new groups showApplyButton(!create); setModified(false); }
bool OpenGL2Writer::open() { static const QString platformName = QGuiApplication::platformName(); useRtt = platformName == "wayland" || platformName == "android" || forceRtt; if (useRtt) { //Don't use rtt when videoDock has native window const QWidget *videoDock = QMPlay2Core.getVideoDock(); useRtt = !videoDock->internalWinId() || (videoDock == videoDock->window()); } if (useRtt) drawable = new OpenGL2Widget; else drawable = new OpenGL2Window; drawable->hwAccellnterface = m_hwAccelInterface; #ifdef Q_OS_WIN drawable->preventFullScreen = preventFullScreen; #endif drawable->allowPBO = allowPBO; drawable->hqScaling = m_hqScaling; if (drawable->testGL()) { drawable->setVSync(vSync); bool hasBrightness = false, hasContrast = false, hasSharpness = false; if (!drawable->videoAdjustmentKeys.isEmpty()) { for (const QString &key : asConst(drawable->videoAdjustmentKeys)) { if (key == "Brightness") hasBrightness = true; else if (key == "Contrast") hasContrast = true; else if (key == "Sharpness") hasSharpness = true; addParam(key); } } else if (drawable->numPlanes > 1) { addParam("Saturation"); if (drawable->canUseHueSharpness) addParam("Hue"); } if (!hasBrightness) addParam("Brightness"); if (!hasContrast) addParam("Contrast"); if (!hasSharpness && drawable->canUseHueSharpness) addParam("Sharpness"); return true; } return false; }
void RSSWidget::refreshSelectedItems() { for (const auto index : asConst(m_rssTreeView->selectionModel()->selectedRows())) { RSS::Item *rssItem = getItemPtr(index); if (rssItem->id() == 0) { refreshAllFeeds(); return; } RSS::Manager::instance()->refreshItem(rssItem->id()); } }
QList<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const { QList<Utils::Net::Subnet> subnets; for (const QString &rawSubnet : asConst(value("Preferences/WebUI/AuthSubnetWhitelist").toStringList())) { bool ok = false; const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(rawSubnet.trimmed(), &ok); if (ok) subnets.append(subnet); } return subnets; }
void SearchController::categoriesAction() { QStringList categories; const QString name = params()["pluginName"].trimmed(); categories << SearchPluginManager::categoryFullName("all"); for (const QString &category : asConst(SearchPluginManager::instance()->getPluginCategories(name))) categories << SearchPluginManager::categoryFullName(category); const QJsonArray result = QJsonArray::fromStringList(categories); setResult(result); }
// The function returns the changed data from the server to synchronize with the web client. // Return value is map in JSON format. // Map contain the key: // - "Rid": ID response // Map can contain the keys: // - "full_update": full data update flag // - "torrents": dictionary contains information about torrents. // - "torrents_removed": a list of hashes of removed torrents // - "categories": map of categories info // - "categories_removed": list of removed categories // - "server_state": map contains information about the state of the server // The keys of the 'torrents' dictionary are hashes of torrents. // Each value of the 'torrents' dictionary contains map. The map can contain following keys: // - "name": Torrent name // - "size": Torrent size // - "progress": Torrent progress // - "dlspeed": Torrent download speed // - "upspeed": Torrent upload speed // - "priority": Torrent priority (-1 if queuing is disabled) // - "num_seeds": Torrent seeds connected to // - "num_complete": Torrent seeds in the swarm // - "num_leechs": Torrent leechers connected to // - "num_incomplete": Torrent leechers in the swarm // - "ratio": Torrent share ratio // - "eta": Torrent ETA // - "state": Torrent state // - "seq_dl": Torrent sequential download state // - "f_l_piece_prio": Torrent first last piece priority state // - "completion_on": Torrent copletion time // - "tracker": Torrent tracker // - "dl_limit": Torrent download limit // - "up_limit": Torrent upload limit // - "downloaded": Amount of data downloaded // - "uploaded": Amount of data uploaded // - "downloaded_session": Amount of data downloaded since program open // - "uploaded_session": Amount of data uploaded since program open // - "amount_left": Amount of data left to download // - "save_path": Torrent save path // - "completed": Amount of data completed // - "max_ratio": Upload max share ratio // - "max_seeding_time": Upload max seeding time // - "ratio_limit": Upload share ratio limit // - "seeding_time_limit": Upload seeding time limit // - "seen_complete": Indicates the time when the torrent was last seen complete/whole // - "last_activity": Last time when a chunk was downloaded/uploaded // - "total_size": Size including unwanted data // Server state map may contain the following keys: // - "connection_status": connection status // - "dht_nodes": DHT nodes count // - "dl_info_data": bytes downloaded // - "dl_info_speed": download speed // - "dl_rate_limit: download rate limit // - "up_info_data: bytes uploaded // - "up_info_speed: upload speed // - "up_rate_limit: upload speed limit // - "queueing": priority system usage flag // - "refresh_interval": torrents table refresh interval // - "free_space_on_disk": Free space on the default save path // GET param: // - rid (int): last response id void SyncController::maindataAction() { auto lastResponse = sessionManager()->session()->getData(QLatin1String("syncMainDataLastResponse")).toMap(); auto lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncMainDataLastAcceptedResponse")).toMap(); QVariantMap data; QVariantHash torrents; BitTorrent::Session *const session = BitTorrent::Session::instance(); for (BitTorrent::TorrentHandle *const torrent : asConst(session->torrents())) { QVariantMap map = serialize(*torrent); map.remove(KEY_TORRENT_HASH); // Calculated last activity time can differ from actual value by up to 10 seconds (this is a libtorrent issue). // So we don't need unnecessary updates of last activity time in response. if (lastResponse.contains("torrents") && lastResponse["torrents"].toHash().contains(torrent->hash()) && lastResponse["torrents"].toHash()[torrent->hash()].toMap().contains(KEY_TORRENT_LAST_ACTIVITY_TIME)) { uint lastValue = lastResponse["torrents"].toHash()[torrent->hash()].toMap()[KEY_TORRENT_LAST_ACTIVITY_TIME].toUInt(); if (qAbs(static_cast<int>(lastValue - map[KEY_TORRENT_LAST_ACTIVITY_TIME].toUInt())) < 15) map[KEY_TORRENT_LAST_ACTIVITY_TIME] = lastValue; } torrents[torrent->hash()] = map; } data["torrents"] = torrents; QVariantHash categories; const auto categoriesList = session->categories(); for (auto it = categoriesList.cbegin(); it != categoriesList.cend(); ++it) { const auto key = it.key(); categories[key] = QVariantMap { {"name", key}, {"savePath", it.value()} }; } data["categories"] = categories; QVariantMap serverState = getTranserInfo(); serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled(); serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = session->refreshInterval(); data["server_state"] = serverState; const int acceptedResponseId {params()["rid"].toInt()}; setResult(QJsonObject::fromVariantMap(generateSyncData(acceptedResponseId, data, lastAcceptedResponse, lastResponse))); sessionManager()->session()->setData(QLatin1String("syncMainDataLastResponse"), lastResponse); sessionManager()->session()->setData(QLatin1String("syncMainDataLastAcceptedResponse"), lastAcceptedResponse); }
void AutomatedRssDownloader::loadFeedList() { const QSignalBlocker feedListSignalBlocker(m_ui->listFeeds); for (const auto feed : asConst(RSS::Session::instance()->feeds())) { QListWidgetItem *item = new QListWidgetItem(feed->name(), m_ui->listFeeds); item->setData(Qt::UserRole, feed->url()); item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsTristate); } updateFeedList(); }
// open the url of the selected RSS articles in the Web browser void RSSWidget::openSelectedArticlesUrls() { for (const QModelIndex &index : asConst(m_articleListView->selectionModel()->selectedRows())) { RSS::Article *article = getArticlePtr(index); Q_ASSERT(article); // Mark as read article->markAsRead(); if (!article->link().isEmpty()) QDesktopServices::openUrl(QUrl(article->link())); } }
void ScanFoldersModel::makePersistent() { QVariantHash dirs; for (const PathData *pathData : asConst(m_pathList)) { if (pathData->downloadType == CUSTOM_LOCATION) dirs.insert(Utils::Fs::fromNativePath(pathData->watchPath), Utils::Fs::fromNativePath(pathData->downloadPath)); else dirs.insert(Utils::Fs::fromNativePath(pathData->watchPath), pathData->downloadType); } Preferences::instance()->setScanDirs(dirs); }
void StatsDialog::update() { const BitTorrent::SessionStatus &ss = BitTorrent::Session::instance()->status(); const BitTorrent::CacheStatus &cs = BitTorrent::Session::instance()->cacheStatus(); // All-time DL/UL quint64 atd = BitTorrent::Session::instance()->getAlltimeDL(); quint64 atu = BitTorrent::Session::instance()->getAlltimeUL(); m_ui->labelAlltimeDL->setText(Utils::Misc::friendlyUnit(atd)); m_ui->labelAlltimeUL->setText(Utils::Misc::friendlyUnit(atu)); // Total waste (this session) m_ui->labelWaste->setText(Utils::Misc::friendlyUnit(ss.totalWasted)); // Global ratio m_ui->labelGlobalRatio->setText( ((atd > 0) && (atu > 0)) ? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2) : "-"); // Cache hits qreal readRatio = cs.readRatio; m_ui->labelCacheHits->setText(QString("%1%").arg( readRatio > 0 ? Utils::String::fromDouble(100 * readRatio, 2) : "0")); // Buffers size m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024)); // Disk overload (100%) equivalent // From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read // to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are. // num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake) quint32 peers = 0; for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents())) peers += torrent->peersCount(); m_ui->labelWriteStarve->setText(QString("%1%") .arg(((ss.diskWriteQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * ss.diskWriteQueue) / peers, 2) : "0")); m_ui->labelReadStarve->setText(QString("%1%") .arg(((ss.diskReadQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * ss.diskReadQueue) / peers, 2) : "0")); // Disk queues m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength)); m_ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime)); m_ui->labelQueuedBytes->setText(Utils::Misc::friendlyUnit(cs.queuedBytes)); // Total connected peers m_ui->labelPeers->setText(QString::number(ss.peersCount)); }
void AutomatedRssDownloader::updateMatchingArticles() { m_ui->treeMatchingArticles->clear(); for (const QListWidgetItem *ruleItem : asConst(m_ui->listRules->selectedItems())) { RSS::AutoDownloadRule rule = (ruleItem == m_currentRuleItem ? m_currentRule : RSS::AutoDownloader::instance()->ruleByName(ruleItem->text())); for (const QString &feedURL : asConst(rule.feedURLs())) { auto feed = RSS::Session::instance()->feedByURL(feedURL); if (!feed) continue; // feed doesn't exist QStringList matchingArticles; for (const auto article : asConst(feed->articles())) if (rule.matches(article->data())) matchingArticles << article->title(); if (!matchingArticles.isEmpty()) addFeedArticlesToTree(feed, matchingArticles); } } m_treeListEntries.clear(); }
void AutomatedRssDownloader::updateMustNotLineValidity() { const QString text = m_ui->lineNotContains->text(); bool isRegex = m_ui->checkRegex->isChecked(); bool valid = true; QString error; if (!text.isEmpty()) { QStringList tokens; if (isRegex) tokens << text; else for (const QString &token : asConst(text.split('|'))) tokens << Utils::String::wildcardToRegex(token); for (const QString &token : asConst(tokens)) { QRegularExpression reg(token, QRegularExpression::CaseInsensitiveOption); if (!reg.isValid()) { if (isRegex) error = tr("Position %1: %2").arg(reg.patternErrorOffset()).arg(reg.errorString()); valid = false; break; } } } if (valid) { m_ui->lineNotContains->setStyleSheet(""); m_ui->labelMustNotStat->setPixmap(QPixmap()); m_ui->labelMustNotStat->setToolTip(""); } else { m_ui->lineNotContains->setStyleSheet("QLineEdit { color: #ff0000; }"); m_ui->labelMustNotStat->setPixmap(GuiIconProvider::instance()->getIcon("task-attention").pixmap(16, 16)); m_ui->labelMustNotStat->setToolTip(error); } }
void CookiesDialog::onButtonDeleteClicked() { QModelIndexList idxs = m_ui->treeView->selectionModel()->selectedRows(); // sort in descending order std::sort(idxs.begin(), idxs.end(), [](const QModelIndex &l, const QModelIndex &r) { return (l.row() > r.row()); } ); for (const QModelIndex &idx : asConst(idxs)) m_cookiesModel->removeRow(idx.row()); }
void EntryModel::setEntryList(const QList<Entry*>& entries) { beginResetModel(); severConnections(); m_group = nullptr; m_allGroups.clear(); m_entries = entries; m_orgEntries = entries; QSet<Database*> databases; for (Entry* entry : asConst(m_entries)) { databases.insert(entry->group()->database()); } for (Database* db : asConst(databases)) { Q_ASSERT(db); const QList<Group*> groupList = db->rootGroup()->groupsRecursive(true); for (const Group* group : groupList) { m_allGroups.append(group); } if (db->metadata()->recycleBin()) { m_allGroups.removeOne(db->metadata()->recycleBin()); } } for (const Group* group : asConst(m_allGroups)) { makeConnections(group); } endResetModel(); Q_EMIT switchedToEntryListMode(); }
void SearchController::checkForUpdatesFinished(const QHash<QString, PluginVersion> &updateInfo) { if (updateInfo.isEmpty()) { LogMsg(tr("All plugins are already up to date."), Log::INFO); return; } LogMsg(tr("Updating %1 plugins").arg(updateInfo.size()), Log::INFO); SearchPluginManager *const pluginManager = SearchPluginManager::instance(); for (const QString &pluginName : asConst(updateInfo.keys())) { LogMsg(tr("Updating plugin %1").arg(pluginName), Log::INFO); pluginManager->updatePlugin(pluginName); } }
bool FFDemux::seek(double pos, bool backward) { bool seeked = false; for (FormatContext *fmtCtx : asConst(formatContexts)) { if (fmtCtx->seek(pos, backward)) seeked |= true; else if (fmtCtx->isStreamed && formatContexts.count() > 1) { fmtCtx->setStreamOffset(pos); seeked |= true; } } return seeked; }
void DeintSettingsW::writeSettings() { Settings &QMPSettings = QMPlay2Core.getSettings(); QMPSettings.set("Deinterlace/ON", isChecked()); QMPSettings.set("Deinterlace/Auto", autoDeintB->isChecked()); QMPSettings.set("Deinterlace/Doubler", doublerB->isChecked()); QMPSettings.set("Deinterlace/AutoParity", autoParityB->isChecked()); QMPSettings.set("Deinterlace/SoftwareMethod", softwareMethodsCB->currentText()); QMPSettings.set("Deinterlace/TFF", (bool)parityCB->currentIndex()); QSet<Module *> videoDeintModules; for (QObject *obj : children()) if (obj->isWidgetType() && !obj->property("module").isNull()) videoDeintModules.insert((Module *)obj->property("module").value<void *>()); for (Module *module : asConst(videoDeintModules)) module->videoDeintSave(); }
void FeedListWidget::dropEvent(QDropEvent *event) { QTreeWidgetItem *destFolderItem = itemAt(event->pos()); RSS::Folder *destFolder = (destFolderItem ? static_cast<RSS::Folder *>(getRSSItem(destFolderItem)) : RSS::Session::instance()->rootFolder()); // move as much items as possible for (QTreeWidgetItem *srcItem : asConst(selectedItems())) { auto rssItem = getRSSItem(srcItem); RSS::Session::instance()->moveItem(rssItem, RSS::Item::joinPath(destFolder->path(), rssItem->name())); } QTreeWidget::dropEvent(event); if (destFolderItem) destFolderItem->setExpanded(true); }