1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Rosegarden 5 A MIDI and audio sequencer and musical notation editor. 6 Copyright 2000-2021 the Rosegarden development team. 7 8 Other copyrights also apply to some parts of this work. Please 9 see the AUTHORS file and individual file headers for details. 10 11 This program is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 2 of the 14 License, or (at your option) any later version. See the file 15 COPYING included with this distribution for more information. 16 */ 17 18 #ifndef RG_TRANSPOSECOMMAND_H 19 #define RG_TRANSPOSECOMMAND_H 20 21 #include "document/BasicSelectionCommand.h" 22 #include <QString> 23 #include <QCoreApplication> 24 25 26 namespace Rosegarden 27 { 28 29 class EventSelection; 30 31 32 class TransposeCommand : public BasicSelectionCommand 33 { Q_DECLARE_TR_FUNCTIONS(Rosegarden::TransposeCommand)34 Q_DECLARE_TR_FUNCTIONS(Rosegarden::TransposeCommand) 35 36 public: 37 TransposeCommand(int semitones, EventSelection &selection) : 38 BasicSelectionCommand(getGlobalName(semitones), selection, true), 39 m_selection(&selection), m_semitones(semitones), m_diatonic(false) { } 40 TransposeCommand(int semitones,int steps,EventSelection & selection)41 TransposeCommand(int semitones, int steps, EventSelection &selection) : 42 BasicSelectionCommand(getDiatonicGlobalName(semitones), selection, true), 43 m_selection(&selection), m_semitones(semitones), m_steps(steps), m_diatonic(true) { } 44 45 static QString getDiatonicGlobalName(int semitones = 0) { 46 switch (semitones) { 47 default: return tr("Transpose by &Interval..."); 48 } 49 } 50 51 static QString getGlobalName(int semitones = 0) { 52 switch (semitones) { 53 case 1: return tr("&Up a Semitone"); 54 case -1: return tr("&Down a Semitone"); 55 case 12: return tr("Up an &Octave"); 56 case -12: return tr("Down an Octa&ve"); 57 default: return tr("&Transpose by Semitones..."); 58 } 59 } 60 61 protected: 62 void modifySegment() override; 63 64 private: 65 EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo) 66 int m_semitones; 67 int m_steps; 68 bool m_diatonic; 69 }; 70 71 72 73 } 74 75 #endif 76