mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 17:43:23 -08:00
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Desktop / Prune caches (push) Waiting to run
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
66 lines
No EOL
1.7 KiB
C++
66 lines
No EOL
1.7 KiB
C++
/**
|
|
* @file flow_widget.h
|
|
* @ingroup UI
|
|
* @brief A QWidget that wraps a FlowLayout inside an optional QScrollArea.
|
|
*/
|
|
//! \todo Document this file.
|
|
|
|
#ifndef FLOW_WIDGET_H
|
|
#define FLOW_WIDGET_H
|
|
|
|
#include <QLoggingCategory>
|
|
#include <QWidget>
|
|
#include <qlogging.h>
|
|
#include <qnamespace.h>
|
|
#include <qtmetamacros.h>
|
|
|
|
class FlowLayout;
|
|
class QHBoxLayout;
|
|
class QKeyEvent;
|
|
class QLayoutItem;
|
|
class QScrollArea;
|
|
|
|
inline Q_LOGGING_CATEGORY(FlowWidgetLog, "flow_widget", QtInfoMsg);
|
|
inline Q_LOGGING_CATEGORY(FlowWidgetSizeLog, "flow_widget.size", QtInfoMsg);
|
|
|
|
class FlowWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
FlowWidget(QWidget *parent,
|
|
Qt::Orientation orientation,
|
|
Qt::ScrollBarPolicy horizontalPolicy,
|
|
Qt::ScrollBarPolicy verticalPolicy);
|
|
|
|
void addWidget(QWidget *widget_to_add);
|
|
void addNavigableWidget(QWidget *widget_to_add);
|
|
void insertWidgetAtIndex(QWidget *toInsert, int index);
|
|
void removeWidget(QWidget *widgetToRemove) const;
|
|
void clearLayout();
|
|
|
|
[[nodiscard]] int count() const;
|
|
[[nodiscard]] QLayoutItem *itemAt(int index) const;
|
|
|
|
QScrollArea *scrollArea; ///< Null when both scroll policies are AlwaysOff.
|
|
|
|
public slots:
|
|
void setMinimumSizeToMaxSizeHint();
|
|
void setSpacing(int hSpacing, int vSpacing);
|
|
|
|
protected:
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
private:
|
|
/// @brief Moves keyboard focus to an adjacent flow item for an arrow-key event.
|
|
/// @return True when the event was an arrow key and was handled.
|
|
bool moveFocus(QKeyEvent *event);
|
|
|
|
Qt::Orientation flowDirection;
|
|
QHBoxLayout *mainLayout;
|
|
FlowLayout *flowLayout;
|
|
QWidget *container;
|
|
};
|
|
|
|
#endif // FLOW_WIDGET_H
|