Commit 1d81fe73 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Tweak formatting after clang-format run

parent 1e0a7d4c
......@@ -511,10 +511,11 @@ void DiscoverObject::showPassiveNotification(const QString &msg)
void DiscoverObject::reboot()
{
QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall(QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("/LogoutPrompt"),
QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("promptReboot")));
auto method = QDBusMessage::createMethodCall(QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("/LogoutPrompt"),
QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("promptReboot"));
QDBusConnection::sessionBus().asyncCall(method);
}
QRect DiscoverObject::initialGeometry() const
......
......@@ -26,20 +26,20 @@
typedef QHash<QString, DiscoverObject::CompactMode> StringCompactMode;
Q_GLOBAL_STATIC_WITH_ARGS(StringCompactMode,
s_decodeCompactMode,
(StringCompactMode{{QLatin1String("auto"), DiscoverObject::Auto},
{QLatin1String("compact"), DiscoverObject::Compact},
{QLatin1String("full"), DiscoverObject::Full}}))
(StringCompactMode{
{QLatin1String("auto"), DiscoverObject::Auto},
{QLatin1String("compact"), DiscoverObject::Compact},
{QLatin1String("full"), DiscoverObject::Full},
}))
QCommandLineParser *createParser()
{
// clang-format off
QCommandLineParser *parser = new QCommandLineParser;
parser->addOption(
QCommandLineOption(QStringLiteral("application"), i18n("Directly open the specified application by its appstream:// URI."), QStringLiteral("name")));
parser->addOption(
QCommandLineOption(QStringLiteral("mime"), i18n("Open with a search for programs that can deal with the given mimetype."), QStringLiteral("name")));
parser->addOption(QCommandLineOption(QStringLiteral("application"), i18n("Directly open the specified application by its appstream:// URI."), QStringLiteral("name")));
parser->addOption(QCommandLineOption(QStringLiteral("mime"), i18n("Open with a search for programs that can deal with the given mimetype."), QStringLiteral("name")));
parser->addOption(QCommandLineOption(QStringLiteral("category"), i18n("Display a list of entries with a category."), QStringLiteral("name")));
parser->addOption(
QCommandLineOption(QStringLiteral("mode"), i18n("Open Discover in a said mode. Modes correspond to the toolbar buttons."), QStringLiteral("name")));
parser->addOption(QCommandLineOption(QStringLiteral("mode"), i18n("Open Discover in a said mode. Modes correspond to the toolbar buttons."), QStringLiteral("name")));
parser->addOption(QCommandLineOption(QStringLiteral("listmodes"), i18n("List all the available modes.")));
parser->addOption(QCommandLineOption(QStringLiteral("compact"), i18n("Compact Mode (auto/compact/full)."), QStringLiteral("mode"), QStringLiteral("auto")));
parser->addOption(QCommandLineOption(QStringLiteral("local-filename"), i18n("Local package file to install"), QStringLiteral("package")));
......@@ -48,6 +48,7 @@ QCommandLineParser *createParser()
parser->addOption(QCommandLineOption(QStringLiteral("feedback"), i18n("Lists the available options for user feedback")));
parser->addOption(QCommandLineOption(QStringLiteral("test"), QStringLiteral("Test file"), QStringLiteral("file.qml")));
parser->addPositionalArgument(QStringLiteral("urls"), i18n("Supports appstream: url scheme"));
// clang-format on
DiscoverBackendsFactory::setupCommandLine(parser);
KAboutData::applicationData().setupCommandLine(parser);
return parser;
......@@ -142,25 +143,23 @@ int main(int argc, char **argv)
mainWindow = new DiscoverObject(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverObject::Full), initialProperties);
}
QObject::connect(&app, &QCoreApplication::aboutToQuit, mainWindow, &DiscoverObject::deleteLater);
QObject::connect(service,
&KDBusService::activateRequested,
mainWindow,
[mainWindow](const QStringList &arguments, const QString & /*workingDirectory*/) {
if (!mainWindow->rootObject())
QCoreApplication::instance()->quit();
auto window = qobject_cast<QWindow *>(mainWindow->rootObject());
if (window && QX11Info::isPlatformX11()) {
KStartupInfo::setNewStartupId(window, QX11Info::nextStartupId());
}
window->raise();
if (arguments.isEmpty())
return;
QScopedPointer<QCommandLineParser> parser(createParser());
parser->parse(arguments);
processArgs(parser.data(), mainWindow);
});
auto onActivateRequested = [mainWindow](const QStringList &arguments, const QString & /*workingDirectory*/) {
if (!mainWindow->rootObject())
QCoreApplication::instance()->quit();
auto window = qobject_cast<QWindow *>(mainWindow->rootObject());
if (window && QX11Info::isPlatformX11()) {
KStartupInfo::setNewStartupId(window, QX11Info::nextStartupId());
}
window->raise();
if (arguments.isEmpty())
return;
QScopedPointer<QCommandLineParser> parser(createParser());
parser->parse(arguments);
processArgs(parser.data(), mainWindow);
};
QObject::connect(service, &KDBusService::activateRequested, mainWindow, onActivateRequested);
processArgs(parser.data(), mainWindow);
......
......@@ -113,8 +113,9 @@ void DiscoverBackendsFactory::setupCommandLine(QCommandLineParser *parser)
void DiscoverBackendsFactory::processCommandLine(QCommandLineParser *parser, bool test)
{
QStringList backends =
test ? QStringList{QStringLiteral("dummy-backend")} : parser->value(QStringLiteral("backends")).split(QLatin1Char(','), Qt::SkipEmptyParts);
QStringList backends = test //
? QStringList{QStringLiteral("dummy-backend")} //
: parser->value(QStringLiteral("backends")).split(QLatin1Char(','), Qt::SkipEmptyParts);
for (auto &backend : backends) {
if (!backend.endsWith(QLatin1String("-backend")))
backend.append(QLatin1String("-backend"));
......
......@@ -92,7 +92,13 @@ Rating::Rating(const QString &packageName, quint64 ratingCount, int data[6])
: m_packageName(packageName)
, m_ratingCount(ratingCount)
// TODO consider storing data[] and present in UI
, m_rating(((data[1] + (data[2] * 2) + (data[3] * 3) + (data[4] * 4) + (data[5] * 5)) * 2) / qMax<float>(1, ratingCount))
, m_rating(((data[1] //
+ (data[2] * 2) //
+ (data[3] * 3) //
+ (data[4] * 4) //
+ (data[5] * 5)) //
* 2)
/ qMax<float>(1, ratingCount))
, m_ratingPoints(0)
, m_sortableRating(0)
{
......
......@@ -109,12 +109,14 @@ void OdrsReviewsBackend::fetchReviews(AbstractResource *app, int page)
Q_UNUSED(page)
m_isFetching = true;
const QJsonDocument document(QJsonObject{{QStringLiteral("app_id"), app->appstreamId()},
{QStringLiteral("distro"), osName()},
{QStringLiteral("user_hash"), userHash()},
{QStringLiteral("version"), app->isInstalled() ? app->installedVersion() : app->availableVersion()},
{QStringLiteral("locale"), QLocale::system().name()},
{QStringLiteral("limit"), -1}});
const QJsonDocument document(QJsonObject{
{QStringLiteral("app_id"), app->appstreamId()},
{QStringLiteral("distro"), osName()},
{QStringLiteral("user_hash"), userHash()},
{QStringLiteral("version"), app->isInstalled() ? app->installedVersion() : app->availableVersion()},
{QStringLiteral("locale"), QLocale::system().name()},
{QStringLiteral("limit"), -1},
});
const auto json = document.toJson(QJsonDocument::Compact);
QNetworkRequest request(QUrl(QStringLiteral(APIURL "/fetch")));
......@@ -162,7 +164,7 @@ void OdrsReviewsBackend::submitUsefulness(Review *review, bool useful)
{QStringLiteral("user_skey"), review->getMetadata(QStringLiteral("ODRS::user_skey")).toString()},
{QStringLiteral("user_hash"), userHash()},
{QStringLiteral("distro"), osName()},
{QStringLiteral("review_id"), QJsonValue(double(review->id()))} // if we really need uint64 we should get it in QJsonValue
{QStringLiteral("review_id"), QJsonValue(double(review->id()))}, // if we really need uint64 we should get it in QJsonValue
});
QNetworkRequest request(QUrl(QStringLiteral(APIURL) + (useful ? QLatin1String("/upvote") : QLatin1String("/downvote"))));
......
......@@ -22,10 +22,12 @@ public:
{
return false;
}
bool hasUpdates() override
{
return false;
}
bool needsReboot() const override
{
return false;
......
......@@ -63,8 +63,9 @@ QDebug operator<<(QDebug debug, const FlatpakResource::Id &id)
static FlatpakResource::Id idForInstalledRef(FlatpakInstallation *installation, FlatpakInstalledRef *ref, const QString &postfix)
{
const FlatpakResource::ResourceType appType =
flatpak_ref_get_kind(FLATPAK_REF(ref)) == FLATPAK_REF_KIND_APP ? FlatpakResource::DesktopApp : FlatpakResource::Runtime;
const FlatpakResource::ResourceType appType = (flatpak_ref_get_kind(FLATPAK_REF(ref)) == FLATPAK_REF_KIND_APP //
? FlatpakResource::DesktopApp
: FlatpakResource::Runtime);
const QString appId = QLatin1String(flatpak_ref_get_name(FLATPAK_REF(ref))) + postfix;
const QString arch = QString::fromUtf8(flatpak_ref_get_arch(FLATPAK_REF(ref)));
const QString branch = QString::fromUtf8(flatpak_ref_get_branch(FLATPAK_REF(ref)));
......@@ -151,8 +152,8 @@ public:
return;
}
const QUrl fileUrl =
QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QLatin1Char('/') + originalUrl.fileName());
const QUrl fileUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation) //
+ QLatin1Char('/') + originalUrl.fileName());
auto replyPut = put(QNetworkRequest(fileUrl), replyGet->readAll());
connect(replyPut, &QNetworkReply::finished, this, [this, originalUrl, fileUrl, replyPut]() {
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> replyPtr(replyPut);
......@@ -1173,10 +1174,12 @@ int FlatpakBackend::updatesCount() const
bool FlatpakBackend::flatpakResourceLessThan(AbstractResource *l, AbstractResource *r) const
{
// clang-format off
return (l->isInstalled() != r->isInstalled()) ? l->isInstalled()
: (l->origin() != r->origin()) ? m_sources->originIndex(l->origin()) < m_sources->originIndex(r->origin())
: (l->rating() && r->rating() && l->rating()->ratingPoints() != r->rating()->ratingPoints()) ? l->rating()->ratingPoints() > r->rating()->ratingPoints()
: l < r;
: (l->origin() != r->origin()) ? m_sources->originIndex(l->origin()) < m_sources->originIndex(r->origin())
: (l->rating() && r->rating() && l->rating()->ratingPoints() != r->rating()->ratingPoints()) ? l->rating()->ratingPoints() > r->rating()->ratingPoints()
: l < r; : l < r);
// clang-format on
}
ResultsStream *FlatpakBackend::search(const AbstractResourcesBackend::Filters &filter)
......@@ -1321,8 +1324,8 @@ Transaction *FlatpakBackend::installApplication(AbstractResource *app, const Add
m_refreshAppstreamMetadataJobs++;
// Make sure we update appstream metadata first
// FIXME we have to let flatpak to return the remote as the one created by FlatpakSourcesBackend will not have appstream directory
refreshAppstreamMetadata(preferredInstallation(),
flatpak_installation_get_remote_by_name(preferredInstallation(), flatpak_remote_get_name(remote), nullptr, nullptr));
auto repo = flatpak_installation_get_remote_by_name(preferredInstallation(), flatpak_remote_get_name(remote), nullptr, nullptr);
refreshAppstreamMetadata(preferredInstallation(), repo);
}
return nullptr;
}
......
......@@ -63,8 +63,13 @@ public:
bool operator==(const Id &other) const
{
return &other == this
|| (other.installation == installation && other.origin == origin && other.type == type && other.id == id && other.branch == branch
&& other.arch == arch);
|| (other.installation == installation //
&& other.origin == origin //
&& other.type == type //
&& other.id == id //
&& other.branch == branch //
&& other.arch == arch //
);
}
};
......
......@@ -28,10 +28,12 @@ public:
: QStandardItem(text)
{
}
void setFlatpakInstallation(FlatpakInstallation *installation)
{
m_installation = installation;
}
FlatpakInstallation *flatpakInstallation() const
{
return m_installation;
......
......@@ -105,8 +105,11 @@ void FlatpakTransactionThread::run()
}
correct = flatpak_transaction_add_install_bundle(m_transaction, file, nullptr, &localError);
} else {
correct =
flatpak_transaction_add_install(m_transaction, m_app->origin().toUtf8().constData(), refName.toUtf8().constData(), nullptr, &localError);
correct = flatpak_transaction_add_install(m_transaction, //
m_app->origin().toUtf8().constData(),
refName.toUtf8().constData(),
nullptr,
&localError);
}
}
......
......@@ -84,26 +84,32 @@ public:
{
return m_id;
}
QString deviceId() const
{
return m_deviceID;
}
QUrl updateURI() const
{
return QUrl(m_updateURI);
}
bool isDeviceLocked() const
{
return m_isDeviceLocked;
}
bool isOnlyOffline() const
{
return m_isOnlyOffline;
}
bool isLiveUpdatable() const
{
return m_isLiveUpdatable;
}
bool needsReboot() const
{
return m_needsReboot;
......
......@@ -35,10 +35,10 @@ public:
if (value == Qt::Checked) {
m_backend->m_currentItem = item;
if (fwupd_remote_get_approval_required(remote)) {
Q_EMIT m_backend->proceedRequest(i18n("Review EULA"),
i18n("The remote %1 require that you accept their license:\n %2",
QString::fromUtf8(fwupd_remote_get_title(remote)),
QString::fromUtf8(fwupd_remote_get_agreement(remote))));
QString eulaText = i18n("The remote %1 require that you accept their license:\n %2",
QString::fromUtf8(fwupd_remote_get_title(remote)),
QString::fromUtf8(fwupd_remote_get_agreement(remote));
Q_EMIT m_backend->proceedRequest(i18n("Review EULA"), eulaText));
} else {
m_backend->proceed();
}
......
......@@ -175,8 +175,13 @@ KNSBackend::KNSBackend(QObject *parent, const QString &iconName, const QString &
if (m_hasApplications) {
auto actualCategory = new Category(m_displayName, QStringLiteral("applications-other"), filters, backendName, topCategories, QUrl(), false);
auto applicationCategory =
new Category(i18n("Applications"), QStringLiteral("applications-internet"), filters, backendName, {actualCategory}, QUrl(), false);
auto applicationCategory = new Category(i18n("Applications"), //
QStringLiteral("applications-internet"),
filters,
backendName,
{actualCategory},
QUrl(),
false);
applicationCategory->setAndFilter({{CategoryFilter, QLatin1String("Application")}});
m_categories.append(applicationCategory->name());
m_rootCategories = {applicationCategory};
......
......@@ -558,8 +558,10 @@ PKResultsStream *PackageKitBackend::findResourceByPackageName(const QUrl &url)
if (url.isLocalFile()) {
QMimeDatabase db;
const auto mime = db.mimeTypeForUrl(url);
if (mime.inherits(QStringLiteral("application/vnd.debian.binary-package")) || mime.inherits(QStringLiteral("application/x-rpm"))
|| mime.inherits(QStringLiteral("application/x-tar")) || mime.inherits(QStringLiteral("application/x-zstd-compressed-tar"))
if (mime.inherits(QStringLiteral("application/vnd.debian.binary-package")) //
|| mime.inherits(QStringLiteral("application/x-rpm")) //
|| mime.inherits(QStringLiteral("application/x-tar")) //
|| mime.inherits(QStringLiteral("application/x-zstd-compressed-tar")) //
|| mime.inherits(QStringLiteral("application/x-xz-compressed-tar"))) {
return new PKResultsStream(this, QStringLiteral("PackageKitStream-localpkg"), {new LocalFilePKResource(url, this)});
}
......
......@@ -43,8 +43,10 @@ public Q_SLOTS:
if (req->error() == QSnapdRequest::NoError) {
const auto auth = req->authData();
replyData = QJsonDocument(QJsonObject{{QStringLiteral("macaroon"), auth->macaroon()},
{QStringLiteral("discharges"), QJsonArray::fromStringList(auth->discharges())}})
replyData = QJsonDocument(QJsonObject{
{QStringLiteral("macaroon"), auth->macaroon()},
{QStringLiteral("discharges"), QJsonArray::fromStringList(auth->discharges())},
})
.toJson();
reply = ActionReply::SuccessReply();
......@@ -53,7 +55,10 @@ public Q_SLOTS:
reply = ActionReply::InvalidActionReply();
reply.setErrorDescription(req->errorString());
}
reply.setData({{QStringLiteral("reply"), replyData}, {QStringLiteral("otpMode"), otpMode}});
reply.setData({
{QStringLiteral("reply"), replyData},
{QStringLiteral("otpMode"), otpMode},
});
return reply;
}
};
......
......@@ -39,7 +39,11 @@ public:
{
KAuth::Action snapAction(QStringLiteral("org.kde.discover.libsnapclient.login"));
snapAction.setHelperId(QStringLiteral("org.kde.discover.libsnapclient"));
snapAction.setArguments({{QStringLiteral("user"), username}, {QStringLiteral("password"), password}, {QStringLiteral("otp"), otp}});
snapAction.setArguments({
{QStringLiteral("user"), username},
{QStringLiteral("password"), password},
{QStringLiteral("otp"), otp},
});
Q_ASSERT(snapAction.isValid());
KAuth::ExecuteJob *reply = snapAction.execute();
......
......@@ -27,6 +27,7 @@ public:
{
return m_name;
}
QString description() const
{
return m_description;
......
......@@ -51,6 +51,7 @@ public:
{
return false;
}
virtual bool canMoveSources() const
{
return false;
......@@ -64,6 +65,7 @@ public Q_SLOTS:
virtual void cancel()
{
}
virtual void proceed()
{
}
......
......@@ -36,18 +36,22 @@ public:
{
return m_isVisible;
}
bool isEnabled() const
{
return m_isEnabled;
}
QString text() const
{
return m_text;
}
QString toolTip() const
{
return m_toolTip;
}
QIcon icon() const
{
return m_icon;
......
......@@ -238,10 +238,11 @@ void DiscoverNotifier::showRebootNotification()
void DiscoverNotifier::reboot()
{
QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall(QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("/LogoutPrompt"),
QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("promptReboot")));
auto method = QDBusMessage::createMethodCall(QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("/LogoutPrompt"),
QStringLiteral("org.kde.LogoutPrompt"),
QStringLiteral("promptReboot"));
QDBusConnection::sessionBus().asyncCall(method);
}
void DiscoverNotifier::foundUpgradeAction(UpgradeAction *action)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment