diff --git a/ChangeLog b/ChangeLog index 68c920b1..a13161b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,8 @@ Bugs - man page: fix Code 11 check digit info - CMake: allow ctest to be run without having to install zint or manually set LD_LIBRARY_PATH and PATH (ticket #279, props Alexey Dokuchaev) +- GUI: fg/bgcolor text edit: fix right-click context menu not working properly + by checking for it on FocusOut Version 2.12.0 (2022-12-12) diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index d65a99c8..9db94371 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -552,10 +552,14 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) } if ((watched == txt_fgcolor || watched == txt_bgcolor) && event->type() == QEvent::FocusOut) { - if (watched == txt_fgcolor) { - setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); - } else { - setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); + // Exclude right-click context menu pop-up (Undo/Redo/Cut/Copy/Paste etc.) + QFocusEvent *focusEvent = static_cast(event); + if (focusEvent->reason() != Qt::PopupFocusReason) { + if (watched == txt_fgcolor) { + setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); + } else { + setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); + } } } @@ -592,9 +596,12 @@ QString MainWindow::getColorStr(const QColor color, bool alpha_always) { } void MainWindow::setColorTxtBtn(const QColor color, QLineEdit *txt, QPushButton* btn) { - int cursorPos = txt->cursorPosition(); - txt->setText(getColorStr(color)); - txt->setCursorPosition(cursorPos); + QString colorStr = getColorStr(color); + if (colorStr != txt->text()) { + int cursorPos = txt->cursorPosition(); + txt->setText(colorStr); + txt->setCursorPosition(cursorPos); + } btn->setStyleSheet(QSL("QPushButton {background-color:") + color.name() + QSL(";}")); }