mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-06 02:15:52 +00:00
refactor: fix some minor clang-tidy warnings
This commit is contained in:
@ -245,7 +245,7 @@ void AbstractExtItem::setNumber(int _number)
|
||||
if (generateNumber) {
|
||||
_number = []() {
|
||||
qCWarning(LOG_LIB) << "Number is empty, generate new one";
|
||||
auto n = QRandomGenerator::global()->generate() % 1000;
|
||||
auto n = QRandomGenerator::global()->bounded(1000);
|
||||
qCInfo(LOG_LIB) << "Generated number is" << n;
|
||||
return n;
|
||||
}();
|
||||
|
@ -184,8 +184,9 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply)
|
||||
_reply->deleteLater();
|
||||
|
||||
auto data = m_providerObject->parse(text);
|
||||
for (auto [key, value] : data.asKeyValueRange())
|
||||
for (auto [key, value] : data.asKeyValueRange()) {
|
||||
m_values[tag(key)] = value;
|
||||
}
|
||||
|
||||
emit(dataReceived(m_values));
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ QString GraphicalItem::image(const QVariant &value)
|
||||
|
||||
m_scene->clear();
|
||||
auto scaleX = 1, scaleY = 1;
|
||||
auto converted = GraphicalItemHelper::getPercents(value.toFloat(), minValue(), maxValue());
|
||||
auto converted = GraphicalItemHelper::getPercents(value.toDouble(), minValue(), maxValue());
|
||||
|
||||
// paint
|
||||
switch (m_type) {
|
||||
@ -182,13 +182,13 @@ int GraphicalItem::itemWidth() const
|
||||
}
|
||||
|
||||
|
||||
float GraphicalItem::maxValue() const
|
||||
double GraphicalItem::maxValue() const
|
||||
{
|
||||
return m_maxValue;
|
||||
}
|
||||
|
||||
|
||||
float GraphicalItem::minValue() const
|
||||
double GraphicalItem::minValue() const
|
||||
{
|
||||
return m_minValue;
|
||||
}
|
||||
@ -321,7 +321,7 @@ void GraphicalItem::setItemWidth(const int _width)
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setMaxValue(const float _value)
|
||||
void GraphicalItem::setMaxValue(const double _value)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Max value" << _value;
|
||||
|
||||
@ -329,7 +329,7 @@ void GraphicalItem::setMaxValue(const float _value)
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setMinValue(const float _value)
|
||||
void GraphicalItem::setMinValue(const double _value)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Min value" << _value;
|
||||
|
||||
@ -406,8 +406,8 @@ void GraphicalItem::readConfiguration()
|
||||
setCount(settings.value("X-AW-Count", count()).toInt());
|
||||
setCustom(settings.value("X-AW-Custom", isCustom()).toBool());
|
||||
setBar(settings.value("X-AW-Value", bar()).toString());
|
||||
setMaxValue(settings.value("X-AW-Max", maxValue()).toFloat());
|
||||
setMinValue(settings.value("X-AW-Min", minValue()).toFloat());
|
||||
setMaxValue(settings.value("X-AW-Max", maxValue()).toDouble());
|
||||
setMinValue(settings.value("X-AW-Min", minValue()).toDouble());
|
||||
setActiveColor(settings.value("X-AW-ActiveColor", activeColor()).toString());
|
||||
setInactiveColor(settings.value("X-AW-InactiveColor", inactiveColor()).toString());
|
||||
setStrType(settings.value("X-AW-Type", strType()).toString());
|
||||
@ -439,9 +439,8 @@ int GraphicalItem::showConfiguration(QWidget *_parent, const QVariant &_args)
|
||||
ui->setupUi(dialog);
|
||||
translate(ui);
|
||||
|
||||
connect(ui->checkBox_custom, &QCheckBox::stateChanged, [this, ui](const int state) { changeValue(ui, state); });
|
||||
connect(ui->comboBox_type, &QComboBox::currentIndexChanged,
|
||||
[this, ui](const int state) { changeCountState(ui, state); });
|
||||
connect(ui->checkBox_custom, &QCheckBox::stateChanged, [ui](const int state) { changeValue(ui, state); });
|
||||
connect(ui->comboBox_type, &QComboBox::currentIndexChanged, [ui](const int state) { changeCountState(ui, state); });
|
||||
connect(ui->toolButton_activeColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); });
|
||||
connect(ui->toolButton_inactiveColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); });
|
||||
|
||||
|
@ -64,8 +64,8 @@ public:
|
||||
[[nodiscard]] bool isCustom() const;
|
||||
[[nodiscard]] int itemHeight() const;
|
||||
[[nodiscard]] int itemWidth() const;
|
||||
[[nodiscard]] float minValue() const;
|
||||
[[nodiscard]] float maxValue() const;
|
||||
[[nodiscard]] double minValue() const;
|
||||
[[nodiscard]] double maxValue() const;
|
||||
[[nodiscard]] Type type() const;
|
||||
[[nodiscard]] QString strType() const;
|
||||
[[nodiscard]] Direction direction() const;
|
||||
@ -80,8 +80,8 @@ public:
|
||||
void setInactiveColor(const QString &_color);
|
||||
void setItemHeight(int _height);
|
||||
void setItemWidth(int _width);
|
||||
void setMinValue(float _value);
|
||||
void setMaxValue(float _value);
|
||||
void setMinValue(double _value);
|
||||
void setMaxValue(double _value);
|
||||
void setType(Type _type);
|
||||
void setStrType(const QString &_type);
|
||||
void setDirection(Direction _direction);
|
||||
@ -110,8 +110,8 @@ private:
|
||||
bool m_custom = false;
|
||||
QString m_activeColor = "color://0,0,0,130";
|
||||
QString m_inactiveColor = "color://255,255,255,130";
|
||||
float m_minValue = 0.0f;
|
||||
float m_maxValue = 100.0f;
|
||||
double m_minValue = 0.0;
|
||||
double m_maxValue = 100.0;
|
||||
Type m_type = Type::Horizontal;
|
||||
Direction m_direction = Direction::LeftToRight;
|
||||
int m_height = 100;
|
||||
|
@ -155,7 +155,7 @@ void GraphicalItemHelper::paintVertical(const float _percent)
|
||||
}
|
||||
|
||||
|
||||
float GraphicalItemHelper::getPercents(const float _value, const float _min, const float _max)
|
||||
double GraphicalItemHelper::getPercents(const double _value, const double _min, const double _max)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Get percent value from" << _value;
|
||||
// newest Qt crashes here if value is nan
|
||||
|
@ -40,12 +40,12 @@ public:
|
||||
void paintHorizontal(float _percent);
|
||||
void paintVertical(float _percent);
|
||||
// additional conversion methods
|
||||
static float getPercents(float _value, float _min, float _max);
|
||||
static double getPercents(double _value, double _min, double _max);
|
||||
static bool isColor(const QString &_input);
|
||||
static QColor stringToColor(const QString &_color);
|
||||
|
||||
private:
|
||||
static QBrush parseBrush(const QString &_input, const int _width, const int _height, const QColor &_default);
|
||||
static QBrush parseBrush(const QString &_input, int _width, int _height, const QColor &_default);
|
||||
void storeValue(float _value);
|
||||
QGraphicsScene *m_scene = nullptr;
|
||||
int m_count = 100;
|
||||
|
Reference in New Issue
Block a user