From 6ed5477dbd23d51f082f4d752bb099d0a3b1677c Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Fri, 10 Jun 2022 07:10:00 +0200 Subject: [PATCH] macOS: Add M1/arm64 support Closes #1884 --- .github/workflows/build-macos.yml | 17 +++- CMakePresets.json | 57 +++++++++++-- docs/build-source-code.rst | 12 +-- src/CMakeLists.txt | 84 +++++-------------- src/copyq.qrc | 1 + src/gui/actiondialog.cpp | 3 + src/gui/mainwindow.cpp | 48 +++-------- src/gui/windowgeometryguard.cpp | 20 ++++- src/gui/windowgeometryguard.h | 5 +- src/platform/mac/copyqpasteboardmime.h | 34 +++++--- src/platform/mac/copyqpasteboardmime.mm | 31 +++++-- src/platform/mac/macclipboard.mm | 19 ++++- src/platform/mac/macplatform.cmake | 5 +- src/platform/mac/macplatform.mm | 12 +-- src/platform/mac/urlpasteboardmime.h | 38 ++++++--- src/platform/mac/urlpasteboardmime.mm | 51 +++++++---- src/scriptable/scriptableproxy.cpp | 31 +++---- src/tests/tests.cpp | 6 ++ utils/github/bundle-macos.sh | 19 ++--- .../homebrew/Formula/extra-cmake-modules.rb | 6 +- .../homebrew/Formula/kf5-kcoreaddons.rb | 36 -------- .../homebrew/Formula/kf5-knotifications.rb | 40 --------- .../{kf5-kconfig.rb => kf6-kconfig.rb} | 16 ++-- .../homebrew/Formula/kf6-knotifications.rb | 38 +++++++++ .../Formula/kf6-kstatusnotifieritem.rb | 38 +++++++++ ...-kwindowsystem.rb => kf6-kwindowsystem.rb} | 16 ++-- utils/github/install-macos.sh | 2 +- 27 files changed, 382 insertions(+), 303 deletions(-) delete mode 100644 utils/github/homebrew/Formula/kf5-kcoreaddons.rb delete mode 100644 utils/github/homebrew/Formula/kf5-knotifications.rb rename utils/github/homebrew/Formula/{kf5-kconfig.rb => kf6-kconfig.rb} (61%) create mode 100644 utils/github/homebrew/Formula/kf6-knotifications.rb create mode 100644 utils/github/homebrew/Formula/kf6-kstatusnotifieritem.rb rename utils/github/homebrew/Formula/{kf5-kwindowsystem.rb => kf6-kwindowsystem.rb} (59%) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 65575bc4b5..72961b4447 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -15,6 +15,14 @@ jobs: - os: macos-12 buildname: macOS 10.15 create_bundle: true + bundle_suffix: '-macos-10' + cmake_preset: macOS-10 + + - os: macos-14 + buildname: macOS 12 M1 + create_bundle: true + bundle_suffix: '-macos-12-m1' + cmake_preset: macOS-12-m1 steps: - name: Checkout source code @@ -42,20 +50,21 @@ jobs: - name: Build with CMake uses: lukka/run-cmake@v10 with: - configurePreset: macOS - buildPreset: macOS + configurePreset: '${{ matrix.cmake_preset }}' + buildPreset: '${{ matrix.cmake_preset }}' + packagePreset: '${{ matrix.cmake_preset }}' - name: Create gnupg directory for tests run: mkdir -p ~/.gnupg && chmod go-rwx ~/.gnupg - name: Create macOS bundle if: matrix.create_bundle - working-directory: '${{runner.workspace}}/build' + working-directory: '${{runner.workspace}}/install' run: '${{github.workspace}}/utils/github/bundle-macos.sh' - name: Upload macOS bundle if: matrix.create_bundle uses: actions/upload-artifact@v4 with: - name: CopyQ.dmg + name: 'CopyQ${{ matrix.bundle_suffix }}.dmg' path: '${{runner.workspace}}/build/CopyQ.dmg' diff --git a/CMakePresets.json b/CMakePresets.json index c469af786c..40065b5b4e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,5 +1,5 @@ { - "version": 3, + "version": 6, "configurePresets": [ { "name": "Debug", @@ -14,32 +14,75 @@ } }, { - "name": "macOS", + "name": "macOS-10", "generator": "Ninja", "binaryDir": "${sourceParentDir}/build", - "installDir": "${sourceParentDir}/build", + "installDir": "${sourceParentDir}/install", "cacheVariables": { + "WITH_QT6": "TRUE", "WITH_TESTS": "TRUE", - "CMAKE_PREFIX_PATH": "/usr/local/opt/qt@5/lib/cmake", + "CMAKE_PREFIX_PATH": "/usr/local/opt/qt/lib/cmake", "CMAKE_OSX_DEPLOYMENT_TARGET": "10.15", "CMAKE_C_COMPILER_LAUNCHER": "ccache", "CMAKE_CXX_COMPILER_LAUNCHER": "ccache", "CMAKE_CXX_FLAGS": "-Wno-deprecated-declarations" } + }, + { + "name": "macOS-12-m1", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build", + "installDir": "${sourceParentDir}/install", + "cacheVariables": { + "WITH_QT6": "TRUE", + "WITH_TESTS": "TRUE", + "CMAKE_PREFIX_PATH": "/usr/local/opt/qt/lib/cmake", + "CMAKE_OSX_DEPLOYMENT_TARGET": "12", + "CMAKE_OSX_ARCHITECTURES": "arm64", + "CMAKE_C_COMPILER_LAUNCHER": "ccache", + "CMAKE_CXX_COMPILER_LAUNCHER": "ccache", + "CMAKE_CXX_FLAGS": "-Wno-deprecated-declarations" + } } ], "buildPresets": [ + { + "name": "macOS", + "configuration": "Release", + "targets": "install" + }, { "name": "Debug", "configurePreset": "Debug", "configuration": "Debug", "targets": "install" }, + { + "name": "macOS-10", + "inherits": ["macOS"], + "configurePreset": "macOS-10" + }, + { + "name": "macOS-12-m1", + "inherits": ["macOS"], + "configurePreset": "macOS-12-m1" + } + ], + "packagePresets": [ { "name": "macOS", - "configurePreset": "macOS", - "configuration": "Release", - "targets": "install" + "packageDirectory": "${sourceParentDir}/install", + "generators": ["DragNDrop"] + }, + { + "name": "macOS-10", + "inherits": ["macOS"], + "configurePreset": "macOS-10" + }, + { + "name": "macOS-12-m1", + "inherits": ["macOS"], + "configurePreset": "macOS-12-m1" } ] } diff --git a/docs/build-source-code.rst b/docs/build-source-code.rst index a3c7adc1f6..498e28d893 100644 --- a/docs/build-source-code.rst +++ b/docs/build-source-code.rst @@ -158,7 +158,7 @@ On OS X, required Qt 5 libraries and utilities can be easily installed with `Hom # brew untap --force copyq/kde # and re-run the above "brew tap" command - brew install qt5 copyq/kde/kf5-knotifications + brew install qt6 copyq/kde/kf6-knotifications copyq/kde/kf6-kstatusnotifieritem Build with the following commands: @@ -166,15 +166,7 @@ Build with the following commands: cmake -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)" . cmake --build . - cmake --install . - macdeployqt CopyQ.app -dmg -verbose=2 -always-overwrite \ - -executable=CopyQ.app/Contents/PlugIns/copyq/libitemfakevim.so \ - -executable=CopyQ.app/Contents/PlugIns/copyq/libitemimage.so \ - -executable=CopyQ.app/Contents/PlugIns/copyq/libitemnotes.so \ - -executable=CopyQ.app/Contents/PlugIns/copyq/libitempinned.so \ - -executable=CopyQ.app/Contents/PlugIns/copyq/libitemsync.so \ - -executable=CopyQ.app/Contents/PlugIns/copyq/libitemtags.so \ - -executable=CopyQ.app/Contents/PlugIns/copyq/libitemtext.so + cpack This will produce a self-contained application bundle ``CopyQ.app`` which can then be copied or moved into ``/Applications``. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 611fa056f9..c8eea6f1a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,11 +86,9 @@ endif() if (NOT APPLE) add_executable(${COPYQ_EXECUTABLE_NAME} ${copyq_COMPILE}) else() - # On Macs we must ensure Carbon and Cocoa are linked - FIND_LIBRARY(CARBON_LIBRARY "Carbon") - FIND_LIBRARY(COCOA_LIBRARY "Cocoa") - MARK_AS_ADVANCED (CARBON_LIBRARY - COCOA_LIBRARY) + FIND_LIBRARY(CARBON_LIBRARY Carbon REQUIRED) + FIND_LIBRARY(COCOA_LIBRARY Cocoa REQUIRED) + MARK_AS_ADVANCED(CARBON_LIBRARY COCOA_LIBRARY) list(APPEND copyq_LIBRARIES "${CARBON_LIBRARY}" "${COCOA_LIBRARY}") set(COPYQ_VERSION_REGEX "^([0-9]+)\.([0-9]+)\.(.*)$") @@ -158,64 +156,24 @@ if (NOT APPLE) else() set_source_files_properties(${copyq_QM} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/translations") + set_target_properties(${COPYQ_EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE TRUE) set_target_properties(${COPYQ_EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/../shared/Info.plist") - set(plugin_dest_dir "${COPYQ_EXECUTABLE_NAME}.app/Contents/PlugIns") - set(qtconf_dest_dir "${COPYQ_EXECUTABLE_NAME}.app/Contents/Resources") - - macro(install_qt_plugin _qt_plugin_name _qt_plugins_var) - get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION) - if(EXISTS "${_qt_plugin_path}") - get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME) - get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH) - get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME) - set(_qt_plugin_dest "${plugin_dest_dir}/${_qt_plugin_type}") - install(FILES "${_qt_plugin_path}" DESTINATION "${_qt_plugin_dest}" COMPONENT Runtime) - set(${_qt_plugins_var} - "${${_qt_plugins_var}};\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_qt_plugin_dest}/${_qt_plugin_file}") - else() - message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found") - endif() - endmacro() - - # Install needed Qt plugins - foreach(_copyq_qt_module ${copyq_qt_modules} "Gui" "Widgets") - set(_module_plugins "${${copyq_qt}${_copyq_qt_module}_PLUGINS}") - foreach(_plugin ${_module_plugins}) - install_qt_plugin("${_plugin}" FIXUP_BUNDLE_QT_PLUGINS) - endforeach() - endforeach() - - # install a qt.conf file - # this inserts some cmake code into the install script to write the file - install(CODE " - file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]\nPlugins = PlugIns\nImports = Resources/qml\nQml2Imports = Resources/qml\n\") - " - COMPONENT Runtime - ) - - # FIXME: Disable cpack for now due to unresolvable libraries: - # https://github.com/Homebrew/homebrew-core/issues/140930 - # set(FIXUP_BUNDLE_APPS "\${CMAKE_INSTALL_PREFIX}/${COPYQ_EXECUTABLE_NAME}.app") - # - # get_property(_copyq_installed_plugins GLOBAL PROPERTY COPYQ_INSTALLED_PLUGINS) - # - # # Directories to look for dependencies - # set(FIXUP_BUNDLE_DEP_DIRS "${CMAKE_BINARY_DIR};${QT_LIBRARY_DIRS};${QT_PLUGINS_DIR}/iconengines;${QT_PLUGINS_DIR}/imageformats;${QT_PLUGINS_DIR}/platforms;${QT_PLUGINS_DIR}/tls;${${copyq_qt}Widgets_DIR}/../..") - # - # message(STATUS "Fixup app: ${FIXUP_BUNDLE_APPS}") - # message(STATUS "Fixup app plugins: ${_copyq_installed_plugins}") - # message(STATUS "Fixup qt plugins: ${FIXUP_BUNDLE_QT_PLUGINS}") - # message(STATUS "Fixup dirs: ${FIXUP_BUNDLE_DEP_DIRS}") - # install(CODE " - # include(BundleUtilities) - # set(BU_CHMOD_BUNDLE_ITEMS ON) - # fixup_bundle(\"${FIXUP_BUNDLE_APPS}\" \"${FIXUP_BUNDLE_QT_PLUGINS};${_copyq_installed_plugins}\" \"${FIXUP_BUNDLE_DEP_DIRS}\") - # verify_app(\"${FIXUP_BUNDLE_APPS}\") - # " - # COMPONENT Runtime - # ) - # - # set(CPACK_GENERATOR "DragNDrop") - # include(CPack) + set(BUNDLE "\${CMAKE_INSTALL_PREFIX}/${COPYQ_EXECUTABLE_NAME}.app") + + # https://doc.qt.io/qt-6/qt-deploy-runtime-dependencies.html + # Generate a deployment script to be executed at install time + qt_generate_deploy_script( + TARGET ${COPYQ_EXECUTABLE_NAME} + OUTPUT_SCRIPT deploy_script + CONTENT " +qt_deploy_runtime_dependencies( + EXECUTABLE \"${BUNDLE}\" + GENERATE_QT_CONF + VERBOSE +)") + install(SCRIPT ${deploy_script}) + + set(CPACK_GENERATOR "DragNDrop") + include(CPack) endif() diff --git a/src/copyq.qrc b/src/copyq.qrc index 825fcc48b8..2fc8a74599 100644 --- a/src/copyq.qrc +++ b/src/copyq.qrc @@ -8,5 +8,6 @@ images/tab_remove.svg images/icon_512x512.png images/fontawesome.ttf + knotifications5/copyq.notifyrc diff --git a/src/gui/actiondialog.cpp b/src/gui/actiondialog.cpp index 7a29ed91ad..c31c621053 100644 --- a/src/gui/actiondialog.cpp +++ b/src/gui/actiondialog.cpp @@ -55,6 +55,9 @@ ActionDialog::ActionDialog(QWidget *parent) { ui->setupUi(this); + // WORKAROUND for broken initial focus in Qt 6.6 (QTBUG-121514) + ui->comboBoxCommands->setFocus(); + auto shortcut = new QShortcut(QKeySequence(Qt::ControlModifier | Qt::Key_P), this); connect(shortcut, &QShortcut::activated, this, &ActionDialog::previousCommand); shortcut = new QShortcut(QKeySequence(Qt::ControlModifier | Qt::Key_N), this); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index c0505f5bf1..32b14b91c3 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -174,14 +174,6 @@ bool canExecuteCommand(const Command &command, const QVariantMap &data, const QS return true; } -void stealFocus(const QWidget &window) -{ - WId wid = window.winId(); - PlatformWindowPtr platformWindow = platformNativeInterface()->getWindow(wid); - if (platformWindow) - platformWindow->raise(); -} - template void disableActionWhenTabGroupSelected(WidgetOrAction *action, MainWindow *window) { @@ -274,38 +266,34 @@ QMenu *createSubMenus(QString *name, QMenu *menu) // WORKAROUND: setWindowFlags() hides the window. // See: https://doc.qt.io/qt-5/qwidget.html#windowFlags-prop -bool setWindowFlag(QWidget *window, Qt::WindowType flag, bool enable) +void setWindowFlag(QPointer window, Qt::WindowType flag, bool enable) { if (!window) - return false; + return; const Qt::WindowFlags flags = window->windowFlags(); const bool wasEnabled = flags.testFlag(flag); if (wasEnabled == enable) - return false; + return; const bool wasVisible = window->isVisible(); const bool wasActive = window->isActiveWindow(); + window->setWindowFlags(flags ^ flag); + if (wasVisible) { if (wasActive) { window->show(); + window->activateWindow(); + QApplication::setActiveWindow(window); + raiseWindow(window); } else { const bool showWithoutActivating = window->testAttribute(Qt::WA_ShowWithoutActivating); window->setAttribute(Qt::WA_ShowWithoutActivating); window->show(); window->setAttribute(Qt::WA_ShowWithoutActivating, showWithoutActivating); } - - if (wasActive) { - window->raise(); - window->activateWindow(); - QApplication::setActiveWindow(window); - stealFocus(*window); - } } - - return true; } void setAlwaysOnTop(QWidget *window, bool alwaysOnTop) @@ -598,8 +586,8 @@ MainWindow::MainWindow(const ClipboardBrowserSharedPtr &sharedData, QWidget *par m_sharedData->menuItems = menuItems(); -#ifdef Q_OS_MAC - // Open above fullscreen windows on OS X. +#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + // Open above fullscreen windows on macOS and Qt 5. setWindowModality(Qt::WindowModal); setWindowFlag(Qt::Sheet); #endif @@ -1954,13 +1942,7 @@ bool MainWindow::toggleMenu(TrayMenu *menu, QPoint pos) } menu->popup( toScreen(pos, menu) ); - - menu->raise(); - menu->activateWindow(); - QApplication::setActiveWindow(menu); - QApplication::processEvents(); - stealFocus(*menu); - + raiseWindow(menu); return true; } @@ -2899,8 +2881,6 @@ void MainWindow::showWindow() showMaximized(); else showNormal(); - raise(); - activateWindow(); auto c = browser(); if (c) { @@ -2909,9 +2889,7 @@ void MainWindow::showWindow() c->setFocus(); } - QApplication::setActiveWindow(this); - - stealFocus(*this); + raiseWindow(this); } void MainWindow::hideWindow() @@ -3707,7 +3685,7 @@ ActionDialog *MainWindow::openActionDialog(const QVariantMap &data) connect( actionDialog, &ActionDialog::commandAccepted, this, &MainWindow::onActionDialogAccepted ); - stealFocus(*actionDialog); + raiseWindow(actionDialog); return actionDialog; } diff --git a/src/gui/windowgeometryguard.cpp b/src/gui/windowgeometryguard.cpp index a39ee11a5a..c681053032 100644 --- a/src/gui/windowgeometryguard.cpp +++ b/src/gui/windowgeometryguard.cpp @@ -3,17 +3,19 @@ #include "windowgeometryguard.h" #include "common/appconfig.h" -#include "common/common.h" #include "common/config.h" #include "common/log.h" #include "common/timer.h" #include "gui/screen.h" +#include "platform/platformnativeinterface.h" +#include "platform/platformwindow.h" #include #include #include #include #include +#include #include namespace { @@ -51,6 +53,22 @@ QScreen *currentScreen() } // namespace +void raiseWindow(QWidget *window) +{ + window->raise(); + if (qApp->applicationState() == Qt::ApplicationActive) + return; + + window->activateWindow(); + QApplication::setActiveWindow(window); + QTimer::singleShot(0, window, [window]{ + const auto wid = window->winId(); + const auto platformWindow = platformNativeInterface()->getWindow(wid); + if (platformWindow) + platformWindow->raise(); + }); +} + void WindowGeometryGuard::create(QWidget *window) { static const bool enabled = isRestoreGeometryEnabled(); diff --git a/src/gui/windowgeometryguard.h b/src/gui/windowgeometryguard.h index c3604bd384..89357b3155 100644 --- a/src/gui/windowgeometryguard.h +++ b/src/gui/windowgeometryguard.h @@ -3,9 +3,12 @@ #define WINDOWGEOMETRYGUARD_H #include -#include #include +class QWidget; + +void raiseWindow(QWidget *window); + class WindowGeometryGuard final : public QObject { public: diff --git a/src/platform/mac/copyqpasteboardmime.h b/src/platform/mac/copyqpasteboardmime.h index 6321e9c0f1..d6022be3f1 100644 --- a/src/platform/mac/copyqpasteboardmime.h +++ b/src/platform/mac/copyqpasteboardmime.h @@ -1,9 +1,15 @@ // SPDX-License-Identifier: GPL-3.0-or-later +#pragma once -#ifndef MACMIME_H -#define MACMIME_H +#include -#include +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +# include +using CopyqPasteboardMimeBase = QUtiMimeConverter; +#else +# include +using CopyqPasteboardMimeBase = QMacPasteboardMime; +#endif /** * Class for doing lossless conversions between OS X UTIs and "normal" mimeTypes. @@ -19,16 +25,20 @@ * - https://www.qt.gitorious.org/qt/qt/source/src/gui/kernel/qclipboard_mac.cpp */ -class CopyQPasteboardMime final : public QMacPasteboardMime { +class CopyQPasteboardMime final : public CopyqPasteboardMimeBase { public: - CopyQPasteboardMime() : QMacPasteboardMime(MIME_ALL) { } +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + QString mimeForUti(const QString &uti) const override; + QString utiForMime(const QString &mime) const override; + QVariant convertToMime(const QString &mime, const QList &data, const QString &uti) const override; + QList convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override; +#else + CopyQPasteboardMime() : CopyqPasteboardMimeBase(MIME_ALL) {} QString convertorName() override; - QString flavorFor(const QString &mime) override; - QString mimeFor(QString flav) override; - bool canConvert(const QString &mime, QString flav) override; - QVariant convertToMime(const QString &mime, QList data, QString flav) override; - QList convertFromMime(const QString &mime, QVariant data, QString flav) override; + QString mimeFor(QString uti) override; + bool canConvert(const QString &mime, QString uti) override; + QVariant convertToMime(const QString &mime, QList data, QString uti) override; + QList convertFromMime(const QString &mime, QVariant data, QString uti) override; +#endif }; - -#endif // MACMIME_H diff --git a/src/platform/mac/copyqpasteboardmime.mm b/src/platform/mac/copyqpasteboardmime.mm index 25f5bea1ee..63d0881317 100644 --- a/src/platform/mac/copyqpasteboardmime.mm +++ b/src/platform/mac/copyqpasteboardmime.mm @@ -7,6 +7,7 @@ #include #include +#include #import @@ -55,12 +56,18 @@ QString convertUtiOrMime(const QString &in, CFStringRef (*convert)(CFStringRef)) } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QString CopyQPasteboardMime::convertorName() { return QLatin1String("CopyQ"); } +#endif +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QString CopyQPasteboardMime::utiForMime(const QString &mime) const +#else QString CopyQPasteboardMime::flavorFor(const QString &mime) +#endif { if (shouldIgnoreMime(mime)) { return QString(); @@ -78,7 +85,11 @@ QString convertUtiOrMime(const QString &in, CFStringRef (*convert)(CFStringRef)) return QString(); } +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QString CopyQPasteboardMime::mimeForUti(const QString &uti) const +#else QString CopyQPasteboardMime::mimeFor(QString uti) +#endif { if (shouldIgnoreUTI(uti)) { return QString(); @@ -97,6 +108,7 @@ QString convertUtiOrMime(const QString &in, CFStringRef (*convert)(CFStringRef)) return COPYQ_MIME_PREFIX + uti; } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) bool CopyQPasteboardMime::canConvert(const QString &mime, QString uti) { if (uti.isEmpty() || mime.isEmpty()) @@ -120,9 +132,13 @@ QString convertUtiOrMime(const QString &in, CFStringRef (*convert)(CFStringRef)) return (convMime == mime); } +#endif - +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QVariant CopyQPasteboardMime::convertToMime(const QString &mime, const QList &data, const QString &uti) const +#else QVariant CopyQPasteboardMime::convertToMime(const QString &mime, QList data, QString uti) +#endif { if (!canConvert(mime, uti)) { return QVariant(); @@ -139,20 +155,23 @@ QString convertUtiOrMime(const QString &in, CFStringRef (*convert)(CFStringRef)) } } -QList CopyQPasteboardMime::convertFromMime(const QString &mime, QVariant variant, - QString uti) +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QList CopyQPasteboardMime::convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const +#else +QList CopyQPasteboardMime::convertFromMime(const QString &mime, QVariant data, QString uti) +#endif { if (!canConvert(mime, uti)) { return QList(); } QList ret; - if (variant.userType() == QMetaType::QByteArray) { + if (data.userType() == QMetaType::QByteArray) { // Was a single item - ret << variant.toByteArray(); + ret << data.toByteArray(); } else { // Was a list or null - QVariantList inp = variant.toList(); + QVariantList inp = data.toList(); foreach(const QVariant &item, inp) { ret << item.toByteArray(); } diff --git a/src/platform/mac/macclipboard.mm b/src/platform/mac/macclipboard.mm index d7bf822e60..c0ebba6862 100644 --- a/src/platform/mac/macclipboard.mm +++ b/src/platform/mac/macclipboard.mm @@ -11,7 +11,12 @@ #include #include #include -#include + +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +# include +#else +# include +#endif #include "mactimer.h" @@ -41,15 +46,21 @@ // This converts text to UTF-16 without BOM. const auto text = getTextData(dataMap); if ( !text.isEmpty() ) { - auto codec = QTextCodec::codecForName("UTF-16"); +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + auto encoder = QStringEncoder(QStringConverter::Utf16); + const QByteArray data = encoder.encode(text); + dataMapForMac[QStringLiteral("public.utf16-plain-text")] = data; +#else + auto codec = QTextCodec::codecForName(QStringLiteral("UTF-16")); Q_ASSERT(codec != nullptr); if (codec) { auto encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); - dataMapForMac["public.utf16-plain-text"] = encoder->fromUnicode(text); + dataMapForMac[QStringLiteral("public.utf16-plain-text")] = encoder->fromUnicode(text); } +#endif } - return DummyClipboard::setData(mode, dataMapForMac); + DummyClipboard::setData(mode, dataMapForMac); } bool MacClipboard::isHidden(const QMimeData &data) const diff --git a/src/platform/mac/macplatform.cmake b/src/platform/mac/macplatform.cmake index 37b1dfdfd7..fef85cc26c 100644 --- a/src/platform/mac/macplatform.cmake +++ b/src/platform/mac/macplatform.cmake @@ -1,5 +1,4 @@ file(GLOB copyq_SOURCES ${copyq_SOURCES} - platform/mac/*.cpp platform/mac/*.mm platform/dummy/dummyclipboard.cpp platform/platformcommon.cpp @@ -8,4 +7,6 @@ file(GLOB copyq_SOURCES ${copyq_SOURCES} set(USE_QXT TRUE) -list(APPEND copyq_qt_modules MacExtras) +if (NOT WITH_QT6) + list(APPEND copyq_qt_modules MacExtras) +endif() diff --git a/src/platform/mac/macplatform.mm b/src/platform/mac/macplatform.mm index 0a233e5ecc..e2b5b5147d 100644 --- a/src/platform/mac/macplatform.mm +++ b/src/platform/mac/macplatform.mm @@ -208,19 +208,13 @@ QString absoluteResourcesePath(const QString &path) { pluginsDir->setPath( qApp->applicationDirPath() ); if (pluginsDir->dirName() != "MacOS") { - if ( pluginsDir->cd("plugins")) { - COPYQ_LOG("Found plugins in build tree"); - return true; - } - return false; + return pluginsDir->cd("plugins"); } if ( pluginsDir->cdUp() // Contents && pluginsDir->cd("PlugIns") && pluginsDir->cd("copyq")) { - // OK, found it in the bundle - COPYQ_LOG("Found plugins in application bundle"); return true; } @@ -229,8 +223,8 @@ QString absoluteResourcesePath(const QString &path) if ( pluginsDir->cdUp() // Contents && pluginsDir->cdUp() // copyq.app && pluginsDir->cdUp() // repo root - && pluginsDir->cd("plugins")) { - COPYQ_LOG("Found plugins in build tree"); + && pluginsDir->cd("plugins")) + { return true; } diff --git a/src/platform/mac/urlpasteboardmime.h b/src/platform/mac/urlpasteboardmime.h index 8fdff1cca0..ae4edd2cfe 100644 --- a/src/platform/mac/urlpasteboardmime.h +++ b/src/platform/mac/urlpasteboardmime.h @@ -1,25 +1,37 @@ // SPDX-License-Identifier: GPL-3.0-or-later +#pragma once -#ifndef URLPASTEBOARDMIME_H -#define URLPASTEBOARDMIME_H +#include -#include +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +# include +using UrlPasteboardMimeBase = QUtiMimeConverter; +#else +# include +using UrlPasteboardMimeBase = QMacPasteboardMime; +#endif /** * Class for doing conversions of URLs between OS X UTIs and "normal" mimeTypes. */ -class UrlPasteboardMime final : public QMacPasteboardMime { +class UrlPasteboardMime final : public UrlPasteboardMimeBase { public: //! Create an instance of UrlPasteboardMime which will try to convert to/from the given UTI. - UrlPasteboardMime(const QString &urlUti); - QString convertorName(); - QString flavorFor(const QString &mime); - QString mimeFor(QString flav); - bool canConvert(const QString &mime, QString flav); - QVariant convertToMime(const QString &mime, QList data, QString flav); - QList convertFromMime(const QString &mime, QVariant data, QString flav); + explicit UrlPasteboardMime(const QString &urlUti); + +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + QString mimeForUti(const QString &uti) const override; + QString utiForMime(const QString &mime) const override; + QVariant convertToMime(const QString &mime, const QList &data, const QString &uti) const override; + QList convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override; +#else + QString convertorName() override; + QString flavorFor(const QString &mime) override; + QString mimeFor(QString uti) override; + bool canConvert(const QString &mime, QString uti) override; + QVariant convertToMime(const QString &mime, QList data, QString uti) override; + QList convertFromMime(const QString &mime, QVariant data, QString uti) override; +#endif private: QString m_urlUti; }; - -#endif // URLPASTEBOARDMIME_H diff --git a/src/platform/mac/urlpasteboardmime.mm b/src/platform/mac/urlpasteboardmime.mm index 5230523460..8d3780d6cb 100644 --- a/src/platform/mac/urlpasteboardmime.mm +++ b/src/platform/mac/urlpasteboardmime.mm @@ -8,24 +8,35 @@ #import #import +#import /* * Much of this code is based on the Qt code here: * https://www.qt.gitorious.org/qt/qt/source/src/gui/kernel/qmime_mac.cpp#L765 */ -UrlPasteboardMime::UrlPasteboardMime(const QString &urlUti): - QMacPasteboardMime(MIME_ALL) +UrlPasteboardMime::UrlPasteboardMime(const QString &urlUti) +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + : UrlPasteboardMimeBase() +#else + : UrlPasteboardMimeBase(MIME_ALL) +#endif , m_urlUti(urlUti) { } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QString UrlPasteboardMime::convertorName() { - return "CopyQ-URL-" + m_urlUti;; + return QLatin1String("CopyQ-URL-") + m_urlUti; } +#endif +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QString UrlPasteboardMime::utiForMime(const QString &mime) const +#else QString UrlPasteboardMime::flavorFor(const QString &mime) +#endif { if (mime.startsWith(QLatin1String(mimeUriList))) { return m_urlUti; @@ -33,21 +44,29 @@ return QString(); } -QString UrlPasteboardMime::mimeFor(QString flav) +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QString UrlPasteboardMime::mimeForUti(const QString &uti) const +#else +QString UrlPasteboardMime::mimeFor(QString uti) +#endif { - if (flav == m_urlUti) { - return mimeUriList; - } - return QString(); + return (uti == m_urlUti) ? mimeUriList : QString(); } -bool UrlPasteboardMime::canConvert(const QString &mime, QString flav) + +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +bool UrlPasteboardMime::canConvert(const QString &mime, QString uti) { - return (mime == QLatin1String(mimeUriList) && flav == m_urlUti);; + return mime == QLatin1String(mimeUriList) && uti == m_urlUti; } +#endif -QVariant UrlPasteboardMime::convertToMime(const QString &mime, QList data, QString flav) +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QVariant UrlPasteboardMime::convertToMime(const QString &mime, const QList &data, const QString &uti) const +#else +QVariant UrlPasteboardMime::convertToMime(const QString &mime, QList data, QString uti) +#endif { - if (!canConvert(mime, flav)) + if (!canConvert(mime, uti)) return QVariant(); QList ret; @@ -70,10 +89,14 @@ return QVariant(ret); } -QList UrlPasteboardMime::convertFromMime(const QString &mime, QVariant data, QString flav) +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QList UrlPasteboardMime::convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const +#else +QList UrlPasteboardMime::convertFromMime(const QString &mime, QVariant data, QString uti) +#endif { QList ret; - if (!canConvert(mime, flav)) + if (!canConvert(mime, uti)) return ret; QVariantList dataList = data.toList(); diff --git a/src/scriptable/scriptableproxy.cpp b/src/scriptable/scriptableproxy.cpp index 235453bfd3..eae828e912 100644 --- a/src/scriptable/scriptableproxy.cpp +++ b/src/scriptable/scriptableproxy.cpp @@ -624,18 +624,6 @@ QString tabNameEmptyError() return ScriptableProxy::tr("Tab name cannot be empty!"); } -void raiseWindow(QPointer window) -{ - window->raise(); - window->activateWindow(); - QApplication::setActiveWindow(window); - QApplication::processEvents(); - const auto wid = window->winId(); - const auto platformWindow = platformNativeInterface()->getWindow(wid); - if (platformWindow) - platformWindow->raise(); -} - } // namespace #ifdef HAS_TESTS @@ -665,6 +653,7 @@ class KeyClicker final : public QObject { const auto currentWindow = platformNativeInterface()->getCurrentWindow(); const auto currentWindowTitle = currentWindow ? currentWindow->getTitle() : QString(); log( QString("Failed to send key press to target widget") + + QLatin1String(qApp->applicationState() == Qt::ApplicationActive ? "" : "\nApp is INACTIVE!") + "\nExpected: " + (expectedWidgetName.isEmpty() ? "Any" : expectedWidgetName) + "\nActual: " + keyClicksTargetDescription(actual) + "\nPopup: " + keyClicksTargetDescription(popup) @@ -685,6 +674,16 @@ class KeyClicker final : public QObject { return; } + if (qApp->applicationState() != Qt::ApplicationActive) { +#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(6,0,0) + // WORKAROUND for focusing back to main window on macOS. + if (m_wnd->isVisible()) + m_wnd->activateWindow(); +#endif + keyClicksRetry(expectedWidgetName, keys, delay, retry); + return; + } + auto widgetName = keyClicksTargetDescription(widget); if ( !expectedWidgetName.isEmpty() && !widgetName.contains(expectedWidgetName) ) { keyClicksRetry(expectedWidgetName, keys, delay, retry); @@ -2109,6 +2108,10 @@ int ScriptableProxy::inputDialog(const NamedValueList &values) widgets.append( createWidget(value.name, value.value, &inputDialog) ); } + // WORKAROUND for broken initial focus in Qt 6.6 (QTBUG-121514) + if (!widgets.isEmpty()) + widgets.first()->setFocus(); + dialog.adjustSize(); if (geometry.height() == 0) @@ -2174,9 +2177,7 @@ int ScriptableProxy::inputDialog(const NamedValueList &values) dialog.show(); - // Skip raising dialog in tests. - if ( !qApp->property("CopyQ_test_id").isValid() ) - raiseWindow(&dialog); + raiseWindow(&dialog); return dialogId; } diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 520f6096c1..9a00e4602c 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -4602,11 +4602,17 @@ void Tests::changeAlwaysOnTop() RUN("config" << "always_on_top" << "true", "true\n"); WAIT_ON_OUTPUT("visible", "true\n"); + // There is a problem activating the window again after + // changing the always-on-top flag on macOS with Qt 6. +#if !defined(Q_OS_MAC) || QT_VERSION < QT_VERSION_CHECK(6,0,0) WAIT_ON_OUTPUT("focused", "true\n"); +#endif RUN("config" << "always_on_top" << "false", "false\n"); WAIT_ON_OUTPUT("visible", "true\n"); +#if !defined(Q_OS_MAC) || QT_VERSION < QT_VERSION_CHECK(6,0,0) WAIT_ON_OUTPUT("focused", "true\n"); +#endif RUN("hide", ""); RUN("visible", "false\n"); diff --git a/utils/github/bundle-macos.sh b/utils/github/bundle-macos.sh index 95728f4d3f..16e251523d 100755 --- a/utils/github/bundle-macos.sh +++ b/utils/github/bundle-macos.sh @@ -5,15 +5,6 @@ set -xeuo pipefail app_bundle_path="CopyQ.app" executable="${PWD}/${app_bundle_path}/Contents/MacOS/CopyQ" -plugins=("$app_bundle_path/Contents/PlugIns/copyq/"*.so) -qt_bin="$(brew --prefix qt@5)/bin" - -rm -rf "$app_bundle_path/Contents/PlugIns/"{platforminputcontexts,printsupport,qmltooling} - -"$qt_bin/macdeployqt" "$app_bundle_path" -dmg -verbose=2 -always-overwrite -no-plugins \ - "${plugins[@]/#/-executable=}" - -ls -Rl "$app_bundle_path" # Test the app before deployment. "$executable" --help @@ -28,7 +19,11 @@ test "$("$executable" info has-global-shortcuts)" -eq "1" # Uninstall local Qt to make sure we only use libraries from the bundle brew remove --ignore-dependencies --force \ - qt@5 copyq/kde/kf5-knotifications freetype + qt@6 copyq/kde/kf6-knotifications copyq/kde/kf6-kstatusnotifieritem freetype + +# Disable animations for tests +defaults write -g NSAutomaticWindowAnimationsEnabled -bool false +defaults write -g NSWindowResizeTime -float 0.001 ( export LD_LIBRARY_PATH="" @@ -44,4 +39,6 @@ brew remove --ignore-dependencies --force \ otool -L "$executable" otool -L "$app_bundle_path/Contents/PlugIns/"*/*.dylib otool -L "$app_bundle_path/Contents/PlugIns/copyq/"* -otool -L "$app_bundle_path/Contents/Frameworks/"Qt*.framework/Versions/5/Qt* +otool -L "$app_bundle_path/Contents/Frameworks/"Qt*.framework/Versions/*/Qt* + +mv copyq-*.dmg CopyQ.dmg diff --git a/utils/github/homebrew/Formula/extra-cmake-modules.rb b/utils/github/homebrew/Formula/extra-cmake-modules.rb index 69a6753bbd..1539564ee3 100644 --- a/utils/github/homebrew/Formula/extra-cmake-modules.rb +++ b/utils/github/homebrew/Formula/extra-cmake-modules.rb @@ -1,15 +1,15 @@ class ExtraCmakeModules < Formula desc "Extra modules and scripts for CMake" homepage "https://api.kde.org/frameworks/extra-cmake-modules/html/index.html" - url "https://download.kde.org/stable/frameworks/5.109/extra-cmake-modules-5.109.0.tar.xz" - sha256 "1526b557cf9718e4d3bf31ff241578178d1ee60bdfb863110c97d43d478b7fb7" + url "https://download.kde.org/unstable/frameworks/5.249.0/extra-cmake-modules-5.249.0.tar.xz" + sha256 "800fbb24496980604886b6f9dbf9c9f44693c73cc924abbe4bab21274ff4379b" license all_of: ["BSD-2-Clause", "BSD-3-Clause", "MIT"] head "https://invent.kde.org/frameworks/extra-cmake-modules.git" depends_on "cmake" => [:build, :test] depends_on "ninja" => :build - depends_on "qt@5" => :build + depends_on "qt" => :build def install args = std_cmake_args diff --git a/utils/github/homebrew/Formula/kf5-kcoreaddons.rb b/utils/github/homebrew/Formula/kf5-kcoreaddons.rb deleted file mode 100644 index 78c22d313b..0000000000 --- a/utils/github/homebrew/Formula/kf5-kcoreaddons.rb +++ /dev/null @@ -1,36 +0,0 @@ -class Kf5Kcoreaddons < Formula - desc "Addons to QtCore" - homepage "https://www.kde.org" - url "https://download.kde.org/stable/frameworks/5.109/kcoreaddons-5.109.0.tar.xz" - sha256 "ff647fc1d4dd62370f261854af0870f2a1c7ba7abe7e276e5a4c42d923f15300" - head "https://invent.kde.org/frameworks/kcoreaddons.git" - - depends_on "cmake" => [:build, :test] - depends_on "ninja" => :build - - depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] - - depends_on "qt@5" - - def install - args = std_cmake_args - args << "-DBUILD_TESTING=OFF" - args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" - args << "-DUPDATE_MIME_DATABASE_EXECUTABLE=OFF" - - mkdir "build" do - system "cmake", "-G", "Ninja", "..", *args - system "ninja" - system "ninja", "install" - prefix.install "install_manifest.txt" - end - end - - test do - (testpath/"CMakeLists.txt").write("find_package(KF5CoreAddons REQUIRED)") - system "cmake", ".", "-Wno-dev" - end -end diff --git a/utils/github/homebrew/Formula/kf5-knotifications.rb b/utils/github/homebrew/Formula/kf5-knotifications.rb deleted file mode 100644 index 73f4fbf04b..0000000000 --- a/utils/github/homebrew/Formula/kf5-knotifications.rb +++ /dev/null @@ -1,40 +0,0 @@ -class Kf5Knotifications < Formula - desc "Abstraction for system notifications" - homepage "https://www.kde.org" - url "https://download.kde.org/stable/frameworks/5.109/knotifications-5.109.0.tar.xz" - sha256 "12b1b41c80739dcdda0cff1d81288323b8b5cb8249da45ecee4b785c604dc13d" - head "https://invent.kde.org/frameworks/knotifications.git" - - depends_on "cmake" => [:build, :test] - depends_on "ninja" => :build - - depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] - depends_on "copyq/kde/kf5-kconfig" - depends_on "copyq/kde/kf5-kcoreaddons" - depends_on "copyq/kde/kf5-kwindowsystem" - depends_on "libcanberra" - - def install - args = std_cmake_args - args << "-DBUILD_TESTING=OFF" - args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" - # setBadgeLabelText method is deprecated since 5.12 - args << "-DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DQT_DISABLE_DEPRECATED_BEFORE=0x050b00" - args << "-DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DQT_DISABLE_DEPRECATED_BEFORE=0x050b00" - - mkdir "build" do - system "cmake", "-G", "Ninja", "..", *args - system "ninja" - system "ninja", "install" - prefix.install "install_manifest.txt" - end - end - - test do - (testpath/"CMakeLists.txt").write("find_package(KF5Notifications REQUIRED)") - system "cmake", ".", "-Wno-dev" - end -end diff --git a/utils/github/homebrew/Formula/kf5-kconfig.rb b/utils/github/homebrew/Formula/kf6-kconfig.rb similarity index 61% rename from utils/github/homebrew/Formula/kf5-kconfig.rb rename to utils/github/homebrew/Formula/kf6-kconfig.rb index 3c3aa9d72e..2f0e42c899 100644 --- a/utils/github/homebrew/Formula/kf5-kconfig.rb +++ b/utils/github/homebrew/Formula/kf6-kconfig.rb @@ -1,8 +1,8 @@ -class Kf5Kconfig < Formula +class Kf6Kconfig < Formula desc "Configuration system" homepage "https://www.kde.org" - url "https://download.kde.org/stable/frameworks/5.109/kconfig-5.109.0.tar.xz" - sha256 "5ba91551fb682d3e1d536bc3735b56cecaa57bb698ab32dd8f662e1cc78f7ad8" + url "https://download.kde.org/unstable/frameworks/5.249.0/kconfig-5.249.0.tar.xz" + sha256 "7d24cbc6c12dd8cb25959fd4ffc232efb14719ebb8a3a9eefd40673a57ff4d0d" head "https://invent.kde.org/frameworks/kconfig.git" depends_on "cmake" => [:build, :test] @@ -10,15 +10,15 @@ class Kf5Kconfig < Formula depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] - depends_on "qt@5" + depends_on "qt" def install args = std_cmake_args args << "-DBUILD_TESTING=OFF" args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" + args << "-DKDE_INSTALL_QMLDIR=lib/qt6/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt6/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt6/plugins" args << "-DKCONFIG_USE_GUI=OFF" args << "-DKCONFIG_USE_DBUS=OFF" @@ -32,7 +32,7 @@ def install end test do - (testpath/"CMakeLists.txt").write("find_package(KF5Config REQUIRED)") + (testpath/"CMakeLists.txt").write("find_package(KF6Config REQUIRED)") system "cmake", ".", "-Wno-dev" end end diff --git a/utils/github/homebrew/Formula/kf6-knotifications.rb b/utils/github/homebrew/Formula/kf6-knotifications.rb new file mode 100644 index 0000000000..52e6345c33 --- /dev/null +++ b/utils/github/homebrew/Formula/kf6-knotifications.rb @@ -0,0 +1,38 @@ +class Kf6Knotifications < Formula + desc "Abstraction for system notifications" + homepage "https://www.kde.org" + url "https://download.kde.org/unstable/frameworks/5.249.0/knotifications-5.249.0.tar.xz" + sha256 "66b945919d0b9a8354be229969c7af20a01f27b0739fa1093f99ffe5e27f4a81" + head "https://invent.kde.org/frameworks/knotifications.git" + + depends_on "cmake" => [:build, :test] + depends_on "ninja" => :build + + depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] + depends_on "copyq/kde/kf6-kconfig" + depends_on "libcanberra" + + def install + args = std_cmake_args + + args << "-DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.90.0" + + args << "-DBUILD_TESTING=OFF" + args << "-DBUILD_QCH=OFF" + args << "-DKDE_INSTALL_QMLDIR=lib/qt6/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt6/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt6/plugins" + + mkdir "build" do + system "cmake", "-G", "Ninja", "..", *args + system "ninja" + system "ninja", "install" + prefix.install "install_manifest.txt" + end + end + + test do + (testpath/"CMakeLists.txt").write("find_package(KF6Notifications REQUIRED)") + system "cmake", ".", "-Wno-dev" + end +end diff --git a/utils/github/homebrew/Formula/kf6-kstatusnotifieritem.rb b/utils/github/homebrew/Formula/kf6-kstatusnotifieritem.rb new file mode 100644 index 0000000000..7cbf07e87b --- /dev/null +++ b/utils/github/homebrew/Formula/kf6-kstatusnotifieritem.rb @@ -0,0 +1,38 @@ +class Kf6Kstatusnotifieritem < Formula + desc "Abstraction for status/tray" + homepage "https://www.kde.org" + url "https://download.kde.org/unstable/frameworks/5.249.0/kstatusnotifieritem-5.249.0.tar.xz" + sha256 "b4485d37226758b4b43c4ebd7fe344b65e2408334f778a3deecef71315451f40" + head "https://invent.kde.org/frameworks/kstatusnotifieritem.git" + + depends_on "cmake" => [:build, :test] + depends_on "ninja" => :build + + depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] + depends_on "copyq/kde/kf6-kconfig" + depends_on "copyq/kde/kf6-kwindowsystem" + + def install + args = std_cmake_args + + args << "-DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.90.0" + + args << "-DBUILD_TESTING=OFF" + args << "-DBUILD_QCH=OFF" + args << "-DKDE_INSTALL_QMLDIR=lib/qt6/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt6/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt6/plugins" + + mkdir "build" do + system "cmake", "-G", "Ninja", "..", *args + system "ninja" + system "ninja", "install" + prefix.install "install_manifest.txt" + end + end + + test do + (testpath/"CMakeLists.txt").write("find_package(KF6Statusnotifieritem REQUIRED)") + system "cmake", ".", "-Wno-dev" + end +end diff --git a/utils/github/homebrew/Formula/kf5-kwindowsystem.rb b/utils/github/homebrew/Formula/kf6-kwindowsystem.rb similarity index 59% rename from utils/github/homebrew/Formula/kf5-kwindowsystem.rb rename to utils/github/homebrew/Formula/kf6-kwindowsystem.rb index db909569c0..a95d14fbd3 100644 --- a/utils/github/homebrew/Formula/kf5-kwindowsystem.rb +++ b/utils/github/homebrew/Formula/kf6-kwindowsystem.rb @@ -1,8 +1,8 @@ -class Kf5Kwindowsystem < Formula +class Kf6Kwindowsystem < Formula desc "Access to the windowing system" homepage "https://www.kde.org" - url "https://download.kde.org/stable/frameworks/5.109/kwindowsystem-5.109.0.tar.xz" - sha256 "088075c9ff367b5b53b6ecdd34dcf8a47a4cf47458ef02fd9d8df3266679c1a2" + url "https://download.kde.org/unstable/frameworks/5.249.0/kwindowsystem-5.249.0.tar.xz" + sha256 "cc5e62380e1ef354a3088ddeb1db93d0e018e47e9ec0869a4b493ab737e81508" head "https://invent.kde.org/frameworks/kwindowsystem.git" depends_on "cmake" => [:build, :test] @@ -10,15 +10,15 @@ class Kf5Kwindowsystem < Formula depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] - depends_on "qt@5" + depends_on "qt" def install args = std_cmake_args args << "-DBUILD_TESTING=OFF" args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" + args << "-DKDE_INSTALL_QMLDIR=lib/qt6/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt6/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt6/plugins" mkdir "build" do system "cmake", "-G", "Ninja", "..", *args @@ -29,7 +29,7 @@ def install end test do - (testpath/"CMakeLists.txt").write("find_package(KF5WindowSystem REQUIRED)") + (testpath/"CMakeLists.txt").write("find_package(KF6WindowSystem REQUIRED)") system "cmake", ".", "-Wno-dev" end end diff --git a/utils/github/install-macos.sh b/utils/github/install-macos.sh index 79e1276a96..42fd7d07db 100755 --- a/utils/github/install-macos.sh +++ b/utils/github/install-macos.sh @@ -23,4 +23,4 @@ rm -rf \ brew tap copyq/kde utils/github/homebrew/ -brew install qt@5 copyq/kde/kf5-knotifications +brew install qt@6 copyq/kde/kf6-knotifications copyq/kde/kf6-kstatusnotifieritem