Skip to content

Commit

Permalink
Merge pull request #126 from MycroftAI/feat/qt6/api
Browse files Browse the repository at this point in the history
Port and Support QT6 API
  • Loading branch information
AIIX authored Mar 8, 2023
2 parents 0cf38d1 + 4041bcb commit abbf812
Show file tree
Hide file tree
Showing 52 changed files with 1,773 additions and 538 deletions.
51 changes: 25 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# 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(KF_MIN_VERSION "5.240.0")

IF(POLICY CMP0048)
CMAKE_POLICY(SET CMP0048 NEW)
Expand All @@ -28,7 +29,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 +43,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 +53,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
Svg
)
find_package(OpenSSL REQUIRED)
endif()

find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n)
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS I18n)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
find_package(Qt5Widgets ${QT_MIN_VERSION} REQUIRED)
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(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Widgets)
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 DBusAddons)
# find_package(KF5Plasma ${KF5_MIN_VERSION} REQUIRED)
# 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(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 +96,5 @@ 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()

10 changes: 5 additions & 5 deletions application/AboutPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*
*/

import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.11 as Kirigami
import Mycroft 1.0 as Mycroft
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as Controls
import org.kde.kirigami 2.19 as Kirigami
import Mycroft 1.0 as Mycroft

Kirigami.ScrollablePage {
title: "About"
Expand Down
46 changes: 23 additions & 23 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,39 +27,40 @@ 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
KF6::DBusAddons
)
# endif()

qt5_add_resources(mycroft_gui_app_SRC
qt_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})
install( PROGRAMS ai.mycroft.gui-app.desktop DESTINATION ${KDE_INSTALL_APPDIR} )
install(PROGRAMS ai.mycroft.gui-app.desktop DESTINATION ${KDE_INSTALL_APPDIR})

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
find_package(KF5Kirigami2 REQUIRED)
find_package(KF6Kirigami2 REQUIRED)
kirigami_package_breeze_icons(ICONS help-hint configure media-playback-pause media-playback-start media-seek-forward media-seek-backward audio-input-microphone help-about)
endif()

Expand Down
10 changes: 5 additions & 5 deletions application/HintsDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*
*/

import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.11 as Kirigami
import QtGraphicalEffects 1.0
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as Controls
import org.kde.kirigami 2.19 as Kirigami
import Mycroft 1.0 as Mycroft
import Qt5Compat.GraphicalEffects

Kirigami.AbstractCard {
id: skillDelegate
Expand Down
10 changes: 5 additions & 5 deletions application/HintsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*
*/

import QtQuick 2.9
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12 as QQC2
import org.kde.kirigami 2.11 as Kirigami
import QtGraphicalEffects 1.0
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.19 as Kirigami
import Mycroft 1.0 as Mycroft
import Qt5Compat.GraphicalEffects

Kirigami.Page {
title: "Hints"
Expand Down
8 changes: 5 additions & 3 deletions application/Idler.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
*/

import QtQuick 2.4
import QtQuick.Controls 2.11
import QtQuick 2.15
import QtQuick.Controls 2.15
import Mycroft 1.0 as Mycroft

/* Class used to simulate the homescreen in cases where we're not using minimal shell
Expand All @@ -29,7 +29,9 @@ Item {
anchors.centerIn: parent
text: "start"
visible: Mycroft.MycroftController.status == Mycroft.MycroftController.Closed
onClicked: Mycroft.MycroftController.start();
onClicked: (mouse)=> {
Mycroft.MycroftController.start();
}
}

ClockFace {
Expand Down
17 changes: 10 additions & 7 deletions application/RemoteStt.qml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import org.kde.kirigami 2.11 as Kirigami
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.19 as Kirigami
import Mycroft 1.0 as Mycroft
import Qt5Compat.GraphicalEffects

Item {
id: root
Expand Down Expand Up @@ -31,11 +32,11 @@ Item {
Connections {
target: Mycroft.AudioRec

onMicAudioLevelChanged: {
function onMicAudioLevelChanged(micLevel) {
animatedCircle.width = Kirigami.Units.iconSizes.large + (Kirigami.Units.iconSizes.smallMedium * micLevel)
}

onRecordTStatus: {
function onRecordTStatus(recStatus) {
switch(recStatus){
case "Completed":
console.log("In Completed")
Expand Down Expand Up @@ -163,7 +164,9 @@ Item {

MouseArea {
anchors.fill: parent
onClicked: audioRecorder.close()
onClicked: (mouse)=> {
audioRecorder.close()
}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions application/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*
*/

import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.11 as Kirigami
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as Controls
import org.kde.kirigami 2.19 as Kirigami
import Mycroft 1.0 as Mycroft

Kirigami.ScrollablePage {
Expand Down Expand Up @@ -50,7 +50,7 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
}

Controls.Control{
Controls.Control {
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
leftPadding: Kirigami.Units.largeSpacing
Expand All @@ -66,7 +66,7 @@ Kirigami.ScrollablePage {
id: webSocketAddressField
Kirigami.Theme.colorSet: nightSwitch.checked ? Kirigami.Theme.Complementary : Kirigami.Theme.Window

Component.onCompleted:{
Component.onCompleted: {
webSocketAddressField.text = Mycroft.GlobalSettings.webSocketAddress
}
}
Expand All @@ -83,7 +83,7 @@ Kirigami.ScrollablePage {
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
text: "Apply"

onClicked:{
onClicked:(mouse)=> {
Mycroft.GlobalSettings.webSocketAddress = webSocketAddressField.text
Mycroft.MycroftController.reconnect()
}
Expand All @@ -96,7 +96,7 @@ Kirigami.ScrollablePage {
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
text: "Revert"

onClicked: {
onClicked:(mouse)=> {
webSocketAddressField.text = "ws://0.0.0.0"
Mycroft.GlobalSettings.webSocketAddress = webSocketAddressField.text
Mycroft.MycroftController.reconnect()
Expand Down
6 changes: 4 additions & 2 deletions application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 All @@ -67,6 +67,9 @@ int main(int argc, char *argv[])

qputenv("QT_WAYLAND_FORCE_DPI", parser.value(dpiOption).toLatin1());

QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);

#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
#else
Expand All @@ -89,7 +92,6 @@ int main(int argc, char *argv[])
parser.showHelp();
return 0;
}

QtWebView::initialize();

QQuickView view;
Expand Down
Loading

0 comments on commit abbf812

Please sign in to comment.