refactoring qad widgets part 1

c++ cast, nullptr, forward declaration, agregate ui, connect to member functions, order and clear includes
This commit is contained in:
2022-12-11 16:27:04 +03:00
parent 5d9381dd37
commit 728c132f2b
22 changed files with 561 additions and 404 deletions

View File

@@ -30,8 +30,9 @@ QIcon IconedLabel::icon() const {
bool IconedLabel::event(QEvent * e) {
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish)
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish) {
setIconSize(iconSize());
}
return QFrame::event(e);
}
@@ -43,9 +44,10 @@ void IconedLabel::checkSpacing() {
layout()->setSpacing(0);
} else {
QStyle * s = style();
if (s)
if (s) {
layout()->setSpacing(s->layoutSpacing(QSizePolicy::Label, QSizePolicy::Label,
dir_ <= Direction::RightToLeft ? Qt::Horizontal : Qt::Vertical));
}
}
}
@@ -79,9 +81,10 @@ void IconedLabel::setIconSize(const QSize & s) {
void IconedLabel::setDirection(IconedLabel::Direction d) {
dir_ = d;
if (layout() != 0)
if (layout()) {
delete layout();
QLayout * lay = new QBoxLayout((QBoxLayout::Direction)dir_);
}
QLayout * lay = new QBoxLayout(static_cast<QBoxLayout::Direction>(dir_));
lay->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Expanding));
lay->addWidget(&label_);
lay->addWidget(&icon_);