mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
Add splash screen
This commit is contained in:
parent
3f03cc3b5a
commit
04cae22e06
@ -2,5 +2,6 @@
|
||||
<qresource prefix="/images">
|
||||
<file>donate-qr.svg</file>
|
||||
<file>icon.svg</file>
|
||||
<file>splash.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
assets/images/splash.png
Normal file
BIN
assets/images/splash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 188 KiB |
@ -82,6 +82,8 @@ ApplicationWindow {
|
||||
windowMaximized = false
|
||||
}
|
||||
|
||||
// Hide splash screen
|
||||
Cpp_ModuleManager.hideSplashscreen()
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -126,7 +126,7 @@ Item {
|
||||
} RadioButton {
|
||||
id: commAuto
|
||||
checked: true
|
||||
text: qsTr("Auto (JSON from serial device)")
|
||||
text: qsTr("No parsing (device sends JSON data)")
|
||||
onCheckedChanged: {
|
||||
if (checked)
|
||||
Cpp_JSON_Generator.setOperationMode(1)
|
||||
@ -136,7 +136,7 @@ Item {
|
||||
} RadioButton {
|
||||
id: commManual
|
||||
checked: false
|
||||
text: qsTr("Manual (use JSON map file)")
|
||||
text: qsTr("Parse via JSON project file")
|
||||
onCheckedChanged: {
|
||||
if (checked)
|
||||
Cpp_JSON_Generator.setOperationMode(0)
|
||||
@ -154,8 +154,8 @@ Item {
|
||||
enabled: commManual.checked
|
||||
onClicked: Cpp_JSON_Generator.loadJsonMap()
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
text: (Cpp_JSON_Generator.jsonMapFilename.length ? qsTr("Change map file (%1)").arg(Cpp_JSON_Generator.jsonMapFilename) :
|
||||
qsTr("Select map file") + "...")
|
||||
text: (Cpp_JSON_Generator.jsonMapFilename.length ? qsTr("Change project file (%1)").arg(Cpp_JSON_Generator.jsonMapFilename) :
|
||||
qsTr("Select project file") + "...")
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -56,8 +56,6 @@ Export::Export()
|
||||
connect(io, &IO::Manager::connectedChanged, this, &Export::closeFile);
|
||||
connect(te, &Misc::TimerEvents::lowFreqTimeout, this, &Export::writeValues);
|
||||
connect(ge, &JSON::Generator::jsonChanged, this, &Export::registerFrame);
|
||||
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,6 @@ Player::Player()
|
||||
, m_timestamp("")
|
||||
{
|
||||
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();
|
||||
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(
|
||||
tr("Serial port open, do you want to continue?"),
|
||||
tr("In order to use this feature, its necessary "
|
||||
@ -317,7 +316,7 @@ void Player::openFile(const QString &filePath)
|
||||
// Open error
|
||||
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"),
|
||||
tr("Please check file permissions & location"));
|
||||
closeFile();
|
||||
@ -470,7 +469,7 @@ QJsonDocument Player::getJsonFrame(const int row)
|
||||
// Create the group/dataset model only one time
|
||||
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);
|
||||
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
|
||||
|
@ -102,9 +102,6 @@ Console::Console()
|
||||
connect(te, SIGNAL(highFreqTimeout()), this, SLOT(displayData()));
|
||||
connect(dm, &Manager::dataSent, this, &Console::onDataSent);
|
||||
connect(dm, &Manager::dataReceived, this, &Console::onDataReceived);
|
||||
|
||||
// Log something to look like a pro
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,9 +58,6 @@ Serial::Serial()
|
||||
// Build serial devices list
|
||||
auto te = Misc::TimerEvents::getInstance();
|
||||
connect(te, SIGNAL(lowFreqTimeout()), this, SLOT(refreshSerialDevices()));
|
||||
|
||||
// Log class init
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +74,6 @@ Manager::Manager()
|
||||
{
|
||||
// setWatchdogInterval(15);
|
||||
setMaxBufferSize(1024 * 1024);
|
||||
LOG_TRACE() << "Class initialized";
|
||||
|
||||
// Configure signals/slots
|
||||
auto serial = DataSources::Serial::getInstance();
|
||||
@ -418,7 +417,7 @@ void Manager::setDataSource(const DataSource source)
|
||||
emit dataSourceChanged();
|
||||
|
||||
// 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;
|
||||
emit deviceChanged();
|
||||
|
||||
LOG_TRACE() << "Device pointer set to" << m_device;
|
||||
LOG_INFO() << "Device pointer set to" << m_device;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -653,7 +652,7 @@ void Manager::setDevice(QIODevice *device)
|
||||
* @param bytes pointer to the number of bytes that we need to chop from the master buffer
|
||||
*/
|
||||
Manager::ValidationStatus Manager::integrityChecks(const QByteArray &frame,
|
||||
const QByteArray &cursor, int *bytes)
|
||||
const QByteArray &cursor, int *bytes)
|
||||
{
|
||||
// Check CRC-8
|
||||
if (cursor.startsWith("crc8:"))
|
||||
|
@ -153,7 +153,7 @@ private:
|
||||
~Manager();
|
||||
|
||||
ValidationStatus integrityChecks(const QByteArray &frame,
|
||||
const QByteArray &masterBuffer, int *bytesToChop);
|
||||
const QByteArray &masterBuffer, int *bytesToChop);
|
||||
|
||||
private:
|
||||
QTimer m_watchdog;
|
||||
|
@ -58,8 +58,6 @@ Generator::Generator()
|
||||
connect(io, SIGNAL(deviceChanged()), this, SLOT(reset()));
|
||||
connect(io, SIGNAL(frameReceived(QByteArray)), this, SLOT(readData(QByteArray)));
|
||||
m_workerThread.start();
|
||||
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,6 +144,7 @@ void Generator::loadJsonMap(const QString &path)
|
||||
if (m_jsonMap.isOpen())
|
||||
{
|
||||
m_jsonMap.close();
|
||||
m_jsonMapData = "";
|
||||
emit jsonFileMapChanged();
|
||||
}
|
||||
|
||||
@ -159,7 +158,7 @@ void Generator::loadJsonMap(const QString &path)
|
||||
auto document = QJsonDocument::fromJson(data, &error);
|
||||
if (error.error != QJsonParseError::NoError)
|
||||
{
|
||||
LOG_TRACE() << "JSON parse error" << error.errorString();
|
||||
LOG_INFO() << "JSON parse error" << error.errorString();
|
||||
|
||||
m_jsonMap.close();
|
||||
writeSettings("");
|
||||
@ -169,7 +168,7 @@ void Generator::loadJsonMap(const QString &path)
|
||||
// JSON contains no errors, load data & save settings
|
||||
else
|
||||
{
|
||||
LOG_TRACE() << "JSON map loaded successfully";
|
||||
LOG_INFO() << "JSON map loaded successfully";
|
||||
|
||||
writeSettings(path);
|
||||
m_jsonMapData = QString::fromUtf8(data);
|
||||
@ -182,7 +181,8 @@ void Generator::loadJsonMap(const QString &path)
|
||||
// Open error
|
||||
else
|
||||
{
|
||||
LOG_TRACE() << "JSON file error" << m_jsonMap.errorString();
|
||||
m_jsonMapData = "";
|
||||
LOG_INFO() << "JSON file error" << m_jsonMap.errorString();
|
||||
|
||||
writeSettings("");
|
||||
Misc::Utilities::showMessageBox(tr("Cannot read JSON file"),
|
||||
@ -212,7 +212,7 @@ void Generator::setOperationMode(const OperationMode mode)
|
||||
m_opMode = mode;
|
||||
emit operationModeChanged();
|
||||
|
||||
LOG_TRACE() << "Operation mode set to" << mode;
|
||||
LOG_INFO() << "Operation mode set to" << mode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,9 +74,6 @@ MacExtras::MacExtras()
|
||||
// Re-translate buttons when language is changed
|
||||
connect(Translator::getInstance(), SIGNAL(languageChanged()), this,
|
||||
SLOT(updateButtonText()));
|
||||
|
||||
// Logger
|
||||
LOG_TRACE() << "Class initialized";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,10 @@
|
||||
*/
|
||||
ModuleManager::ModuleManager()
|
||||
{
|
||||
m_splash.setPixmap(QPixmap(":/images/splash.png"));
|
||||
m_splash.show();
|
||||
|
||||
setSplashScreenMessage(tr("Initializing..."));
|
||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(stopOperations()));
|
||||
}
|
||||
|
||||
@ -74,6 +78,8 @@ ModuleManager::ModuleManager()
|
||||
*/
|
||||
void ModuleManager::configureLogger()
|
||||
{
|
||||
setSplashScreenMessage(tr("Configuring logger..."));
|
||||
|
||||
auto fileAppender = new FileAppender;
|
||||
auto consoleAppender = new ConsoleAppender;
|
||||
fileAppender->setFormat(LOG_FORMAT);
|
||||
@ -94,11 +100,13 @@ void ModuleManager::configureUpdater()
|
||||
if (!autoUpdaterEnabled())
|
||||
return;
|
||||
|
||||
LOG_TRACE() << "Configuring QSimpleUpdater...";
|
||||
setSplashScreenMessage(tr("Configuring updater..."));
|
||||
|
||||
LOG_INFO() << "Configuring QSimpleUpdater...";
|
||||
QSimpleUpdater::getInstance()->setNotifyOnUpdate(APP_UPDATER_URL, true);
|
||||
QSimpleUpdater::getInstance()->setNotifyOnFinish(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()
|
||||
{
|
||||
LOG_TRACE() << "Registering QML types...";
|
||||
LOG_INFO() << "Registering QML types...";
|
||||
qRegisterMetaType<JFI_Object>("JFI_Object");
|
||||
qmlRegisterType<JSON::Group>("SerialStudio", 1, 0, "Group");
|
||||
qmlRegisterType<JSON::Dataset>("SerialStudio", 1, 0, "Dataset");
|
||||
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
|
||||
LOG_INFO() << "Initializing C++ modules";
|
||||
setSplashScreenMessage(tr("Initializing modules..."));
|
||||
auto translator = Misc::Translator::getInstance();
|
||||
auto csvExport = CSV::Export::getInstance();
|
||||
auto csvPlayer = CSV::Player::getInstance();
|
||||
@ -188,6 +197,7 @@ void ModuleManager::initializeQmlInterface()
|
||||
c->setContextProperty("Cpp_Plugins_Bridge", pluginsBridge);
|
||||
c->setContextProperty("Cpp_Misc_MacExtras", macExtras);
|
||||
c->setContextProperty("Cpp_Misc_TimerEvents", timerEvents);
|
||||
c->setContextProperty("Cpp_ModuleManager", this);
|
||||
|
||||
// Register app info with QML
|
||||
c->setContextProperty("Cpp_AppName", qApp->applicationName());
|
||||
@ -200,10 +210,12 @@ void ModuleManager::initializeQmlInterface()
|
||||
engine()->load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
||||
|
||||
// Start common event timers
|
||||
setSplashScreenMessage(tr("Starting timers..."));
|
||||
timerEvents->startTimers();
|
||||
|
||||
// Log QML engine status
|
||||
LOG_INFO() << "Finished loading QML interface";
|
||||
setSplashScreenMessage(tr("Loading user interface..."));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,6 +226,28 @@ QQmlApplicationEngine *ModuleManager::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
|
||||
*/
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define MODULE_MANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSplashScreen>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
class ModuleManager : public QObject
|
||||
@ -41,10 +42,15 @@ public:
|
||||
|
||||
QQmlApplicationEngine *engine();
|
||||
|
||||
public slots:
|
||||
void hideSplashscreen();
|
||||
void setSplashScreenMessage(const QString &message);
|
||||
|
||||
private slots:
|
||||
void stopOperations();
|
||||
|
||||
private:
|
||||
QSplashScreen m_splash;
|
||||
QQmlApplicationEngine m_engine;
|
||||
};
|
||||
|
||||
|
@ -59,7 +59,6 @@ TimerEvents::TimerEvents()
|
||||
// Configure signals/slots
|
||||
connect(&m_timerLowFreq, &QTimer::timeout, this, &TimerEvents::lowFreqTimeout);
|
||||
connect(&m_timerHighFreq, &QTimer::timeout, this, &TimerEvents::highFreqTimeout);
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,7 +99,7 @@ void TimerEvents::startTimers()
|
||||
m_timerLowFreq.start();
|
||||
m_timerHighFreq.start();
|
||||
|
||||
LOG_TRACE() << "Timers started";
|
||||
LOG_INFO() << "Timers started";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,8 +38,7 @@ static Translator *INSTANCE = nullptr;
|
||||
Translator::Translator()
|
||||
{
|
||||
m_language = systemLanguage();
|
||||
LOG_TRACE() << "Class initialized";
|
||||
LOG_TRACE() << "System language" << systemLanguage();
|
||||
LOG_INFO() << "System language" << systemLanguage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,5 +214,5 @@ void Translator::setLanguage(const QLocale &locale, const QString &language)
|
||||
qApp->installTranslator(&m_translator);
|
||||
emit languageChanged();
|
||||
|
||||
LOG_TRACE() << "Language set to" << language;
|
||||
LOG_INFO() << "Language set to" << language;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ DataProvider::DataProvider()
|
||||
connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData()));
|
||||
connect(ge, SIGNAL(jsonFileMapChanged()), this, SLOT(resetData()));
|
||||
connect(ge, &JSON::Generator::jsonChanged, this, &DataProvider::selectLatestJSON);
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,6 @@ GraphProvider::GraphProvider()
|
||||
this, SLOT(csvPlayerFixes()));
|
||||
|
||||
// clang-format on
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,6 @@ WidgetProvider::WidgetProvider()
|
||||
connect(cp, SIGNAL(openChanged()), this, SLOT(resetData()));
|
||||
connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData()));
|
||||
connect(jg, SIGNAL(jsonFileMapChanged()), this, SLOT(resetData()));
|
||||
LOG_TRACE() << "Class initialized";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,9 +117,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Create module manager & configure the logger
|
||||
// Create module manager
|
||||
ModuleManager moduleManager;
|
||||
moduleManager.configureLogger();
|
||||
moduleManager.configureUpdater();
|
||||
|
||||
// Begin logging
|
||||
LOG_INFO() << QDateTime::currentDateTime();
|
||||
@ -135,9 +136,6 @@ int main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Configure the updater
|
||||
moduleManager.configureUpdater();
|
||||
|
||||
// Enter application event loop
|
||||
auto code = app.exec();
|
||||
LOG_INFO() << "Application exit code" << code;
|
||||
|
Loading…
x
Reference in New Issue
Block a user