On 08.07.2016 08:17, racoon wrote:
On 07.07.2016 14:41, racoon wrote:
Can someone give me a hint where LyX stores the individual toolbars'
properties, i.e. position and visibility.

Okay, got it (via QSettings). I was just a bit confused because the
visibility is also (somewhat) stored in the preferences file.

Okay, so here are my first thoughts on a toolbars position lock menu entry. I know this is not an essential feature but I thought I could use it to learn something about the LyX code without a deadline :). But since it is non-essential don't worry if no one has time to help me with this. Also I am not sure how much time I can invest in this in the future. That might be another thought whether it is worth your time or not.

Anyway, I am a beginner (both in C++ and Qt) and maybe someone can point out my mistakes to me. Furthermore, I can't compile the source, so it's all just on paper (http://www.mail-archive.com/lyx-devel%40lists.lyx.org/msg195015.html).

I'll start with the lock state (isMoveable/setMoveable) of the toolbars being saved and restored using QSettings. I am not sure I have understood the "cit" correctly.

In GuiView.cpp ("..." signifies left out code that is untouched):

...

void GuiView::saveLayout() const
{
        QSettings settings;
        
        ...
        
        // setting > toolbars ...
        settings.beginGroup("toolbars");
        // ... > movable
        settings.beginGroup("moveable");
        // extracts the toolbars from the backend
        Toolbars::Infos::const_iterator cit = guiApp->toolbars().begin();
        Toolbars::Infos::const_iterator end = guiApp->toolbars().end();
        // store moveable setting per toolbar
        for (; cit != end; ++cit) {
                GuiToolbar * tb = toolbar(cit->name);
                settings.setValue(tb->objectName(), tb->isMovable());
        }
        settings.endGroup();
        settings.endGroup();
}

...

bool GuiView::restoreLayout()
{
        QSettings settings;
        
        ...

        /* The following part is replaced by the code below:
        if (!restoreState(settings.value("layout").toByteArray(), 0))
                initToolbars();
        
        // init the toolbars that have not been restored
        Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
        Toolbars::Infos::iterator end = guiApp->toolbars().end();
        for (; cit != end; ++cit) {
                GuiToolbar * tb = toolbar(cit->name);
                if (tb && !tb->isRestored())
                        initToolbar(cit->name);
        }
        */

        if (!restoreState(settings.value("layout").toByteArray(), 0))
                initToolbars();
        else {
// toolbar property moveable isn't part of "state" so it has to be done manually ...
                
                // ... setting > toolbars ...
                settings.beginGroup("toolbars");
                // ... > movable
                settings.beginGroup("moveable");
                // extracts the toolbars from the backend
                Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
                Toolbars::Infos::iterator end = guiApp->toolbars().end();
                for (; cit != end; ++cit) {
                        if (tb && !tb->isRestored()) {
                                // init the toolbar that has not been restored
                                initToolbar(cit->name);
                        } else {
                                GuiToolbar * tb = toolbar(cit->name);
// restore moveable from setting tb->setMovable(settings.value(tb->objectName(), false).toBool());
                        }
                }
                settings.endGroup();
                settings.endGroup();
        }

        updateDialogs();
        return true;
}

...

Daniel

Reply via email to