Add splash screen

This commit is contained in:
Alex Spataru 2021-09-23 22:56:03 -05:00
parent 3f03cc3b5a
commit 04cae22e06
20 changed files with 70 additions and 47 deletions

View File

@ -2,5 +2,6 @@
<qresource prefix="/images"> <qresource prefix="/images">
<file>donate-qr.svg</file> <file>donate-qr.svg</file>
<file>icon.svg</file> <file>icon.svg</file>
<file>splash.png</file>
</qresource> </qresource>
</RCC> </RCC>

BIN
assets/images/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -82,6 +82,8 @@ ApplicationWindow {
windowMaximized = false windowMaximized = false
} }
// Hide splash screen
Cpp_ModuleManager.hideSplashscreen()
} }
// //

View File

@ -126,7 +126,7 @@ Item {
} RadioButton { } RadioButton {
id: commAuto id: commAuto
checked: true checked: true
text: qsTr("Auto (JSON from serial device)") text: qsTr("No parsing (device sends JSON data)")
onCheckedChanged: { onCheckedChanged: {
if (checked) if (checked)
Cpp_JSON_Generator.setOperationMode(1) Cpp_JSON_Generator.setOperationMode(1)
@ -136,7 +136,7 @@ Item {
} RadioButton { } RadioButton {
id: commManual id: commManual
checked: false checked: false
text: qsTr("Manual (use JSON map file)") text: qsTr("Parse via JSON project file")
onCheckedChanged: { onCheckedChanged: {
if (checked) if (checked)
Cpp_JSON_Generator.setOperationMode(0) Cpp_JSON_Generator.setOperationMode(0)
@ -154,8 +154,8 @@ Item {
enabled: commManual.checked enabled: commManual.checked
onClicked: Cpp_JSON_Generator.loadJsonMap() onClicked: Cpp_JSON_Generator.loadJsonMap()
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
text: (Cpp_JSON_Generator.jsonMapFilename.length ? qsTr("Change map file (%1)").arg(Cpp_JSON_Generator.jsonMapFilename) : text: (Cpp_JSON_Generator.jsonMapFilename.length ? qsTr("Change project file (%1)").arg(Cpp_JSON_Generator.jsonMapFilename) :
qsTr("Select map file") + "...") qsTr("Select project file") + "...")
} }
// //

View File

@ -56,8 +56,6 @@ Export::Export()
connect(io, &IO::Manager::connectedChanged, this, &Export::closeFile); connect(io, &IO::Manager::connectedChanged, this, &Export::closeFile);
connect(te, &Misc::TimerEvents::lowFreqTimeout, this, &Export::writeValues); connect(te, &Misc::TimerEvents::lowFreqTimeout, this, &Export::writeValues);
connect(ge, &JSON::Generator::jsonChanged, this, &Export::registerFrame); connect(ge, &JSON::Generator::jsonChanged, this, &Export::registerFrame);
LOG_TRACE() << "Class initialized";
} }
/** /**

View File

@ -60,7 +60,6 @@ Player::Player()
, m_timestamp("") , m_timestamp("")
{ {
connect(this, SIGNAL(playerStateChanged()), this, SLOT(updateData())); connect(this, SIGNAL(playerStateChanged()), this, SLOT(updateData()));
LOG_TRACE() << "Class initialized";
} }
/** /**
@ -258,7 +257,7 @@ void Player::openFile(const QString &filePath)
auto sm = IO::Manager::getInstance(); auto sm = IO::Manager::getInstance();
if (sm->connected()) if (sm->connected())
{ {
LOG_TRACE() << "Serial device open, asking user what to do..."; LOG_INFO() << "Serial device open, asking user what to do...";
auto response = Misc::Utilities::showMessageBox( auto response = Misc::Utilities::showMessageBox(
tr("Serial port open, do you want to continue?"), tr("Serial port open, do you want to continue?"),
tr("In order to use this feature, its necessary " tr("In order to use this feature, its necessary "
@ -317,7 +316,7 @@ void Player::openFile(const QString &filePath)
// Open error // Open error
else else
{ {
LOG_TRACE() << "CSV file read error" << m_csvFile.errorString(); LOG_INFO() << "CSV file read error" << m_csvFile.errorString();
Misc::Utilities::showMessageBox(tr("Cannot read CSV file"), Misc::Utilities::showMessageBox(tr("Cannot read CSV file"),
tr("Please check file permissions & location")); tr("Please check file permissions & location"));
closeFile(); closeFile();
@ -470,7 +469,7 @@ QJsonDocument Player::getJsonFrame(const int row)
// Create the group/dataset model only one time // Create the group/dataset model only one time
if (m_model.isEmpty()) if (m_model.isEmpty())
{ {
LOG_TRACE() << "Generating group/dataset model from CSV..."; LOG_INFO() << "Generating group/dataset model from CSV...";
auto titles = m_csvData.at(0); auto titles = m_csvData.at(0);
for (int i = 1; i < titles.count(); ++i) for (int i = 1; i < titles.count(); ++i)
@ -537,7 +536,7 @@ QJsonDocument Player::getJsonFrame(const int row)
} }
} }
LOG_TRACE() << "Group/dataset model created successfully"; LOG_INFO() << "Group/dataset model created successfully";
} }
// Check that row is valid // Check that row is valid

View File

@ -102,9 +102,6 @@ Console::Console()
connect(te, SIGNAL(highFreqTimeout()), this, SLOT(displayData())); connect(te, SIGNAL(highFreqTimeout()), this, SLOT(displayData()));
connect(dm, &Manager::dataSent, this, &Console::onDataSent); connect(dm, &Manager::dataSent, this, &Console::onDataSent);
connect(dm, &Manager::dataReceived, this, &Console::onDataReceived); connect(dm, &Manager::dataReceived, this, &Console::onDataReceived);
// Log something to look like a pro
LOG_TRACE() << "Class initialized";
} }
/** /**

View File

@ -58,9 +58,6 @@ Serial::Serial()
// Build serial devices list // Build serial devices list
auto te = Misc::TimerEvents::getInstance(); auto te = Misc::TimerEvents::getInstance();
connect(te, SIGNAL(lowFreqTimeout()), this, SLOT(refreshSerialDevices())); connect(te, SIGNAL(lowFreqTimeout()), this, SLOT(refreshSerialDevices()));
// Log class init
LOG_TRACE() << "Class initialized";
} }
/** /**

View File

@ -74,7 +74,6 @@ Manager::Manager()
{ {
// setWatchdogInterval(15); // setWatchdogInterval(15);
setMaxBufferSize(1024 * 1024); setMaxBufferSize(1024 * 1024);
LOG_TRACE() << "Class initialized";
// Configure signals/slots // Configure signals/slots
auto serial = DataSources::Serial::getInstance(); auto serial = DataSources::Serial::getInstance();
@ -418,7 +417,7 @@ void Manager::setDataSource(const DataSource source)
emit dataSourceChanged(); emit dataSourceChanged();
// Log changes // Log changes
LOG_TRACE() << "Data source set to" << source; LOG_INFO() << "Data source set to" << source;
} }
/** /**
@ -640,7 +639,7 @@ void Manager::setDevice(QIODevice *device)
m_device = device; m_device = device;
emit deviceChanged(); emit deviceChanged();
LOG_TRACE() << "Device pointer set to" << m_device; LOG_INFO() << "Device pointer set to" << m_device;
} }
/** /**

View File

@ -58,8 +58,6 @@ Generator::Generator()
connect(io, SIGNAL(deviceChanged()), this, SLOT(reset())); connect(io, SIGNAL(deviceChanged()), this, SLOT(reset()));
connect(io, SIGNAL(frameReceived(QByteArray)), this, SLOT(readData(QByteArray))); connect(io, SIGNAL(frameReceived(QByteArray)), this, SLOT(readData(QByteArray)));
m_workerThread.start(); m_workerThread.start();
LOG_TRACE() << "Class initialized";
} }
/** /**
@ -146,6 +144,7 @@ void Generator::loadJsonMap(const QString &path)
if (m_jsonMap.isOpen()) if (m_jsonMap.isOpen())
{ {
m_jsonMap.close(); m_jsonMap.close();
m_jsonMapData = "";
emit jsonFileMapChanged(); emit jsonFileMapChanged();
} }
@ -159,7 +158,7 @@ void Generator::loadJsonMap(const QString &path)
auto document = QJsonDocument::fromJson(data, &error); auto document = QJsonDocument::fromJson(data, &error);
if (error.error != QJsonParseError::NoError) if (error.error != QJsonParseError::NoError)
{ {
LOG_TRACE() << "JSON parse error" << error.errorString(); LOG_INFO() << "JSON parse error" << error.errorString();
m_jsonMap.close(); m_jsonMap.close();
writeSettings(""); writeSettings("");
@ -169,7 +168,7 @@ void Generator::loadJsonMap(const QString &path)
// JSON contains no errors, load data & save settings // JSON contains no errors, load data & save settings
else else
{ {
LOG_TRACE() << "JSON map loaded successfully"; LOG_INFO() << "JSON map loaded successfully";
writeSettings(path); writeSettings(path);
m_jsonMapData = QString::fromUtf8(data); m_jsonMapData = QString::fromUtf8(data);
@ -182,7 +181,8 @@ void Generator::loadJsonMap(const QString &path)
// Open error // Open error
else else
{ {
LOG_TRACE() << "JSON file error" << m_jsonMap.errorString(); m_jsonMapData = "";
LOG_INFO() << "JSON file error" << m_jsonMap.errorString();
writeSettings(""); writeSettings("");
Misc::Utilities::showMessageBox(tr("Cannot read JSON file"), Misc::Utilities::showMessageBox(tr("Cannot read JSON file"),
@ -212,7 +212,7 @@ void Generator::setOperationMode(const OperationMode mode)
m_opMode = mode; m_opMode = mode;
emit operationModeChanged(); emit operationModeChanged();
LOG_TRACE() << "Operation mode set to" << mode; LOG_INFO() << "Operation mode set to" << mode;
} }
/** /**

View File

@ -74,9 +74,6 @@ MacExtras::MacExtras()
// Re-translate buttons when language is changed // Re-translate buttons when language is changed
connect(Translator::getInstance(), SIGNAL(languageChanged()), this, connect(Translator::getInstance(), SIGNAL(languageChanged()), this,
SLOT(updateButtonText())); SLOT(updateButtonText()));
// Logger
LOG_TRACE() << "Class initialized";
#endif #endif
} }

View File

@ -65,6 +65,10 @@
*/ */
ModuleManager::ModuleManager() ModuleManager::ModuleManager()
{ {
m_splash.setPixmap(QPixmap(":/images/splash.png"));
m_splash.show();
setSplashScreenMessage(tr("Initializing..."));
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(stopOperations())); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(stopOperations()));
} }
@ -74,6 +78,8 @@ ModuleManager::ModuleManager()
*/ */
void ModuleManager::configureLogger() void ModuleManager::configureLogger()
{ {
setSplashScreenMessage(tr("Configuring logger..."));
auto fileAppender = new FileAppender; auto fileAppender = new FileAppender;
auto consoleAppender = new ConsoleAppender; auto consoleAppender = new ConsoleAppender;
fileAppender->setFormat(LOG_FORMAT); fileAppender->setFormat(LOG_FORMAT);
@ -94,11 +100,13 @@ void ModuleManager::configureUpdater()
if (!autoUpdaterEnabled()) if (!autoUpdaterEnabled())
return; return;
LOG_TRACE() << "Configuring QSimpleUpdater..."; setSplashScreenMessage(tr("Configuring updater..."));
LOG_INFO() << "Configuring QSimpleUpdater...";
QSimpleUpdater::getInstance()->setNotifyOnUpdate(APP_UPDATER_URL, true); QSimpleUpdater::getInstance()->setNotifyOnUpdate(APP_UPDATER_URL, true);
QSimpleUpdater::getInstance()->setNotifyOnFinish(APP_UPDATER_URL, false); QSimpleUpdater::getInstance()->setNotifyOnFinish(APP_UPDATER_URL, false);
QSimpleUpdater::getInstance()->setMandatoryUpdate(APP_UPDATER_URL, false); QSimpleUpdater::getInstance()->setMandatoryUpdate(APP_UPDATER_URL, false);
LOG_TRACE() << "QSimpleUpdater configuration finished!"; LOG_INFO() << "QSimpleUpdater configuration finished!";
} }
/** /**
@ -109,12 +117,12 @@ void ModuleManager::configureUpdater()
*/ */
void ModuleManager::registerQmlTypes() void ModuleManager::registerQmlTypes()
{ {
LOG_TRACE() << "Registering QML types..."; LOG_INFO() << "Registering QML types...";
qRegisterMetaType<JFI_Object>("JFI_Object"); qRegisterMetaType<JFI_Object>("JFI_Object");
qmlRegisterType<JSON::Group>("SerialStudio", 1, 0, "Group"); qmlRegisterType<JSON::Group>("SerialStudio", 1, 0, "Group");
qmlRegisterType<JSON::Dataset>("SerialStudio", 1, 0, "Dataset"); qmlRegisterType<JSON::Dataset>("SerialStudio", 1, 0, "Dataset");
qmlRegisterType<UI::QmlPlainTextEdit>("SerialStudio", 1, 0, "QmlPlainTextEdit"); qmlRegisterType<UI::QmlPlainTextEdit>("SerialStudio", 1, 0, "QmlPlainTextEdit");
LOG_TRACE() << "QML types registered!"; LOG_INFO() << "QML types registered!";
} }
/** /**
@ -141,6 +149,7 @@ void ModuleManager::initializeQmlInterface()
{ {
// Initialize modules // Initialize modules
LOG_INFO() << "Initializing C++ modules"; LOG_INFO() << "Initializing C++ modules";
setSplashScreenMessage(tr("Initializing modules..."));
auto translator = Misc::Translator::getInstance(); auto translator = Misc::Translator::getInstance();
auto csvExport = CSV::Export::getInstance(); auto csvExport = CSV::Export::getInstance();
auto csvPlayer = CSV::Player::getInstance(); auto csvPlayer = CSV::Player::getInstance();
@ -188,6 +197,7 @@ void ModuleManager::initializeQmlInterface()
c->setContextProperty("Cpp_Plugins_Bridge", pluginsBridge); c->setContextProperty("Cpp_Plugins_Bridge", pluginsBridge);
c->setContextProperty("Cpp_Misc_MacExtras", macExtras); c->setContextProperty("Cpp_Misc_MacExtras", macExtras);
c->setContextProperty("Cpp_Misc_TimerEvents", timerEvents); c->setContextProperty("Cpp_Misc_TimerEvents", timerEvents);
c->setContextProperty("Cpp_ModuleManager", this);
// Register app info with QML // Register app info with QML
c->setContextProperty("Cpp_AppName", qApp->applicationName()); c->setContextProperty("Cpp_AppName", qApp->applicationName());
@ -200,10 +210,12 @@ void ModuleManager::initializeQmlInterface()
engine()->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); engine()->load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
// Start common event timers // Start common event timers
setSplashScreenMessage(tr("Starting timers..."));
timerEvents->startTimers(); timerEvents->startTimers();
// Log QML engine status // Log QML engine status
LOG_INFO() << "Finished loading QML interface"; LOG_INFO() << "Finished loading QML interface";
setSplashScreenMessage(tr("Loading user interface..."));
} }
/** /**
@ -214,6 +226,28 @@ QQmlApplicationEngine *ModuleManager::engine()
return &m_engine; return &m_engine;
} }
/**
* Hides the splash screen widget
*/
void ModuleManager::hideSplashscreen()
{
m_splash.hide();
m_splash.close();
qApp->processEvents();
}
/**
* Changes the text displayed on the splash screen
*/
void ModuleManager::setSplashScreenMessage(const QString &message)
{
if (!message.isEmpty())
{
m_splash.showMessage(message, Qt::AlignBottom | Qt::AlignLeft, Qt::white);
qApp->processEvents();
}
}
/** /**
* Calls the functions needed to safely quit the application * Calls the functions needed to safely quit the application
*/ */

View File

@ -24,6 +24,7 @@
#define MODULE_MANAGER_H #define MODULE_MANAGER_H
#include <QObject> #include <QObject>
#include <QSplashScreen>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
class ModuleManager : public QObject class ModuleManager : public QObject
@ -41,10 +42,15 @@ public:
QQmlApplicationEngine *engine(); QQmlApplicationEngine *engine();
public slots:
void hideSplashscreen();
void setSplashScreenMessage(const QString &message);
private slots: private slots:
void stopOperations(); void stopOperations();
private: private:
QSplashScreen m_splash;
QQmlApplicationEngine m_engine; QQmlApplicationEngine m_engine;
}; };

