Changeset View
Standalone View
src/widgets/kpropertiesdialog.cpp
Context not available. | |||||
1106 | sizelay->addWidget(d->m_sizeDetermineButton, 0); | 1106 | sizelay->addWidget(d->m_sizeDetermineButton, 0); | ||
---|---|---|---|---|---|
1107 | sizelay->addWidget(d->m_sizeStopButton, 0); | 1107 | sizelay->addWidget(d->m_sizeStopButton, 0); | ||
1108 | 1108 | | |||
1109 | if (!QStandardPaths::findExecutable(QStringLiteral("filelight")).isEmpty()) { | 1109 | KService::Ptr serv = KService::serviceByDesktopName(QStringLiteral("org.kde.filelight")); | ||
ngraham: prefer descriptive variable names; "service" is better than "serv" | |||||
1110 | | ||||
1111 | if (serv) { | ||||
1110 | d->m_sizeDetailsButton = new QPushButton(i18n("Explore in Filelight"), d->m_frame); | 1112 | d->m_sizeDetailsButton = new QPushButton(i18n("Explore in Filelight"), d->m_frame); | ||
1111 | d->m_sizeDetailsButton->setIcon(QIcon::fromTheme(QStringLiteral("filelight"))); | 1113 | d->m_sizeDetailsButton->setIcon(QIcon::fromTheme(QStringLiteral("filelight"))); | ||
broulik: You can also use the icon from the service | |||||
shubham: I tried removing it, but I couldn't see the icon on the button then. | |||||
Does this not work? d->m_sizeDetailsButton->setIcon(QIcon::fromTheme(service->icon()); broulik: Does this not work?
```
d->m_sizeDetailsButton->setIcon(QIcon::fromTheme(service->icon());
``` | |||||
1112 | connect(d->m_sizeDetailsButton, &QPushButton::clicked, this, &KFilePropsPlugin::slotSizeDetails); | 1114 | connect(d->m_sizeDetailsButton, &QPushButton::clicked, this, &KFilePropsPlugin::slotSizeDetails); | ||
We don't need to reparse desktop file on every click just make it connect(d->m_sizeDetailsButton, &QPushButton::clicked, this, [this, service]() { KRun::runApplication(*service, { properties->url() }, properties->window()); }); anthonyfieroni: We don't need to reparse desktop file on every click just make it
```
connect(d… | |||||
broulik: Not sure copying that pointer into the lambda is a good idea? | |||||
service is a QExplicitlySharedDataPointer<KService> in fact, I guess it covers lambda use cases. meven: service is a QExplicitlySharedDataPointer<KService> in fact, I guess it covers lambda use cases. | |||||
OK, it can be a problem since we can have many objects of KFilePropsPlugin thus lambda will extend service ptr life to the process end, which can result in memory leak (it's not leak) But since it's a plugin we don't expect a tons of objects, but i'm fine to make service a class scope var to not outlive the plugin. anthonyfieroni: OK, it can be a problem since we can have many objects of KFilePropsPlugin thus lambda will… | |||||
I'm pretty sure that isn't true. KFilePropsPlugin are the tabs inside the properties dialog. They get instantiated for each dialog and destroyed when the dialog is destroyed. They are not persistent throughout the life time of the process. sitter: I'm pretty sure that isn't true.
KFilePropsPlugin are the tabs inside the properties dialog. | |||||
@shubham reimplement slotSizeDetails with KService::serviceByDesktopName(QStringLiteral("org.kde.filelight")); + Krun::runApplication meven: @shubham reimplement slotSizeDetails with `KService::serviceByDesktopName(QStringLiteral("org. | |||||
Context not available. | |||||
1450 | void KFilePropsPlugin::slotSizeDetails() | 1452 | void KFilePropsPlugin::slotSizeDetails() | ||
1451 | { | 1453 | { | ||
1452 | // Open the current folder in filelight | 1454 | // Open the current folder in filelight | ||
1453 | KRun::run((QStandardPaths::findExecutable(QStringLiteral("filelight"))), { properties->url() }, properties->window(), QStringLiteral("Filelight"), QStringLiteral("filelight")); | 1455 | KService::Ptr serv = KService::serviceByDesktopName(QStringLiteral("org.kde.filelight")); | ||
anthonyfieroni: service can be nullptr, add a check | |||||
shubham: This slot is called from a check at line 1111, so not required | |||||
1456 | KRun::runApplication(*serv, { properties->url() }, properties->window()); | ||||
1454 | } | 1457 | } | ||
anthonyfieroni: Remove | |||||
1455 | 1458 | | |||
1456 | KFilePropsPlugin::~KFilePropsPlugin() | 1459 | KFilePropsPlugin::~KFilePropsPlugin() | ||
Context not available. |
prefer descriptive variable names; "service" is better than "serv"