bloguetronica / cp2130-conf

CP2130 Configurator (cp2130-conf) is an application that can be used to configure CP2130 devices, including VID, PID, as well as other descriptors. Most importantly, the application allows you to configure pin functions and states.
GNU General Public License v3.0
1 stars 1 forks source link

No need to include QCoreApplication #39

Closed samuelfmlourenco closed 1 week ago

samuelfmlourenco commented 1 year ago

Currently, the library QCoreApplication is included just to invoke QCoreApplication::installTranslator() in a procedural fashion. However, QApplication implements the same function in an object-oriented manner, as a function of the object itself. Thus, main() could be rewritten:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTranslator translator;
    if (!translator.load("cp2130-conf_" + QLocale::system().name(), ":/translations/translations")) {  // It the locale translation does not exist or cannot be loaded
        translator.load("cp2130-conf_en_US", ":/translations/translations");  // Fall back to the en-US translation
    }
    a.installTranslator(&translator);  // Replaces QCoreApplication::installTranslator(&translator)
    MainWindow w;
    w.show();
    return a.exec();
}

This approach is more object-oriented, and QCoreApplication doesn't need to be included.

samuelfmlourenco commented 1 week ago

Corrected in version 3.0.