From 8593e4a0562f8c1cbcb165d9e54d418524c5b02f Mon Sep 17 00:00:00 2001 From: reionwong Date: Sun, 11 Oct 2026 19:16:48 +0800 Subject: [PATCH] feat(terminal): run on QGuiApplication as an application module the booster can start --- CMakeLists.txt | 8 ++------ src/main.cpp | 10 ++++++---- src/processhelper.cpp | 4 ++-- src/utils.cpp | 6 +++--- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adc0077..4f0326a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,14 +48,12 @@ if(BUILD_TESTING) add_subdirectory(tests) endif() -add_executable(${PROJECT_NAME} ${SRCS} ${RESOURCES}) -target_link_libraries(${PROJECT_NAME} +cutefish_add_application(${PROJECT_NAME} SOURCES ${SRCS} ${RESOURCES}) +target_link_libraries(${PROJECT_NAME}-module PRIVATE Qt6::Core Qt6::Qml Qt6::Quick - Qt6::Widgets Qt6::DBus - Cutefish::Application ) file(GLOB TS_FILES translations/*.ts) @@ -64,8 +62,6 @@ add_custom_target(translations DEPENDS ${QM_FILES} SOURCES ${TS_FILES}) add_dependencies(${PROJECT_NAME} translations) install(FILES ${QM_FILES} DESTINATION /usr/share/cutefish-terminal/translations) -install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION /usr/bin) - install(FILES cutefish-terminal.desktop DESTINATION /usr/share/applications/ diff --git a/src/main.cpp b/src/main.cpp index 1953fb2..89defb5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2026 Reion Wong // SPDX-License-Identifier: GPL-3.0-or-later -#include +#include #include #include #include @@ -19,10 +19,12 @@ #include "fonts.h" #include "windows.h" -int main(int argc, char *argv[]) +int cutefish_application_main(int argc, char *argv[]) { - QApplication app(argc, argv); - Cutefish::Application::prepare(); + Q_UNUSED(argc); + Q_UNUSED(argv); + + QGuiApplication &app = *qGuiApp; app.setWindowIcon(QIcon::fromTheme("terminal")); // Everything after -e is the command and its own options, so it is split diff --git a/src/processhelper.cpp b/src/processhelper.cpp index 4be0079..b8b27e9 100644 --- a/src/processhelper.cpp +++ b/src/processhelper.cpp @@ -4,7 +4,7 @@ #include "processhelper.h" #include "applicationlauncher.h" #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ static void callFileManager(const QString &method, const QString &path) QStringLiteral("org.freedesktop.FileManager1"), method); message << QStringList { QUrl::fromLocalFile(path).toString() } - << QString::number(QApplication::applicationPid()); + << QString::number(QCoreApplication::applicationPid()); QDBusConnection::sessionBus().asyncCall(message); } diff --git a/src/utils.cpp b/src/utils.cpp index 0d73a33..3f42104 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "utils.h" -#include #include +#include static Utils *SELF = nullptr; @@ -23,10 +23,10 @@ Utils::Utils(QObject *parent) QString Utils::text() const { - return qApp->clipboard()->text(); + return QGuiApplication::clipboard()->text(); } void Utils::setText(const QString &text) { - qApp->clipboard()->setText(text); + QGuiApplication::clipboard()->setText(text); }