Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
c7ce11c2
Commit
c7ce11c2
authored
Jan 26, 2022
by
Julius Künzel
Browse files
Improve Sandbox detection, use dedicated config files for sandbox packages
parent
85e4072c
Pipeline
#128841
passed with stage
in 5 minutes and 29 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/core.cpp
View file @
c7ce11c2
...
...
@@ -40,9 +40,10 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#endif
std
::
unique_ptr
<
Core
>
Core
::
m_self
;
Core
::
Core
()
Core
::
Core
(
const
QString
&
packageType
)
:
audioThumbCache
(
QStringLiteral
(
"audioCache"
),
2000000
)
,
taskManager
(
this
)
,
m_packageType
(
packageType
)
,
m_thumbProfile
(
nullptr
)
,
m_capture
(
new
MediaCapture
(
this
))
{
...
...
@@ -67,12 +68,12 @@ Core::~Core()
ClipController
::
mediaUnavailable
.
reset
();
}
bool
Core
::
build
(
bool
testMode
)
bool
Core
::
build
(
const
QString
&
packageType
,
bool
testMode
)
{
if
(
m_self
)
{
return
true
;
}
m_self
.
reset
(
new
Core
());
m_self
.
reset
(
new
Core
(
packageType
));
m_self
->
initLocale
();
qRegisterMetaType
<
audioShortVector
>
(
"audioShortVector"
);
...
...
@@ -88,7 +89,7 @@ bool Core::build(bool testMode)
qRegisterMetaType
<
requestClipInfo
>
(
"requestClipInfo"
);
qRegisterMetaType
<
QVector
<
QPair
<
QString
,
QVariant
>>>
(
"paramVector"
);
qRegisterMetaType
<
ProfileParam
*>
(
"ProfileParam*"
);
if
(
!
testMode
)
{
// Check if we had a crash
QFile
lockFile
(
QDir
::
temp
().
absoluteFilePath
(
QStringLiteral
(
"kdenlivelock"
)));
...
...
@@ -113,20 +114,7 @@ bool Core::build(bool testMode)
return
true
;
}
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
)
void
Core
::
initGUI
(
bool
inSandbox
,
const
QString
&
MltPath
,
const
QUrl
&
Url
,
const
QString
&
clipsToLoad
)
{
m_profile
=
KdenliveSettings
::
default_profile
();
m_currentProfile
=
m_profile
;
...
...
@@ -176,7 +164,7 @@ void Core::initGUI(const QString &MltPath, const QUrl &Url, const QString &clips
// The MLT Factory will be initiated there, all MLT classes will be usable only after this
if
(
inSandbox
()
)
{
if
(
inSandbox
)
{
// In a sandbox enviroment we need to search some paths recursively
QString
appPath
=
qApp
->
applicationDirPath
();
KdenliveSettings
::
setFfmpegpath
(
QDir
::
cleanPath
(
appPath
+
QStringLiteral
(
"/ffmpeg"
)));
...
...
src/core.h
View file @
c7ce11c2
...
...
@@ -74,26 +74,22 @@ public:
/**
* @brief Setup the basics of the application, in particular the connection
* with Mlt
* @param isAppImage do we expect an AppImage (if yes, we use App path to deduce
* other binaries paths (melt, ffmpeg, etc)
* @param MltPath (optional) path to MLT environment
*/
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
();
static
bool
build
(
const
QString
&
packageType
,
bool
testMode
=
false
);
/**
* @brief Init the GUI part of the app and show the main window
* @param inSandbox does the app run in a sanbox? If yes, we use App path to deduce
* other binaries paths (melt, ffmpeg, etc)
* @param MltPath
* @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
(
const
QString
&
MltPath
,
const
QUrl
&
Url
,
const
QString
&
clipsToLoad
=
QString
());
* a default new file will be created.
* @param clipsToLoad
*/
void
initGUI
(
bool
inSandbox
,
const
QString
&
MltPath
,
const
QUrl
&
Url
,
const
QString
&
clipsToLoad
=
QString
());
/** @brief Returns a pointer to the singleton object. */
static
std
::
unique_ptr
<
Core
>
&
self
();
...
...
@@ -281,8 +277,10 @@ public:
const
QSize
getCompositionSizeOnTrack
(
const
ObjectId
&
id
);
void
loadTimelinePreview
(
const
QString
&
chunks
,
const
QString
&
dirty
,
const
QDateTime
&
documentDate
,
int
enablePreview
,
Mlt
::
Playlist
&
playlist
);
QString
packageType
()
{
return
m_packageType
;
};
private:
explicit
Core
();
explicit
Core
(
const
QString
&
packageType
);
static
std
::
unique_ptr
<
Core
>
m_self
;
/** @brief Makes sure Qt's locale and system locale settings match. */
...
...
@@ -302,6 +300,7 @@ private:
QString
m_currentProfile
;
QString
m_profile
;
QString
m_packageType
;
Timecode
m_timecode
;
std
::
unique_ptr
<
Mlt
::
Profile
>
m_thumbProfile
;
/** @brief Mlt profile used in the consumer 's monitors */
...
...
src/main.cpp
View file @
c7ce11c2
...
...
@@ -125,6 +125,27 @@ int main(int argc, char *argv[])
}
}
#endif
QString
packageType
;
if
(
qEnvironmentVariableIsSet
(
"PACKAGE_TYPE"
))
{
packageType
=
qgetenv
(
"PACKAGE_TYPE"
).
toLower
();
}
else
{
// no package type defined, try to detected it
QString
appPath
=
qApp
->
applicationDirPath
();
if
(
appPath
.
contains
(
QStringLiteral
(
"/tmp/.mount_"
)))
{
packageType
=
QStringLiteral
(
"appimage"
);
}
else
{
qDebug
()
<<
"Could not detect package type, probably default? App dir is"
<<
qApp
->
applicationDirPath
();
}
}
bool
inSandbox
=
false
;
if
(
packageType
==
QStringLiteral
(
"appimage"
)
||
packageType
==
QStringLiteral
(
"flatpak"
)
||
packageType
==
QStringLiteral
(
"snap"
))
{
inSandbox
=
true
;
// use a dedicated config file for sandbox packages,
// however the next line has no effect if the --config cmd option is used
KConfig
::
setMainConfigName
(
QStringLiteral
(
"kdenlive-%1rc"
).
arg
(
packageType
));
}
KSharedConfigPtr
config
=
KSharedConfig
::
openConfig
();
KConfigGroup
grp
(
config
,
"unmanaged"
);
if
(
!
grp
.
exists
())
{
...
...
@@ -210,6 +231,7 @@ int main(int argc, char *argv[])
aboutData
.
setupCommandLine
(
&
parser
);
parser
.
setApplicationDescription
(
aboutData
.
shortDescription
());
// config option is processed in KConfig (src/core/kconfig.cpp)
parser
.
addOption
(
QCommandLineOption
(
QStringList
()
<<
QStringLiteral
(
"config"
),
i18n
(
"Set a custom config file name"
),
QStringLiteral
(
"config"
)));
parser
.
addOption
(
QCommandLineOption
(
QStringList
()
<<
QStringLiteral
(
"mlt-path"
),
i18n
(
"Set the path for MLT environment"
),
QStringLiteral
(
"mlt-path"
)));
parser
.
addOption
(
QCommandLineOption
(
QStringList
()
<<
QStringLiteral
(
"mlt-log"
),
i18n
(
"MLT log level"
),
QStringLiteral
(
"verbose/debug"
)));
...
...
@@ -270,7 +292,7 @@ int main(int argc, char *argv[])
}
qApp
->
processEvents
(
QEventLoop
::
AllEvents
);
int
result
=
0
;
if
(
!
Core
::
build
())
{
if
(
!
Core
::
build
(
packageType
))
{
// App is crashing, delete config files and restart
result
=
EXIT_CLEAN_RESTART
;
}
else
{
...
...
@@ -278,7 +300,7 @@ int main(int argc, char *argv[])
QObject
::
connect
(
pCore
.
get
(),
&
Core
::
closeSplash
,
&
splash
,
[
&
]
()
{
splash
.
finish
(
pCore
->
window
());
});
pCore
->
initGUI
(
parser
.
value
(
QStringLiteral
(
"mlt-path"
)),
url
,
clipsToLoad
);
pCore
->
initGUI
(
inSandbox
,
parser
.
value
(
QStringLiteral
(
"mlt-path"
)),
url
,
clipsToLoad
);
result
=
app
.
exec
();
}
Core
::
clean
();
...
...
src/mainwindow.cpp
View file @
c7ce11c2
...
...
@@ -4331,9 +4331,8 @@ 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"
)));
QString
packageType
=
pCore
->
packageType
();
debuginfo
.
append
(
QStringLiteral
(
"Package Type: %1
\n
"
).
arg
(
packageType
.
isEmpty
()
?
QStringLiteral
(
"Unknown/Default"
)
:
packageType
));
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
()));
...
...
tests/TestMain.cpp
View file @
c7ce11c2
...
...
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
app
.
setApplicationName
(
QStringLiteral
(
"kdenlive"
));
std
::
unique_ptr
<
Mlt
::
Repository
>
repo
(
Mlt
::
Factory
::
init
(
nullptr
));
qputenv
(
"MLT_TESTS"
,
QByteArray
(
"1"
));
Core
::
build
(
true
);
Core
::
build
(
QString
(),
true
);
MltConnection
::
construct
(
QString
());
pCore
->
projectItemModel
()
->
buildPlaylist
();
// if Kdenlive is not installed, ensure we have one keyframable effect
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment