Commit 5e23fa63 authored by Martin Straka's avatar Martin Straka

Set debug and log verbosity level in the settings

parent 8eccca75
......@@ -37,6 +37,8 @@ Item {
Component.onCompleted: {
languageComboBox.selectCurrentKey(settings.language())
fontSizeSpinBox.setVal(settings.fontSize())
debugVerosityLevelSpinBox.setVal(settings.debugVerbosityLevel())
logVerosityLevelSpinBox.setVal(settings.logVerbosityLevel())
}
Component.onDestruction: {
......@@ -118,6 +120,47 @@ Item {
text: qsTr("Note: Font size will be changed after application restart. Default is %1.").arg(fontSizeSpinBox.dflt)
wrapMode: Text.Wrap
}
AccessibleText {
color: datovkaPalette.text
width: parent.width
text: qsTr("Debug verbosity level")
}
AccessibleSpinBox {
id: debugVerosityLevelSpinBox
property int dflt: 1
from: 0
to: 3
stepSize: 1
accessibleDescription: qsTr("Set application debug verbosity level")
onValueModified: settings.setDebugVerbosityLevel(debugVerosityLevelSpinBox.val())
}
AccessibleText {
color: datovkaPalette.mid
width: parent.width
text: qsTr("Note: Debug verbosity level will be changed after application restart. Default is %1.").arg(debugVerosityLevelSpinBox.dflt)
wrapMode: Text.Wrap
}
AccessibleText {
color: datovkaPalette.text
width: parent.width
text: qsTr("Log verbosity level")
}
AccessibleSpinBox {
id: logVerosityLevelSpinBox
property int dflt: 1
from: 0
to: 3
stepSize: 1
accessibleDescription: qsTr("Set application log verbosity level")
onValueModified: settings.setLogVerosityLevel(logVerosityLevelSpinBox.val())
}
AccessibleText {
color: datovkaPalette.mid
width: parent.width
text: qsTr("Note: Log verbosity level will be changed after application restart. Default is %1.").arg(logVerosityLevelSpinBox.dflt)
wrapMode: Text.Wrap
}
} // Column layout
} // Pane
ScrollIndicator.vertical: ScrollIndicator {}
......
......@@ -298,8 +298,27 @@ int main(int argc, char *argv[])
GlobInstcs::logPtr->setLogLevelBits(LogDevice::LF_FILE, LOGSRC_ANY,
LOG_UPTO(LOG_DEBUG));
GlobInstcs::logPtr->setDebugVerbosity(1);
GlobInstcs::logPtr->setLogVerbosity(1);
/* Create global settings object and load application settings */
{
/* Perform check that configuration file can be accessed. */
if (Settings::settingsPath().isEmpty()) {
return EXIT_FAILURE;
}
GlobInstcs::setPtr = new (std::nothrow) Settings;
if (GlobInstcs::setPtr == Q_NULLPTR) {
logErrorNL("%s", "Cannot create settings.");
return EXIT_FAILURE;
}
QSettings settings(Settings::settingsPath(),
QSettings::IniFormat);
GlobInstcs::setPtr->loadFromSettings(settings);
}
/* Set debug and log verbosity level from settings */
GlobInstcs::logPtr->setDebugVerbosity(GlobInstcs::setPtr->debugVerbosityLevel);
GlobInstcs::logPtr->setLogVerbosity(GlobInstcs::setPtr->logVerbosityLevel);
deleteOldestLogFile();
/*
......@@ -309,12 +328,6 @@ int main(int argc, char *argv[])
QmlDlgHelper dlgHelper;
QmlDlgHelper::dlgEmitter = &dlgHelper;
/* Perform check that configuration file can be accessed. */
const QString settingsFileName(Settings::settingsPath());
if (settingsFileName.isEmpty()) {
return EXIT_FAILURE;
}
QCoreApplication::addLibraryPath("./");
/* Initialise random number generator. */
......@@ -349,12 +362,6 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
GlobInstcs::setPtr = new (std::nothrow) Settings;
if (GlobInstcs::setPtr == Q_NULLPTR) {
logErrorNL("%s", "Cannot create settings.");
return EXIT_FAILURE;
}
GlobInstcs::recMgmtSetPtr =
new (std::nothrow) RecordsManagementSettings;
if (GlobInstcs::recMgmtSetPtr == Q_NULLPTR) {
......@@ -371,13 +378,6 @@ int main(int argc, char *argv[])
cmdLineFileNames = parser.positionalArguments();
#endif /* defined(Q_OS_ANDROID) */
/* load global settings */
{
QSettings settings(Settings::settingsPath(),
QSettings::IniFormat);
GlobInstcs::setPtr->loadFromSettings(settings);
}
/* set font family and font size from settings */
QFont font;
font.setFamily(DEFAULT_FONT_FAMILY);
......
......@@ -41,6 +41,9 @@
#define DEFAULT_ZFO_LIMIT_MB 200
#define DEFAULT_PIN_INACT_TIMEOUT 0
#define DEFAULT_FONT_SIZE 16
#define DEFAULT_DEBUG_VERBOSITY_LEVEL 1
#define DEFAULT_LOG_VERBOSITY_LEVEL 1
/* Names of setting items in GLOBALS group in the datovka.conf file */
#define SETTINGS_GLOBAL_GROUP "GLOBALS"
#define SETTINGS_ONLY_NEW_MSGS "only_new_msgs"
......@@ -53,6 +56,8 @@
#define SETTINGS_LANGUAGE "language"
#define SETTINGS_FONTSIZE "font_size"
#define SETTINGS_DBS_LOCATION "dbs_location"
#define SETTINGS_DEBUG_VERBOSITY_LEVEL "debug_verbosity_level"
#define SETTINGS_LOG_VERBOSITY_LEVEL "log_verbosity_level"
/*
* These names are kept for backward compatibility purposes. They were formerly
......@@ -73,6 +78,8 @@ Settings::Settings(void)
pinInactTimeoutInSecs(DEFAULT_PIN_INACT_TIMEOUT),
dbsLocation(),
zfoDbSizeMBs(DEFAULT_ZFO_LIMIT_MB),
debugVerbosityLevel(DEFAULT_DEBUG_VERBOSITY_LEVEL),
logVerbosityLevel(DEFAULT_LOG_VERBOSITY_LEVEL),
m_lastUpdate()
{
}
......@@ -89,6 +96,8 @@ void Settings::saveToSettings(QSettings &settings) const
settings.setValue(SETTINGS_MSG_LIFETIME_IN_DAYS, msgLifeTimeInDays);
settings.setValue(SETTINGS_FILE_LIFETIME_IN_DAYS, fileLifeTimeInDays);
settings.setValue(SETTINGS_ZFO_LIMIT_MB, zfoDbSizeMBs);
settings.setValue(SETTINGS_DEBUG_VERBOSITY_LEVEL, debugVerbosityLevel);
settings.setValue(SETTINGS_LOG_VERBOSITY_LEVEL, logVerbosityLevel);
if (!_pinVal.isEmpty()) {
{
......@@ -154,6 +163,12 @@ void Settings::loadFromSettings(const QSettings &settings)
zfoDbSizeMBs = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_ZFO_LIMIT_MB,
DEFAULT_ZFO_LIMIT_MB).toInt();
debugVerbosityLevel = settings.value(SETTINGS_GLOBAL_GROUP "/"
SETTINGS_DEBUG_VERBOSITY_LEVEL,
DEFAULT_DEBUG_VERBOSITY_LEVEL).toInt();
logVerbosityLevel = settings.value(SETTINGS_GLOBAL_GROUP "/"
SETTINGS_LOG_VERBOSITY_LEVEL,
DEFAULT_LOG_VERBOSITY_LEVEL).toInt();
/*
* The PIN settings are newly kept in a separate group.
......
......@@ -98,6 +98,8 @@ public:
int pinInactTimeoutInSecs; /*!< Inactivity locking interval. */
QString dbsLocation; /*!< Path to databses location. */
int zfoDbSizeMBs; /*!< Zfo database max size in MB. */
int debugVerbosityLevel; /*!< Application debug verbosity level. */
int logVerbosityLevel; /*!< Application log verbosity level). */
private:
QString m_lastUpdate;
......
......@@ -401,3 +401,41 @@ void GlobalSettingsQmlWrapper::saveAllSettings(
settings);
settings.sync();
}
int GlobalSettingsQmlWrapper::debugVerbosityLevel(void) const
{
if (GlobInstcs::setPtr != Q_NULLPTR) {
return GlobInstcs::setPtr->debugVerbosityLevel;
} else {
Q_ASSERT(0);
return 1;
}
}
int GlobalSettingsQmlWrapper::logVerbosityLevel(void) const
{
if (GlobInstcs::setPtr != Q_NULLPTR) {
return GlobInstcs::setPtr->logVerbosityLevel;
} else {
Q_ASSERT(0);
return 1;
}
}
void GlobalSettingsQmlWrapper::setDebugVerbosityLevel(int dVL)
{
if (GlobInstcs::setPtr != Q_NULLPTR) {
GlobInstcs::setPtr->debugVerbosityLevel = dVL;
} else {
Q_ASSERT(0);
}
}
void GlobalSettingsQmlWrapper::setLogVerosityLevel(int lVL)
{
if (GlobInstcs::setPtr != Q_NULLPTR) {
GlobInstcs::setPtr->logVerbosityLevel = lVL;
} else {
Q_ASSERT(0);
}
}
......@@ -301,6 +301,34 @@ public:
static
void saveAllSettings(const AccountListModel *accountModel);
/*!
* @brief Return debug verbosity level.
*/
Q_INVOKABLE
int debugVerbosityLevel(void) const;
/*!
* @brief Return log verbosity level.
*/
Q_INVOKABLE
int logVerbosityLevel(void) const;
/*!
* @brief Set debug verbosity level.
*
* @param[in] dVL log verbosity level.
*/
Q_INVOKABLE
void setDebugVerbosityLevel(int dVL);
/*!
* @brief Set log verbosity level.
*
* @param[in] lVL log verbosity level.
*/
Q_INVOKABLE
void setLogVerosityLevel(int lVL);
signals:
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment