[Development] QSettings refactor updates

Ziller Eike Eike.Ziller at theqtcompany.com
Fri Oct 10 08:47:39 CEST 2014


On Oct 10, 2014, at 12:48 AM, Thiago Macieira <thiago.macieira at intel.com> wrote:

> On Thursday 09 October 2014 19:43:08 Tomaz Canabrava wrote:
>> Please be kind, this is the first step to contributing to qt that I'm
>> trying. :)
>> 
>> First, I'v implemented the rationale that thiago asked me to do on the
>> other thread:
>> 
>> Settings format: .ini ( current settings uses native format, should I
>> implement that too or the reasoning here is 'be simple'? )
> 
> I think we should stick to .ini only. Access to the Windows registry should be 
> done via QSettings or via a dedicated class.

I think it would not be good to create a new API for settings, and simultaneously force us to keep the old API because the new API doesn’t cover the old use cases.
So, if Windows registry access should not be done through the new settings API (which I can’t tell), we should have a dedicated API for it at the same time the new settings API is introduced.

> Mac people: do we need access to plist files?

Plist is the format for application and other settings on OS X, and there are native tools for nicely editing these. Ini is highly alien on OS X.
So, I’d answer yes.

Br, Eike

> Usage on code:
>> 
>> Open a QConfig, get the root() group, fill some values,
>> if a value is changed a 'dirty' flag will be set on that particular group.
>> upon destruction it will generate a binary json representation to be kept
>> in memory
>> when .sync() it will forcefully sync on disk
>> when the QConfigCore object is destroyed, it will also flush on disk.
>> 
>> Working code example of usage:
>> 
>> int main(int argc, char *argv[])
>> {
>>    QConfig config;
>> 
>>    QConfigGroup& root = config.root();
> 
> Make sure a reference is not needed.
> 
>> 
>>    QConfigGroup& window = root.group("window");
>>    window.setValue("width", 800);
>>    window.setValue("height", 600);
>>    window.setValue("x", 100);
>>    window.setValue("y",100);
>>    window.setValue("opacity", 55);
>> 
>>    QConfigGroup& font = root.group("fonts");
>>    font.setValue("family", "san-serif");
>>    font.setValue("pointSize", 9);
>>    font.setValue("bold", true);
>>    font.setValue("italic", true);
>> 
>>    QConfigGroup& plasmoids = root.group("plasmoids");
>>    for(int i = 0; i < 5; i++){
>>        QConfigGroup& plasmoid = plasmoids.group(QString::number(i));
>>        plasmoid.setValue("name", "name_" + QString::number(i));
>>        plasmoid.setValue("width", rand() % 100 + 100);
>>        plasmoid.setValue("value", rand() % 100 + 100);
>>    }
>> }
>> 
>> Any tougths?
> 
> Looks good!
> 
> -- 
> Thiago Macieira - thiago.macieira (AT) intel.com
>  Software Architect - Intel Open Source Technology Center
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

-- 
Eike Ziller, Senior Software Engineer - Digia, Qt
 
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B




More information about the Development mailing list