Add button to open the folder in filelight to view more details
AbandonedPublic

Authored by shubham on Oct 24 2019, 6:01 PM.

Details

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
shubham created this revision.Oct 24 2019, 6:01 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald TranscriptOct 24 2019, 6:01 PM
shubham requested review of this revision.Oct 24 2019, 6:01 PM
shubham edited the summary of this revision. (Show Details)Oct 24 2019, 6:04 PM
ngraham requested changes to this revision.Oct 24 2019, 7:25 PM
ngraham added inline comments.
src/widgets/kpropertiesdialog.cpp
446

We're trying to port our software away from using foreach and Q_FOREACH; not back to them! :) Don't change these.

745

All of this logic is unnecessary; instead use https://doc.qt.io/qt-5/qstandardpaths.html#findExecutable

1101

Maybe "Explore in Filelight?" or "See usage with Filelight" If the user isn't familiar with what Filelight is, it might be unclear what you would want to open a folder in it.

1458

Use KRun to launch it, not QProcess

This revision now requires changes to proceed.Oct 24 2019, 7:25 PM
shubham updated this revision to Diff 68759.Oct 25 2019, 4:12 PM
shubham marked 3 inline comments as done.
shubham marked an inline comment as done.

Much better, thanks.

src/widgets/kpropertiesdialog.cpp
1100

isEmpty() is preferred over comparing to QString()

1103

This is a QPushButton, so connect to &QPushButton::clicked

shubham added inline comments.Oct 26 2019, 3:41 AM
src/widgets/kpropertiesdialog.cpp
1103

It is done this way a bit below in line 1106

ngraham requested changes to this revision.Oct 26 2019, 6:33 PM

It doesn't compile:

/home/nate/kde/src/kio/src/widgets/kpropertiesdialog.cpp:1389:72: error: ‘QString::QString(const char*)’ is private within this context
 1389 |     KRun::runCommand(QStringLiteral("filelight"), directory, nullptr, QStringLiteral("/"));
      |                                                                        ^

Anyway, should use KRun::runApplication() for this since that's made for launching GUI apps and handling arguments passed to the binary.

This revision now requires changes to proceed.Oct 26 2019, 6:33 PM

@ngraham How should I create a KService for runApplication?

Copy some other code that's already doing it this way I guess. For example, in plasma: https://cgit.kde.org/plasma-workspace.git/tree/libtaskmanager/tasktools.cpp#n767

If you don't already know about it, let me introduce you to the magic of LXR: https://lxr.kde.org/ident?_i=runApplication

shubham updated this revision to Diff 72254.EditedDec 27 2019, 4:02 PM
shubham marked 2 inline comments as done.
shubham edited the summary of this revision. (Show Details)

Fix above mentioned issues, now works perfectly fine
@ngraham Ping?

shubham edited the summary of this revision. (Show Details)Dec 27 2019, 4:05 PM
shubham edited the test plan for this revision. (Show Details)
shubham edited the summary of this revision. (Show Details)
shubham retitled this revision from [WIP]: Add Button to open the folder in filelight for more details to Add Button to open the folder in filelight for more details.Dec 27 2019, 4:09 PM
ngraham requested changes to this revision.Dec 27 2019, 6:01 PM

We're getting there, but this code now causes a crash that must be fixed. Please make sure you are testing your changes for all conditions (i.e. don't just make sure that it works when Filelight is installed, also test the case where it's not installed).

src/widgets/kpropertiesdialog.cpp
782

When you add a newline, make sure it doesn't have any spaces in it

786

ditto

1099

ditto

1101

Heh, I think I confused you, my bad. I wasn't trying to imply that the label should actually have a question mark in it. Button labels don't typically end with punctuation like that. Just "Explore in Filelight" is enough.

1102

ditto

1105

ditto

1108

This causes a crash when Filelight isn't installed, because in that case, d->m_sizeDetailsButton is a nullptr.

1109

ditto

1455

ditto

This revision now requires changes to proceed.Dec 27 2019, 6:01 PM
shubham updated this revision to Diff 72261.Dec 27 2019, 6:22 PM
shubham edited the summary of this revision. (Show Details)

Fix whitespaces and crash condition

shubham marked 9 inline comments as done.Dec 27 2019, 6:22 PM
shubham retitled this revision from Add Button to open the folder in filelight for more details to Add Button to open the folder in filelight to view more details.Dec 27 2019, 6:28 PM
shubham retitled this revision from Add Button to open the folder in filelight to view more details to Add button to open the folder in filelight to view more details.
ngraham added a comment.EditedDec 27 2019, 6:36 PM

Much better now, thanks. There's just one more thing I only noticed now, sorry. Then I think it'll be good to go.

src/widgets/kpropertiesdialog.cpp
1454

Instead of defining this as a variable that's used only once, you can just directly access the value from properties->url() in the KRun::run() function

shubham updated this revision to Diff 72263.Dec 27 2019, 6:41 PM

Remove the use of variable

shubham marked an inline comment as done.Dec 27 2019, 6:42 PM
ngraham accepted this revision.Dec 27 2019, 7:06 PM

Ship it!

This revision is now accepted and ready to land.Dec 27 2019, 7:06 PM
shubham closed this revision.Dec 28 2019, 5:32 AM
pino added a subscriber: pino.Dec 28 2019, 6:37 PM
pino added inline comments.
src/widgets/kpropertiesdialog.cpp
1455

please do not hardcode the path to filelight... other than breaking on systems where filelight is installed in a prefix different than /usr, this breaks on Mac and Windows (and not only).

As a reference for the future: this change broke the two weeks string freeze - which we haven't enforced so strongly in the past months, but please keep an eye on it. Expecially this time of the year with many countries on vacation.

broulik reopened this revision.Jan 7 2020, 10:35 AM
broulik added a subscriber: broulik.

Can you please look for filelight using KService::serviceByDesktopName("org.kde.filelight"), then you don't have hardcode the executable path, name, icon, etc.

This revision is now accepted and ready to land.Jan 7 2020, 10:35 AM
broulik requested changes to this revision.Jan 7 2020, 10:44 AM
This revision now requires changes to proceed.Jan 7 2020, 10:44 AM
shubham updated this revision to Diff 73376.Jan 13 2020, 8:53 AM

@broulik I believe this is what you wanted?

It would make more sense to submit a new patch. This one wasn't reverted, so it's not clear what would happen if we tried to land it.

shubham abandoned this revision.EditedJan 14 2020, 5:19 AM

Abandoned in favour of D26650