mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
* [VDE] Deck Analytics Widgets overhaul Took 2 minutes Took 3 minutes Took 3 minutes * Qt5 version guards. Took 33 minutes Took 3 seconds * Include QtMath Took 3 minutes Took 8 seconds * Use getCards() Took 4 minutes * Non pointer stuff Took 52 seconds * Add a newline to the tooltip Took 2 minutes Took 27 seconds * Fix build failure on macOS 15 * Rename some things. Took 17 minutes Took 11 seconds Took 18 seconds * Address overloads, fix default configuration. Took 1 hour 9 minutes Took 8 seconds * Fix mana curve default config. Took 4 minutes * Namespace to Qt libs Took 5 minutes * Selection overlay is transparent for mouse events. Took 2 minutes * Brace initialize. Took 8 minutes * Debian 11. Took 5 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: RickyRister <ricky.rister.wang@gmail.com>
34 lines
766 B
C++
34 lines
766 B
C++
#ifndef COCKATRICE_QT_UTILS_H
|
|
#define COCKATRICE_QT_UTILS_H
|
|
#include <QObject>
|
|
|
|
namespace QtUtils
|
|
{
|
|
template <typename T> T *findParentOfType(const QObject *obj)
|
|
{
|
|
const QObject *p = obj ? obj->parent() : nullptr;
|
|
while (p) {
|
|
if (auto casted = qobject_cast<T *>(const_cast<QObject *>(p))) {
|
|
return casted;
|
|
}
|
|
p = p->parent();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
static inline void clearLayoutRec(QLayout *l)
|
|
{
|
|
if (!l)
|
|
return;
|
|
QLayoutItem *it;
|
|
while ((it = l->takeAt(0)) != nullptr) {
|
|
if (QWidget *w = it->widget())
|
|
w->deleteLater();
|
|
if (QLayout *sub = it->layout())
|
|
clearLayoutRec(sub);
|
|
delete it;
|
|
}
|
|
}
|
|
} // namespace QtUtils
|
|
|
|
#endif // COCKATRICE_QT_UTILS_H
|