Simplify the code a bit
There is a type called QObjectList already. Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
095731d741
commit
84ce2eb418
|
@ -144,11 +144,11 @@ void FramelessHelper::addDraggableArea(const QWindow *window, const QRectF &val)
|
|||
m_draggableAreas[window] = areas;
|
||||
}
|
||||
|
||||
QList<QObject *> FramelessHelper::getIgnoreObjects(const QWindow *window) const
|
||||
QObjectList FramelessHelper::getIgnoreObjects(const QWindow *window) const
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
QList<QObject *> ret{};
|
||||
const QList<QObject *> objs = m_ignoreObjects.value(window);
|
||||
QObjectList ret{};
|
||||
const QObjectList objs = m_ignoreObjects.value(window);
|
||||
if (!objs.isEmpty()) {
|
||||
for (auto &&_obj : qAsConst(objs)) {
|
||||
if (_obj) {
|
||||
|
@ -162,16 +162,16 @@ QList<QObject *> FramelessHelper::getIgnoreObjects(const QWindow *window) const
|
|||
void FramelessHelper::addIgnoreObject(const QWindow *window, QObject *val)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
QList<QObject *> objs = m_ignoreObjects[window];
|
||||
QObjectList objs = m_ignoreObjects[window];
|
||||
objs.append(val);
|
||||
m_ignoreObjects[window] = objs;
|
||||
}
|
||||
|
||||
QList<QObject *> FramelessHelper::getDraggableObjects(const QWindow *window) const
|
||||
QObjectList FramelessHelper::getDraggableObjects(const QWindow *window) const
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
QList<QObject *> ret{};
|
||||
const QList<QObject *> objs = m_draggableObjects.value(window);
|
||||
QObjectList ret{};
|
||||
const QObjectList objs = m_draggableObjects.value(window);
|
||||
if (!objs.isEmpty()) {
|
||||
for (auto &&_obj : qAsConst(objs)) {
|
||||
if (_obj) {
|
||||
|
@ -185,7 +185,7 @@ QList<QObject *> FramelessHelper::getDraggableObjects(const QWindow *window) con
|
|||
void FramelessHelper::addDraggableObject(const QWindow *window, QObject *val)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
QList<QObject *> objs = m_draggableObjects[window];
|
||||
QObjectList objs = m_draggableObjects[window];
|
||||
objs.append(val);
|
||||
m_draggableObjects[window] = objs;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event)
|
|||
return false;
|
||||
};
|
||||
const auto isInSpecificObjects = [](const QPointF &mousePos,
|
||||
const QList<QObject *> &objects) -> bool {
|
||||
const QObjectList &objects) -> bool {
|
||||
if (objects.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -65,10 +65,10 @@ public:
|
|||
QList<QRectF> getDraggableAreas(const QWindow *window) const;
|
||||
|
||||
void addIgnoreObject(const QWindow *window, QObject *val);
|
||||
QList<QObject *> getIgnoreObjects(const QWindow *window) const;
|
||||
QObjectList getIgnoreObjects(const QWindow *window) const;
|
||||
|
||||
void addDraggableObject(const QWindow *window, QObject *val);
|
||||
QList<QObject *> getDraggableObjects(const QWindow *window) const;
|
||||
QObjectList getDraggableObjects(const QWindow *window) const;
|
||||
|
||||
bool getResizable(const QWindow *window) const;
|
||||
void setResizable(const QWindow *window, const bool val);
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
// platforms through native API.
|
||||
int m_borderWidth = 8, m_borderHeight = 8, m_titleBarHeight = 30;
|
||||
QHash<const QWindow *, QList<QRectF>> m_ignoreAreas = {}, m_draggableAreas = {};
|
||||
QHash<const QWindow *, QList<QObject *>> m_ignoreObjects = {}, m_draggableObjects = {};
|
||||
QHash<const QWindow *, QObjectList> m_ignoreObjects = {}, m_draggableObjects = {};
|
||||
QHash<const QWindow *, bool> m_fixedSize = {}, m_disableTitleBar = {};
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1742,7 +1742,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
|
|||
return false;
|
||||
};
|
||||
const auto isInSpecificObjects =
|
||||
[](const QPointF &mousePos, const QList<QObject *> &objects, const qreal dpr) -> bool {
|
||||
[](const QPointF &mousePos, const QObjectList &objects, const qreal dpr) -> bool {
|
||||
if (objects.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
#include <QAbstractNativeEventFilter>
|
||||
#include <QColor>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
QT_FORWARD_DECLARE_CLASS(QWindow)
|
||||
QT_FORWARD_DECLARE_CLASS(QObject)
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
framelessModeEnabled = false;
|
||||
int borderWidth = -1, borderHeight = -1, titleBarHeight = -1;
|
||||
QList<QRect> ignoreAreas = {}, draggableAreas = {};
|
||||
QList<QObject *> ignoreObjects = {}, draggableObjects = {};
|
||||
QObjectList ignoreObjects = {}, draggableObjects = {};
|
||||
QSize maximumSize = {}, minimumSize = {};
|
||||
QString currentScreen = {};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue