mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
Reset ColorEditor checked state after the popup is hidden
This commit is contained in:
parent
b06d1f008f
commit
a294e24a85
@ -60,14 +60,7 @@ void CSVWidget::ColorEditor::showPicker()
|
||||
|
||||
void CSVWidget::ColorEditor::pickerHid()
|
||||
{
|
||||
// If the popup is hidden and mouse isn't above the editor,
|
||||
// reset the editor checked state manually
|
||||
QPoint globalEditorPosition = mapToGlobal(QPoint(0, 0));
|
||||
QRect globalEditorRect(globalEditorPosition, geometry().size());
|
||||
if (!globalEditorRect.contains(QCursor::pos()))
|
||||
{
|
||||
setChecked(false);
|
||||
}
|
||||
setChecked(false);
|
||||
emit pickingFinished();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include "colorpickerpopup.hpp"
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QPushButton>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QLayout>
|
||||
#include <QStyleOption>
|
||||
|
||||
CSVWidget::ColorPickerPopup::ColorPickerPopup(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
@ -40,6 +43,26 @@ void CSVWidget::ColorPickerPopup::showPicker(const QPoint &position, const QColo
|
||||
show();
|
||||
}
|
||||
|
||||
void CSVWidget::ColorPickerPopup::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QPushButton *button = qobject_cast<QPushButton *>(parentWidget());
|
||||
if (button != NULL)
|
||||
{
|
||||
QStyleOptionButton option;
|
||||
option.init(button);
|
||||
QRect buttonRect = option.rect;
|
||||
buttonRect.moveTo(button->mapToGlobal(buttonRect.topLeft()));
|
||||
|
||||
// If the mouse is pressed above the pop-up parent,
|
||||
// the pop-up will be hidden and the pressed signal won't be repeated for the parent
|
||||
if (buttonRect.contains(event->globalPos()) || buttonRect.contains(event->pos()))
|
||||
{
|
||||
setAttribute(Qt::WA_NoMouseReplay);
|
||||
}
|
||||
}
|
||||
QFrame::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void CSVWidget::ColorPickerPopup::hideEvent(QHideEvent *event)
|
||||
{
|
||||
QFrame::hideEvent(event);
|
||||
|
@ -19,6 +19,7 @@ namespace CSVWidget
|
||||
void showPicker(const QPoint &position, const QColor &initialColor);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void hideEvent(QHideEvent *event);
|
||||
virtual bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user