Changeset View
Changeset View
Standalone View
Standalone View
src/kmoretools/kmoretools_p.h
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 65 | public: | |||
---|---|---|---|---|---|
77 | 77 | | |||
78 | bool isInstalled = true; | 78 | bool isInstalled = true; | ||
79 | 79 | | |||
80 | /** | 80 | /** | ||
81 | * only used if isInstalled == false | 81 | * only used if isInstalled == false | ||
82 | */ | 82 | */ | ||
83 | QUrl homepageUrl; | 83 | QUrl homepageUrl; | ||
84 | 84 | | |||
85 | QUrl appstreamUrl; | ||||
86 | | ||||
85 | public: | 87 | public: | ||
86 | void jsonRead(const QJsonObject &json) | 88 | void jsonRead(const QJsonObject &json) | ||
87 | { | 89 | { | ||
88 | id = json[_("id")].toString(); | 90 | id = json[_("id")].toString(); | ||
89 | menuSection = json[_("menuSection")].toString() == _("main") ? KMoreTools::MenuSection_Main : KMoreTools::MenuSection_More; | 91 | menuSection = json[_("menuSection")].toString() == _("main") ? KMoreTools::MenuSection_Main : KMoreTools::MenuSection_More; | ||
90 | isInstalled = json[_("isInstalled")].toBool(); | 92 | isInstalled = json[_("isInstalled")].toBool(); | ||
91 | } | 93 | } | ||
92 | 94 | | |||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Line(s) | |||||
370 | { | 372 | { | ||
371 | public: | 373 | public: | ||
372 | /** | 374 | /** | ||
373 | * For one given application/service which is named @p title a QMenu is | 375 | * For one given application/service which is named @p title a QMenu is | ||
374 | * created with the given @p icon and @p homepageUrl. | 376 | * created with the given @p icon and @p homepageUrl. | ||
375 | * It will be used as submenu for the menu that displays the not-installed | 377 | * It will be used as submenu for the menu that displays the not-installed | ||
376 | * services. | 378 | * services. | ||
377 | */ | 379 | */ | ||
378 | static QMenu* createSubmenuForNotInstalledApp(const QString& title, QWidget* parent, const QIcon& icon, const QUrl& homepageUrl) | 380 | static QMenu* createSubmenuForNotInstalledApp(const QString& title, QWidget* parent, const QIcon& icon, const QUrl& homepageUrl, const QUrl& appstreamUrl) | ||
379 | { | 381 | { | ||
380 | QMenu* submenuForNotInstalled = new QMenu(title, parent); | 382 | QMenu* submenuForNotInstalled = new QMenu(title, parent); | ||
381 | submenuForNotInstalled->setIcon(icon); | 383 | submenuForNotInstalled->setIcon(icon); | ||
382 | 384 | | |||
383 | if (homepageUrl.isValid()) { | 385 | if (homepageUrl.isValid()) { | ||
384 | auto websiteAction = submenuForNotInstalled->addAction(i18nc("@action:inmenu", "Visit homepage")); | 386 | auto websiteAction = submenuForNotInstalled->addAction(i18nc("@action:inmenu", "Visit homepage")); | ||
385 | auto url = homepageUrl; | 387 | auto url = homepageUrl; | ||
386 | // todo/review: is it ok to have sender and receiver the same object? | 388 | // todo/review: is it ok to have sender and receiver the same object? | ||
387 | QObject::connect(websiteAction, &QAction::triggered, websiteAction, [url](bool) { | 389 | QObject::connect(websiteAction, &QAction::triggered, websiteAction, [url](bool) { | ||
388 | QDesktopServices::openUrl(url); | 390 | QDesktopServices::openUrl(url); | ||
389 | }); | 391 | }); | ||
390 | } else { | 392 | } | ||
393 | | ||||
394 | if (appstreamUrl.isValid()) { | ||||
gregormi: What does the % sign do here? Can this be used to concatenate strings? Did not try it myself. | |||||
+ would give the same result. What % does is acting as a QStringBuilder, which is more performant in theory (not that it really matters in this case) nicolasfella: + would give the same result. What % does is acting as a QStringBuilder, which is more… | |||||
See http://doc.qt.io/qt-5/qstring.html#more-efficient-string-construction for a detailed explanation nicolasfella: See http://doc.qt.io/qt-5/qstring.html#more-efficient-string-construction for a detailed… | |||||
395 | auto installAction = submenuForNotInstalled->addAction(i18nc("@action:inmenu", "Install")); | ||||
396 | QObject::connect(installAction, &QAction::triggered, installAction, [appstreamUrl](bool) { | ||||
397 | QDesktopServices::openUrl(appstreamUrl); | ||||
398 | }); | ||||
399 | } | ||||
400 | | ||||
401 | if (!homepageUrl.isValid() && !appstreamUrl.isValid()) { | ||||
391 | submenuForNotInstalled->addAction(i18nc("@action:inmenu", "No further information available.")) | 402 | submenuForNotInstalled->addAction(i18nc("@action:inmenu", "No further information available.")) | ||
392 | ->setEnabled(false); | 403 | ->setEnabled(false); | ||
393 | } | 404 | } | ||
394 | 405 | | |||
395 | return submenuForNotInstalled; | 406 | return submenuForNotInstalled; | ||
396 | } | 407 | } | ||
397 | }; | 408 | }; | ||
398 | 409 | | |||
Show All 21 Lines |
What does the % sign do here? Can this be used to concatenate strings? Did not try it myself.
Otherwise ready to land.