1 /*********************************************************************************/ 2 /*! 3 @file GuiSidePanel.h 4 5 @brief xxxx. 6 7 @author L. J. Barman 8 9 Copyright (c) 2008-2013, L. J. Barman, all rights reserved 10 11 This file is part of the PianoBooster application 12 13 PianoBooster is free software: you can redistribute it and/or modify 14 it under the terms of the GNU General Public License as published by 15 the Free Software Foundation, either version 3 of the License, or 16 (at your option) any later version. 17 18 PianoBooster is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with PianoBooster. If not, see <http://www.gnu.org/licenses/>. 25 26 */ 27 /*********************************************************************************/ 28 29 #ifndef __GUISIDEPANEL_H__ 30 #define __GUISIDEPANEL_H__ 31 32 #include <QtWidgets> 33 34 #include "Song.h" 35 #include "Score.h" 36 #include "TrackList.h" 37 #include "Settings.h" 38 39 #include "ui_GuiSidePanel.h" 40 41 class GuiTopBar; 42 43 class GuiSidePanel : public QWidget, private Ui::GuiSidePanel 44 { 45 Q_OBJECT 46 47 public: 48 GuiSidePanel(QWidget *parent, CSettings* settings); 49 50 void init(CSong* songObj, CTrackList* trackList, GuiTopBar* topBar); 51 52 void refresh(); 53 54 void loadBookList(); 55 void setBookName(QString bookName); 56 void setSongName(QString songName); getSongIndex()57 int getSongIndex() {return songCombo->currentIndex();} setSongIndex(int index)58 void setSongIndex(int index){songCombo->setCurrentIndex(index);} 59 void setCurrentHand(QString hand); 60 isRepeatSong()61 bool isRepeatSong(){return repeatSong->isChecked();} 62 63 void updateTranslate(); 64 setActiveHand(whichPart_t hand)65 void setActiveHand(whichPart_t hand) 66 { 67 if (hand == PB_PART_right) rightHandRadio->setChecked(true); 68 if (hand == PB_PART_both) bothHandsRadio->setChecked(true); 69 if (hand == PB_PART_left) leftHandRadio->setChecked(true); 70 } 71 nextSong(int amount)72 void nextSong(int amount) 73 { 74 int n = songCombo->currentIndex() + amount; 75 if (n < 0 || n >= songCombo->count()) 76 return; 77 78 songCombo->setCurrentIndex(n); 79 on_songCombo_activated(n); 80 } 81 nextBook(int amount)82 void nextBook(int amount) 83 { 84 int n = bookCombo->currentIndex() + amount; 85 if (n < 0 || n >= bookCombo->count()) 86 return; 87 88 bookCombo->setCurrentIndex(n); 89 on_bookCombo_activated(n); 90 } 91 92 private slots: 93 void on_songCombo_activated (int index); 94 void on_bookCombo_activated (int index); 95 void on_rightHandRadio_toggled (bool checked); 96 void on_bothHandsRadio_toggled (bool checked); 97 void on_leftHandRadio_toggled (bool checked); 98 void on_repeatSong_released(); 99 on_trackListWidget_currentRowChanged(int currentRow)100 void on_trackListWidget_currentRowChanged(int currentRow) { 101 if (m_trackList){ 102 m_trackList->currentRowChanged(currentRow); 103 autoSetMuteYourPart(); 104 } 105 } 106 on_boostSlider_valueChanged(int value)107 void on_boostSlider_valueChanged(int value) { 108 if (m_song) m_song->boostVolume(value); 109 } 110 on_pianoSlider_valueChanged(int value)111 void on_pianoSlider_valueChanged(int value) { 112 if (m_song) m_song->pianoVolume(value); 113 } on_listenRadio_toggled(bool checked)114 void on_listenRadio_toggled (bool checked) 115 { 116 if (!m_song || !checked) return; 117 m_settings->setValue("SidePanel/skill",PB_PLAY_MODE_listen); 118 m_song->setPlayMode(PB_PLAY_MODE_listen); 119 autoSetMuteYourPart(); 120 } 121 on_rhythmTapRadio_toggled(bool checked)122 void on_rhythmTapRadio_toggled (bool checked) 123 { 124 if (!m_song || !checked) return; 125 m_settings->setValue("SidePanel/skill",PB_PLAY_MODE_rhythmTapping); 126 m_song->setPlayMode(PB_PLAY_MODE_rhythmTapping); 127 autoSetMuteYourPart(); 128 } 129 on_followYouRadio_toggled(bool checked)130 void on_followYouRadio_toggled (bool checked) 131 { 132 if (!m_song || !checked) return; 133 m_settings->setValue("SidePanel/skill",PB_PLAY_MODE_followYou); 134 m_song->setPlayMode(PB_PLAY_MODE_followYou); 135 autoSetMuteYourPart(); 136 } 137 on_playAlongRadio_toggled(bool checked)138 void on_playAlongRadio_toggled (bool checked) 139 { 140 if (!m_song || !checked) return; 141 m_settings->setValue("SidePanel/skill",PB_PLAY_MODE_playAlong); 142 m_song->setPlayMode(PB_PLAY_MODE_playAlong); 143 autoSetMuteYourPart(); 144 } 145 146 void on_rhythmTappingCombo_activated (int index); 147 on_muteYourPartCheck_toggled(bool checked)148 void on_muteYourPartCheck_toggled (bool checked) 149 { 150 if (m_song) m_song->mutePianistPart(checked); 151 } 152 setTrackRightHandPart()153 void setTrackRightHandPart() { 154 int row = trackListWidget->currentRow(); 155 int otherRow = m_trackList->getHandTrackIndex(PB_PART_left); 156 if (otherRow == row) otherRow = -1; 157 m_trackList->setActiveHandsIndex(otherRow, row); 158 trackListWidget->setCurrentRow(row); 159 m_song->refreshScroll(); 160 } 161 setTrackLeftHandPart()162 void setTrackLeftHandPart() { 163 int row = trackListWidget->currentRow(); 164 int otherRow = m_trackList->getHandTrackIndex(PB_PART_right); 165 if (otherRow == row) otherRow = -1; 166 m_trackList->setActiveHandsIndex(row, otherRow); 167 trackListWidget->setCurrentRow(row); 168 m_song->refreshScroll(); 169 } 170 clearTrackPart()171 void clearTrackPart() { 172 int row = trackListWidget->currentRow(); 173 m_trackList->setActiveHandsIndex( -1, -1); 174 trackListWidget->setCurrentRow(row); 175 m_song->refreshScroll(); 176 } 177 178 private: 179 void autoSetMuteYourPart(); 180 181 QMap<QWidget*,QMap<QString,QString>> listWidgetsRetranslateUi; 182 QMap<QAction*,QMap<QString,QString>> listActionsRetranslateUi; 183 184 CSong* m_song; 185 CScore* m_score; 186 CTrackList* m_trackList; 187 GuiTopBar* m_topBar; 188 CSettings* m_settings; 189 QWidget *m_parent; 190 }; 191 192 #endif //__GUISIDEPANEL_H__ 193