Skip to content

Commit

Permalink
Linux Portable: support desktop integration removal
Browse files Browse the repository at this point in the history
Run 'friction --xdg-remove' to uninstall desktop integration.

Also update build scripts.
  • Loading branch information
rodlie committed Aug 17, 2024
1 parent a9731e3 commit 54a2b98
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 81 deletions.
20 changes: 16 additions & 4 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,18 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
setlocale(LC_NUMERIC, "C");

#ifdef Q_OS_LINUX
if (AppSupport::isAppPortable()) {
if (QApplication::arguments().contains("--xdg-remove")) {
const bool removedXDG = AppSupport::removeXDGDesktopIntegration();
qWarning() << "Removed XDG Integration:" << removedXDG;
return removedXDG ? 0 : -1;
}
}
#endif

#ifdef Q_OS_WIN
// we ship a custom build of Qt 5.12.12 (with this feature backported) on Windows, so ignore this check
// #if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
QWindowsWindowFunctions::setHasBorderInFullScreenDefault(true);
// #endif
#endif

#ifndef Q_OS_DARWIN
Expand Down Expand Up @@ -206,7 +213,12 @@ int main(int argc, char *argv[])
" This will add Friction to your application launcher"
" and add mime type for project files."));
if (ask == QMessageBox::Yes) {
AppSupport::setupXDGDesktopIntegration();
if (!AppSupport::setupXDGDesktopIntegration()) {
QMessageBox::warning(nullptr,
QObject::tr("Desktop Integration Failed"),
QObject::tr("Failed to install the required files for desktop integration,"
" please check your permissions."));
}
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/core/appsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,3 +862,26 @@ bool AppSupport::setupXDGDesktopIntegration()

return true;
}

bool AppSupport::removeXDGDesktopIntegration()
{
QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
if (path.isEmpty() ||
!path.startsWith(QDir::homePath())) { path = QString("%1/.local/share").arg(QDir::homePath()); }

QStringList files;
files << "applications/graphics.friction.Friction.desktop";
files << "mime/packages/graphics.friction.Friction.xml";
files << "icons/hicolor/scalable/apps/graphics.friction.Friction.svg";
files << "icons/hicolor/256x256/apps/graphics.friction.Friction.png";
files << "icons/hicolor/scalable/mimetypes/application-x-graphics.friction.Friction.svg";
files << "icons/hicolor/256x256/mimetypes/application-x-graphics.friction.Friction.png";

for (const auto &file : files) {
QFile fileName(QString("%1/%2").arg(path, file));
if (fileName.exists()) {
if (!fileName.remove()) { return false; }
}
}
return true;
}
1 change: 1 addition & 0 deletions src/core/appsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class CORE_EXPORT AppSupport : public QObject
static bool isAppPortable();
static bool hasXDGDesktopIntegration();
static bool setupXDGDesktopIntegration();
static bool removeXDGDesktopIntegration();
};

#endif // APPSUPPORT_H
19 changes: 5 additions & 14 deletions src/scripts/build_vfxplatform_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,26 @@ rpmbuild -bb rpm.spec
cp -a ${HOME}/rpmbuild/RPMS/*/*.rpm ${DISTFILES}/builds/${VERSION}/

# Portable
FRICTION_PORTABLE=${FRICTION_PKG}-portable-linux-x86_64
FRICTION_PORTABLE=${FRICTION_PKG}-linux-x86_64
FRICTION_PORTABLE_DIR=${BUILD}/${FRICTION_PORTABLE}
cd ${BUILD}
rm -f ${FRICTION_PORTABLE_DIR} || true
mv ${BUILD}/${FRICTION_PKG} ${FRICTION_PORTABLE_DIR}
(cd ${FRICTION_PORTABLE_DIR} ;
cp ${BUILD}/friction/src/scripts/desktop_integration.sh .
chmod +x desktop_integration.sh
touch bin/portable.txt
rm -rf usr
mv opt/friction/* .
rm -rf opt share/doc
ln -sf bin/friction .
)
cd ${BUILD}
tar cvf ${FRICTION_PORTABLE}.tar ${FRICTION_PORTABLE}
bzip2 -9 ${FRICTION_PORTABLE}.tar
cp -a ${FRICTION_PORTABLE}.tar.bz2 ${DISTFILES}/builds/${VERSION}/
xz -9 ${FRICTION_PORTABLE}.tar
cp -a ${FRICTION_PORTABLE}.tar.xz ${DISTFILES}/builds/${VERSION}/

# AppImage
(cd ${FRICTION_PORTABLE_DIR} ;
rm -f desktop_integration.sh
rm -f bin/portable.txt
rm -f friction
mkdir usr
mv lib bin plugins share usr/
Expand All @@ -203,14 +202,6 @@ ln -sf usr/share/icons/hicolor/256x256/apps/${APPID}.png .DirIcon
tar xf ${DISTFILES}/linux/appimagetool-${APPIMAGETOOL}.tar.bz2
ARCH=x86_64 ./appimagetool/AppRun --verbose --runtime-file=${DISTFILES}/linux/runtime-x86_64-${APPIMAGERUNTIME}.bin ${FRICTION_PORTABLE}

# TODO
# FRICTION_ISO=${FRICTION_PKG}-x86_64.squashfs
# FRICTION_APP=${FRICTION_PKG}-test-x86_64.AppImage
# mksquashfs ${FRICTION_PORTABLE} ${FRICTION_ISO} -comp zstd -root-owned -noappend -b 1M -mkfs-time 0
# cat ${DISTFILES}/linux/runtime-x86_64-${APPIMAGERUNTIME}.bin > ${FRICTION_APP}
# cat ${FRICTION_ISO} >> ${FRICTION_APP}
# chmod a+x ${FRICTION_ISO}

cp -a *.AppImage ${DISTFILES}/builds/${VERSION}/

echo "FRICTION PACKAGE DONE"
63 changes: 0 additions & 63 deletions src/scripts/desktop_integration.sh

This file was deleted.

0 comments on commit 54a2b98

Please sign in to comment.