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
|
- man page: fix Code 11 check digit info
|
||||||
- CMake: allow ctest to be run without having to install zint or manually set
|
- CMake: allow ctest to be run without having to install zint or manually set
|
||||||
LD_LIBRARY_PATH and PATH (ticket #279, props Alexey Dokuchaev)
|
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)
|
Version 2.12.0 (2022-12-12)
|
||||||
|
@ -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 || watched == txt_bgcolor) && event->type() == QEvent::FocusOut) {
|
||||||
if (watched == txt_fgcolor) {
|
// Exclude right-click context menu pop-up (Undo/Redo/Cut/Copy/Paste etc.)
|
||||||
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor);
|
QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event);
|
||||||
} else {
|
if (focusEvent->reason() != Qt::PopupFocusReason) {
|
||||||
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor);
|
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) {
|
void MainWindow::setColorTxtBtn(const QColor color, QLineEdit *txt, QPushButton* btn) {
|
||||||
int cursorPos = txt->cursorPosition();
|
QString colorStr = getColorStr(color);
|
||||||
txt->setText(getColorStr(color));
|
if (colorStr != txt->text()) {
|
||||||
txt->setCursorPosition(cursorPos);
|
int cursorPos = txt->cursorPosition();
|
||||||
|
txt->setText(colorStr);
|
||||||
|
txt->setCursorPosition(cursorPos);
|
||||||
|
}
|
||||||
btn->setStyleSheet(QSL("QPushButton {background-color:") + color.name() + QSL(";}"));
|
btn->setStyleSheet(QSL("QPushButton {background-color:") + color.name() + QSL(";}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user