MuseScore/mscore/exportmidi.h
Dag Henning Liodden Sørbø 2b6cb8b432 Change to new preferences model
The old Preferences struct holding all preferences are removed in favor of a
new Preferences class which acts as a proxy for QSettings. The settings stored
in QSettings are accessed directly through access methods like getBool(key),
getInt(key), etc. and changed with setPreference(key, value).

Since we are using QSettings directly the preferences are stored automatically
without the need for a custom write() and read() method like before.

The preferences.cpp/.h and prefdialog.cpp/h are refactored to have fewer
responsibilities than before. The Preferences class are all about storing and
retrieving preferences - it should not contain any code to handle any other
aspect of MuseScore.

Testing:
The Preferences class can be used in tests. All preferences are initialized with
default values in mtest. If a test requires that a preference has a specific
value it can be changed using setPreference() for that single test. In the tests
the preferences are stored in memory only.

The Preference class is supposed to be used as a singleton. In preferences.h an
'extern Preferences preferences' is set and it is defined in preferences.cpp. All
files which includes preferences.h have access to the 'preferences' singleton
and should use this to get and set preferences.
2018-02-08 16:59:10 +01:00

60 lines
1.6 KiB
C++

//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-2012 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __EXPORTMIDI_H__
#define __EXPORTMIDI_H__
#include "midi/midifile.h"
namespace Ms {
class Score;
class TempoMap;
//---------------------------------------------------------
// ExportMidi
//---------------------------------------------------------
class ExportMidi {
QFile f;
Score* cs;
//---------------------------------------------------
// PauseMap
// MIDI files cannot contain pauses so need to insert
// extra ticks extra ticks and tempo changes instead.
//---------------------------------------------------
class PauseMap : std::map<int, int> {
int offsetAtUTick(int utick) const;
public:
TempoMap* tempomapWithPauses;
void calculate(const Score* s);
inline int addPauseTicks(int utick) const { return utick + this->offsetAtUTick(utick); }
};
PauseMap pauseMap;
void writeHeader();
public:
MidiFile mf;
ExportMidi(Score* s) { cs = s; }
bool write(const QString& name, bool midiExpandRepeats, bool exportRPNs);
};
} // namespace Ms
#endif