View File

@ -59,7 +59,6 @@ TimerEvents::TimerEvents()
// Configure signals/slots // Configure signals/slots
connect(&m_timerLowFreq, &QTimer::timeout, this, &TimerEvents::lowFreqTimeout); connect(&m_timerLowFreq, &QTimer::timeout, this, &TimerEvents::lowFreqTimeout);
connect(&m_timerHighFreq, &QTimer::timeout, this, &TimerEvents::highFreqTimeout); connect(&m_timerHighFreq, &QTimer::timeout, this, &TimerEvents::highFreqTimeout);
LOG_TRACE() << "Class initialized";
} }
/** /**
@ -100,7 +99,7 @@ void TimerEvents::startTimers()
m_timerLowFreq.start(); m_timerLowFreq.start();
m_timerHighFreq.start(); m_timerHighFreq.start();
LOG_TRACE() << "Timers started"; LOG_INFO() << "Timers started";
} }
/** /**

View File

@ -38,8 +38,7 @@ static Translator *INSTANCE = nullptr;
Translator::Translator() Translator::Translator()
{ {
m_language = systemLanguage(); m_language = systemLanguage();
LOG_TRACE() << "Class initialized"; LOG_INFO() << "System language" << systemLanguage();
LOG_TRACE() << "System language" << systemLanguage();
} }
/** /**
@ -215,5 +214,5 @@ void Translator::setLanguage(const QLocale &locale, const QString &language)
qApp->installTranslator(&m_translator); qApp->installTranslator(&m_translator);
emit languageChanged(); emit languageChanged();
LOG_TRACE() << "Language set to" << language; LOG_INFO() << "Language set to" << language;
} }

View File

@ -52,7 +52,6 @@ DataProvider::DataProvider()
connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData())); connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData()));
connect(ge, SIGNAL(jsonFileMapChanged()), this, SLOT(resetData())); connect(ge, SIGNAL(jsonFileMapChanged()), this, SLOT(resetData()));
connect(ge, &JSON::Generator::jsonChanged, this, &DataProvider::selectLatestJSON); connect(ge, &JSON::Generator::jsonChanged, this, &DataProvider::selectLatestJSON);
LOG_TRACE() << "Class initialized";
} }
/** /**

View File

@ -81,7 +81,6 @@ GraphProvider::GraphProvider()
this, SLOT(csvPlayerFixes())); this, SLOT(csvPlayerFixes()));
// clang-format on // clang-format on
LOG_TRACE() << "Class initialized";
} }
/** /**

View File

@ -55,7 +55,6 @@ WidgetProvider::WidgetProvider()
connect(cp, SIGNAL(openChanged()), this, SLOT(resetData())); connect(cp, SIGNAL(openChanged()), this, SLOT(resetData()));
connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData())); connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData()));
connect(jg, SIGNAL(jsonFileMapChanged()), this, SLOT(resetData())); connect(jg, SIGNAL(jsonFileMapChanged()), this, SLOT(resetData()));
LOG_TRACE() << "Class initialized";
} }
/** /**

View File

@ -117,9 +117,10 @@ int main(int argc, char **argv)
} }
} }
// Create module manager & configure the logger // Create module manager
ModuleManager moduleManager; ModuleManager moduleManager;
moduleManager.configureLogger(); moduleManager.configureLogger();
moduleManager.configureUpdater();
// Begin logging // Begin logging
LOG_INFO() << QDateTime::currentDateTime(); LOG_INFO() << QDateTime::currentDateTime();
@ -135,9 +136,6 @@ int main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// Configure the updater
moduleManager.configureUpdater();
// Enter application event loop // Enter application event loop
auto code = app.exec(); auto code = app.exec();
LOG_INFO() << "Application exit code" << code; LOG_INFO() << "Application exit code" << code;