fix: make reply-cancel button less coarse-grained (#6106)

Co-authored-by: nerix <nerixdev@outlook.de>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Brian Leung
2025-04-05 07:19:36 -07:00
committed by GitHub
parent df079e572c
commit c5b6f21d5f
5 changed files with 23 additions and 21 deletions
+1
View File
@@ -3,6 +3,7 @@
## Unversioned ## Unversioned
- Bugfix: Don't create native messaging manifest file if browser directory doesn't exist. (#6116) - Bugfix: Don't create native messaging manifest file if browser directory doesn't exist. (#6116)
- Bugfix: Make reply-cancel button less coarse-grained. (#6106)
- Dev: Conan will no longer generate a `CMakeUserPresets.json` file. (#6117) - Dev: Conan will no longer generate a `CMakeUserPresets.json` file. (#6117)
- Dev: Pass `--force-openssl` when installing from CMake in Qt 6.8+. (#6129) - Dev: Pass `--force-openssl` when installing from CMake in Qt 6.8+. (#6129)
+6 -9
View File
@@ -84,7 +84,12 @@ void Button::setSvgResource(const QString &resourcePath)
return; return;
} }
if (this->svgRenderer)
{
this->svgRenderer->deleteLater();
}
this->svgRenderer = new QSvgRenderer(resourcePath, this); this->svgRenderer = new QSvgRenderer(resourcePath, this);
this->svgRenderer->setAspectRatioMode(Qt::KeepAspectRatio);
this->svgResourcePath = resourcePath; this->svgResourcePath = resourcePath;
this->update(); this->update();
@@ -199,15 +204,7 @@ void Button::paintButton(QPainter &painter)
if (this->enableMargin_) if (this->enableMargin_)
{ {
auto s = this->getMargin(); auto s = this->getMargin();
auto outSize = rect.size() - QSize{2 * s, 2 * s}; rect = {{s, s}, rect.size() - QSize{2 * s, 2 * s}};
outSize = this->svgRenderer->defaultSize().scaled(
outSize, Qt::KeepAspectRatio);
auto margin = rect.size() - outSize;
rect = QRect{
QPoint{margin.width() / 2, margin.height() / 2},
outSize,
};
} }
this->svgRenderer->render(&painter, rect); this->svgRenderer->render(&painter, rect);
+12 -9
View File
@@ -112,9 +112,8 @@ void SplitInput::initLayout()
replyHbox->addStretch(1); replyHbox->addStretch(1);
auto replyCancelButton = replyHbox.emplace<EffectLabel>(nullptr, 4) auto replyCancelButton =
.assign(&this->ui_.cancelReplyButton); replyHbox.emplace<Button>().assign(&this->ui_.cancelReplyButton);
replyCancelButton->getLabel().setTextFormat(Qt::RichText);
replyCancelButton->hide(); replyCancelButton->hide();
replyLabel->hide(); replyLabel->hide();
@@ -303,13 +302,17 @@ void SplitInput::updateCancelReplyButton()
{ {
float scale = this->scale(); float scale = this->scale();
auto text = if (this->theme->isLightTheme())
QStringLiteral("<img src=':/buttons/%1.svg' width='%2' height='%2' />") {
.arg(this->theme->isLightTheme() ? "cancelDark" : "cancel") this->ui_.cancelReplyButton->setSvgResource(":/buttons/cancelDark.svg");
.arg(int(12 * scale)); }
else
this->ui_.cancelReplyButton->getLabel().setText(text); {
this->ui_.cancelReplyButton->setSvgResource(":/buttons/cancel.svg");
}
this->ui_.cancelReplyButton->setEnableMargin(false);
this->ui_.cancelReplyButton->setFixedHeight(int(12 * scale)); this->ui_.cancelReplyButton->setFixedHeight(int(12 * scale));
this->ui_.cancelReplyButton->setFixedWidth(int(20 * scale));
} }
void SplitInput::openEmotePopup() void SplitInput::openEmotePopup()
+1 -1
View File
@@ -144,7 +144,7 @@ protected:
QHBoxLayout *replyHbox; QHBoxLayout *replyHbox;
MessageView *replyMessage; MessageView *replyMessage;
QLabel *replyLabel; QLabel *replyLabel;
EffectLabel *cancelReplyButton; Button *cancelReplyButton;
// input widgets // input widgets
QWidget *inputWrapper; QWidget *inputWrapper;
+3 -2
View File
@@ -50,8 +50,9 @@ TEST(NetworkResult, Errors)
TEST(NetworkResult, InvalidError) TEST(NetworkResult, InvalidError)
{ {
checkResult({static_cast<Error>(-1), {}, {}}, static_cast<Error>(-1), checkResult({static_cast<Error>(1000000), {}, {}},
std::nullopt, "unknown error (-1)"); static_cast<Error>(1000000), std::nullopt,
"unknown error (1000000)");
checkResult({static_cast<Error>(-1), 42, {}}, static_cast<Error>(-1), 42, checkResult({static_cast<Error>(-1), 42, {}}, static_cast<Error>(-1), 42,
"unknown error (status: 42, error: -1)"); "unknown error (status: 42, error: -1)");
} }