mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 21:06:43 +00:00
Reset ColorEditor checked state after the popup is hidden
This commit is contained in:
parent
b06d1f008f
commit
a294e24a85
3 changed files with 25 additions and 8 deletions
|
@ -60,14 +60,7 @@ void CSVWidget::ColorEditor::showPicker()
|
||||||
|
|
||||||
void CSVWidget::ColorEditor::pickerHid()
|
void CSVWidget::ColorEditor::pickerHid()
|
||||||
{
|
{
|
||||||
// If the popup is hidden and mouse isn't above the editor,
|
setChecked(false);
|
||||||
// reset the editor checked state manually
|
|
||||||
QPoint globalEditorPosition = mapToGlobal(QPoint(0, 0));
|
|
||||||
QRect globalEditorRect(globalEditorPosition, geometry().size());
|
|
||||||
if (!globalEditorRect.contains(QCursor::pos()))
|
|
||||||
{
|
|
||||||
setChecked(false);
|
|
||||||
}
|
|
||||||
emit pickingFinished();
|
emit pickingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#include "colorpickerpopup.hpp"
|
#include "colorpickerpopup.hpp"
|
||||||
|
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
#include <QStyleOption>
|
||||||
|
|
||||||
CSVWidget::ColorPickerPopup::ColorPickerPopup(QWidget *parent)
|
CSVWidget::ColorPickerPopup::ColorPickerPopup(QWidget *parent)
|
||||||
: QFrame(parent)
|
: QFrame(parent)
|
||||||
|
@ -40,6 +43,26 @@ void CSVWidget::ColorPickerPopup::showPicker(const QPoint &position, const QColo
|
||||||
show();
|
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)
|
void CSVWidget::ColorPickerPopup::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
QFrame::hideEvent(event);
|
QFrame::hideEvent(event);
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace CSVWidget
|
||||||
void showPicker(const QPoint &position, const QColor &initialColor);
|
void showPicker(const QPoint &position, const QColor &initialColor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
virtual void hideEvent(QHideEvent *event);
|
virtual void hideEvent(QHideEvent *event);
|
||||||
virtual bool eventFilter(QObject *object, QEvent *event);
|
virtual bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue