diff options
author | Florian Jung <flo@windfisch.org> | 2011-08-16 16:27:54 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-08-16 16:27:54 +0000 |
commit | 6b5e69ff5def2c8469657e33413bec84d815df9d (patch) | |
tree | 71bf8eb1a0ae14c20529dc35b91b14e0b43a560a /muse2/muse/cobject.cpp | |
parent | 23f3026199641b6e2a2af69e10353cbe304e5649 (diff) |
this is only a backup commit
toolbar states are now saved also for shared toolbars
toolbar and window state saving is now handled in TopWin
TODO: finish list, cliplist, masterlist, marker, arranger
Diffstat (limited to 'muse2/muse/cobject.cpp')
-rw-r--r-- | muse2/muse/cobject.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/muse2/muse/cobject.cpp b/muse2/muse/cobject.cpp index 8f3932ec..a97a29a1 100644 --- a/muse2/muse/cobject.cpp +++ b/muse2/muse/cobject.cpp @@ -19,9 +19,28 @@ using std::list; +int TopWin::_widthInit[TOPLEVELTYPE_LAST_ENTRY]; +int TopWin::_heightInit[TOPLEVELTYPE_LAST_ENTRY]; +QByteArray TopWin::_toolbarSharedInit[TOPLEVELTYPE_LAST_ENTRY]; +QByteArray TopWin::_toolbarNonsharedInit[TOPLEVELTYPE_LAST_ENTRY]; +bool TopWin::initInited=false; + TopWin::TopWin(ToplevelType t, QWidget* parent, const char* name, Qt::WindowFlags f) : QMainWindow(parent, f) { + if (initInited==false) + { + for (int i=0;i<TOPLEVELTYPE_LAST_ENTRY;i++) + { + _widthInit[i]=800; + _heightInit[i]=600; + } + + initInited=true; + } + + initalizing=true; + _type=t; setObjectName(QString(name)); @@ -228,3 +247,93 @@ void TopWin::shareToolsAndMenu(bool val) emit toolsAndMenuSharingChanged(val); } + + +//--------------------------------------------------------- +// storeInitialState +//--------------------------------------------------------- + +void TopWin::storeInitialState() + { + if (initalizing) + printf("THIS SHOULD NEVER HAPPEN: STORE INIT STATE CALLED WHILE INITING! please IMMEDIATELY report that to flo!\n"); + + _widthInit[_type] = width(); + _heightInit[_type] = height(); + if (sharesToolsAndMenu()) + { + if (muse->getCurrentMenuSharingTopwin() == this) + _toolbarSharedInit[_type] = muse->saveState(); + } + else + _toolbarNonsharedInit[_type] = saveState(); + } + +//--------------------------------------------------------- +// readConfiguration +//--------------------------------------------------------- + +void TopWin::readConfiguration(ToplevelType t, Xml& xml) + { + for (;;) { + Xml::Token token = xml.parse(); + if (token == Xml::Error || token == Xml::End) + break; + const QString& tag = xml.s1(); + switch (token) { + case Xml::TagStart: + if (tag == "width") + _widthInit[t] = xml.parseInt(); + else if (tag == "height") + _heightInit[t] = xml.parseInt(); + else if (tag == "nonshared_toolbars") + _toolbarNonsharedInit[t] = QByteArray::fromHex(xml.parse1().toAscii()); + else if (tag == "shared_toolbars") + _toolbarSharedInit[t] = QByteArray::fromHex(xml.parse1().toAscii()); + else + xml.unknown("TopWin"); + break; + case Xml::TagEnd: + if (tag == "topwin") + return; + default: + break; + } + } + } + +//--------------------------------------------------------- +// writeConfiguration +//--------------------------------------------------------- + +void TopWin::writeConfiguration(ToplevelType t, int level, Xml& xml) + { + xml.tag(level++, "topwin"); + xml.intTag(level, "width", _widthInit[t]); + xml.intTag(level, "height", _heightInit[t]); + xml.strTag(level, "nonshared_toolbars", _toolbarNonsharedInit[t].toHex().data()); + xml.strTag(level, "shared_toolbars", _toolbarSharedInit[t].toHex().data()); + xml.etag(level, "topwin"); + } + +void TopWin::initTopwinState() +{ + printf("FINDMICH: in initTopwinState()\n"); + + if (sharesToolsAndMenu()) + { + if (this == muse->getCurrentMenuSharingTopwin()) + { + printf("FINDMICH RESTORING for %s...\n",windowTitle().toAscii().data()); + muse->restoreState(_toolbarSharedInit[_type]); + } + } + else + restoreState(_toolbarNonsharedInit[_type]); +} + +void TopWin::restoreMainwinState() +{ + if (sharesToolsAndMenu()) + initTopwinState(); +} |