Refactor our Configuration Dialog and Implement the Remote Object Cache Setting

This commit is contained in:
Justin Hammond 2020-06-15 22:58:47 +08:00
parent 1ed65a7129
commit e06f64e3f6
10 changed files with 232 additions and 119 deletions

View file

@ -27,108 +27,124 @@ Configuration::Configuration(QWidget *parent) :
else
qCDebug(ozwadmin) << "No m_options";
QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this);
QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this);
m_OZWvariantManager = new QtVariantPropertyManager(this);
m_OZWenumManager = new QtEnumPropertyManager(this);
QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this);
QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this);
m_variantManager = new QtVariantPropertyManager(this);
m_enumManager = new QtEnumPropertyManager(this);
{
/* OZW Pane */
this->m_OZWEditor = new QtTreePropertyBrowser(this);
m_OZWEditor->setFactoryForManager(m_OZWvariantManager, variantFactory);
m_OZWEditor->setFactoryForManager(m_OZWenumManager, enumFactory);
m_OZWEditor->setFactoryForManager(m_variantManager, variantFactory);
m_OZWEditor->setFactoryForManager(m_enumManager, enumFactory);
m_OZWEditor->setPropertiesWithoutValueMarked(true);
m_OZWEditor->setRootIsDecorated(false);
QtProperty *topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QtProperty *topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String(" Paths"));
topItem->addSubProperty(this->addStringProperty("ConfigPath", m_options->ConfigPath(), m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("UserPath", m_options->UserPath(), m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("ConfigPath", m_options->ConfigPath(), !m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("UserPath", m_options->UserPath(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Driver"));
topItem->addSubProperty(this->addBoolProperty("NotifyTransactions", m_options->NotifyTransactions(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("SaveConfiguration", m_options->SaveConfiguration(), m_options->isLocked()));
topItem->addSubProperty(this->addIntProperty("DriverMaxAttempts", m_options->DriverMaxAttempts(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("SuppressValueRefresh", m_options->SuppressValueRefresh(), m_options->isLocked()));
topItem->addSubProperty(this->addIntProperty("RetryTimeout", m_options->RetryTimeout(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("EnableSIS", m_options->EnableSIS(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("NotifyOnDriverUnload", m_options->NotifyOnDriverUnload(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("NotifyTransactions", m_options->NotifyTransactions(), !m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("SaveConfiguration", m_options->SaveConfiguration(), !m_options->isLocked()));
topItem->addSubProperty(this->addIntProperty("DriverMaxAttempts", m_options->DriverMaxAttempts(), !m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("SuppressValueRefresh", m_options->SuppressValueRefresh(), !m_options->isLocked()));
topItem->addSubProperty(this->addIntProperty("RetryTimeout", m_options->RetryTimeout(), !m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("EnableSIS", m_options->EnableSIS(), !m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("NotifyOnDriverUnload", m_options->NotifyOnDriverUnload(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Associations"));
topItem->addSubProperty(this->addBoolProperty("Associate", m_options->Associate(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("PerformReturnRoutes", m_options->PerformReturnRoutes(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("Associate", m_options->Associate(), !m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("PerformReturnRoutes", m_options->PerformReturnRoutes(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Polling"));
topItem->addSubProperty(this->addIntProperty("PollInterval", m_options->PollInterval(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("IntervalBetweenPolls", m_options->IntervalBetweenPolls(), m_options->isLocked()));
topItem->addSubProperty(this->addIntProperty("PollInterval", m_options->PollInterval(), !m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("IntervalBetweenPolls", m_options->IntervalBetweenPolls(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("CommandClasses"));
topItem->addSubProperty(this->addStringProperty("Exclude", m_options->Exclude(), m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("Include", m_options->Include(), m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("Exclude", m_options->Exclude(), !m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("Include", m_options->Include(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Security"));
topItem->addSubProperty(this->addEnumProperty("SecurityStrategy", m_options->SecurityStrategy().getEnums(), m_options->SecurityStrategy().getSelected(), m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("CustomSecuredCC", m_options->CustomSecuredCC(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("EnforceSecureReception", m_options->EnforceSecureReception(), m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("networkKey", m_options->NetworkKey(), m_options->isLocked()));
topItem->addSubProperty(this->addEnumProperty("SecurityStrategy", m_options->SecurityStrategy().getEnums(), m_options->SecurityStrategy().getSelected(), !m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("CustomSecuredCC", m_options->CustomSecuredCC(), !m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("EnforceSecureReception", m_options->EnforceSecureReception(), !m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("NetworkKey", m_options->NetworkKey(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Sleeping Devices"));
topItem->addSubProperty(this->addBoolProperty("AssumeAwake", m_options->AssumeAwake(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("AssumeAwake", m_options->AssumeAwake(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("UserCode CommandClass"));
topItem->addSubProperty(this->addBoolProperty("RefreshAllUserCodes", m_options->RefreshAllUserCodes(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("RefreshAllUserCodes", m_options->RefreshAllUserCodes(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Device Database"));
topItem->addSubProperty(this->addBoolProperty("AutoUpdateConfigFile", m_options->AutoUpdateConfigFile(), m_options->isLocked()));
topItem->addSubProperty(this->addEnumProperty("ReloadAfterUpdate", m_options->ReloadAfterUpdate().getEnums(), m_options->ReloadAfterUpdate().getSelected(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("AutoUpdateConfigFile", m_options->AutoUpdateConfigFile(), !m_options->isLocked()));
topItem->addSubProperty(this->addEnumProperty("ReloadAfterUpdate", m_options->ReloadAfterUpdate().getEnums(), m_options->ReloadAfterUpdate().getSelected(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Language"));
topItem->addSubProperty(this->addStringProperty("Language", m_options->Language(), m_options->isLocked()));
topItem->addSubProperty(this->addStringProperty("Language", m_options->Language(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String("Multi Channel Devices"));
topItem->addSubProperty(this->addBoolProperty("IncludeInstanceLabels", m_options->IncludeInstanceLabels(), m_options->isLocked()));
topItem->addSubProperty(this->addBoolProperty("IncludeInstanceLabels", m_options->IncludeInstanceLabels(), !m_options->isLocked()));
m_OZWEditor->addProperty(topItem);
//m_OZWEditor->setEnabled(!m_options->isLocked());
//m_OZWEditor->setEnabled(!!m_options->isLocked());
this->ui->config_ozw->layout()->addWidget(m_OZWEditor);
}
{
/* Network Pane */
m_NetvariantManager = new QtVariantPropertyManager(this);
m_NetenumManager = new QtEnumPropertyManager(this);
this->m_NetworkEditor = new QtTreePropertyBrowser(this);
m_NetworkEditor->setFactoryForManager(m_NetvariantManager, variantFactory);
m_NetworkEditor->setFactoryForManager(m_NetenumManager, enumFactory);
m_NetworkEditor->setFactoryForManager(m_variantManager, variantFactory);
m_NetworkEditor->setFactoryForManager(m_enumManager, enumFactory);
m_NetworkEditor->setPropertiesWithoutValueMarked(true);
m_NetworkEditor->setRootIsDecorated(false);
QtProperty *topItem = m_OZWvariantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String(" Paths"));
QtVariantProperty *variantProperty;
QtProperty *topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String(" Network"));
variantProperty = this->addIntProperty("Network Object Cache", OZWCore::get()->settings.networkCache(), true);
connect(variantProperty, &QtVariantProperty::valueChanged, &OZWCore::get()->settings, QOverload<QVariant>::of(&SettingsManager::setNetworkCache));
topItem->addSubProperty(variantProperty);
m_NetworkEditor->addProperty(topItem);
topItem = m_variantManager->addProperty(QtVariantPropertyManager::groupTypeId(),
QLatin1String(" Logging"));
variantProperty = this->addIntProperty("Log Buffer Size", OZWCore::get()->settings.logBufferSize(), true);
connect(variantProperty, &QtVariantProperty::valueChanged, &OZWCore::get()->settings, QOverload<QVariant>::of(&SettingsManager::setLogBufferSize));
topItem->addSubProperty(variantProperty);
variantProperty = this->addBoolProperty("Retrive All Logs on Connect", OZWCore::get()->settings.retriveLogBuffer(), true);
connect(variantProperty, &QtVariantProperty::valueChanged, &OZWCore::get()->settings, QOverload<QVariant>::of(&SettingsManager::setRetriveLogBuffer));
topItem->addSubProperty(variantProperty);
m_NetworkEditor->addProperty(topItem);
this->ui->config_net->layout()->addWidget(m_NetworkEditor);
}
@ -142,33 +158,7 @@ Configuration::~Configuration()
void Configuration::saveConfiguration() {
QtVariantProperty *property;
QtProperty *property1 = dynamic_cast<QtProperty *>(this->m_variantToProperty["SaveLogLevel"]);
OptionList SaveLogLevel = m_options->SaveLogLevel();
if (property1->valueText() != SaveLogLevel.getSelectedName()) {
SaveLogLevel.setSelected(property1->valueText());
m_options->setSaveLogLevel(SaveLogLevel);
settings.setValue("openzwave/SaveLogLevel", SaveLogLevel.getSelectedName());
qDebug() << "Saved SaveLogLevel Param with " << SaveLogLevel.getSelectedName();
}
property1 = dynamic_cast<QtProperty *>(this->m_variantToProperty["QueueLogLevel"]);
OptionList QueueLogLevel = m_options->SaveLogLevel();
if (property1->valueText() != QueueLogLevel.getSelectedName()) {
QueueLogLevel.setSelected(property1->valueText());
m_options->setQueueLogLevel(QueueLogLevel);
settings.setValue("openzwave/QueueLogLevel", QueueLogLevel.getSelectedName());
qDebug() << "Saved QueueLogLevel Param with " << QueueLogLevel.getSelectedName();
}
property1 = dynamic_cast<QtProperty *>(this->m_variantToProperty["DumpTriggerLevel"]);
OptionList DumpTriggerLevel = m_options->DumpTriggerLevel();
if (property1->valueText() != DumpTriggerLevel.getSelectedName()) {
DumpTriggerLevel.setSelected(property1->valueText());
m_options->setQueueLogLevel(DumpTriggerLevel);
settings.setValue("openzwave/DumpTriggerLevel", DumpTriggerLevel.getSelectedName());
qDebug() << "Saved DumpTriggerLevel Param with " << DumpTriggerLevel.getSelectedName();
}
QtProperty *property1;
property = dynamic_cast<QtVariantProperty *>(this->m_variantToProperty["Associate"]);
if (property->value() != m_options->Associate()) {
@ -344,36 +334,33 @@ void Configuration::saveConfiguration() {
}
QtVariantProperty *Configuration::addStringProperty(QString name, QString value, bool locked) {
QtVariantProperty *variantitem = m_OZWvariantManager->addProperty(QVariant::String, name);
QtVariantProperty *variantitem = m_variantManager->addProperty(QVariant::String, name);
variantitem->setValue(value);
variantitem->setBold(settings.contains("openzwave/"+name));
variantitem->setEnabled(!locked);
variantitem->setEnabled(locked);
this->m_variantToProperty.insert(name, variantitem);
return variantitem;
}
QtVariantProperty *Configuration::addBoolProperty(QString name, bool value, bool locked) {
QtVariantProperty *variantitem = m_OZWvariantManager->addProperty(QVariant::Bool, name);
QtVariantProperty *variantitem = m_variantManager->addProperty(QVariant::Bool, name);
variantitem->setValue(value);
variantitem->setBold(settings.contains("openzwave/"+name));
variantitem->setEnabled(!locked);
variantitem->setEnabled(locked);
this->m_variantToProperty.insert(name, variantitem);
return variantitem;
}
QtVariantProperty *Configuration::addIntProperty(QString name, int value, bool locked) {
QtVariantProperty *variantitem = m_OZWvariantManager->addProperty(QVariant::Int, name);
QtVariantProperty *variantitem = m_variantManager->addProperty(QVariant::Int, name);
variantitem->setValue(value);
variantitem->setBold(settings.contains("openzwave/"+name));
variantitem->setEnabled(!locked);
variantitem->setEnabled(locked);
this->m_variantToProperty.insert(name, variantitem);
return variantitem;
}
QtProperty *Configuration::addEnumProperty(QString name, QStringList options, int selected, bool readonly) {
QtProperty *enumitem = m_OZWenumManager->addProperty(name);
m_OZWenumManager->setEnumNames(enumitem, options);
m_OZWenumManager->setValue(enumitem, selected);
QtProperty *enumitem = m_enumManager->addProperty(name);
m_enumManager->setEnumNames(enumitem, options);
m_enumManager->setValue(enumitem, selected);
enumitem->setBold(settings.contains("openzwave/"+name));
enumitem->setEnabled(!readonly);
this->m_variantToProperty.insert(name, enumitem);

View file

@ -31,13 +31,11 @@ private:
private:
Ui::Configuration *ui;
QSettings settings;
QtTreePropertyBrowser *m_OZWEditor;
QtVariantPropertyManager *m_OZWvariantManager;
QtEnumPropertyManager *m_OZWenumManager;
QtVariantPropertyManager *m_variantManager;
QtEnumPropertyManager *m_enumManager;
QtTreePropertyBrowser *m_OZWEditor;
QtTreePropertyBrowser *m_NetworkEditor;
QtVariantPropertyManager *m_NetvariantManager;
QtEnumPropertyManager *m_NetenumManager;
QMap<QString, QtProperty *> m_variantToProperty;

View file

@ -53,6 +53,7 @@ void LogWindow::init() {
void LogWindow::logsReady(bool ready) {
if (ready) {
this->m_log->syncroniseLogs();
if (OZWCore::get()->settings.retriveLogBuffer() == true)
this->m_log->syncroniseLogs();
}
}

View file

@ -97,28 +97,40 @@ void MainWindow::QTOZW_Ready(bool ready) {
qCDebug(ozwadmin) << "QTOZW Ready";
/* apply our Local Configuration Options to the OZW Options Class */
OZWCore::get()->settings.beginGroup("openzwave");
QStringList optionlist = OZWCore::get()->settings.allKeys();
QSettings().beginGroup("openzwave");
QStringList optionlist = QSettings().allKeys();
for (int i = 0; i < optionlist.size(); i++) {
qCDebug(ozwadmin) << "Updating Option " << optionlist.at(i) << " to " << OZWCore::get()->settings.value(optionlist.at(i));
qCDebug(ozwadmin) << "Updating Option " << optionlist.at(i) << " to " << QSettings().value(optionlist.at(i));
QTOZWOptions *ozwoptions = OZWCore::get()->getQTOZWManager()->getOptions();
QStringList listtypes;
listtypes << "SaveLogLevel" << "QueueLogLevel" << "DumpLogLevel";
if (listtypes.contains(optionlist.at(i))) {
OptionList list = ozwoptions->property(optionlist.at(i).toLocal8Bit()).value<OptionList>();
if (list.getEnums().size() > 0)
list.setSelected(OZWCore::get()->settings.value(optionlist.at(i)).toString());
list.setSelected(QSettings().value(optionlist.at(i)).toString());
}
else
{
ozwoptions->setProperty(optionlist.at(i).toLocal8Bit(), OZWCore::get()->settings.value(optionlist.at(i)));
ozwoptions->setProperty(optionlist.at(i).toLocal8Bit(), QSettings().value(optionlist.at(i)));
}
}
OZWCore::get()->settings.endGroup();
QSettings().endGroup();
openDefaultWindows();
}
void MainWindow::openDefaultWindows() {
if ((OZWCore::get()->getQTOZWManager()->getNodeModel()->rowCount() > (int)OZWCore::get()->settings.networkCache()) ||
(OZWCore::get()->getQTOZWManager()->getValueModel()->rowCount() > (int)OZWCore::get()->settings.networkCache()) ||
(OZWCore::get()->getQTOZWManager()->getAssociationModel()->rowCount() > (int)OZWCore::get()->settings.networkCache())) {
quint32 size = OZWCore::get()->getQTOZWManager()->getNodeModel()->rowCount();
size = qMax<int>(size, OZWCore::get()->getQTOZWManager()->getValueModel()->rowCount());
size = qMax<int>(size, OZWCore::get()->getQTOZWManager()->getAssociationModel()->rowCount());
QString msg("Please Increase the Network Cache Size in the Configuration. Current Setting: %1 Remote Max Records: %2");
this->openCriticalDialog("Network Cache Size Insufficent", msg.arg(OZWCore::get()->settings.networkCache()).arg(size));
QCoreApplication::exit(-1);
}
this->ntw = new nodeTableWidget(this);
DeviceInfo *di = new DeviceInfo(this);
NodeStatus *ni = new NodeStatus(this);
@ -214,7 +226,7 @@ void MainWindow::OpenConnection() {
}
else
{
OZWCore::get()->settings.setValue("connection/startserver", su.getstartServer());
QSettings().setValue("connection/startserver", su.getstartServer());
connectToLocal(su.getserialPort());
return;
}
@ -227,18 +239,18 @@ void MainWindow::OpenConnection() {
void MainWindow::connectToLocal(QString serial) {
this->connected(true);
OZWCore::get()->settings.setValue("connection/serialport", serial);
qCDebug(ozwadmin) << "Doing Local Connection: " << serial << OZWCore::get()->settings.value("StartServer").toBool();
QSettings().setValue("connection/serialport", serial);
qCDebug(ozwadmin) << "Doing Local Connection: " << serial << QSettings().value("StartServer").toBool();
startupprogress *sup = new startupprogress(false, this);
sup->show();
OZWCore::get()->getQTOZWManager()->initilizeSource(OZWCore::get()->settings.value("connection/startserver").toBool());
OZWCore::get()->getQTOZWManager()->initilizeSource(QSettings().value("connection/startserver").toBool());
OZWCore::get()->getQTOZWManager()->open(serial);
}
void MainWindow::connectToRemote(QUrl server, QString key) {
this->connected(true);
OZWCore::get()->settings.setValue("connection/remotehost", server);
OZWCore::get()->settings.setValue("connection/authKey", key);
QSettings().setValue("connection/remotehost", server);
QSettings().setValue("connection/authKey", key);
qCDebug(ozwadmin) << "Doing Remote Connection:" << server;
startupprogress *sup = new startupprogress(true, this);
sup->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);

View file

@ -22,8 +22,8 @@ OZWCore *OZWCore::get() {
void OZWCore::initilize() {
m_configpath = QFileInfo(settings.value("openzwave/ConfigPath").toString()).absoluteFilePath();
m_userpath = QFileInfo(settings.value("openzwave/UserPath").toString()).absoluteFilePath();
m_configpath = QFileInfo(QSettings().value("openzwave/ConfigPath").toString()).absoluteFilePath();
m_userpath = QFileInfo(QSettings().value("openzwave/UserPath").toString()).absoluteFilePath();
this->m_openzwave = new QTOpenZwave(this, m_configpath, m_userpath);
this->m_qtozwmanager = this->m_openzwave->GetManager();
qCInfo(ozwadmin) << "OZWCore Initilized" << this->m_openzwave << this->m_qtozwmanager;
@ -39,3 +39,83 @@ QTOZWManager *OZWCore::getQTOZWManager() {
qCWarning(ozwadmin) << "QTOZWManager is not created!";
return this->m_qtozwmanager;
}
SettingsManager::SettingsManager(QObject *parent) :
QObject(parent)
{
bool ok;
int size = qEnvironmentVariableIntValue("QTRO_NODES_CACHE_SIZE", &ok);
if (!ok) {
qCDebug(ozwadmin) << "Using Saved Network Cache Size:" << networkCache();
setNetworkCache(networkCache());
} else {
qCDebug(ozwadmin) << "Using Enviroment Network Cache:" << size;
setNetworkCache(size);
}
setLogBufferSize(logBufferSize());
setRetriveLogBuffer(retriveLogBuffer());
}
SettingsManager::~SettingsManager()
{
}
quint32 SettingsManager::networkCache()
{
return m_settings.value("network/cachesize", 1000).toInt();
}
void SettingsManager::setNetworkCache(QVariant size)
{
qCInfo(ozwadmin) << "setNetworkCache Variant Called";
setNetworkCache(size.toInt());
}
void SettingsManager::setNetworkCache(quint32 size)
{
if (size != networkCache()) {
m_settings.setValue("network/cachesize", size);
emit networkCacheChanged(size);
qputenv("QTRO_NODES_CACHE_SIZE", QString::number(size).toLocal8Bit());
}
}
quint32 SettingsManager::logBufferSize()
{
return m_settings.value("network/logbuffersize", 10000).toInt();
}
void SettingsManager::setLogBufferSize(QVariant size)
{
qCInfo(ozwadmin) << "setLogBufferSize Variant Called";
setLogBufferSize(size.toInt());
}
void SettingsManager::setLogBufferSize(quint32 size)
{
if (size != logBufferSize()) {
m_settings.setValue("network/logbuffersize", size);
emit logBufferSizeChanged(size);
}
}
bool SettingsManager::retriveLogBuffer()
{
return m_settings.value("network/retrivelogbuffer", true).toBool();
}
void SettingsManager::setRetriveLogBuffer(QVariant value)
{
qCInfo(ozwadmin) << "setRetriveLogBuffer Variant Called" << value;
setRetriveLogBuffer(value.toBool());
}
void SettingsManager::setRetriveLogBuffer(bool value)
{
if (value != retriveLogBuffer()) {
m_settings.setValue("network/retrivelogbuffer", value);
emit retriveLogBufferChanged(value);
}
}

View file

@ -10,6 +10,37 @@
class ControllerCommands;
class SettingsManager : public QObject
{
Q_OBJECT
public:
SettingsManager(QObject *parent = nullptr);
~SettingsManager();
Q_PROPERTY(quint32 networkCache READ networkCache WRITE setNetworkCache NOTIFY networkCacheChanged);
Q_PROPERTY(quint32 logBufferSize READ logBufferSize WRITE setLogBufferSize NOTIFY logBufferSizeChanged);
Q_PROPERTY(bool retriveLogBuffer READ retriveLogBuffer WRITE setRetriveLogBuffer NOTIFY retriveLogBufferChanged);
quint32 networkCache();
quint32 logBufferSize();
bool retriveLogBuffer();
public Q_SLOTS:
void setNetworkCache(QVariant size);
void setNetworkCache(quint32 size);
void setLogBufferSize(QVariant size);
void setLogBufferSize(quint32 size);
void setRetriveLogBuffer(QVariant value);
void setRetriveLogBuffer(bool value);
Q_SIGNALS:
void networkCacheChanged(int size);
void logBufferSizeChanged(quint32 size);
void retriveLogBufferChanged(bool value);
private:
QSettings m_settings;
};
class OZWCore : public QObject
{
Q_OBJECT
@ -19,8 +50,7 @@ public:
void initilize();
QTOpenZwave *getQTOZW();
QTOZWManager *getQTOZWManager();
QSettings settings;
SettingsManager settings;
signals:
QMessageBox::StandardButton raiseCriticalError(QString title, QString message);
public slots:

View file

@ -20,18 +20,18 @@ Startup::Startup(QWidget *parent) :
QObject::connect(ui->startlocal, &QPushButton::clicked, this, &Startup::localPressed);
QObject::connect(ui->startremote, &QPushButton::clicked, this, &Startup::remotePressed);
#if defined(Q_OS_MACOS)
ui->serialport->setText(OZWCore::get()->settings.value("connection/serialport", "/dev/cu.SLAB_USBtoUART").toString());
ui->serialport->setText(QSettings().value("connection/serialport", "/dev/cu.SLAB_USBtoUART").toString());
#elif defined(Q_OS_WIN)
ui->serialport->setText(OZWCore::get()->settings.value("connection/serialport", "COM1").toString());
ui->serialport->setText(QSettings().value("connection/serialport", "COM1").toString());
#else
ui->serialport->setText(OZWCore::get()->settings.value("connection/serialport", "/dev/ttyUSB0").toString());
ui->serialport->setText(QSettings().value("connection/serialport", "/dev/ttyUSB0").toString());
#endif
ui->enableserver->setChecked(OZWCore::get()->settings.value("connection/startserver", true).toBool());
QUrl server = QUrl::fromUserInput(OZWCore::get()->settings.value("connection/remotehost", "ws://localhost:1983").toString());
ui->enableserver->setChecked(QSettings().value("connection/startserver", true).toBool());
QUrl server = QUrl::fromUserInput(QSettings().value("connection/remotehost", "ws://localhost:1983").toString());
qDebug() << server;
ui->remotehost->setText(server.host());
ui->remoteport->setText(QString::number(server.port()));
ui->authKey->setText(OZWCore::get()->settings.value("connection/authKey", "").toString());
ui->authKey->setText(QSettings().value("connection/authKey", "").toString());
}
Startup::~Startup()

View file

@ -71,8 +71,9 @@ typedef QLineEdit::EchoMode EchoMode;
class QtAbstractPropertyManager;
class QtPropertyPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtProperty
class QT_QTPROPERTYBROWSER_EXPORT QtProperty : public QObject
{
Q_OBJECT
public:
virtual ~QtProperty();

View file

@ -485,6 +485,7 @@ void QtVariantPropertyManagerPrivate::valueChanged(QtProperty *property, const Q
return;
emit q_ptr->valueChanged(varProp, val);
emit q_ptr->propertyChanged(varProp);
emit varProp->valueChanged(val);
}
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, int val)

View file

@ -57,13 +57,16 @@ class QtVariantPropertyPrivate;
class QT_QTPROPERTYBROWSER_EXPORT QtVariantProperty : public QtProperty
{
Q_OBJECT
public:
~QtVariantProperty();
QVariant value() const;
QVariant attributeValue(const QString &attribute) const;
int valueType() const;
int propertyType() const;
Q_SIGNALS:
void valueChanged(const QVariant value);
public Q_SLOTS:
void setValue(const QVariant &value);
void setAttribute(const QString &attribute, const QVariant &value);
protected: