From dbe9c641e3f26dea6c5e427f97c1d65c8dd60135 Mon Sep 17 00:00:00 2001 From: Stefan Pfeifer Date: Mon, 22 Aug 2022 13:58:44 +0200 Subject: [PATCH] Some fixes for the macOS version --- platforms/macos/CMakeLists.txt | 2 +- .../gui/widgets/propertytree/items/ColorPropertyItem.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platforms/macos/CMakeLists.txt b/platforms/macos/CMakeLists.txt index 91ca86d3..54c6e3c5 100644 --- a/platforms/macos/CMakeLists.txt +++ b/platforms/macos/CMakeLists.txt @@ -9,7 +9,7 @@ set_target_properties( ) configure_file(Info.plist ${CMAKE_BINARY_DIR}/application/VirtualBow.app/Contents/Info.plist) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/logo.icns DESTINATION ${CMAKE_BINARY_DIR}/application/VirtualBow.app/Contents/Resources/logo.icns) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/logo.icns DESTINATION ${CMAKE_BINARY_DIR}/application/VirtualBow.app/Contents/Resources) file(COPY ${CMAKE_SOURCE_DIR}/resources/docs/user-manual DESTINATION ${CMAKE_BINARY_DIR}/application/VirtualBow.app/Contents/Resources) # Target: Copy shared libraries to application directory diff --git a/source/gui/widgets/propertytree/items/ColorPropertyItem.cpp b/source/gui/widgets/propertytree/items/ColorPropertyItem.cpp index 66213b13..59554986 100644 --- a/source/gui/widgets/propertytree/items/ColorPropertyItem.cpp +++ b/source/gui/widgets/propertytree/items/ColorPropertyItem.cpp @@ -3,10 +3,11 @@ #include "gui/limbview/LayerColors.hpp" #include #include +#include // According to the answers in [1], dialogs can be used directly as editors in a delegate. // This is also supported by the internal Qt code shown in [2]. -// Hovever, this approach turned out to have some issues: +// However, this approach turned out to have some issues: // // * On Linux it mostly worked, except on Linux Mint where the dialog would just disappear when clicking on it (probably an older Qt version) // * On Windows, the dialog would pop up in a weird location with the title bar not visible, so couldn't be moved either. Didn't manage to move it in code. @@ -14,6 +15,7 @@ // // So the other solution was picked: Create a wrapper widget that opens the dialog as a child. // The final hurdle is to get the widget to trigger the item delegate when the dialog is finished, see [2]. +// This worked with a FocusOut event on Windows and Linux, but on Mac only with a key press event. // // [1] https://stackoverflow.com/q/40264262 // [2] https://stackoverflow.com/q/30063133 @@ -27,10 +29,12 @@ class ColorEditor: public QWidget { // When the dialog is closed, send a QEvent::FocusOut event to trigger the item delegate // to update the model (using clearFocus() does not work). QObject::connect(dialog, &QColorDialog::finished, [=](int result) { - QEvent event(QEvent::FocusOut); + //QEvent event(QEvent::KeyPress); + QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); QApplication::sendEvent(this, &event); }); + dialog->setOption(QColorDialog::DontUseNativeDialog); dialog->setWindowModality(Qt::ApplicationModal); dialog->setWindowTitle("Color"); dialog->show();