Commit 5b5a1542 authored by Julius Künzel's avatar Julius Künzel
Browse files

PACKAGING CHANGE!! Introduce PACKAGE_TYPE envvar

When Kdenlive runs inside a sandbox enviroment like with Appimage,
Flatpak or Snap it needs to resolve some paths rekursive. This is
currently detected by whether a custom config file was specified or not.
This patch changes the behaviour. The package type is now detected
through the envvar PACKAGE_TYPE. You can set it to "appimage", "flatpak"
or "snap" to let Kdenlive run in sandbox mode.
parent d6910eac
Pipeline #127878 passed with stage
in 7 minutes and 26 seconds
......@@ -253,6 +253,8 @@ export APPIMAGE_STARTUP_QT_PLUGIN_PATH=\$QT_PLUGIN_PATH
export APPIMAGE_STARTUP_XDG_DATA_DIRS=\$XDG_DATA_DIRS
export APPIMAGE_STARTUP_PATH=\$PATH
export PACKAGE_TYPE=appimage
kdenlive --config kdenlive-appimagerc \$@
EOF
chmod +x $APPDIR/AppRun
......
......@@ -21,7 +21,8 @@
"--env=TMPDIR=/var/tmp",
"--env=QT_ENABLE_HIGHDPI_SCALING=1",
"--env=FREI0R_PATH=/app/lib/frei0r-1",
"--env=LADSPA_PATH=/app/extensions/Plugins/ladspa:/app/lib/ladspa"
"--env=LADSPA_PATH=/app/extensions/Plugins/ladspa:/app/lib/ladspa",
"--env=PACKAGE_TYPE=flatpak"
],
"add-extensions": {
"org.freedesktop.LinuxAudio.Plugins": {
......
......@@ -113,7 +113,20 @@ bool Core::build(bool testMode)
return true;
}
void Core::initGUI(bool isAppImage, const QString &MltPath, const QUrl &Url, const QString &clipsToLoad)
bool Core::inSandbox()
{
if (!qEnvironmentVariableIsSet("PACKAGE_TYPE")) {
return false;
}
QString type = qgetenv("PACKAGE_TYPE");
type = type.toLower();
if (type == QStringLiteral("appimage") || type == QStringLiteral("flatpak") || type == QStringLiteral("snap")) {
return true;
}
return false;
}
void Core::initGUI(const QString &MltPath, const QUrl &Url, const QString &clipsToLoad)
{
m_profile = KdenliveSettings::default_profile();
m_currentProfile = m_profile;
......@@ -163,7 +176,8 @@ void Core::initGUI(bool isAppImage, const QString &MltPath, const QUrl &Url, con
// The MLT Factory will be initiated there, all MLT classes will be usable only after this
if (isAppImage) {
if (inSandbox()) {
// In a sandbox enviroment we need to search some paths recursively
QString appPath = qApp->applicationDirPath();
KdenliveSettings::setFfmpegpath(QDir::cleanPath(appPath + QStringLiteral("/ffmpeg")));
KdenliveSettings::setFfplaypath(QDir::cleanPath(appPath + QStringLiteral("/ffplay")));
......
......@@ -80,13 +80,20 @@ public:
*/
static bool build(bool testMode = false);
/**
* @brief Whether the app runs in a sandbox
* Will be true for Appimage, Flatpak and Snap
* The detection works through the PACKAGE_TYPE envvar
*/
bool inSandbox();
/**
* @brief Init the GUI part of the app and show the main window
* @param Url (optional) file to open
* If Url is present, it will be opened, otherwise, if openlastproject is
* set, latest project will be opened. If no file is open after trying this,
* a default new file will be created. */
void initGUI(bool isAppImage, const QString &MltPath, const QUrl &Url, const QString &clipsToLoad = QString());
void initGUI(const QString &MltPath, const QUrl &Url, const QString &clipsToLoad = QString());
/** @brief Returns a pointer to the singleton object. */
static std::unique_ptr<Core> &self();
......
......@@ -62,7 +62,7 @@ bool MyWizardPage::isComplete() const
return m_isComplete;
}
Wizard::Wizard(bool autoClose, bool appImageCheck, QWidget *parent)
Wizard::Wizard(bool autoClose, QWidget *parent)
: QWizard(parent)
, m_systemCheckIsOk(false)
, m_brokenModule(false)
......@@ -112,7 +112,7 @@ Wizard::Wizard(bool autoClose, bool appImageCheck, QWidget *parent)
list->addItems(conversion.second);
}
}
if (!m_errors.isEmpty() || !m_warnings.isEmpty() || (!m_infos.isEmpty() && !appImageCheck)) {
if (!m_errors.isEmpty() || !m_warnings.isEmpty() || (!m_infos.isEmpty())) {
QLabel *lab = new QLabel(this);
lab->setText(i18n("Startup error or warning, check our <a href='#'>online manual</a>."));
connect(lab, &QLabel::linkActivated, this, &Wizard::slotOpenManual);
......
......@@ -32,7 +32,7 @@ class Wizard : public QWizard
{
Q_OBJECT
public:
explicit Wizard(bool autoClose, bool appImageCheck, QWidget *parent = nullptr);
explicit Wizard(bool autoClose, QWidget *parent = nullptr);
void installExtraMimes(const QString &baseName, const QStringList &globs);
void runUpdateMimeDatabase();
void adjustSettings();
......
......@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
QObject::connect(pCore.get(), &Core::closeSplash, &splash, [&] () {
splash.finish(pCore->window());
});
pCore->initGUI(!parser.value(QStringLiteral("config")).isEmpty(), parser.value(QStringLiteral("mlt-path")), url, clipsToLoad);
pCore->initGUI(parser.value(QStringLiteral("mlt-path")), url, clipsToLoad);
result = app.exec();
}
Core::clean();
......
......@@ -1948,7 +1948,7 @@ bool MainWindow::readOptions()
KRecentDirs::add(QStringLiteral(":KdenliveClipFolder"), QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
// this is our first run, show Wizard
QPointer<Wizard> w = new Wizard(true, false);
QPointer<Wizard> w = new Wizard(true);
if (w->exec() == QDialog::Accepted && w->isOk()) {
w->adjustSettings();
delete w;
......@@ -1958,7 +1958,7 @@ bool MainWindow::readOptions()
}
} else if (!KdenliveSettings::ffmpegpath().isEmpty() && !QFile::exists(KdenliveSettings::ffmpegpath())) {
// Invalid entry for FFmpeg, check system
QPointer<Wizard> w = new Wizard(true, config->name().contains(QLatin1String("appimage")));
QPointer<Wizard> w = new Wizard(true);
if (w->exec() == QDialog::Accepted && w->isOk()) {
w->adjustSettings();
}
......@@ -1970,7 +1970,7 @@ bool MainWindow::readOptions()
void MainWindow::slotRunWizard()
{
QPointer<Wizard> w = new Wizard(false, false, this);
QPointer<Wizard> w = new Wizard(false, this);
if (w->exec() == QDialog::Accepted && w->isOk()) {
w->adjustSettings();
}
......@@ -4331,6 +4331,9 @@ void MainWindow::slotSpeechRecognition()
void MainWindow::slotCopyDebugInfo() {
QString debuginfo = QStringLiteral("Kdenlive: %1\n").arg(KAboutData::applicationData().version());
QString packageType = qEnvironmentVariableIsSet("PACKAGE_TYPE") ? qgetenv("PACKAGE_TYPE") : QStringLiteral("Unknown/Other");
debuginfo.append(QStringLiteral("Package Type: %1\n").arg(packageType));
debuginfo.append(QStringLiteral("Sandbox: %1\n").arg(pCore->inSandbox() ? QStringLiteral("yes") : QStringLiteral("no")));
debuginfo.append(QStringLiteral("MLT: %1\n").arg(mlt_version_get_string()));
debuginfo.append(QStringLiteral("Qt: %1 (built against %2 %3)\n").arg(QString::fromLocal8Bit(qVersion()), QT_VERSION_STR, QSysInfo::buildAbi()));
debuginfo.append(QStringLiteral("Frameworks: %2\n").arg(KCoreAddons::versionString()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment