Home GnuPG

Add DocAction helper class

Description

Add DocAction helper class

This is an Action that checks for a specific document in
a path and calls QDesktopServicesOpenURL on trigger if
the file exists.

Details

Provenance
aheineckeAuthored on Tue, Jan 4, 1:23 PM
Parents
rLIBKLEOeefdd2851fe1: Require GpgME version 1.15.0
Branches
Unknown
Tags
Unknown
References
refs/keep-around/d192f52fa9d09d75b67d923861d8be5e67ab4260

Event Timeline

ikloecker added inline comments.
/src/kleo/docaction.cpp
37–42

Using something like

const auto dataDirPath = QDir{QCoreApplication::applicationDirPath()}.filePath(
    pathHint.isEmpty() ? QStringLiteral("/../share/kleopatra") : pathHint);
const QDir dataDir{dataDirPath};

would make this easier to read and save you the trouble to create tmp.

Also, don't use QString::isNull() unless you absolutely must use it. Or do you really want this function to behave differently for pathHint == QString{} and pathHint == QStringLiteral{""}? If the answer is yes, then a second c'tor that doesn't take a pathHint paramter would be much better API in my opinion.

45–46

Since you already have a QDir, you could have used

isEnabled = datadir.exists(filename);
/src/kleo/docaction.h
42

Maybe you should document that ../share/kleopatra is used as pathHint if pathHint is QString{}. On the other hand, this is a library function and it defaults to an application specific value?

I suggest moving this application specific default value for pathHint where it belongs: in the application(s).

52–53

You delete c'tors that don't even exist in the first place. c'tors of base classes are never inherited by subclasses unless they are explicitly made visible to overload resolution with using. (I'm wondering why gcc doesn't complain about this.)

You can easily verify this by commenting those two lines and then trying to do DocAction foo{nullptr}; somewhere. gcc will tell you that there is no matching function call and that the only available candidate expects 5 arguments.