Skip to content

Commit

Permalink
Some fixes for the macOS version
Browse files Browse the repository at this point in the history
  • Loading branch information
stfnp committed Aug 22, 2022
1 parent 4d6426a commit dbe9c64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion platforms/macos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions source/gui/widgets/propertytree/items/ColorPropertyItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
#include "gui/limbview/LayerColors.hpp"
#include <QColorDialog>
#include <QApplication>
#include <QKeyEvent>

// 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.
// * On macOS it seemed to work without any issues
//
// 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
Expand All @@ -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();
Expand Down

0 comments on commit dbe9c64

Please sign in to comment.