AntiMicroX/antimicrox

Refactor constructors of some classes

Offen

#554 geöffnet am 09.10.2022

 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (236 Forks)auto 404
good first issuelow-priotityrefactor

Repository-Metriken

Stars
 (3.844 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Classes like ButtonEditDialog JoyButtonSlot (and probably many other) have many duplications in overrides constructors.

For example

JoyButtonSlot::JoyButtonSlot(QObject *parent)
    : QObject(parent)
    , extraData()
{
    deviceCode = 0;
    m_mode = JoyKeyboard;
    m_distance = 0.0;
    previousDistance = 0.0;
    qkeyaliasCode = 0;
    easingActive = false;
    mix_slots = nullptr;
}

JoyButtonSlot::JoyButtonSlot(int code, JoySlotInputAction mode, QObject *parent)
    : QObject(parent)
    , extraData()
{
    deviceCode = 0;
    qkeyaliasCode = 0;

    if (code > 0)
        deviceCode = code;

    m_mode = mode;
    m_distance = 0.0;
    easingActive = false;
    mix_slots = nullptr;
}

JoyButtonSlot::JoyButtonSlot(int code, int alias, JoySlotInputAction mode, QObject *parent)
    : QObject(parent)
    , extraData()
{
    deviceCode = 0;
    qkeyaliasCode = 0;

    if (code > 0)
        deviceCode = code;

    if (alias > 0)
        qkeyaliasCode = alias;

    m_mode = mode;
    m_distance = 0.0;
    easingActive = false;
    mix_slots = nullptr;
}

Instead of duplicating code, these constructors could call each other

Contributor Guide