fix: restore input layout (almost) (#5519)
This commit is contained in:
@@ -84,27 +84,26 @@ void SplitInput::initLayout()
|
||||
layoutCreator.setLayoutType<QVBoxLayout>().withoutMargin().assign(
|
||||
&this->ui_.vbox);
|
||||
layout->setSpacing(0);
|
||||
auto marginPx = this->marginForTheme();
|
||||
layout->setContentsMargins(marginPx, marginPx, marginPx, marginPx);
|
||||
this->applyOuterMargin();
|
||||
|
||||
// reply label stuff
|
||||
auto replyWrapper =
|
||||
layout.emplace<QWidget>().assign(&this->ui_.replyWrapper);
|
||||
replyWrapper->setContentsMargins(0, 0, 0, 0);
|
||||
replyWrapper->setContentsMargins(0, 0, 1, 1);
|
||||
|
||||
auto replyVbox =
|
||||
replyWrapper.setLayoutType<QVBoxLayout>().withoutMargin().assign(
|
||||
&this->ui_.replyVbox);
|
||||
replyVbox->setSpacing(0);
|
||||
replyVbox->setSpacing(1);
|
||||
|
||||
auto replyHbox =
|
||||
replyVbox.emplace<QHBoxLayout>().assign(&this->ui_.replyHbox);
|
||||
|
||||
auto messageVbox = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||
this->ui_.replyMessage = new MessageView();
|
||||
messageVbox->addWidget(this->ui_.replyMessage, 1, Qt::AlignLeft);
|
||||
messageVbox->addWidget(this->ui_.replyMessage, 0, Qt::AlignLeft);
|
||||
messageVbox->setContentsMargins(10, 0, 0, 0);
|
||||
replyVbox->addLayout(messageVbox->layout(), 1);
|
||||
replyVbox->addLayout(messageVbox->layout(), 0);
|
||||
|
||||
auto replyLabel = replyHbox.emplace<QLabel>().assign(&this->ui_.replyLabel);
|
||||
replyLabel->setAlignment(Qt::AlignLeft);
|
||||
@@ -122,7 +121,7 @@ void SplitInput::initLayout()
|
||||
|
||||
auto inputWrapper =
|
||||
layout.emplace<QWidget>().assign(&this->ui_.inputWrapper);
|
||||
inputWrapper->setContentsMargins(0, 0, 0, 0);
|
||||
inputWrapper->setContentsMargins(1, 1, 1, 1);
|
||||
|
||||
// hbox for input, right box
|
||||
auto hboxLayout =
|
||||
@@ -231,7 +230,7 @@ void SplitInput::scaleChangedEvent(float scale)
|
||||
this->setMaximumHeight(this->scaledMaxHeight());
|
||||
if (this->replyTarget_ != nullptr)
|
||||
{
|
||||
this->ui_.vbox->setSpacing(this->marginForTheme() * 2);
|
||||
this->ui_.vbox->setSpacing(this->marginForTheme());
|
||||
}
|
||||
}
|
||||
this->ui_.textEdit->setFont(
|
||||
@@ -271,11 +270,10 @@ void SplitInput::themeChangedEvent()
|
||||
}
|
||||
|
||||
// update vbox
|
||||
auto marginPx = this->marginForTheme();
|
||||
this->ui_.vbox->setContentsMargins(marginPx, marginPx, marginPx, marginPx);
|
||||
this->applyOuterMargin();
|
||||
if (this->replyTarget_ != nullptr)
|
||||
{
|
||||
this->ui_.vbox->setSpacing(this->marginForTheme() * 2);
|
||||
this->ui_.vbox->setSpacing(this->marginForTheme());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1095,26 +1093,26 @@ void SplitInput::paintEvent(QPaintEvent * /*event*/)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
int s = this->marginForTheme();
|
||||
QColor borderColor =
|
||||
this->theme->isLightTheme() ? QColor("#ccc") : QColor("#333");
|
||||
|
||||
QRect baseRect = this->rect();
|
||||
QRect inputBoxRect = this->ui_.inputWrapper->geometry();
|
||||
inputBoxRect.setX(baseRect.x());
|
||||
inputBoxRect.setWidth(baseRect.width());
|
||||
baseRect.setWidth(baseRect.width() - 1);
|
||||
|
||||
painter.fillRect(inputBoxRect, this->theme->splits.input.background);
|
||||
auto *inputWrap = this->ui_.inputWrapper;
|
||||
auto inputBoxRect = inputWrap->geometry();
|
||||
inputBoxRect.setSize(inputBoxRect.size() - QSize{1, 1});
|
||||
|
||||
painter.setBrush({this->theme->splits.input.background});
|
||||
painter.setPen(borderColor);
|
||||
painter.drawRect(inputBoxRect);
|
||||
|
||||
if (this->enableInlineReplying_ && this->replyTarget_ != nullptr)
|
||||
{
|
||||
QRect replyRect = this->ui_.replyWrapper->geometry();
|
||||
replyRect.setX(baseRect.x());
|
||||
replyRect.setWidth(baseRect.width());
|
||||
auto replyRect = this->ui_.replyWrapper->geometry();
|
||||
replyRect.setSize(replyRect.size() - QSize{1, 1});
|
||||
|
||||
painter.fillRect(replyRect, this->theme->splits.input.background);
|
||||
painter.setBrush(this->theme->splits.input.background);
|
||||
painter.setPen(borderColor);
|
||||
painter.drawRect(replyRect);
|
||||
|
||||
@@ -1140,7 +1138,7 @@ void SplitInput::resizeEvent(QResizeEvent *event)
|
||||
this->ui_.textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
}
|
||||
|
||||
this->ui_.replyMessage->setWidth(this->width());
|
||||
this->ui_.replyMessage->setWidth(this->replyMessageWidth());
|
||||
}
|
||||
|
||||
void SplitInput::giveFocus(Qt::FocusReason reason)
|
||||
@@ -1170,11 +1168,11 @@ void SplitInput::setReply(MessagePtr target)
|
||||
|
||||
if (this->enableInlineReplying_)
|
||||
{
|
||||
this->ui_.replyMessage->setWidth(this->replyMessageWidth());
|
||||
this->ui_.replyMessage->setMessage(this->replyTarget_);
|
||||
this->ui_.replyMessage->setWidth(this->width());
|
||||
|
||||
// add spacing between reply box and input box
|
||||
this->ui_.vbox->setSpacing(this->marginForTheme() * 2);
|
||||
this->ui_.vbox->setSpacing(this->marginForTheme());
|
||||
if (!this->isHidden())
|
||||
{
|
||||
// update maximum height to give space for message
|
||||
@@ -1274,4 +1272,15 @@ int SplitInput::marginForTheme() const
|
||||
}
|
||||
}
|
||||
|
||||
void SplitInput::applyOuterMargin()
|
||||
{
|
||||
auto margin = std::max(this->marginForTheme() - 1, 0);
|
||||
this->ui_.vbox->setContentsMargins(margin, margin, margin, margin);
|
||||
}
|
||||
|
||||
int SplitInput::replyMessageWidth() const
|
||||
{
|
||||
return this->ui_.inputWrapper->width() - 1 - 10;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user