Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/backends/FlatpakBackend/FlatpakBackend.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 66 | { | |||
---|---|---|---|---|---|
71 | 71 | | |||
72 | // Load flatpak installation | 72 | // Load flatpak installation | ||
73 | if (!setupFlatpakInstallations(&error)) { | 73 | if (!setupFlatpakInstallations(&error)) { | ||
74 | qWarning() << "Failed to setup flatpak installations: " << error->message; | 74 | qWarning() << "Failed to setup flatpak installations: " << error->message; | ||
75 | } else { | 75 | } else { | ||
76 | reloadPackageList(); | 76 | reloadPackageList(); | ||
77 | 77 | | |||
78 | checkForUpdates(); | 78 | checkForUpdates(); | ||
79 | | ||||
80 | m_sources = new FlatpakSourcesBackend(m_flatpakInstallationSystem, m_flatpakInstallationUser, this); | ||||
81 | SourcesModel::global()->addSourcesBackend(m_sources); | ||||
79 | } | 82 | } | ||
80 | 83 | | |||
81 | QAction* updateAction = new QAction(this); | 84 | QAction* updateAction = new QAction(this); | ||
82 | updateAction->setIcon(QIcon::fromTheme(QStringLiteral("system-software-update"))); | 85 | updateAction->setIcon(QIcon::fromTheme(QStringLiteral("system-software-update"))); | ||
83 | updateAction->setText(i18nc("@action Checks the Internet for updates", "Check for Updates")); | 86 | updateAction->setText(i18nc("@action Checks the Internet for updates", "Check for Updates")); | ||
84 | updateAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); | 87 | updateAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); | ||
85 | connect(updateAction, &QAction::triggered, this, &FlatpakBackend::checkForUpdates); | 88 | connect(updateAction, &QAction::triggered, this, &FlatpakBackend::checkForUpdates); | ||
86 | 89 | | |||
87 | m_messageActions = QList<QAction*>() << updateAction; | 90 | m_messageActions = QList<QAction*>() << updateAction; | ||
88 | 91 | | |||
89 | m_sources = new FlatpakSourcesBackend(m_flatpakInstallationSystem, m_flatpakInstallationUser, this); | | |||
90 | SourcesModel::global()->addSourcesBackend(m_sources); | | |||
91 | | ||||
92 | connect(m_reviews, &OdrsReviewsBackend::ratingsReady, this, &FlatpakBackend::announceRatingsReady); | 92 | connect(m_reviews, &OdrsReviewsBackend::ratingsReady, this, &FlatpakBackend::announceRatingsReady); | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | FlatpakBackend::~FlatpakBackend() | 95 | FlatpakBackend::~FlatpakBackend() | ||
96 | { | 96 | { | ||
97 | g_object_unref(m_flatpakInstallationSystem); | 97 | g_object_unref(m_flatpakInstallationSystem); | ||
98 | g_object_unref(m_flatpakInstallationUser); | 98 | g_object_unref(m_flatpakInstallationUser); | ||
99 | g_object_unref(m_cancellable); | 99 | g_object_unref(m_cancellable); | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | bool FlatpakBackend::isValid() const | ||||
103 | { | ||||
104 | return m_sources && m_flatpakInstallationUser && m_flatpakInstallationSystem; | ||||
105 | } | ||||
106 | | ||||
102 | void FlatpakBackend::announceRatingsReady() | 107 | void FlatpakBackend::announceRatingsReady() | ||
103 | { | 108 | { | ||
104 | emitRatingsReady(); | 109 | emitRatingsReady(); | ||
105 | 110 | | |||
106 | const auto ids = m_reviews->appstreamIds().toSet(); | 111 | const auto ids = m_reviews->appstreamIds().toSet(); | ||
107 | foreach(AbstractResource* res, m_resources) { | 112 | foreach(AbstractResource* res, m_resources) { | ||
108 | if (ids.contains(res->appstreamId())) { | 113 | if (ids.contains(res->appstreamId())) { | ||
109 | res->ratingFetched(); | 114 | res->ratingFetched(); | ||
▲ Show 20 Lines • Show All 982 Lines • Show Last 20 Lines |