summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-05-15 16:52:14 +0000
committerFlorian Jung <flo@windfisch.org>2011-05-15 16:52:14 +0000
commitc7d22c133d2d9a5e8494d0285af10da6a6dff9d9 (patch)
treee5dfd68bde4f86f32e3595c4b9bfdb9b21a071ea
parenta79460c36201572c453974a93e62903fe77fd824 (diff)
defaults for toolbars are now saved
-rw-r--r--muse2/muse/master/masteredit.cpp39
-rw-r--r--muse2/muse/master/masteredit.h7
-rw-r--r--muse2/muse/midiedit/drumedit.cpp16
-rw-r--r--muse2/muse/midiedit/drumedit.h4
-rw-r--r--muse2/muse/midiedit/pianoroll.cpp19
-rw-r--r--muse2/muse/midiedit/pianoroll.h3
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp26
-rw-r--r--muse2/muse/midiedit/scoreedit.h5
-rw-r--r--muse2/muse/waveedit/waveedit.cpp21
-rw-r--r--muse2/muse/waveedit/waveedit.h4
10 files changed, 133 insertions, 11 deletions
diff --git a/muse2/muse/master/masteredit.cpp b/muse2/muse/master/masteredit.cpp
index 17d390e9..fd7000dd 100644
--- a/muse2/muse/master/masteredit.cpp
+++ b/muse2/muse/master/masteredit.cpp
@@ -33,6 +33,9 @@
#include <QToolButton>
int MasterEdit::_rasterInit = 0;
+int MasterEdit::_widthInit = 600;
+int MasterEdit::_heightInit = 400;
+QByteArray MasterEdit::_toolbarInit;
//---------------------------------------------------------
// closeEvent
@@ -82,7 +85,7 @@ MasterEdit::MasterEdit()
setWindowTitle(tr("MusE: Mastertrack"));
_raster = 0; // measure
setMinimumSize(400, 300);
- resize(500, 350);
+ resize(_widthInit, _heightInit);
//---------Pulldown Menu----------------------------
// QPopupMenu* file = new QPopupMenu(this);
@@ -229,6 +232,9 @@ MasterEdit::MasterEdit()
connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+
+ if (!_toolbarInit.isEmpty())
+ restoreState(_toolbarInit);
}
//---------------------------------------------------------
@@ -317,6 +323,12 @@ void MasterEdit::readConfiguration(Xml& xml)
case Xml::TagStart:
if (tag == "raster")
_rasterInit = xml.parseInt();
+ else if (tag == "width")
+ _widthInit = xml.parseInt();
+ else if (tag == "height")
+ _heightInit = xml.parseInt();
+ else if (tag == "toolbars")
+ _toolbarInit = QByteArray::fromHex(xml.parse1().toAscii());
else
xml.unknown("MasterEdit");
break;
@@ -337,6 +349,9 @@ void MasterEdit::writeConfiguration(int level, Xml& xml)
{
xml.tag(level++, "masteredit");
xml.intTag(level, "raster", _rasterInit);
+ xml.intTag(level, "width", _widthInit);
+ xml.intTag(level, "height", _heightInit);
+ xml.strTag(level, "toolbars", _toolbarInit.toHex().data());
xml.tag(level, "/masteredit");
}
@@ -404,3 +419,25 @@ void MasterEdit::setTempo(int val)
}
}
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void MasterEdit::resizeEvent(QResizeEvent* ev)
+ {
+ QWidget::resizeEvent(ev);
+ _widthInit = ev->size().width();
+ _heightInit = ev->size().height();
+ }
+
+
+//---------------------------------------------------------
+// focusOutEvent
+//---------------------------------------------------------
+
+void MasterEdit::focusOutEvent(QFocusEvent* ev)
+ {
+ QWidget::focusOutEvent(ev);
+ _toolbarInit=saveState();
+ }
diff --git a/muse2/muse/master/masteredit.h b/muse2/muse/master/masteredit.h
index af43c7b0..5abcfc8d 100644
--- a/muse2/muse/master/masteredit.h
+++ b/muse2/muse/master/masteredit.h
@@ -8,6 +8,9 @@
#ifndef __MASTER_EDIT_H__
#define __MASTER_EDIT_H__
+#include <QByteArray>
+#include <QResizeEvent>
+
#include "midieditor.h"
#include "noteinfo.h"
#include "cobject.h"
@@ -56,9 +59,13 @@ class MasterEdit : public MidiEditor {
QToolButton* enableButton;
static int _rasterInit;
+ static int _widthInit, _heightInit;
+ static QByteArray _toolbarInit;
Q_OBJECT
virtual void closeEvent(QCloseEvent*);
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
private slots:
void _setRaster(int);
diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp
index 617d3d1f..b762d776 100644
--- a/muse2/muse/midiedit/drumedit.cpp
+++ b/muse2/muse/midiedit/drumedit.cpp
@@ -65,6 +65,7 @@ int DrumEdit::_widthInit = 600;
int DrumEdit::_heightInit = 400;
int DrumEdit::_dlistWidthInit = 50;
int DrumEdit::_dcanvasWidthInit = 300;
+QByteArray DrumEdit::_toolbarInit;
static const int xscale = -10;
static const int yscale = 1;
@@ -470,6 +471,9 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini
connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl()));
+ if (!_toolbarInit.isEmpty())
+ restoreState(_toolbarInit);
+
QClipboard* cb = QApplication::clipboard();
connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
@@ -754,6 +758,8 @@ void DrumEdit::readConfiguration(Xml& xml)
_dcanvasWidthInit = xml.parseInt();
else if (tag == "dlistwidth")
_dlistWidthInit = xml.parseInt();
+ else if (tag == "toolbars")
+ _toolbarInit = QByteArray::fromHex(xml.parse1().toAscii());
else
xml.unknown("DrumEdit");
break;
@@ -779,6 +785,7 @@ void DrumEdit::writeConfiguration(int level, Xml& xml)
xml.intTag(level, "height", _heightInit);
xml.intTag(level, "dlistwidth", _dlistWidthInit);
xml.intTag(level, "dcanvaswidth", _dcanvasWidthInit);
+ xml.strTag(level, "toolbars", _toolbarInit.toHex().data());
xml.tag(level, "/drumedit");
}
@@ -1022,6 +1029,15 @@ void DrumEdit::resizeEvent(QResizeEvent* ev)
//TODO: Make the dlist not expand/shrink, but the canvas instead
}
+//---------------------------------------------------------
+// focusOutEvent
+//---------------------------------------------------------
+
+void DrumEdit::focusOutEvent(QFocusEvent* ev)
+ {
+ QWidget::focusOutEvent(ev);
+ _toolbarInit=saveState();
+ }
//---------------------------------------------------------
// configChanged
diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h
index dd3ad223..ab6c6cb3 100644
--- a/muse2/muse/midiedit/drumedit.h
+++ b/muse2/muse/midiedit/drumedit.h
@@ -8,6 +8,8 @@
#ifndef __DRUM_EDIT_H__
#define __DRUM_EDIT_H__
+#include <QByteArray>
+
#include <values.h>
#include "midieditor.h"
#include "noteinfo.h"
@@ -69,6 +71,7 @@ class DrumEdit : public MidiEditor {
static int _rasterInit;
static int _widthInit, _heightInit;
static int _dlistWidthInit, _dcanvasWidthInit;
+ static QByteArray _toolbarInit;
QAction *loadAction, *saveAction, *resetAction;
QAction *cutAction, *copyAction, *pasteAction, *deleteAction;
@@ -82,6 +85,7 @@ class DrumEdit : public MidiEditor {
virtual void closeEvent(QCloseEvent*);
QWidget* genToolbar(QWidget* parent);
virtual void resizeEvent(QResizeEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
virtual void keyPressEvent(QKeyEvent*);
void setHeaderToolTips();
void setHeaderWhatsThis();
diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp
index 79699860..02fe7f5d 100644
--- a/muse2/muse/midiedit/pianoroll.cpp
+++ b/muse2/muse/midiedit/pianoroll.cpp
@@ -56,6 +56,7 @@ int PianoRoll::_rasterInit = 96;
int PianoRoll::_widthInit = 600;
int PianoRoll::_heightInit = 400;
int PianoRoll::colorModeInit = 0;
+QByteArray PianoRoll::_toolbarInit;
static const int xscale = -10;
static const int yscale = 1;
@@ -456,6 +457,10 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i
setFocusPolicy(Qt::StrongFocus);
setEventColorMode(colorMode);
+ if (!_toolbarInit.isEmpty())
+ restoreState(_toolbarInit);
+
+
QClipboard* cb = QApplication::clipboard();
connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
@@ -786,6 +791,8 @@ void PianoRoll::readConfiguration(Xml& xml)
_widthInit = xml.parseInt();
else if (tag == "height")
_heightInit = xml.parseInt();
+ else if (tag == "toolbars")
+ _toolbarInit = QByteArray::fromHex(xml.parse1().toAscii());
else
xml.unknown("PianoRoll");
break;
@@ -809,6 +816,7 @@ void PianoRoll::writeConfiguration(int level, Xml& xml)
xml.intTag(level, "width", _widthInit);
xml.intTag(level, "height", _heightInit);
xml.intTag(level, "colormode", colorModeInit);
+ xml.strTag(level, "toolbars", _toolbarInit.toHex().data());
xml.etag(level, "pianoroll");
}
@@ -1188,6 +1196,17 @@ void PianoRoll::resizeEvent(QResizeEvent* ev)
}
+//---------------------------------------------------------
+// focusOutEvent
+//---------------------------------------------------------
+
+void PianoRoll::focusOutEvent(QFocusEvent* ev)
+ {
+ QWidget::focusOutEvent(ev);
+ _toolbarInit=saveState();
+ }
+
+
/*
//---------------------------------------------------------
// trackInfoScroll
diff --git a/muse2/muse/midiedit/pianoroll.h b/muse2/muse/midiedit/pianoroll.h
index 0c1066b4..6090e34f 100644
--- a/muse2/muse/midiedit/pianoroll.h
+++ b/muse2/muse/midiedit/pianoroll.h
@@ -12,6 +12,7 @@
#include <QResizeEvent>
#include <QLabel>
#include <QKeyEvent>
+#include <QByteArray>
#include <values.h>
#include "noteinfo.h"
@@ -114,6 +115,7 @@ class PianoRoll : public MidiEditor {
static int _rasterInit;
static int _widthInit, _heightInit;
+ static QByteArray _toolbarInit;
static int colorModeInit;
@@ -129,6 +131,7 @@ class PianoRoll : public MidiEditor {
virtual void closeEvent(QCloseEvent*);
virtual void keyPressEvent(QKeyEvent*);
virtual void resizeEvent(QResizeEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
private slots:
void setSelection(int, Event&, Part*);
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 62519036..31203396 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -141,6 +141,7 @@ QColor* mycolors; // array [NUM_MYCOLORS]
set<QString> ScoreEdit::names;
int ScoreEdit::width_init = 600;
int ScoreEdit::height_init = 400;
+QByteArray ScoreEdit::default_toolbar_state;
//---------------------------------------------------------
@@ -151,6 +152,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
: TopWin(parent, name)
{
setAttribute(Qt::WA_DeleteOnClose);
+ setFocusPolicy(Qt::StrongFocus);
resize(width_init, height_init);
@@ -216,6 +218,8 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
transport_toolbar->setObjectName("transport");
transport_toolbar->addActions(transportAction->actions());
+ addToolBarBreak();
+
QToolBar* newnote_toolbar = addToolBar(tr("New note settings"));
newnote_toolbar->setObjectName("New note settings");
newnote_toolbar->addWidget(new QLabel(tr("Note length:"), newnote_toolbar));
@@ -341,6 +345,9 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
menu_mapper->setMapping(func_notelen_action, CMD_NOTELEN);
menu_mapper->setMapping(func_velocity_action, CMD_VELOCITY);
+ if (!default_toolbar_state.isEmpty())
+ restoreState(default_toolbar_state);
+
score_canvas->fully_recalculate();
score_canvas->goto_tick(initPos,true);
@@ -351,6 +358,11 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
init_name();
}
+void ScoreEdit::focusOutEvent(QFocusEvent* ev)
+{
+ default_toolbar_state=saveState();
+ QMainWindow::focusOutEvent(ev);
+}
void ScoreEdit::add_parts(PartList* pl, bool all_in_one)
{
@@ -783,10 +795,12 @@ void ScoreEdit::read_configuration(Xml& xml)
switch (token)
{
case Xml::TagStart:
- if (tag == "width")
+ if (tag == "height")
height_init = xml.parseInt();
- else if (tag == "height")
+ else if (tag == "width")
width_init = xml.parseInt();
+ else if (tag == "toolbars")
+ default_toolbar_state = QByteArray::fromHex(xml.parse1().toAscii());
else
xml.unknown("ScoreEdit");
break;
@@ -807,6 +821,7 @@ void ScoreEdit::write_configuration(int level, Xml& xml)
xml.tag(level++, "scoreedit");
xml.intTag(level, "width", width_init);
xml.intTag(level, "height", height_init);
+ xml.strTag(level, "toolbars", default_toolbar_state.toHex().data());
xml.etag(level, "scoreedit");
}
@@ -4103,15 +4118,14 @@ void staff_t::apply_lasso(QRect rect, set<Event*>& already_processed)
* between, for example, when a cis is tied to a des
*
* CURRENT TODO
- * x nothing atm
+ * o let the user change velocity of already existent notes
+ * o save dialog-window's values
*
* IMPORTANT TODO
* o add a select-clef-toolbox for tracks
* o respect the track's clef (has to be implemented first in muse)
* o do partial recalculating; recalculating can take pretty long
* (0,5 sec) when displaying a whole song in scores
- * o save toolbar position also in the global window settings
- * and provide sane defaults
* o support edge-scrolling when opening a lasso
*
* less important stuff
@@ -4122,7 +4136,7 @@ void staff_t::apply_lasso(QRect rect, set<Event*>& already_processed)
* calc_pos_add_list must be called before calc_item_pos then,
* and calc_item_pos must respect the pos_add_list instead of
* keeping its own pos_add variable (which is only an optimisation)
- * o save more configuration stuff (quant, color, to_init)
+ * o save more configuration stuff (quant, color)
*
* really unimportant nice-to-haves
* o support in-song clef-changes
diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h
index d664f139..cfe6f34e 100644
--- a/muse2/muse/midiedit/scoreedit.h
+++ b/muse2/muse/midiedit/scoreedit.h
@@ -21,12 +21,11 @@
#include <QAction>
#include <QActionGroup>
#include <QGridLayout>
+#include <QByteArray>
#include <values.h>
#include "noteinfo.h"
#include "cobject.h"
-//#include "midieditor.h"
-//#include "tools.h"
#include "event.h"
#include "view.h"
#include "gconfig.h"
@@ -74,6 +73,7 @@ class ScoreEdit : public TopWin
private:
virtual void closeEvent(QCloseEvent*);
virtual void resizeEvent(QResizeEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
void init_name();
@@ -110,6 +110,7 @@ class ScoreEdit : public TopWin
static set<QString> names;
static int width_init, height_init;
+ static QByteArray default_toolbar_state;
QString name;
diff --git a/muse2/muse/waveedit/waveedit.cpp b/muse2/muse/waveedit/waveedit.cpp
index 0e3c1c30..f2d936f4 100644
--- a/muse2/muse/waveedit/waveedit.cpp
+++ b/muse2/muse/waveedit/waveedit.cpp
@@ -42,6 +42,7 @@ extern QColor readColor(Xml& xml);
int WaveEdit::_widthInit = 600;
int WaveEdit::_heightInit = 400;
+QByteArray WaveEdit::_toolbarInit;
//---------------------------------------------------------
// closeEvent
@@ -170,8 +171,8 @@ WaveEdit::WaveEdit(PartList* pl)
// ToolBar: Solo Cursor1 Cursor2
addToolBarBreak();
- tb1 = addToolBar(tr("Pianoroll tools"));
- tb1->setObjectName("Pianoroll tools");
+ tb1 = addToolBar(tr("WaveEdit tools"));
+ tb1->setObjectName("WaveEdit tools");
//tb1->setLabel(tr("weTools"));
solo = new QToolButton();
@@ -249,6 +250,8 @@ WaveEdit::WaveEdit(PartList* pl)
connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
+ if (!_toolbarInit.isEmpty())
+ restoreState(_toolbarInit);
initShortcuts();
@@ -354,6 +357,8 @@ void WaveEdit::readConfiguration(Xml& xml)
_widthInit = xml.parseInt();
else if (tag == "height")
_heightInit = xml.parseInt();
+ else if (tag == "toolbars")
+ _toolbarInit = QByteArray::fromHex(xml.parse1().toAscii());
else
xml.unknown("WaveEdit");
break;
@@ -379,6 +384,7 @@ void WaveEdit::writeConfiguration(int level, Xml& xml)
xml.colorTag(level, "bgcolor", config.waveEditBackgroundColor);
xml.intTag(level, "width", _widthInit);
xml.intTag(level, "height", _heightInit);
+ xml.strTag(level, "toolbars", _toolbarInit.toHex().data());
xml.tag(level, "/waveedit");
}
@@ -442,6 +448,17 @@ void WaveEdit::resizeEvent(QResizeEvent* ev)
}
//---------------------------------------------------------
+// focusOutEvent
+//---------------------------------------------------------
+
+void WaveEdit::focusOutEvent(QFocusEvent* ev)
+ {
+ QWidget::focusOutEvent(ev);
+ _toolbarInit=saveState();
+ }
+
+
+//---------------------------------------------------------
// songChanged1
// signal from "song"
//---------------------------------------------------------
diff --git a/muse2/muse/waveedit/waveedit.h b/muse2/muse/waveedit/waveedit.h
index 67230897..921b314c 100644
--- a/muse2/muse/waveedit/waveedit.h
+++ b/muse2/muse/waveedit/waveedit.h
@@ -14,6 +14,8 @@
#include <QResizeEvent>
#include <QKeyEvent>
#include <QCloseEvent>
+#include <QByteArray>
+
#include "midieditor.h"
class QToolButton;
@@ -45,11 +47,13 @@ class WaveEdit : public MidiEditor {
QAction* pasteAction;
static int _widthInit, _heightInit;
+ static QByteArray _toolbarInit;
Q_OBJECT
virtual void closeEvent(QCloseEvent*);
virtual void resizeEvent(QResizeEvent* ev);
virtual void keyPressEvent(QKeyEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
QMenu* menuFunctions, *select, *menuGain;