Skip to content

Commit

Permalink
initial commit to support Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
AIIX committed Jan 17, 2023
1 parent 53fb4a1 commit 0a618b4
Show file tree
Hide file tree
Showing 15 changed files with 962 additions and 459 deletions.
47 changes: 25 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Set minimum CMake version (required for CMake 3.0 or later)
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.16.0)

option(BUILD_REMOTE_TTS "Build remote TTS support" OFF)
option(BUILD_PLASMA_MOBILE "Build remote TTS support" OFF)
set(QT_MIN_VERSION "5.9.0")
set(KF5_MIN_VERSION "5.50.0")

set(QT_MIN_VERSION "6.4.0")
set(KF5_MIN_VERSION "5.98.0")
set(CMAKE_CXX_STANDARD 17)

IF(POLICY CMP0048)
CMAKE_POLICY(SET CMP0048 NEW)
Expand All @@ -13,6 +15,8 @@ ENDIF(POLICY CMP0048)
PROJECT(mycroft-gui)
PROJECT(mycroft-gui VERSION "1.0.1")

find_package(Qt6 COMPONENTS Core)

# Use Extra CMake Modules (ECM) for common functionality.
# See http://api.kde.org/ecm/manual/ecm.7.html
# and http://api.kde.org/ecm/manual/ecm-kde-modules.7.html
Expand All @@ -28,7 +32,7 @@ include(KDECMakeSettings)
include(ECMInstallIcons)
set(CMAKE_AUTOMOC ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Werror")

#this is used for mycroft spawning. It's horrible and should not be needed, but mycroft packaging is questionable at best
#in any sane world mycroft would install something in $PATH
Expand All @@ -42,7 +46,7 @@ endif()
#configure_file(config-mycroft.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-mycroft.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Quick
Core
Qml
Expand All @@ -52,40 +56,39 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Multimedia
)

if (QT_MAJOR_VERSION STREQUAL "6")
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS WebEngineQuick)
else ()
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS WebEngine)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Android")
find_package(Qt5AndroidExtras ${QT_MIN_VERSION} REQUIRED)
find_package(Qt5QuickControls2 ${QT_MIN_VERSION} REQUIRED)
find_package(Qt5Svg ${QT_MIN_VERSION} REQUIRED)
find_package(Qt5TextToSpeech ${QT_MIN_VERSION} REQUIRED)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS
AndroidExtras
QuickControls2
TextToSpeech
)
find_package(OpenSSL REQUIRED)
endif()

find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
find_package(Qt5Widgets ${QT_MIN_VERSION} REQUIRED)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Widgets)
find_package(KF5Plasma ${KF5_MIN_VERSION} REQUIRED)
find_package(KF5DBusAddons ${KF5_MIN_VERSION} REQUIRED)
find_package(KF5KIO ${KF5_MIN_VERSION} REQUIRED) # FIXME look for "KIOWidgets" (KRun) explicitly
find_package(KF5KIO ${KF5_MIN_VERSION} REQUIRED)
endif()

add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)

#add_definitions(-Wno-deprecated)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060F00)

add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_USE_QSTRINGBUILDER -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII)

add_subdirectory(application)
add_subdirectory(icons)
#add_subdirectory(icons)

add_subdirectory(import)

# SSP: Disabled, now syncing with mycroft-core instance via sync_skills.sh
#
# install( DIRECTORY skills DESTINATION ${MYCROFT_CORE_DIR}/skills/ui
# PATTERN "*.qmlc" EXCLUDE
# )

configure_file(data/mycroft-gui-core-loader.in ${CMAKE_CURRENT_BINARY_DIR}/mycroft-gui-core-loader)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mycroft-gui-core-loader DESTINATION ${KDE_INSTALL_BINDIR})

Expand All @@ -96,6 +99,6 @@ configure_file(data/mycroft-gui-ptt-loader.in ${CMAKE_CURRENT_BINARY_DIR}/mycrof
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mycroft-gui-ptt-loader DESTINATION ${KDE_INSTALL_BINDIR})

if (BUILD_TESTING AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
add_subdirectory(autotests)
#add_subdirectory(autotests)
endif()

480 changes: 480 additions & 0 deletions CMakeLists.txt.user

Large diffs are not rendered by default.

41 changes: 20 additions & 21 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
PROJECT(mycroftguiapp)

include(ECMSetupVersion)

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
Expand Down Expand Up @@ -28,32 +27,32 @@ endif()

ecm_setup_version(PROJECT VERSION_HEADER version.h)

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
set(mycroft_gui_app_EXTRA_LIBS
Qt5::AndroidExtras
Qt5::QuickControls2
#NOTE: qtsvg is needed for android packaging to work
Qt5::Svg
Qt5::WebSockets
OpenSSL::SSL
Qt5::TextToSpeech
)
qt5_add_resources(mycroft_gui_app_SRC
controlsconf.qrc
)
else()
# if (CMAKE_SYSTEM_NAME STREQUAL "Android")
# set(mycroft_gui_app_EXTRA_LIBS
# Qt${QT_MAJOR_VERSION}::AndroidExtras
# Qt${QT_MAJOR_VERSION}::QuickControls2
# #NOTE: qtsvg is needed for android packaging to work
# Qt${QT_MAJOR_VERSION}::Svg
# Qt${QT_MAJOR_VERSION}::WebSockets
# OpenSSL::SSL
# Qt${QT_MAJOR_VERSION}::TextToSpeech
# )
# qt6_add_resources(mycroft_gui_app_SRC
# controlsconf.qrc
# )
# else()
set(mycroft_gui_app_EXTRA_LIBS
Qt5::Widgets
KF5::DBusAddons
)
endif()
Qt${QT_MAJOR_VERSION}::Widgets
#KF5::DBusAddons
)
# endif()

qt5_add_resources(mycroft_gui_app_SRC
qt6_add_resources(mycroft_gui_app_SRC
qml.qrc
)

add_executable(mycroft-gui-app ${mycroft_gui_app_SRC})
target_link_libraries(mycroft-gui-app Qt5::Core Qt5::Quick Qt5::WebView ${mycroft_gui_app_EXTRA_LIBS})
target_link_libraries(mycroft-gui-app Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Quick Qt${QT_MAJOR_VERSION}::WebView ${mycroft_gui_app_EXTRA_LIBS})


install(TARGETS mycroft-gui-app ${INSTALL_TARGETS_DEFAULT_ARGS})
Expand Down
9 changes: 5 additions & 4 deletions application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "keyfilter.h"
#else
#include <QApplication>
#include <KDBusService>
//#include <KDBusService>
#endif

#include "speechintent.h"
Expand All @@ -42,7 +42,7 @@

int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QStringList arguments;
for (int a = 0; a < argc; ++a) {
Expand Down Expand Up @@ -70,6 +70,8 @@ int main(int argc, char *argv[])
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
#else
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
QApplication app(argc, argv);
#endif

Expand All @@ -89,7 +91,6 @@ int main(int argc, char *argv[])
parser.showHelp();
return 0;
}

QtWebView::initialize();

QQuickView view;
Expand Down Expand Up @@ -128,7 +129,7 @@ int main(int argc, char *argv[])
#ifndef Q_OS_ANDROID
if (parser.isSet(skillOption)) {
app.setApplicationName(QStringLiteral("mycroft.gui.") + singleSkill);
KDBusService service(KDBusService::Unique);
//KDBusService service(KDBusService::Unique);
}
#endif

Expand Down
Loading

0 comments on commit 0a618b4

Please sign in to comment.