Skip to content

Commit

Permalink
Make Mapplauncherd support optional
Browse files Browse the repository at this point in the history
It's worth revisiting if this makes sense to keep as a dependency with
some repeatable benchmarks where a quantifiable difference may or may
not be observed when running this on a watch.

If this is to be removed cmake/FindMapplauncherd_qt*.cmake additionally
should also be gone.
  • Loading branch information
JamiKettunen committed Nov 24, 2024
1 parent 8aa3368 commit 9d6d744
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)

option(WITH_ASTEROIDAPP "Build the AsteroidApp class" ON)
option(WITH_MAPPLAUNCHERD "Build the AsteroidApp class with Mapplauncherd booster support" ON)
option(WITH_CMAKE_MODULES "Install AsteroidOS CMake modules" ON)

include(FeatureSummary)
Expand All @@ -22,7 +23,9 @@ set(ASTEROID_MODULES_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/asteroidapp/cmake)
find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS DBus Qml Quick Svg ShaderTools REQUIRED)
if (WITH_ASTEROIDAPP)
find_package(Mlite6 MODULE REQUIRED)
find_package(Mapplauncherd_qt6 MODULE REQUIRED)
if (WITH_MAPPLAUNCHERD)
find_package(Mapplauncherd_qt6 MODULE REQUIRED)
endif()
endif()

ecm_find_qmlmodule(QtQuick.VirtualKeyboard 2.1)
Expand Down
10 changes: 7 additions & 3 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ target_link_libraries(asteroidapp
Qt6::Quick
PRIVATE
Mlite6::Mlite6
Mapplauncherd_qt6::Mapplauncherd_qt6)
$<$<BOOL:${WITH_MAPPLAUNCHERD}>:Mapplauncherd_qt6::Mapplauncherd_qt6>)

set_target_properties(asteroidapp PROPERTIES
EXPORT_NAME AsteroidApp
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION})
VERSION ${PROJECT_VERSION}
COMPILE_DEFINITIONS $<$<BOOL:${WITH_MAPPLAUNCHERD}>:WITH_MAPPLAUNCHERD=1>)

target_include_directories(asteroidapp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand All @@ -34,9 +35,12 @@ install(FILES asteroidapp.prf
DESTINATION ${CMAKE_INSTALL_LIBDIR}/mkspecs/features
COMPONENT Devel)

if (WITH_MAPPLAUNCHERD)
set(ASTEROIDAPP_PKGCONF_DEPS "qdeclarative6-boostable")
endif()
ecm_generate_pkgconfig_file(
BASE_NAME asteroidapp
DEPS qdeclarative6-boostable
DEPS ${ASTEROIDAPP_PKGCONF_DEPS}
FILENAME_VAR asteroidapp
DESCRIPTION ${PROJECT_DESCRIPTION}
INSTALL)
Expand Down
14 changes: 14 additions & 0 deletions src/app/asteroidapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QFileInfo>
#include <MDesktopEntry>
#include <QTranslator>
#if WITH_MAPPLAUNCHERD
#include <mdeclarativecache/MDeclarativeCache>

static QString applicationPath()
Expand All @@ -47,11 +48,16 @@ static QString applicationPath()
return QCoreApplication::applicationFilePath();
}
}
#endif

namespace AsteroidApp {
QString appName()
{
#if WITH_MAPPLAUNCHERD
QFileInfo exe = QFileInfo(applicationPath());
#else
QFileInfo exe = QFileInfo(QCoreApplication::applicationFilePath());
#endif
return exe.baseName();
}

Expand All @@ -60,7 +66,11 @@ namespace AsteroidApp {
static QGuiApplication *app = NULL;

if (app == NULL) {
#if WITH_MAPPLAUNCHERD
app = MDeclarativeCache::qApplication(argc, argv);
#else
app = new QGuiApplication(argc, argv);
#endif

app->setOrganizationName(appName());
app->setOrganizationDomain(appName());
Expand All @@ -78,7 +88,11 @@ namespace AsteroidApp {

QQuickView *createView()
{
#if WITH_MAPPLAUNCHERD
QQuickView *view = MDeclarativeCache::qQuickView();
#else
QQuickView *view = new QQuickView;
#endif
MDesktopEntry entry("/usr/share/applications/" + appName() + ".desktop");
if (entry.isValid()) {
view->setTitle(entry.name());
Expand Down

0 comments on commit 9d6d744

Please sign in to comment.