1 /* 2 Drumstick MIDI File Player Multiplatform Program 3 Copyright (C) 2006-2021, Pedro Lopez-Cabanillas <plcl@users.sf.net> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef INCLUDED_GUIPLAYER_H 20 #define INCLUDED_GUIPLAYER_H 21 22 #include <QMainWindow> 23 #include <QProgressDialog> 24 #include <QObject> 25 #include <QString> 26 #include <QList> 27 #include <QHash> 28 #include <QPointer> 29 #include <QTranslator> 30 #include <QThread> 31 32 #include "connections.h" 33 #include "recentfileshelper.h" 34 #include "pianola.h" 35 #include "channels.h" 36 #include "lyrics.h" 37 #include "prefsdialog.h" 38 #include "playlist.h" 39 #include "toolbareditdialog.h" 40 #include "helpwindow.h" 41 42 #if defined(Q_OS_WINDOWS) 43 #include "winsnap.h" 44 #endif 45 46 class MIDIEvent; 47 48 namespace drumstick { namespace rt { 49 class MIDIOutput; 50 }} 51 52 namespace Ui { 53 class GUIPlayerClass; 54 } 55 56 class SequencePlayer; 57 class About; 58 59 const QString QSTR_DOMAIN("drumstick.sourceforge.net"); 60 const QString QSTR_APPNAME("Drumstick Multiplatform MIDI File Player"); 61 62 class GUIPlayer : public QMainWindow 63 { 64 Q_OBJECT 65 66 public: 67 GUIPlayer(QWidget *parent = 0); 68 ~GUIPlayer(); 69 70 enum PlayerState { 71 InvalidState, 72 EmptyState, 73 PlayingState, 74 PausedState, 75 StoppedState 76 }; 77 Q_ENUM(PlayerState) 78 79 enum PlaylistRepetition { 80 Nothing, 81 CurrentSong, 82 WholePlaylist 83 }; 84 Q_ENUM(PlaylistRepetition) 85 86 void appendSMFEvent(MIDIEvent* ev); 87 void appendWRKEvent(unsigned long ticks, MIDIEvent* ev); 88 void appendOVEEvent(unsigned long ticks, MIDIEvent* ev); 89 90 void updateTimeLabel(long milliseconds); 91 void updateTempoLabel(float ftempo); 92 bool isSupported(QString fileName); 93 void connectOutput(const QString &driver, const QString &connection); 94 void openFile(const QString &fileName); 95 void openFileList(const QStringList &fileNames); 96 void updateState(PlayerState newState); 97 void applySettings(); 98 void updNavButtons(); 99 void updatePositionWidgets(); 100 101 protected: 102 void dragEnterEvent( QDragEnterEvent* event ) override; 103 void dropEvent( QDropEvent* event ) override; 104 void closeEvent( QCloseEvent* event ) override; 105 bool nativeEvent( const QByteArray &eventType, void *message, 106 #if QT_VERSION < QT_VERSION_CHECK(6,0,0) 107 long *result 108 #else 109 qintptr *result 110 #endif 111 ) override; 112 void showEvent(QShowEvent *event) override; 113 114 public slots: 115 void about(); 116 void play(); 117 void pause(); 118 void stop(); 119 void open(); 120 void setup(); 121 void preferences(); 122 void tempoReset(); 123 void volumeReset(); 124 void tempoSlider(int value); 125 void quit(); 126 void volumeSlider(int value); 127 void pitchShift(int value); 128 void playerFinished(); 129 void playerStopped(); 130 void playerEcho(long time, long ticks); 131 void nextSong(); 132 void prevSong(); 133 void positionSliderPressed(); 134 void positionSliderMoved(int value); 135 void positionSliderReleased(); 136 void forward(); 137 void backward(); 138 void jump(); 139 void loop(); 140 141 void progressDialogInit(const QString& type, int max); 142 void progressDialogUpdate(int pos); 143 void progressDialogClose(); 144 145 void slotShowPianola(bool checked); 146 void slotPianolaClosed(); 147 void slotShowChannels(bool checked); 148 void slotChannelsClosed(); 149 void slotShowLyrics(bool checked); 150 void slotLyricsClosed(); 151 void slotShowRhythm(bool checked); 152 153 void slotAboutTranslation(); 154 void slotSwitchLanguage(QAction *action); 155 void slotFileInfo(); 156 void slotPlayList(); 157 void slotEditToolbar(); 158 void slotPlaylistRepeat(QAction *action); 159 void slotHelp(); 160 void slotOpenWebSite(); 161 162 void slotVolume(int channel, qreal vol); 163 void slotMuted(int channel, bool mute); 164 void slotLocked(int channel, bool lock); 165 void slotPatch(int channel, int patch); 166 167 private: 168 void createLanguageMenu(); 169 void retranslateUi(); 170 void connectOutPort(); 171 172 PlayerState m_state; 173 PlaylistRepetition m_repeat; 174 drumstick::rt::MIDIOutput* m_midiOut; 175 SequencePlayer* m_player; 176 Ui::GUIPlayerClass* m_ui; 177 QPointer<QProgressDialog> m_pd; 178 QThread m_playerThread; 179 QPointer<RecentFilesHelper> m_recentFiles; 180 QPointer<Connections> m_connections; 181 QPointer<Pianola> m_pianola; 182 QPointer<Channels> m_channels; 183 QPointer<Lyrics> m_lyrics; 184 QPointer<PrefsDialog> m_preferences; 185 QPointer<PlayList> m_playList; 186 QPointer<ToolBarEditDialog> m_toolbarEditor; 187 QPointer<HelpWindow> m_helpWindow; 188 QTranslator *m_trq, *m_trp, *m_trl; 189 QAction *m_currentLang; 190 bool m_firstShown{true}; 191 int m_newSliderPosition{0}; 192 #if defined(Q_OS_WINDOWS) 193 WinSnap m_snapper; 194 #endif 195 }; 196 197 #endif // INCLUDED_GUIPLAYER_H 198