Fix UserProfile resizing

This commit is contained in:
Nicolas Werner 2020-03-31 00:38:17 +02:00
parent 94f5b25888
commit 31a5972f2a
2 changed files with 9 additions and 13 deletions

View file

@ -29,7 +29,8 @@ qmlMessageHandler(QtMsgType type, const QMessageLogContext &context, const QStri
if (msg.endsWith( if (msg.endsWith(
"QML Binding: Not restoring previous value because restoreMode has not been set.This " "QML Binding: Not restoring previous value because restoreMode has not been set.This "
"behavior is deprecated.In Qt < 6.0 the default is Binding.RestoreBinding.In Qt >= " "behavior is deprecated.In Qt < 6.0 the default is Binding.RestoreBinding.In Qt >= "
"6.0 the default is Binding.RestoreBindingOrValue.") || msg.endsWith("Both point size and pixel size set. Using pixel size.")) "6.0 the default is Binding.RestoreBindingOrValue.") ||
msg.endsWith("Both point size and pixel size set. Using pixel size."))
return; return;
switch (type) { switch (type) {

View file

@ -142,8 +142,6 @@ UserProfile::UserProfile(QWidget *parent)
devices_->setSelectionMode(QAbstractItemView::NoSelection); devices_->setSelectionMode(QAbstractItemView::NoSelection);
devices_->setAttribute(Qt::WA_MacShowFocusRect, 0); devices_->setAttribute(Qt::WA_MacShowFocusRect, 0);
devices_->setSpacing(DEVICE_SPACING); devices_->setSpacing(DEVICE_SPACING);
devices_->setMinimumHeight(devices_->sizeHint().height() * 1.2);
devices_->hide();
QFont descriptionLabelFont; QFont descriptionLabelFont;
descriptionLabelFont.setWeight(65); descriptionLabelFont.setWeight(65);
@ -151,6 +149,7 @@ UserProfile::UserProfile(QWidget *parent)
devicesLabel_ = new QLabel(tr("Devices").toUpper(), this); devicesLabel_ = new QLabel(tr("Devices").toUpper(), this);
devicesLabel_->setFont(descriptionLabelFont); devicesLabel_->setFont(descriptionLabelFont);
devicesLabel_->hide(); devicesLabel_->hide();
devicesLabel_->setFixedSize(devicesLabel_->sizeHint());
auto okBtn = new QPushButton("OK", this); auto okBtn = new QPushButton("OK", this);
@ -160,29 +159,24 @@ UserProfile::UserProfile(QWidget *parent)
closeLayout->addWidget(okBtn); closeLayout->addWidget(okBtn);
auto vlayout = new QVBoxLayout{this}; auto vlayout = new QVBoxLayout{this};
vlayout->addWidget(avatar_); vlayout->addWidget(avatar_, 0, Qt::AlignCenter | Qt::AlignTop);
vlayout->addLayout(textLayout); vlayout->addLayout(textLayout);
vlayout->addLayout(btnLayout); vlayout->addLayout(btnLayout);
vlayout->addWidget(devicesLabel_, Qt::AlignLeft); vlayout->addWidget(devicesLabel_, 0, Qt::AlignLeft);
vlayout->addWidget(devices_); vlayout->addWidget(devices_, 1);
vlayout->addLayout(closeLayout); vlayout->addLayout(closeLayout);
vlayout->addStretch(1);
vlayout->setAlignment(avatar_, Qt::AlignCenter | Qt::AlignTop);
vlayout->setAlignment(userIdLabel_, Qt::AlignCenter | Qt::AlignTop);
QFont largeFont; QFont largeFont;
largeFont.setPointSizeF(largeFont.pointSizeF() * 1.5); largeFont.setPointSizeF(largeFont.pointSizeF() * 1.5);
setMinimumWidth( setMinimumWidth(
std::max(devices_->sizeHint().width() + 4 * WIDGET_MARGIN, conf::window::minModalWidth)); std::max(devices_->sizeHint().width() + 4 * WIDGET_MARGIN, conf::window::minModalWidth));
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
vlayout->setSpacing(WIDGET_SPACING); vlayout->setSpacing(WIDGET_SPACING);
vlayout->setContentsMargins(WIDGET_MARGIN, TOP_WIDGET_MARGIN, WIDGET_MARGIN, WIDGET_MARGIN); vlayout->setContentsMargins(WIDGET_MARGIN, TOP_WIDGET_MARGIN, WIDGET_MARGIN, WIDGET_MARGIN);
static auto ignored = qRegisterMetaType<std::vector<DeviceInfo>>(); qRegisterMetaType<std::vector<DeviceInfo>>();
(void)ignored;
auto closeShortcut = new QShortcut(QKeySequence(QKeySequence::Cancel), this); auto closeShortcut = new QShortcut(QKeySequence(QKeySequence::Cancel), this);
connect(closeShortcut, &QShortcut::activated, this, &UserProfile::close); connect(closeShortcut, &QShortcut::activated, this, &UserProfile::close);
@ -307,4 +301,5 @@ UserProfile::updateDeviceList(const QString &user_id, const std::vector<DeviceIn
devicesLabel_->show(); devicesLabel_->show();
devices_->show(); devices_->show();
adjustSize();
} }