mirror of https://github.com/KDE/kasts.git
Refactor to use QNetworkInformation instead of SolidExtras for Qt6
SolidExtras will still be used for the Qt5 version for the time being. This refactoring makes it trivial to rip out SolidExtras once the jump to Qt6-only will be made.
This commit is contained in:
parent
eac74ecbbb
commit
0c54ab7edf
|
@ -58,9 +58,17 @@ endif()
|
|||
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Sql Svg Xml)
|
||||
find_package(KF${KF_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS I18n CoreAddons Kirigami2 Syndication Config ThreadWeaver)
|
||||
|
||||
if (QT_MAJOR_VERSION EQUAL "6")
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Network)
|
||||
else()
|
||||
find_package(KF${KF_MAJOR_VERSION} ${KF_MIN_VERSION} OPTIONAL_COMPONENTS NetworkManagerQt)
|
||||
endif()
|
||||
|
||||
if (NOT KF_MAJOR_VERSION EQUAL "6") # TODO temporary workaround until kirigami-addons is switched to KF6
|
||||
find_package(KF5KirigamiAddons 0.7 REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(Taglib REQUIRED)
|
||||
find_package(Qt${QT_MAJOR_VERSION}Keychain)
|
||||
set_package_properties(Qt${QT_MAJOR_VERSION}Keychain PROPERTIES
|
||||
|
@ -68,8 +76,6 @@ set_package_properties(Qt${QT_MAJOR_VERSION}Keychain PROPERTIES
|
|||
PURPOSE "Secure storage of account secrets"
|
||||
)
|
||||
|
||||
find_package(KF${KF_MAJOR_VERSION} ${KF_MIN_VERSION} OPTIONAL_COMPONENTS NetworkManagerQt)
|
||||
|
||||
if (ANDROID)
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Svg)
|
||||
if (QT_MAJOR_VERSION EQUAL "5")
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
add_subdirectory(kmediasession)
|
||||
if (NOT QT_MAJOR_VERSION EQUAL "6")
|
||||
add_subdirectory(solidextras)
|
||||
endif()
|
||||
|
||||
set(kasts_srcs
|
||||
main.cpp
|
||||
|
@ -23,6 +25,7 @@ set(kasts_srcs
|
|||
updatefeedjob.cpp
|
||||
fetchfeedsjob.cpp
|
||||
systrayicon.cpp
|
||||
networkconnectionmanager.cpp
|
||||
models/abstractepisodemodel.cpp
|
||||
models/abstractepisodeproxymodel.cpp
|
||||
models/chaptermodel.cpp
|
||||
|
@ -131,6 +134,13 @@ ecm_qt_declare_logging_category(kasts_srcs
|
|||
DEFAULT_SEVERITY Info
|
||||
)
|
||||
|
||||
ecm_qt_declare_logging_category(kasts_srcs
|
||||
HEADER "networkconnectionmanagerlogging.h"
|
||||
IDENTIFIER "kastsNetworkConnectionManager"
|
||||
CATEGORY_NAME "org.kde.kasts.networkconnectionmanager"
|
||||
DEFAULT_SEVERITY Info
|
||||
)
|
||||
|
||||
if(ANDROID)
|
||||
list(APPEND kasts_srcs
|
||||
androidlogging.h)
|
||||
|
@ -161,7 +171,13 @@ add_executable(kasts ${kasts_srcs})
|
|||
kconfig_add_kcfg_files(kasts settingsmanager.kcfgc GENERATE_MOC)
|
||||
|
||||
target_include_directories(kasts PRIVATE ${CMAKE_BINARY_DIR})
|
||||
target_link_libraries(kasts PRIVATE Qt::Core Qt::Qml Qt::Quick Qt::QuickControls2 Qt::Sql Qt::Svg Qt::Xml KF${KF_MAJOR_VERSION}::Kirigami2 KF${KF_MAJOR_VERSION}::Syndication KF${KF_MAJOR_VERSION}::CoreAddons KF${KF_MAJOR_VERSION}::ConfigGui KF${KF_MAJOR_VERSION}::I18n Taglib::Taglib KastsSolidExtras ${QTKEYCHAIN_LIBRARIES} KF${KF_MAJOR_VERSION}::ThreadWeaver KMediaSession)
|
||||
target_link_libraries(kasts PRIVATE Qt::Core Qt::Qml Qt::Quick Qt::QuickControls2 Qt::Sql Qt::Svg Qt::Xml KF${KF_MAJOR_VERSION}::Kirigami2 KF${KF_MAJOR_VERSION}::Syndication KF${KF_MAJOR_VERSION}::CoreAddons KF${KF_MAJOR_VERSION}::ConfigGui KF${KF_MAJOR_VERSION}::I18n Taglib::Taglib ${QTKEYCHAIN_LIBRARIES} KF${KF_MAJOR_VERSION}::ThreadWeaver KMediaSession)
|
||||
|
||||
if (QT_MAJOR_VERSION EQUAL "6")
|
||||
target_link_libraries(kasts PRIVATE Qt6::Network)
|
||||
else ()
|
||||
target_link_libraries(kasts PRIVATE KastsSolidExtras)
|
||||
endif()
|
||||
|
||||
if(KASTS_FLATPAK)
|
||||
target_compile_definitions(kasts PUBLIC KASTS_FLATPAK)
|
||||
|
|
|
@ -19,15 +19,12 @@
|
|||
#include "feed.h"
|
||||
#include "fetcher.h"
|
||||
#include "models/errorlogmodel.h"
|
||||
#include "networkconnectionmanager.h"
|
||||
#include "settingsmanager.h"
|
||||
|
||||
#include <solidextras/networkstatus.h>
|
||||
|
||||
class AudioManagerPrivate
|
||||
{
|
||||
private:
|
||||
SolidExtras::NetworkStatus m_networkStatus;
|
||||
|
||||
KMediaSession m_player = KMediaSession(QStringLiteral("kasts"), QStringLiteral("org.kde.kasts"));
|
||||
|
||||
Entry *m_entry = nullptr;
|
||||
|
@ -298,9 +295,7 @@ void AudioManager::setEntry(Entry *entry)
|
|||
|
||||
// do some checks on the new entry to see whether it's valid and not corrupted
|
||||
if (entry != nullptr && entry->hasEnclosure() && entry->enclosure()
|
||||
&& (entry->enclosure()->status() == Enclosure::Downloaded
|
||||
|| (d->m_networkStatus.connectivity() != SolidExtras::NetworkStatus::No
|
||||
&& (d->m_networkStatus.metered() != SolidExtras::NetworkStatus::Yes || SettingsManager::self()->allowMeteredStreaming())))) {
|
||||
&& (entry->enclosure()->status() == Enclosure::Downloaded || NetworkConnectionManager::instance().streamingAllowed())) {
|
||||
qCDebug(kastsAudio) << "Going to change source";
|
||||
|
||||
setEntryInfo(entry);
|
||||
|
@ -394,8 +389,7 @@ void AudioManager::play()
|
|||
// if we're streaming, check that we're still connected and check for metered
|
||||
// connection
|
||||
if (isStreaming()) {
|
||||
if (d->m_networkStatus.connectivity() == SolidExtras::NetworkStatus::No
|
||||
|| (d->m_networkStatus.metered() != SolidExtras::NetworkStatus::No && !SettingsManager::self()->allowMeteredStreaming())) {
|
||||
if (!NetworkConnectionManager::instance().streamingAllowed()) {
|
||||
qCDebug(kastsAudio) << "Refusing to play: no connection or streaming on metered connection not allowed";
|
||||
Q_EMIT logError(Error::Type::MeteredStreamingNotAllowed,
|
||||
d->m_entry->feed()->url(),
|
||||
|
@ -496,9 +490,7 @@ bool AudioManager::canGoNext() const
|
|||
if (next_entry->enclosure()->status() == Enclosure::Downloaded) {
|
||||
return true;
|
||||
} else {
|
||||
SolidExtras::NetworkStatus networkStatus;
|
||||
if (networkStatus.connectivity() == SolidExtras::NetworkStatus::Yes
|
||||
&& (networkStatus.metered() == SolidExtras::NetworkStatus::No || SettingsManager::self()->allowMeteredStreaming())) {
|
||||
if (NetworkConnectionManager::instance().streamingAllowed()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
#include "fetcher.h"
|
||||
#include "models/downloadmodel.h"
|
||||
#include "models/errorlogmodel.h"
|
||||
#include "networkconnectionmanager.h"
|
||||
#include "settingsmanager.h"
|
||||
#include "storagemanager.h"
|
||||
#include "sync/sync.h"
|
||||
|
||||
#include <solidextras/networkstatus.h>
|
||||
|
||||
Enclosure::Enclosure(Entry *entry)
|
||||
: QObject(entry)
|
||||
, m_entry(entry)
|
||||
|
@ -156,7 +155,7 @@ void Enclosure::download()
|
|||
return;
|
||||
}
|
||||
|
||||
if (SolidExtras::NetworkStatus().metered() == SolidExtras::NetworkStatus::Yes && !SettingsManager::self()->allowMeteredEpisodeDownloads()) {
|
||||
if (!NetworkConnectionManager::instance().episodeDownloadsAllowed()) {
|
||||
Q_EMIT downloadError(Error::Type::MeteredNotAllowed,
|
||||
m_entry->feed()->url(),
|
||||
m_entry->id(),
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
#include "fetchfeedsjob.h"
|
||||
#include "kasts-version.h"
|
||||
#include "models/errorlogmodel.h"
|
||||
#include "networkconnectionmanager.h"
|
||||
#include "settingsmanager.h"
|
||||
#include "storagemanager.h"
|
||||
#include "sync/sync.h"
|
||||
|
||||
#include <solidextras/networkstatus.h>
|
||||
|
||||
Fetcher::Fetcher()
|
||||
{
|
||||
connect(this, &Fetcher::error, &ErrorLogModel::instance(), &ErrorLogModel::monitorErrorMessages);
|
||||
|
@ -130,9 +129,7 @@ QString Fetcher::image(const QString &url)
|
|||
|
||||
// if image has not yet been cached, then check for network connectivity if
|
||||
// possible; and download the image
|
||||
SolidExtras::NetworkStatus networkStatus;
|
||||
if (networkStatus.connectivity() == SolidExtras::NetworkStatus::No
|
||||
|| (networkStatus.metered() == SolidExtras::NetworkStatus::Yes && !SettingsManager::self()->allowMeteredImageDownloads())) {
|
||||
if (!NetworkConnectionManager::instance().imageDownloadsAllowed()) {
|
||||
return QLatin1String("no-image");
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "models/feedsproxymodel.h"
|
||||
#include "models/podcastsearchmodel.h"
|
||||
#include "models/queuemodel.h"
|
||||
#include "networkconnectionmanager.h"
|
||||
#include "settingsmanager.h"
|
||||
#include "storagemanager.h"
|
||||
#include "sync/sync.h"
|
||||
|
@ -152,6 +153,7 @@ int main(int argc, char *argv[])
|
|||
return engine->toScriptValue(KAboutData::applicationData());
|
||||
});
|
||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "Database", &Database::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "NetworkConnectionManager", &NetworkConnectionManager::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "Fetcher", &Fetcher::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "DataManager", &DataManager::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "SettingsManager", SettingsManager::self());
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#include "networkconnectionmanager.h"
|
||||
#include "networkconnectionmanagerlogging.h"
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QNetworkInformation>
|
||||
#endif
|
||||
|
||||
#include "settingsmanager.h"
|
||||
|
||||
NetworkConnectionManager::NetworkConnectionManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
, m_networkStatus(SolidExtras::NetworkStatus())
|
||||
#endif
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
m_backendAvailable = QNetworkInformation::loadDefaultBackend();
|
||||
|
||||
if (m_backendAvailable) {
|
||||
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, [this]() {
|
||||
Q_EMIT feedUpdatesAllowedChanged();
|
||||
Q_EMIT episodeDownloadsAllowedChanged();
|
||||
Q_EMIT imageDownloadsAllowedChanged();
|
||||
Q_EMIT streamingAllowedChanged();
|
||||
});
|
||||
connect(QNetworkInformation::instance(), &QNetworkInformation::isMeteredChanged, this, [this]() {
|
||||
Q_EMIT feedUpdatesAllowedChanged();
|
||||
Q_EMIT episodeDownloadsAllowedChanged();
|
||||
Q_EMIT imageDownloadsAllowedChanged();
|
||||
Q_EMIT streamingAllowedChanged();
|
||||
});
|
||||
}
|
||||
#else
|
||||
connect(&m_networkStatus, &SolidExtras::NetworkStatus::connectivityChanged, this, [this]() {
|
||||
Q_EMIT feedUpdatesAllowedChanged();
|
||||
Q_EMIT episodeDownloadsAllowedChanged();
|
||||
Q_EMIT imageDownloadsAllowedChanged();
|
||||
Q_EMIT streamingAllowedChanged();
|
||||
});
|
||||
connect(&m_networkStatus, &SolidExtras::NetworkStatus::meteredChanged, this, [this]() {
|
||||
Q_EMIT feedUpdatesAllowedChanged();
|
||||
Q_EMIT episodeDownloadsAllowedChanged();
|
||||
Q_EMIT imageDownloadsAllowedChanged();
|
||||
Q_EMIT streamingAllowedChanged();
|
||||
});
|
||||
#endif
|
||||
|
||||
connect(SettingsManager::self(), &SettingsManager::allowMeteredFeedUpdatesChanged, this, &NetworkConnectionManager::feedUpdatesAllowedChanged);
|
||||
connect(SettingsManager::self(), &SettingsManager::allowMeteredEpisodeDownloadsChanged, this, &NetworkConnectionManager::episodeDownloadsAllowedChanged);
|
||||
connect(SettingsManager::self(), &SettingsManager::allowMeteredImageDownloadsChanged, this, &NetworkConnectionManager::imageDownloadsAllowedChanged);
|
||||
connect(SettingsManager::self(), &SettingsManager::allowMeteredStreamingChanged, this, &NetworkConnectionManager::streamingAllowedChanged);
|
||||
}
|
||||
|
||||
bool NetworkConnectionManager::feedUpdatesAllowed() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool allowed = true;
|
||||
if (m_backendAvailable) {
|
||||
allowed = (QNetworkInformation::instance()->reachability() != QNetworkInformation::Reachability::Disconnected
|
||||
&& (!QNetworkInformation::instance()->isMetered() || SettingsManager::self()->allowMeteredFeedUpdates()));
|
||||
}
|
||||
#else
|
||||
bool allowed = (m_networkStatus.connectivity() != SolidExtras::NetworkStatus::No
|
||||
&& (m_networkStatus.metered() != SolidExtras::NetworkStatus::Yes || SettingsManager::self()->allowMeteredFeedUpdates()));
|
||||
#endif
|
||||
|
||||
qCDebug(kastsNetworkConnectionManager) << "FeedUpdatesAllowed()" << allowed;
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
bool NetworkConnectionManager::episodeDownloadsAllowed() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool allowed = true;
|
||||
if (m_backendAvailable) {
|
||||
allowed = (QNetworkInformation::instance()->reachability() != QNetworkInformation::Reachability::Disconnected
|
||||
&& (!QNetworkInformation::instance()->isMetered() || SettingsManager::self()->allowMeteredEpisodeDownloads()));
|
||||
}
|
||||
#else
|
||||
bool allowed = (m_networkStatus.connectivity() != SolidExtras::NetworkStatus::No
|
||||
&& (m_networkStatus.metered() != SolidExtras::NetworkStatus::Yes || SettingsManager::self()->allowMeteredEpisodeDownloads()));
|
||||
#endif
|
||||
|
||||
qCDebug(kastsNetworkConnectionManager) << "EpisodeDownloadsAllowed()" << allowed;
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
bool NetworkConnectionManager::imageDownloadsAllowed() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool allowed = true;
|
||||
if (m_backendAvailable) {
|
||||
allowed = (QNetworkInformation::instance()->reachability() != QNetworkInformation::Reachability::Disconnected
|
||||
&& (!QNetworkInformation::instance()->isMetered() || SettingsManager::self()->allowMeteredImageDownloads()));
|
||||
}
|
||||
#else
|
||||
bool allowed = (m_networkStatus.connectivity() != SolidExtras::NetworkStatus::No
|
||||
&& (m_networkStatus.metered() != SolidExtras::NetworkStatus::Yes || SettingsManager::self()->allowMeteredImageDownloads()));
|
||||
#endif
|
||||
|
||||
qCDebug(kastsNetworkConnectionManager) << "ImageDownloadsAllowed()" << allowed;
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
bool NetworkConnectionManager::streamingAllowed() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool allowed = true;
|
||||
if (m_backendAvailable) {
|
||||
allowed = (QNetworkInformation::instance()->reachability() != QNetworkInformation::Reachability::Disconnected
|
||||
&& (!QNetworkInformation::instance()->isMetered() || SettingsManager::self()->allowMeteredStreaming()));
|
||||
}
|
||||
#else
|
||||
bool allowed = (m_networkStatus.connectivity() != SolidExtras::NetworkStatus::No
|
||||
&& (m_networkStatus.metered() != SolidExtras::NetworkStatus::Yes || SettingsManager::self()->allowMeteredStreaming()));
|
||||
#endif
|
||||
|
||||
qCDebug(kastsNetworkConnectionManager) << "StreamingAllowed()" << allowed;
|
||||
|
||||
return allowed;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <solidextras/networkstatus.h>
|
||||
#endif
|
||||
|
||||
class NetworkConnectionManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool feedUpdatesAllowed READ feedUpdatesAllowed NOTIFY feedUpdatesAllowedChanged)
|
||||
Q_PROPERTY(bool episodeDownloadsAllowed READ episodeDownloadsAllowed NOTIFY episodeDownloadsAllowedChanged)
|
||||
Q_PROPERTY(bool imageDownloadsAllowed READ imageDownloadsAllowed NOTIFY imageDownloadsAllowedChanged)
|
||||
Q_PROPERTY(bool streamingAllowed READ streamingAllowed NOTIFY streamingAllowedChanged)
|
||||
|
||||
public:
|
||||
static NetworkConnectionManager &instance()
|
||||
{
|
||||
static NetworkConnectionManager _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool feedUpdatesAllowed() const;
|
||||
[[nodiscard]] bool episodeDownloadsAllowed() const;
|
||||
[[nodiscard]] bool imageDownloadsAllowed() const;
|
||||
[[nodiscard]] bool streamingAllowed() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void feedUpdatesAllowedChanged();
|
||||
void episodeDownloadsAllowedChanged();
|
||||
void imageDownloadsAllowedChanged();
|
||||
void streamingAllowedChanged();
|
||||
|
||||
private:
|
||||
NetworkConnectionManager(QObject *parent = nullptr);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
SolidExtras::NetworkStatus m_networkStatus;
|
||||
#else
|
||||
bool m_backendAvailable = false;
|
||||
#endif
|
||||
};
|
|
@ -9,7 +9,6 @@ import QtQuick.Controls 2.14 as Controls
|
|||
import QtQuick.Layouts 1.14
|
||||
|
||||
import org.kde.kirigami 2.14 as Kirigami
|
||||
import org.kde.kasts.solidextras 1.0
|
||||
import org.kde.kmediasession 1.0
|
||||
|
||||
import org.kde.kasts 1.0
|
||||
|
@ -21,8 +20,7 @@ Kirigami.BasicListItem {
|
|||
property var entry: undefined
|
||||
property var overlay: undefined
|
||||
|
||||
property bool streamingAllowed: (NetworkStatus.connectivity !== NetworkStatus.No && (SettingsManager.allowMeteredStreaming || NetworkStatus.metered !== NetworkStatus.Yes))
|
||||
property bool streamingButtonVisible: entry != undefined && entry.enclosure && (entry.enclosure.status !== Enclosure.Downloaded) && streamingAllowed && (SettingsManager.prioritizeStreaming || AudioManager.entry === entry)
|
||||
property bool streamingButtonVisible: entry != undefined && entry.enclosure && (entry.enclosure.status !== Enclosure.Downloaded) && NetworkConnectionManager.streamingAllowed && (SettingsManager.prioritizeStreaming || AudioManager.entry === entry)
|
||||
|
||||
text: model.title
|
||||
subtitle: model.formattedStart
|
||||
|
|
|
@ -9,7 +9,6 @@ import QtQuick.Controls 2.14 as Controls
|
|||
import QtQuick.Layouts 1.14
|
||||
|
||||
import org.kde.kirigami 2.19 as Kirigami
|
||||
import org.kde.kasts.solidextras 1.0
|
||||
|
||||
import org.kde.kasts 1.0
|
||||
|
||||
|
@ -19,7 +18,7 @@ Kirigami.Dialog {
|
|||
closePolicy: Kirigami.Dialog.CloseOnEscape | Kirigami.Dialog.CloseOnPressOutside
|
||||
|
||||
property string headingText: i18n("Podcast updates are currently not allowed on metered connections")
|
||||
property bool condition: SettingsManager.allowMeteredFeedUpdates
|
||||
property bool condition: NetworkConnectionManager.feedUpdatesAllowed
|
||||
|
||||
// Function to be overloaded where this is instantiated with another purpose
|
||||
// than refreshing all feeds
|
||||
|
@ -45,7 +44,7 @@ Kirigami.Dialog {
|
|||
// this is the function that should be called if the action should be
|
||||
// triggered conditionally (on the basis that the condition is passed)
|
||||
function run() {
|
||||
if (NetworkStatus.metered !== NetworkStatus.Yes || condition) {
|
||||
if (condition) {
|
||||
action();
|
||||
} else {
|
||||
overlay.open();
|
||||
|
|
|
@ -152,7 +152,7 @@ Kirigami.ScrollablePage {
|
|||
},
|
||||
Kirigami.Action {
|
||||
text: i18nc("@action:intoolbar Action to start playback by streaming the episode rather than downloading it first", "Stream")
|
||||
visible: entry.enclosure && entry.enclosure.status !== Enclosure.Downloaded && (AudioManager.entry !== entry || AudioManager.playbackState !== KMediaSession.PlayingState)
|
||||
visible: entry.enclosure && entry.enclosure.status !== Enclosure.Downloaded && NetworkConnectionManager.streamingAllowed && (AudioManager.entry !== entry || AudioManager.playbackState !== KMediaSession.PlayingState)
|
||||
icon.name: "media-playback-cloud"
|
||||
onTriggered: {
|
||||
if (!entry.queueStatus) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import QtGraphicalEffects 1.15
|
|||
import QtQml.Models 2.15
|
||||
|
||||
import org.kde.kirigami 2.14 as Kirigami
|
||||
import org.kde.kasts.solidextras 1.0
|
||||
import org.kde.kmediasession 1.0
|
||||
|
||||
import org.kde.kasts 1.0
|
||||
|
@ -32,15 +31,13 @@ Kirigami.SwipeListItem {
|
|||
property bool selected: false
|
||||
property int row: model ? model.row : -1
|
||||
|
||||
property bool streamingAllowed: (NetworkStatus.connectivity !== NetworkStatus.No && SettingsManager.prioritizeStreaming && (SettingsManager.allowMeteredStreaming || NetworkStatus.metered !== NetworkStatus.Yes))
|
||||
|
||||
property bool showRemoveFromQueueButton: entry ? (!entry.enclosure && entry.queueStatus) : false
|
||||
property bool showDownloadButton: entry ? ((!isDownloads || entry.enclosure.status === Enclosure.PartiallyDownloaded) && entry.enclosure && (entry.enclosure.status === Enclosure.Downloadable || entry.enclosure.status === Enclosure.PartiallyDownloaded) && (!streamingAllowed || isDownloads) && !(AudioManager.entry === entry && AudioManager.playbackState === KMediaSession.PlayingState)) : false
|
||||
property bool showDownloadButton: entry ? ((!isDownloads || entry.enclosure.status === Enclosure.PartiallyDownloaded) && entry.enclosure && (entry.enclosure.status === Enclosure.Downloadable || entry.enclosure.status === Enclosure.PartiallyDownloaded) && (!NetworkConnectionManager.streamingAllowed || isDownloads) && !(AudioManager.entry === entry && AudioManager.playbackState === KMediaSession.PlayingState)) : false
|
||||
property bool showCancelDownloadButton: entry ? (entry.enclosure && entry.enclosure.status === Enclosure.Downloading) : false
|
||||
property bool showDeleteDownloadButton: entry ? (isDownloads && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded) : false
|
||||
property bool showAddToQueueButton: entry ? (!isDownloads && !entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded) : false
|
||||
property bool showPlayButton: entry ? (!isDownloads && entry.queueStatus && entry.enclosure && (entry.enclosure.status === Enclosure.Downloaded) && (AudioManager.entry !== entry || AudioManager.playbackState !== KMediaSession.PlayingState)) : false
|
||||
property bool showStreamingPlayButton: entry ? (!isDownloads && entry.enclosure && (entry.enclosure.status !== Enclosure.Downloaded && entry.enclosure.status !== Enclosure.Downloading && streamingAllowed) && (AudioManager.entry !== entry || AudioManager.playbackState !== KMediaSession.PlayingState)) : false
|
||||
property bool showStreamingPlayButton: entry ? (!isDownloads && entry.enclosure && (entry.enclosure.status !== Enclosure.Downloaded && entry.enclosure.status !== Enclosure.Downloading && NetworkConnectionManager.streamingAllowed) && (AudioManager.entry !== entry || AudioManager.playbackState !== KMediaSession.PlayingState)) : false
|
||||
property bool showPauseButton: entry ? (!isDownloads && entry.queueStatus && entry.enclosure && (AudioManager.entry === entry && AudioManager.playbackState === KMediaSession.PlayingState)) : false
|
||||
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ ListView {
|
|||
}
|
||||
Controls.MenuItem {
|
||||
action: listView.streamAction
|
||||
visible: singleSelectedEntry ? (singleSelectedEntry.hasEnclosure ? singleSelectedEntry.enclosure.status !== Enclosure.Downloaded : false) : false
|
||||
visible: singleSelectedEntry ? (singleSelectedEntry.hasEnclosure ? (singleSelectedEntry.enclosure.status !== Enclosure.Downloaded && NetworkConnectionManager.streamingAllowed) : false) : false
|
||||
height: visible ? implicitHeight : 0 // workaround for qqc2-breeze-style
|
||||
}
|
||||
onClosed: {
|
||||
|
|
|
@ -12,7 +12,6 @@ import QtGraphicalEffects 1.12
|
|||
import Qt.labs.settings 1.0
|
||||
|
||||
import org.kde.kirigami 2.20 as Kirigami
|
||||
import org.kde.kasts.solidextras 1.0
|
||||
|
||||
import org.kde.kasts 1.0
|
||||
|
||||
|
@ -124,7 +123,7 @@ Kirigami.ApplicationWindow {
|
|||
// Refresh feeds on startup if allowed
|
||||
// NOTE: refresh+sync on startup is handled in Sync and not here, since it
|
||||
// requires credentials to be loaded before starting a refresh+sync
|
||||
if (NetworkStatus.connectivity != NetworkStatus.No && (SettingsManager.allowMeteredFeedUpdates || NetworkStatus.metered !== NetworkStatus.Yes)) {
|
||||
if (NetworkConnectionManager.feedUpdatesAllowed) {
|
||||
if (SettingsManager.refreshOnStartup && !(SettingsManager.syncEnabled && SettingsManager.syncWhenUpdatingFeeds)) {
|
||||
Fetcher.fetchAll();
|
||||
}
|
||||
|
@ -429,7 +428,7 @@ Kirigami.ApplicationWindow {
|
|||
id: downloadOverlay
|
||||
|
||||
headingText: i18n("Podcast downloads are currently not allowed on metered connections")
|
||||
condition: SettingsManager.allowMeteredEpisodeDownloads
|
||||
condition: NetworkConnectionManager.episodeDownloadsAllowed
|
||||
property var entry: undefined
|
||||
property var selection: undefined
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "fetcher.h"
|
||||
#include "fetchfeedsjob.h"
|
||||
#include "models/errorlogmodel.h"
|
||||
#include "networkconnectionmanager.h"
|
||||
#include "settingsmanager.h"
|
||||
#include "storagemanager.h"
|
||||
#include "sync/gpodder/devicerequest.h"
|
||||
|
@ -48,8 +49,6 @@
|
|||
#include "sync/syncjob.h"
|
||||
#include "sync/syncutils.h"
|
||||
|
||||
#include <solidextras/networkstatus.h>
|
||||
|
||||
using namespace SyncUtils;
|
||||
|
||||
Sync::Sync()
|
||||
|
@ -101,9 +100,7 @@ void Sync::retrieveCredentialsFromConfig()
|
|||
// Now that we have all credentials we can do the initial sync if
|
||||
// it's enabled in the config. If it's not enabled, then we handle
|
||||
// the automatic refresh through main.qml
|
||||
SolidExtras::NetworkStatus networkStatus;
|
||||
if (networkStatus.connectivity() != SolidExtras::NetworkStatus::No
|
||||
&& (networkStatus.metered() != SolidExtras::NetworkStatus::Yes || SettingsManager::self()->allowMeteredFeedUpdates())) {
|
||||
if (NetworkConnectionManager::instance().feedUpdatesAllowed()) {
|
||||
if (SettingsManager::self()->refreshOnStartup() && SettingsManager::self()->syncWhenUpdatingFeeds()) {
|
||||
doRegularSync(true);
|
||||
}
|
||||
|
@ -814,9 +811,7 @@ void Sync::doQuickSync()
|
|||
|
||||
// since this method is supposed to be called automatically, we cannot check
|
||||
// the network state from the UI, so we have to do it here
|
||||
SolidExtras::NetworkStatus networkStatus;
|
||||
if (networkStatus.connectivity() == SolidExtras::NetworkStatus::No
|
||||
|| (networkStatus.metered() == SolidExtras::NetworkStatus::Yes && !SettingsManager::self()->allowMeteredFeedUpdates())) {
|
||||
if (!NetworkConnectionManager::instance().feedUpdatesAllowed()) {
|
||||
qCDebug(kastsSync) << "Not uploading episode actions on metered connection due to settings";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include "sync/sync.h"
|
||||
#include "sync/syncutils.h"
|
||||
|
||||
#include <solidextras/networkstatus.h>
|
||||
|
||||
using namespace SyncUtils;
|
||||
|
||||
SyncJob::SyncJob(SyncStatus syncStatus, GPodder *gpodder, const QString &device, bool forceFetchAll, QObject *parent)
|
||||
|
|
Loading…
Reference in New Issue