13.19i: distro checks pass on all five; the pickers preview only while open and end on the popup's Hide, as Qt 6.10 changed both
This commit is contained in:
1 parent
c59e85babc
commit
c854e42116
12 files changed
+99
-13
No files matched your search
@@ -1,4 +1,6 @@
|
||||
#include "UI/BlendModePicker.h"
|
||||
#include <QAbstractItemView>
|
||||
#include <QEvent>
|
||||
|
||||
BlendModePicker::BlendModePicker(EditorSession &session, QWidget *parent) : QComboBox(parent), m_session(session)
|
||||
{
|
||||
@@ -13,6 +15,8 @@ BlendModePicker::BlendModePicker(EditorSession &session, QWidget *parent) : QCom
|
||||
connect(this, &QComboBox::highlighted, this, &BlendModePicker::highlight);
|
||||
connect(this, &QComboBox::activated, this, &BlendModePicker::choose);
|
||||
connect(&m_session, &EditorSession::changed, this, &BlendModePicker::synchronize);
|
||||
// Qt 6.10 closes on Escape without calling hidePopup.
|
||||
view()->window()->installEventFilter(this);
|
||||
synchronize();
|
||||
}
|
||||
|
||||
@@ -24,9 +28,10 @@ void BlendModePicker::showPopup()
|
||||
QComboBox::showPopup();
|
||||
}
|
||||
|
||||
void BlendModePicker::hidePopup()
|
||||
bool BlendModePicker::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
QComboBox::hidePopup();
|
||||
if (watched != view()->window() || event->type() != QEvent::Hide)
|
||||
return QComboBox::eventFilter(watched, event);
|
||||
m_tracking = false;
|
||||
// A click closes the menu, then chooses: clear after.
|
||||
QMetaObject::invokeMethod(this, [this] {
|
||||
@@ -34,6 +39,7 @@ void BlendModePicker::hidePopup()
|
||||
m_layerID = std::nullopt;
|
||||
m_highlighted = std::nullopt;
|
||||
}, Qt::QueuedConnection);
|
||||
return false;
|
||||
}
|
||||
|
||||
void BlendModePicker::synchronize()
|
||||
@@ -47,6 +53,9 @@ void BlendModePicker::synchronize()
|
||||
|
||||
void BlendModePicker::highlight(int index)
|
||||
{
|
||||
// Qt 6.10 signals too, as the closed menu follows.
|
||||
if (!m_tracking)
|
||||
return;
|
||||
const std::optional<LayerBlendMode> mode = layerBlendMode(itemText(index));
|
||||
if (mode)
|
||||
m_highlighted = mode;
|
||||
|
||||
@@ -9,7 +9,10 @@ public:
|
||||
explicit BlendModePicker(EditorSession &session, QWidget *parent = nullptr);
|
||||
|
||||
void showPopup() override;
|
||||
void hidePopup() override;
|
||||
|
||||
protected:
|
||||
// The popup closed, however Qt closed it.
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void synchronize();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "UI/TypeControls.h"
|
||||
#include <QAbstractItemView>
|
||||
#include <QEvent>
|
||||
#include <QFontInfo>
|
||||
#include <QRawFont>
|
||||
#include <QtConcurrent>
|
||||
@@ -147,18 +148,22 @@ TypeFontPicker::TypeFontPicker(std::function<void(PreviewStep, const QString &)>
|
||||
{
|
||||
setAccessibleName(QStringLiteral("Font"));
|
||||
prepareOwnNames();
|
||||
// Only a face previews; (Multiple) leaves the last one showing.
|
||||
// An open menu's face previews; Qt 6.10 signals closed too.
|
||||
connect(this, &QComboBox::highlighted, this, [this](int index) {
|
||||
if (!isMultiple(index))
|
||||
if (view()->isVisible() && !isMultiple(index))
|
||||
m_preview(PreviewStep::show, itemText(index));
|
||||
});
|
||||
// Qt 6.10 closes on Escape without calling hidePopup.
|
||||
view()->window()->installEventFilter(this);
|
||||
}
|
||||
|
||||
// Qt reports a choice after the close: the revert waits.
|
||||
void TypeFontPicker::hidePopup()
|
||||
bool TypeFontPicker::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
QComboBox::hidePopup();
|
||||
if (watched != view()->window() || event->type() != QEvent::Hide)
|
||||
return QComboBox::eventFilter(watched, event);
|
||||
QMetaObject::invokeMethod(this, [this] { m_preview(PreviewStep::revert, QString()); }, Qt::QueuedConnection);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TypeFontPicker::isMultiple(int index) const
|
||||
|
||||
@@ -45,14 +45,14 @@ public:
|
||||
// Shows `name`, or (Multiple) when empty; an open menu stays.
|
||||
void sync(const QString &name);
|
||||
void showPopup() override;
|
||||
// Closed, the text goes back; a choice already kept it.
|
||||
void hidePopup() override;
|
||||
// Swift's isMultiple: the top item that is no font.
|
||||
bool isMultiple(int index) const;
|
||||
|
||||
protected:
|
||||
// A long name is cut short, never widening the control.
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
// Closed, the text goes back; a choice already kept it.
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void showMultiple();
|
||||
|
||||
Reference in new issue
Block a user