summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-08-21 14:29:25 +0000
committerFlorian Jung <flo@windfisch.org>2011-08-21 14:29:25 +0000
commit958f22a0b718d5a94cecd20073710c80e609cdac (patch)
tree714f9cf4fc6aca09e2c1c9d275e70ce347f692ff
parentedbe737895dacf8bf54813d7bc99c5e851dc8018 (diff)
fixed bugs regarding saving and restoring toolbar state
-rw-r--r--muse2/muse/app.cpp2
-rw-r--r--muse2/muse/cobject.cpp37
-rw-r--r--muse2/muse/cobject.h2
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp4
4 files changed, 41 insertions, 4 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 60075a1a..ba4d2487 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -3143,7 +3143,7 @@ void MusE::shareMenuAndToolbarChanged(TopWin* win, bool val)
{
if (win == currentMenuSharingTopwin)
{
- if (win != activeTopWin)
+ if (activeTopWin && (win != activeTopWin) && (activeTopWin->sharesToolsAndMenu()))
setCurrentMenuSharingTopwin(activeTopWin);
else
setCurrentMenuSharingTopwin(NULL);
diff --git a/muse2/muse/cobject.cpp b/muse2/muse/cobject.cpp
index 02a7ca74..7b5b4cb6 100644
--- a/muse2/muse/cobject.cpp
+++ b/muse2/muse/cobject.cpp
@@ -58,6 +58,8 @@ TopWin::TopWin(ToplevelType t, QWidget* parent, const char* name, Qt::WindowFlag
if (_defaultSubwin[_type])
setIsMdiWin(true);
+ if (_sharesToolsAndMenu)
+ menuBar()->hide();
subwinAction->setChecked(isMdiWin());
shareAction->setChecked(_sharesToolsAndMenu);
@@ -82,8 +84,15 @@ void TopWin::readStatus(Xml& xml)
fprintf(stderr,"ERROR: couldn't restore geometry. however, this is probably not really a problem.\n");
}
else if (tag == "toolbars") {
- if (!restoreState(QByteArray::fromHex(xml.parse1().toAscii())))
- fprintf(stderr,"ERROR: couldn't restore toolbars. however, this is not really a problem.\n");
+ if (!sharesToolsAndMenu()) {
+ if (!restoreState(QByteArray::fromHex(xml.parse1().toAscii())))
+ fprintf(stderr,"ERROR: couldn't restore toolbars. however, this is not really a problem.\n");
+ }
+ else {
+ _savedToolbarState=QByteArray::fromHex(xml.parse1().toAscii());
+ if (_savedToolbarState.isEmpty())
+ _savedToolbarState=_toolbarNonsharedInit[_type];
+ }
}
else if (tag == "shares_menu") {
shareToolsAndMenu(xml.parseInt());
@@ -117,7 +126,11 @@ void TopWin::writeStatus(int level, Xml& xml) const
xml.intTag(level, "is_subwin", isMdiWin());
xml.strTag(level, "geometry_state", saveGeometry().toHex().data());
xml.intTag(level, "shares_menu", sharesToolsAndMenu());
- xml.strTag(level, "toolbars", saveState().toHex().data());
+
+ if (!sharesToolsAndMenu())
+ xml.strTag(level, "toolbars", saveState().toHex().data());
+ else
+ xml.strTag(level, "toolbars", _savedToolbarState.toHex().data());
xml.tag(level, "/topwin");
}
@@ -167,6 +180,8 @@ void TopWin::setIsMdiWin(bool val)
{
if (!isMdiWin())
{
+ _savedToolbarState = saveState();
+
bool vis=isVisible();
QMdiSubWindow* subwin = createMdiWrapper();
muse->addMdiSubWindow(subwin);
@@ -238,6 +253,13 @@ QToolBar* TopWin::addToolBar(const QString& title)
void TopWin::shareToolsAndMenu(bool val)
{
+ if (_sharesToolsAndMenu == val)
+ {
+ if (debugMsg) printf("TopWin::shareToolsAndMenu() called but has no effect\n");
+ return;
+ }
+
+
_sharesToolsAndMenu = val;
if (!val)
@@ -246,14 +268,23 @@ void TopWin::shareToolsAndMenu(bool val)
for (list<QToolBar*>::iterator it=_toolbars.begin(); it!=_toolbars.end(); it++)
if (*it != NULL)
+ {
QMainWindow::addToolBar(*it);
+ (*it)->show();
+ }
else
QMainWindow::addToolBarBreak();
+
+ restoreState(_savedToolbarState);
+ _savedToolbarState.clear();
menuBar()->show();
}
else
{
+ if (_savedToolbarState.isEmpty()) // this check avoids overwriting a previously saved state
+ _savedToolbarState = saveState(); // (by setIsMdiWin) with a now incorrect (empty) state
+
for (list<QToolBar*>::iterator it=_toolbars.begin(); it!=_toolbars.end(); it++)
if (*it != NULL)
{
diff --git a/muse2/muse/cobject.h b/muse2/muse/cobject.h
index 14a40a93..604a8c28 100644
--- a/muse2/muse/cobject.h
+++ b/muse2/muse/cobject.h
@@ -93,6 +93,8 @@ class TopWin : public QMainWindow
static QByteArray _toolbarSharedInit[TOPLEVELTYPE_LAST_ENTRY];
static bool initInited;
+ QByteArray _savedToolbarState;
+
void initTopwinState();
bool initalizing; //if true, no state is saved
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 1b6c66e7..d674d81d 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -4439,6 +4439,7 @@ void staff_t::update_part_indices()
/* BUGS and potential bugs
* o THIS SHOULD NEVER HAPPEN: could not split note (found by tim)
+ * o when un-mdi-fying, toolbar state gets broken
*
* o tied notes don't work properly when there's a key-change in
* between, for example, when a cis is tied to a des
@@ -4446,8 +4447,11 @@ void staff_t::update_part_indices()
* and both A and B get scheduled to be expanded (because we
* have one event from A and one event from B), this causes a bug,
* because after A (and B) got resized, the B-resize is invalid!
+ * o when changing toolbarstate when sharing and immediately after that
+ * changing "share" status, the changed state isn't stored
*
* CURRENT TODO
+ * o save toolstate also when changing share/don't share
* o remove that ugly "bool initalizing" stuff. it's probably unneeded (watch out for the FINDMICH message)
* o shortcuts for "pencil" etc don't work when only mdiwin has focus and not the mainwin inside
* o implement borland-style maximize: free windows do not cover the main menu, even when maximized