소스 검색

Instantiate a QSettings within ctkSettingsDialog

Doing so will prevent user of the class to explicitly call setSettings.

Indeed, as mentionned in QSettings documentation:

"Constructs a QSettings object for accessing settings of the
application and organization set previously with a call
to QCoreApplication::setOrganizationName(),
QCoreApplication::setOrganizationDomain(),
and QCoreApplication::setApplicationName()."
Jean-Christophe Fillion-Robin 14 년 전
부모
커밋
c628fca5cf
2개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      Libs/Widgets/ctkSettingsDialog.cpp
  2. 1 0
      Libs/Widgets/ctkSettingsPanel.cpp

+ 4 - 2
Libs/Widgets/ctkSettingsDialog.cpp

@@ -66,6 +66,9 @@ ctkSettingsDialogPrivate::ctkSettingsDialogPrivate(ctkSettingsDialog& object)
 void ctkSettingsDialogPrivate::init()
 {
   Q_Q(ctkSettingsDialog);
+
+  this->Settings = new QSettings(q);
+
   this->setupUi(q);
 
   QObject::connect(this->SettingsTreeWidget,
@@ -277,8 +280,7 @@ void ctkSettingsDialog
 {
   Q_D(ctkSettingsDialog);
   Q_UNUSED(previousItem);
-  d->SettingsStackedWidget->setCurrentWidget(
-    d->panel(currentItem));
+  d->SettingsStackedWidget->setCurrentWidget(d->panel(currentItem));
 }
 
 // --------------------------------------------------------------------------

+ 1 - 0
Libs/Widgets/ctkSettingsPanel.cpp

@@ -154,6 +154,7 @@ void ctkSettingsPanel::updateProperties()
       {
       QVariant value = d->Settings->value(key);
       PropertyType& prop = d->Properties[key];
+      // Update object registered using registerProperty()
       bool res = prop.setValue(value);
       Q_ASSERT(res);
       Q_UNUSED(res);