-
Notifications
You must be signed in to change notification settings - Fork 99
Add watchers for xdg desktop file changes #174
Conversation
428d5cd to
c581048
Compare
|
@dobey Should be fixed up now :) |
c581048 to
ae2df97
Compare
|
@mardy There we go, that should fix it :) Also found a little error in my toStandardAppId() thats fixed now. |
|
|
||
| void AppDrawerModel::appRemoved(const QString &appId) | ||
| // ubuntuAppId is appID without version suffix, see xdgwatcher.cpp. | ||
| void AppDrawerModel::appRemoved(const QString &appId, const QString &ubuntuAppId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing both in here, why not make the functions (which seem to not require the class object itself to be useful), into public static methods, and then just call XdgWatcher::stripAppIdVersion(appid) when needed below? This avoids a semi-duplicated argument, and makes the code easier to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem with that is that the "normal/standard" appID might not be the same as strippedAppId as the "ubuntu style" app id does not add the parent folder into app id.
example:
.local/share/desktop/kde/kate.desktop would be kde-kate as appID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example where these conflics:
.local/share/desktop/ubports/system-settings_ubports_1.1.1.desktop would then be passed as ubports-system-settings_ubports_1.1.1 to appRemoved, then stripped to ubports-system-settings_ubports and that would be wrong, as "ubuntu style" appID does not append "folder name" as xdg one does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, click hook does not create desktop files in a subdir, and we get the app ID for these from inside the desktop file, so this isn't an issue. I don't see any need to have extra special handling in here. The model has a list of app IDs, and one gets removed. there doesn't need to be extra logic for special cases in here.
| } | ||
|
|
||
| // Ubuntu appID is filename without versionNumber after last "_" | ||
| const QString XdgWatcher::toUbuntuAppId(const QString rawAppID) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be renamed to not have "Ubuntu" in the name. Perhaps it should be stripAppIdVersion instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah make sense, will update this
| int idx = -1; | ||
| for (int i = 0; i < m_list.count(); i++) { | ||
| if (m_list.at(i)->appId() == appId) { | ||
| if (m_list.at(i)->appId() == appId || m_list.at(i)->appId() == ubuntuAppId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need the second comparison here (and thus the argument or need to strip the version) at all? Shouldn't the appId that gets passed in already have the version stripped always? In what cases would it not be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this is to make sure we don't strip an "standard" appID by accident. Example is kate_kde.desktop, we would strip "_kde" in that case. Since the file has been removed we have no way of knowing if it's a "ubuntu style" app id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I re-read the comment in XdgWatcher, and this is a hack to deal with the fact the file was removed. I will have to think a bit on this, but I'm certain we can handle it a better way.
ae2df97 to
593caba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because previous comments and GitHub is broke.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
593caba to
443fc3f
Compare
|
@dobey that should be better, now its a static method that gets called instead of passing it with the signal. |
443fc3f to
eed86d5
Compare
|
Cool! It builds now. Just ignore the others as they are only here due to changes to Jenkins. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more concerns that came up thinking about this.
| // "Ubuntu style" appID is filename without versionNumber after last "_" | ||
| const QString XdgWatcher::stripAppIdVersion(const QString rawAppID) { | ||
| auto appIdComponents = rawAppID.split("_"); | ||
| appIdComponents.removeLast(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should only do this, if the appIdComponents.length() == 3, otherwise it is not a valid versioned app ID for the purposes here. This would also solve the concern above that we might strip kde_kate improperly. It would also simplify the code a fair bit, as we could then avoid special-casing below, and above, only passing the result of toAppId() around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that make sense, will add that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has still not been updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this, we may still improperly strip for example org_kde_kate, so we would still need to open the file to check
|
|
||
| const QString XdgWatcher::toAppId(const QFileInfo fileInfo) const { | ||
| QFile qFile(fileInfo.absoluteFilePath()); | ||
| qFile.open(QIODevice::ReadOnly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think we can just get rid of the whole need to open the file and check for X-Ubuntu-Application-ID entirely, and only use toStandardAppId() to get the app ID, since click hooks place the files as the correct ${APP_ID}.desktop filename. Then we can just always strip the version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i guess that should also work just fine, since we use to remove the app anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has still not been updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this, we may still improperly strip for example org_kde_kate, so we would still need to open the file to check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a real concern. KDE does not install applications in this manner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kde was just an example, but one app that does do this on my local system is krita_jpg_jpeg.desktop
| connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &XdgWatcher::onDirectoryChanged); | ||
| connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &XdgWatcher::onFileChanged); | ||
|
|
||
| const auto paths = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this will only watch directories in the host, this PR doesn't solve the issue for install/remove of apps in Libertine. How are we going to handle those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the idea to that was to make symlinks the .desktop to the standard locations instead, this makes it easier for libertine work on other DE (if needed)
eed86d5 to
598f92f
Compare
|
So, I added an internal registry, this way we will always give the correct id. This also really simplifies the code overall. and I think i covered all your comments @dobey. Please re-review :) |
598f92f to
126b2b9
Compare
|
|
||
| const QString XdgWatcher::toAppId(const QFileInfo fileInfo) const { | ||
| QFile qFile(fileInfo.absoluteFilePath()); | ||
| qFile.open(QIODevice::ReadOnly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a real concern. KDE does not install applications in this manner.
This adds watchers for xdg desktop file changes. It also figures out if the appid id is "ubuntu-app-launch" or "standard xdg" style. This spawns the first code to replace most (if not all) of ubuntu-app-launch, but with QT! This fixes: ubports/ubuntu-touch#1058
126b2b9 to
0a52673
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this is not quite right, but I don't want to hold it up any longer on semantics.
This adds watchers for xdg desktop file changes. It also figures out if
the appid id is "ubuntu-app-launch" or "standard xdg" style.
This spawns the first code to replace most (if not all) of
ubuntu-app-launch, but with QT!
This fixes: ubports/ubuntu-touch#1058