diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c67b1856..14925cab2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ - Minor: Improve appearance of reply button. (#5491) - Minor: Introduce HTTP API for plugins. (#5383, #5492, #5494) - Minor: Support more Firefox variants for incognito link opening. (#5503) -- Minor: Replying to a message will now display the message being replied to. (#4350) +- Minor: Replying to a message will now display the message being replied to. (#4350, #5519) - Minor: Links can now have prefixes and suffixes such as parentheses. (#5486) - Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426) - Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378) diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 29ed3929f..17eb40418 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -84,27 +84,26 @@ void SplitInput::initLayout() layoutCreator.setLayoutType().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().assign(&this->ui_.replyWrapper); - replyWrapper->setContentsMargins(0, 0, 0, 0); + replyWrapper->setContentsMargins(0, 0, 1, 1); auto replyVbox = replyWrapper.setLayoutType().withoutMargin().assign( &this->ui_.replyVbox); - replyVbox->setSpacing(0); + replyVbox->setSpacing(1); auto replyHbox = replyVbox.emplace().assign(&this->ui_.replyHbox); auto messageVbox = layoutCreator.setLayoutType(); 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().assign(&this->ui_.replyLabel); replyLabel->setAlignment(Qt::AlignLeft); @@ -122,7 +121,7 @@ void SplitInput::initLayout() auto inputWrapper = layout.emplace().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 diff --git a/src/widgets/splits/SplitInput.hpp b/src/widgets/splits/SplitInput.hpp index 8319f9f71..fe822285f 100644 --- a/src/widgets/splits/SplitInput.hpp +++ b/src/widgets/splits/SplitInput.hpp @@ -124,6 +124,10 @@ protected: int marginForTheme() const; + void applyOuterMargin(); + + int replyMessageWidth() const; + Split *const split_; ChannelView *const channelView_; QPointer emotePopup_;