diff --git a/gpt4all-chat/CHANGELOG.md b/gpt4all-chat/CHANGELOG.md index def1c479db30..a6e722d38ac6 100644 --- a/gpt4all-chat/CHANGELOG.md +++ b/gpt4all-chat/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [Unreleased] + +### Changed +- Implement Qt 6.8 compatibility ([#3121](https://github.com/nomic-ai/gpt4all/pull/3121)) + ## [3.4.2] - 2024-10-16 ### Fixed @@ -164,6 +169,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Fix several Vulkan resource management issues ([#2694](https://github.com/nomic-ai/gpt4all/pull/2694)) - Fix crash/hang when some models stop generating, by showing special tokens ([#2701](https://github.com/nomic-ai/gpt4all/pull/2701)) +[Unreleased]: https://github.com/nomic-ai/gpt4all/compare/v3.4.2...HEAD [3.4.2]: https://github.com/nomic-ai/gpt4all/compare/v3.4.1...v3.4.2 [3.4.1]: https://github.com/nomic-ai/gpt4all/compare/v3.4.0...v3.4.1 [3.4.0]: https://github.com/nomic-ai/gpt4all/compare/v3.3.0...v3.4.0 diff --git a/gpt4all-chat/CMakeLists.txt b/gpt4all-chat/CMakeLists.txt index 0950774a0fa2..57d05031e21f 100644 --- a/gpt4all-chat/CMakeLists.txt +++ b/gpt4all-chat/CMakeLists.txt @@ -77,6 +77,10 @@ configure_file( find_package(Qt6 6.4 COMPONENTS Core HttpServer LinguistTools Pdf Quick QuickDialogs2 Sql Svg REQUIRED) +if (QT_KNOWN_POLICY_QTP0004) + qt_policy(SET QTP0004 NEW) # generate extra qmldir files on Qt 6.8+ +endif() + # Get the Qt6Core target properties get_target_property(Qt6Core_INCLUDE_DIRS Qt6::Core INTERFACE_INCLUDE_DIRECTORIES) get_target_property(Qt6Core_LIBRARY_RELEASE Qt6::Core LOCATION_RELEASE) diff --git a/gpt4all-chat/qml/MySettingsStack.qml b/gpt4all-chat/qml/MySettingsStack.qml index 9f0273ef689a..17901325aba6 100644 --- a/gpt4all-chat/qml/MySettingsStack.qml +++ b/gpt4all-chat/qml/MySettingsStack.qml @@ -2,6 +2,7 @@ import QtCore import QtQuick import QtQuick.Controls import QtQuick.Controls.Basic +import QtQuick.Controls.impl import QtQuick.Layouts import QtQuick.Dialogs import Qt.labs.folderlistmodel diff --git a/gpt4all-chat/src/server.cpp b/gpt4all-chat/src/server.cpp index b02d59d47ddc..577859a3266b 100644 --- a/gpt4all-chat/src/server.cpp +++ b/gpt4all-chat/src/server.cpp @@ -37,6 +37,10 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +# include +#endif + using namespace std::string_literals; using namespace Qt::Literals::StringLiterals; @@ -435,7 +439,6 @@ T &parseRequest(T &request, QJsonObject &&obj) Server::Server(Chat *chat) : ChatLLM(chat, true /*isServer*/) , m_chat(chat) - , m_server(nullptr) { connect(this, &Server::threadStarted, this, &Server::start); connect(this, &Server::databaseResultsChanged, this, &Server::handleDatabaseResultsChanged); @@ -457,10 +460,23 @@ static QJsonObject requestFromJson(const QByteArray &request) void Server::start() { m_server = std::make_unique(this); - if (!m_server->listen(QHostAddress::LocalHost, MySettings::globalInstance()->networkPort())) { - qWarning() << "ERROR: Unable to start the server"; +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + auto *tcpServer = new QTcpServer(m_server.get()); +#else + auto *tcpServer = m_server.get(); +#endif + + auto port = MySettings::globalInstance()->networkPort(); + if (!tcpServer->listen(QHostAddress::LocalHost, port)) { + qWarning() << "Server ERROR: Failed to listen on port" << port; return; } +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + if (!m_server->bind(tcpServer)) { + qWarning() << "Server ERROR: Failed to HTTP server to socket" << port; + return; + } +#endif m_server->route("/v1/models", QHttpServerRequest::Method::Get, [](const QHttpServerRequest &) { @@ -600,10 +616,19 @@ void Server::start() } ); - m_server->afterRequest([] (QHttpServerResponse &&resp) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + m_server->addAfterRequestHandler(this, [](const QHttpServerRequest &req, QHttpServerResponse &resp) { + Q_UNUSED(req); + auto headers = resp.headers(); + headers.append("Access-Control-Allow-Origin"_L1, "*"_L1); + resp.setHeaders(std::move(headers)); + }); +#else + m_server->afterRequest([](QHttpServerResponse &&resp) { resp.addHeader("Access-Control-Allow-Origin", "*"); return std::move(resp); }); +#endif connect(this, &Server::requestServerNewPromptResponsePair, m_chat, &Chat::serverNewPromptResponsePair, Qt::BlockingQueuedConnection);