mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: Comply with Wdouble-promotion
Remove implicit float to double conversions.
This commit is contained in:
parent
02d5270dcc
commit
b0bf3d77cb
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
int getColumn() const;
|
||||
|
||||
virtual void setWidth(qreal width) = 0;
|
||||
virtual void setWidth(float width) = 0;
|
||||
int type() const final;
|
||||
|
||||
virtual void selectionMouseMove(QPointF scenePos);
|
||||
|
|
|
@ -76,7 +76,7 @@ QWidget* ChatLineContentProxy::getWidget() const
|
|||
return proxy->widget();
|
||||
}
|
||||
|
||||
void ChatLineContentProxy::setWidth(qreal width)
|
||||
void ChatLineContentProxy::setWidth(float width)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
proxy->widget()->setFixedWidth(qMax(static_cast<int>(width * widthPercent), widthMin));
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
ChatLineContentProxy(FileTransferWidget* widget, int minWidth, float widthInPercent = 1.0f);
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void setWidth(qreal width) override;
|
||||
void setWidth(float width) override;
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||
qreal getAscent() const override;
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString& sender, const QSt
|
|||
QColor color = Style::getColor(Style::MainText);
|
||||
if (colorizeName) {
|
||||
QByteArray hash = QCryptographicHash::hash((sender.toUtf8()), QCryptographicHash::Sha256);
|
||||
float lightness = color.lightnessF();
|
||||
auto lightness = color.lightnessF();
|
||||
// Adapt as good as possible to Light/Dark themes
|
||||
lightness = lightness*0.5 + 0.3;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void Broken::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
|||
|
||||
}
|
||||
|
||||
void Broken::setWidth(qreal width)
|
||||
void Broken::setWidth(float width)
|
||||
{
|
||||
std::ignore = width;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
QRectF boundingRect() const override;
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget) override;
|
||||
void setWidth(qreal width) override;
|
||||
void setWidth(float width) override;
|
||||
qreal getAscent() const override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -50,7 +50,7 @@ void Image::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWi
|
|||
std::ignore = widget;
|
||||
}
|
||||
|
||||
void Image::setWidth(qreal width)
|
||||
void Image::setWidth(float width)
|
||||
{
|
||||
std::ignore = width;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
QRectF boundingRect() const override;
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget) override;
|
||||
void setWidth(qreal width) override;
|
||||
void setWidth(float width) override;
|
||||
qreal getAscent() const override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -61,7 +61,7 @@ void NotificationIcon::paint(QPainter* painter, const QStyleOptionGraphicsItem*
|
|||
std::ignore = widget;
|
||||
}
|
||||
|
||||
void NotificationIcon::setWidth(qreal width)
|
||||
void NotificationIcon::setWidth(float width)
|
||||
{
|
||||
std::ignore = width;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
QRectF boundingRect() const override;
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget) override;
|
||||
void setWidth(qreal width) override;
|
||||
void setWidth(float width) override;
|
||||
qreal getAscent() const override;
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -60,7 +60,7 @@ void Spinner::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, Q
|
|||
{
|
||||
painter->setClipRect(boundingRect());
|
||||
|
||||
QTransform trans = QTransform().rotate(curRot)
|
||||
QTransform trans = QTransform().rotate(static_cast<qreal>(curRot))
|
||||
.translate(-size.width() / 2.0, -size.height() / 2.0);
|
||||
painter->setOpacity(alpha);
|
||||
painter->setTransform(trans, true);
|
||||
|
@ -75,7 +75,7 @@ void Spinner::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, Q
|
|||
std::ignore = widget;
|
||||
}
|
||||
|
||||
void Spinner::setWidth(qreal width)
|
||||
void Spinner::setWidth(float width)
|
||||
{
|
||||
std::ignore = width;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
QRectF boundingRect() const override;
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget) override;
|
||||
void setWidth(qreal width) override;
|
||||
void setWidth(float width) override;
|
||||
qreal getAscent() const override;
|
||||
|
||||
private slots:
|
||||
|
@ -46,8 +46,8 @@ private:
|
|||
static constexpr int framerate = 30; // 30Hz
|
||||
QSize size;
|
||||
QPixmap pmap;
|
||||
qreal rotSpeed;
|
||||
qreal curRot;
|
||||
float rotSpeed;
|
||||
float curRot;
|
||||
QTimer timer;
|
||||
qreal alpha = 0.0;
|
||||
QVariantAnimation* blendAnimation;
|
||||
|
|
|
@ -91,7 +91,7 @@ void Text::deselectText()
|
|||
update();
|
||||
}
|
||||
|
||||
void Text::setWidth(qreal w)
|
||||
void Text::setWidth(float w)
|
||||
{
|
||||
width = w;
|
||||
dirty = true;
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
void selectText(const QRegularExpression& exp, const std::pair<int, int>& point);
|
||||
void deselectText();
|
||||
|
||||
void setWidth(qreal width) final;
|
||||
void setWidth(float width) final;
|
||||
|
||||
void selectionMouseMove(QPointF scenePos) final;
|
||||
void selectionStarted(QPointF scenePos) final;
|
||||
|
|
|
@ -129,8 +129,8 @@ double ToxFileProgress::getTimeLeftSeconds() const
|
|||
}
|
||||
|
||||
const auto speed = getSpeed();
|
||||
if (speed == 0.0f) {
|
||||
return std::numeric_limits<float>::infinity();
|
||||
if (speed == 0.0) {
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
return double(filesize - samples[activeSample].bytesSent) / getSpeed();
|
||||
|
|
|
@ -172,7 +172,7 @@ void AVForm::rescanDevices()
|
|||
|
||||
void AVForm::setVolume(float value)
|
||||
{
|
||||
volumeDisplay->setValue(getStepsFromValue(value, audio.minOutputVolume(), audio.maxOutputVolume()));
|
||||
volumeDisplay->setValue(getStepsFromValue(static_cast<qreal>(value), audio.minOutputVolume(), audio.maxOutputVolume()));
|
||||
}
|
||||
|
||||
void AVForm::on_videoModescomboBox_currentIndexChanged(int index)
|
||||
|
@ -310,7 +310,7 @@ void AVForm::fillCameraModesComboBox()
|
|||
QString str;
|
||||
std::string pixelFormat = CameraDevice::getPixelFormatString(mode.pixel_format).toStdString();
|
||||
qDebug("width: %d, height: %d, FPS: %f, pixel format: %s", mode.width, mode.height,
|
||||
mode.FPS, pixelFormat.c_str());
|
||||
static_cast<double>(mode.FPS), pixelFormat.c_str());
|
||||
|
||||
if (mode.height && mode.width) {
|
||||
str += QString("%1p").arg(mode.height);
|
||||
|
@ -352,7 +352,7 @@ void AVForm::fillScreenModesComboBox()
|
|||
VideoMode mode = videoModes[i];
|
||||
std::string pixelFormat = CameraDevice::getPixelFormatString(mode.pixel_format).toStdString();
|
||||
qDebug("%dx%d+%d,%d FPS: %f, pixel format: %s\n", mode.width, mode.height, mode.x, mode.y,
|
||||
mode.FPS, pixelFormat.c_str());
|
||||
static_cast<double>(mode.FPS), pixelFormat.c_str());
|
||||
|
||||
QString name;
|
||||
if (mode.width && mode.height)
|
||||
|
@ -651,5 +651,5 @@ int AVForm::getStepsFromValue(qreal val, qreal valMin, qreal valMax)
|
|||
|
||||
qreal AVForm::getValueFromSteps(int steps, qreal valMin, qreal valMax)
|
||||
{
|
||||
return (static_cast<float>(steps) / totalSliderSteps) * (valMax - valMin) + valMin;
|
||||
return (static_cast<qreal>(steps) / totalSliderSteps) * (valMax - valMin) + valMin;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ bool FlyoutOverlayWidget::isBeingShown() const
|
|||
|
||||
void FlyoutOverlayWidget::animateShow()
|
||||
{
|
||||
if (percent == 1.0f)
|
||||
if (percent == 1.0)
|
||||
return;
|
||||
|
||||
if (animation->state() != QAbstractAnimation::Running)
|
||||
|
|
|
@ -92,7 +92,7 @@ Identicon::Identicon(const QByteArray& data)
|
|||
* @param bytes Bytes to convert to a color
|
||||
* @return Value in the range of 0.0..1.0
|
||||
*/
|
||||
float Identicon::bytesToColor(QByteArray bytes)
|
||||
qreal Identicon::bytesToColor(QByteArray bytes)
|
||||
{
|
||||
static_assert(IDENTICON_COLOR_BYTES <= 8, "IDENTICON_COLOR max value is 8");
|
||||
const uint8_t* const bytesChr = reinterpret_cast<const uint8_t*>(bytes.constData());
|
||||
|
@ -108,8 +108,8 @@ float Identicon::bytesToColor(QByteArray bytes)
|
|||
}
|
||||
|
||||
// normalize to 0.0 ... 1.0
|
||||
return (static_cast<float>(hue))
|
||||
/ (static_cast<float>(((static_cast<uint64_t>(1)) << (8 * IDENTICON_COLOR_BYTES)) - 1));
|
||||
return (static_cast<qreal>(hue))
|
||||
/ (static_cast<qreal>(((static_cast<uint64_t>(1)) << (8 * IDENTICON_COLOR_BYTES)) - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ class Identicon
|
|||
public:
|
||||
Identicon(const QByteArray& data);
|
||||
QImage toImage(int scaleFactor = 1);
|
||||
static float bytesToColor(QByteArray bytes);
|
||||
static qreal bytesToColor(QByteArray bytes);
|
||||
|
||||
public:
|
||||
static constexpr int IDENTICON_ROWS = 5;
|
||||
|
|
|
@ -52,12 +52,12 @@ void MovableWidget::setBoundary(QRect newBoundary)
|
|||
return;
|
||||
}
|
||||
|
||||
float changeX = newBoundary.width() / static_cast<float>(boundaryRect.width());
|
||||
float changeY = newBoundary.height() / static_cast<float>(boundaryRect.height());
|
||||
qreal changeX = newBoundary.width() / static_cast<qreal>(boundaryRect.width());
|
||||
qreal changeY = newBoundary.height() / static_cast<qreal>(boundaryRect.height());
|
||||
|
||||
float percentageX = (x() - boundaryRect.x()) / static_cast<float>(boundaryRect.width() - width());
|
||||
float percentageY =
|
||||
(y() - boundaryRect.y()) / static_cast<float>(boundaryRect.height() - height());
|
||||
qreal percentageX = (x() - boundaryRect.x()) / static_cast<qreal>(boundaryRect.width() - width());
|
||||
qreal percentageY =
|
||||
(y() - boundaryRect.y()) / static_cast<qreal>(boundaryRect.height() - height());
|
||||
|
||||
actualSize.setWidth(actualSize.width() * changeX);
|
||||
actualSize.setHeight(actualSize.height() * changeY);
|
||||
|
|
Loading…
Reference in New Issue
Block a user