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:
@@ -3,6 +3,7 @@
|
||||
## Unversioned
|
||||
|
||||
- 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: Pass `--force-openssl` when installing from CMake in Qt 6.8+. (#6129)
|
||||
|
||||
|
||||
@@ -84,7 +84,12 @@ void Button::setSvgResource(const QString &resourcePath)
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->svgRenderer)
|
||||
{
|
||||
this->svgRenderer->deleteLater();
|
||||
}
|
||||
this->svgRenderer = new QSvgRenderer(resourcePath, this);
|
||||
this->svgRenderer->setAspectRatioMode(Qt::KeepAspectRatio);
|
||||
this->svgResourcePath = resourcePath;
|
||||
|
||||
this->update();
|
||||
@@ -199,15 +204,7 @@ void Button::paintButton(QPainter &painter)
|
||||
if (this->enableMargin_)
|
||||
{
|
||||
auto s = this->getMargin();
|
||||
auto outSize = 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,
|
||||
};
|
||||
rect = {{s, s}, rect.size() - QSize{2 * s, 2 * s}};
|
||||
}
|
||||
|
||||
this->svgRenderer->render(&painter, rect);
|
||||
|
||||
@@ -112,9 +112,8 @@ void SplitInput::initLayout()
|
||||
|
||||
replyHbox->addStretch(1);
|
||||
|
||||
auto replyCancelButton = replyHbox.emplace<EffectLabel>(nullptr, 4)
|
||||
.assign(&this->ui_.cancelReplyButton);
|
||||
replyCancelButton->getLabel().setTextFormat(Qt::RichText);
|
||||
auto replyCancelButton =
|
||||
replyHbox.emplace<Button>().assign(&this->ui_.cancelReplyButton);
|
||||
|
||||
replyCancelButton->hide();
|
||||
replyLabel->hide();
|
||||
@@ -303,13 +302,17 @@ void SplitInput::updateCancelReplyButton()
|
||||
{
|
||||
float scale = this->scale();
|
||||
|
||||
auto text =
|
||||
QStringLiteral("<img src=':/buttons/%1.svg' width='%2' height='%2' />")
|
||||
.arg(this->theme->isLightTheme() ? "cancelDark" : "cancel")
|
||||
.arg(int(12 * scale));
|
||||
|
||||
this->ui_.cancelReplyButton->getLabel().setText(text);
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
this->ui_.cancelReplyButton->setSvgResource(":/buttons/cancelDark.svg");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.cancelReplyButton->setSvgResource(":/buttons/cancel.svg");
|
||||
}
|
||||
this->ui_.cancelReplyButton->setEnableMargin(false);
|
||||
this->ui_.cancelReplyButton->setFixedHeight(int(12 * scale));
|
||||
this->ui_.cancelReplyButton->setFixedWidth(int(20 * scale));
|
||||
}
|
||||
|
||||
void SplitInput::openEmotePopup()
|
||||
|
||||
@@ -144,7 +144,7 @@ protected:
|
||||
QHBoxLayout *replyHbox;
|
||||
MessageView *replyMessage;
|
||||
QLabel *replyLabel;
|
||||
EffectLabel *cancelReplyButton;
|
||||
Button *cancelReplyButton;
|
||||
|
||||
// input widgets
|
||||
QWidget *inputWrapper;
|
||||
|
||||
@@ -50,8 +50,9 @@ TEST(NetworkResult, Errors)
|
||||
|
||||
TEST(NetworkResult, InvalidError)
|
||||
{
|
||||
checkResult({static_cast<Error>(-1), {}, {}}, static_cast<Error>(-1),
|
||||
std::nullopt, "unknown error (-1)");
|
||||
checkResult({static_cast<Error>(1000000), {}, {}},
|
||||
static_cast<Error>(1000000), std::nullopt,
|
||||
"unknown error (1000000)");
|
||||
checkResult({static_cast<Error>(-1), 42, {}}, static_cast<Error>(-1), 42,
|
||||
"unknown error (status: 42, error: -1)");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user