New custom expanding widgets
This commit is contained in:
@@ -129,6 +129,8 @@ add_executable(Bloom
|
|||||||
src/Insight/UserInterfaces/InsightWindow/AboutWindow.cpp
|
src/Insight/UserInterfaces/InsightWindow/AboutWindow.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
|
||||||
|
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp
|
||||||
|
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp
|
||||||
|
|
||||||
# Target package widgets
|
# Target package widgets
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QSize>
|
||||||
|
|
||||||
|
#include "src/Logger/Logger.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::Widgets
|
||||||
|
{
|
||||||
|
class Q_WIDGETS_EXPORT ExpandingHeightScrollAreaWidget: public QScrollArea
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
[[nodiscard]] QSize scrollAreaSize() const {
|
||||||
|
auto parentWidget = this->parentWidget();
|
||||||
|
auto widget = this->widget();
|
||||||
|
|
||||||
|
if (parentWidget != nullptr) {
|
||||||
|
auto size = parentWidget->size();
|
||||||
|
|
||||||
|
if (widget != nullptr) {
|
||||||
|
size.setWidth(widget->width() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QScrollArea::size();
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] QSize sizeHint() const override {
|
||||||
|
return this->scrollAreaSize();
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] QSize minimumSizeHint() const override {
|
||||||
|
return this->scrollAreaSize();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExpandingHeightScrollAreaWidget(QWidget* parent): QScrollArea(parent) {};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QSize>
|
||||||
|
|
||||||
|
#include "src/Logger/Logger.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::Widgets
|
||||||
|
{
|
||||||
|
class Q_WIDGETS_EXPORT ExpandingWidget: public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
[[nodiscard]] QSize minimumSizeHint() const override {
|
||||||
|
auto parentWidget = this->parentWidget();
|
||||||
|
|
||||||
|
if (parentWidget != nullptr) {
|
||||||
|
return parentWidget->size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QWidget::size();
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] QSize sizeHint() const override {
|
||||||
|
return this->minimumSizeHint();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExpandingWidget(QWidget* parent): QWidget(parent) {};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user