mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
GUI: fg/bgcolor text edit: fix right-click context menu not working
properly by checking for it on FocusOut
This commit is contained in:
parent
6f7cdd660c
commit
48eaa0cc4e
@ -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)
|
||||
|
@ -552,12 +552,16 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
}
|
||||
|
||||
if ((watched == txt_fgcolor || watched == txt_bgcolor) && event->type() == QEvent::FocusOut) {
|
||||
// Exclude right-click context menu pop-up (Undo/Redo/Cut/Copy/Paste etc.)
|
||||
QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event);
|
||||
if (focusEvent->reason() != Qt::PopupFocusReason) {
|
||||
if (watched == txt_fgcolor) {
|
||||
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor);
|
||||
} else {
|
||||
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
@ -592,9 +596,12 @@ QString MainWindow::getColorStr(const QColor color, bool alpha_always) {
|
||||
}
|
||||
|
||||
void MainWindow::setColorTxtBtn(const QColor color, QLineEdit *txt, QPushButton* btn) {
|
||||
QString colorStr = getColorStr(color);
|
||||
if (colorStr != txt->text()) {
|
||||
int cursorPos = txt->cursorPosition();
|
||||
txt->setText(getColorStr(color));
|
||||
txt->setText(colorStr);
|
||||
txt->setCursorPosition(cursorPos);
|
||||
}
|
||||
btn->setStyleSheet(QSL("QPushButton {background-color:") + color.name() + QSL(";}"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user