<div dir="ltr"><p dir="ltr">Em 30 de jul de 2016 16:59, "Dirk Hohndel" <<a href="mailto:dirk@hohndel.org" target="_blank">dirk@hohndel.org</a>> escreveu:<br>
><br>
> Tomaz,<br>
><br>
> Would you create a short writeup how the wrapper objects should be used?<br>
> I'll admit that I feel less then clear about this right now.<br>
><br>
> For each of the seperate types, should there be only one instance of these<br>
> objects in the running application? Or can any class create their own<br>
> wrapper object and things will still work correctly (somehow I doubt that,<br>
> looking at the way this seems to work with the change notifications).<br>
><br>
> But if it's a single instance only, then why aren't there instance()<br>
> functions for them?<br>
><br>
> I guess I'm confused :-(<br>
><br>
> My example:<br>
><br>
> cloudstorage.cpp creates a CloudStorageSettings object and uses that to<br>
> make sure that the verification status is maintained correctly. But<br>
> another part of the CloudStorageSettings is prefs.git_local_only /<br>
> CloudStorageSettings::gitLocalOnly() - and that needs to be accessed from<br>
> multiple locations.<br>
><br>
> So if I want to connect a function with the gitLocalOnlyChanged() signal<br>
> (which, oh, btw, currently isn't sent when that preference is changed),<br>
> then how do I do this? Clearly creating a separate object isn't going to<br>
> do the right thing... so I think this needs to indeed be a glabal<br>
> instance.</p><p>I had to re-read the code since there's a long time since I don't do anything proper for subsurface, so here it goes.</p>
<p dir="ltr">There's one SettingsObjectWrapper, that is a singleton, and you use it to access everything.</p><p>If you wan't to access *some* specific property, and deal with the property changes you would do:</p><p><br></p><p>SettingsObjectWrapper *prefs = SettingsObjectWrapper::instance();</p><p>// connect the desired preference to some method, the preferences are grouped by structs, so it's easy to find the one you need. <br></p><p>connect(prefs->cloud_storage, &Signal, this, &MyMethod);</p><p>set the desired preference:</p><p>prefs->cloud_storage->setSomething( blah );</p><p>this will trigger the changed signal on the CloudStorageSettings object that in turn will call the slots.</p><p>I'm working on that particular code right now, so I'll change all other parts of the code that deal with preferences and make it sane again.</p><p>Tomaz<br></p><p dir="ltr">> Help?<br>
><br>
> /D<br>
> _______________________________________________<br>
> subsurface mailing list<br>
><a href="mailto:subsurface@subsurface-divelog.org" target="_blank"> subsurface@subsurface-divelog.org</a><br>
><a href="http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface" target="_blank"> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface</a><br>
</p>
</div>