1 /*************************************************************************** 2 ** ** 3 ** Polyphone, a soundfont editor ** 4 ** Copyright (C) 2013-2020 Davy Triponney ** 5 ** ** 6 ** This program is free software: you can redistribute it and/or modify ** 7 ** it under the terms of the GNU General Public License as published by ** 8 ** the Free Software Foundation, either version 3 of the License, or ** 9 ** (at your option) any later version. ** 10 ** ** 11 ** This program is distributed in the hope that it will be useful, ** 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 14 ** GNU General Public License for more details. ** 15 ** ** 16 ** You should have received a copy of the GNU General Public License ** 17 ** along with this program. If not, see http://www.gnu.org/licenses/. ** 18 ** ** 19 **************************************************************************** 20 ** Author: Davy Triponney ** 21 ** Website/Contact: https://www.polyphone-soundfonts.com ** 22 ** Date: 01.01.2013 ** 23 ***************************************************************************/ 24 25 #ifndef PAGE_SF2_H 26 #define PAGE_SF2_H 27 28 #include <QWidget> 29 #include <QFocusEvent> 30 #include <QKeyEvent> 31 #include "page.h" 32 33 namespace Ui { 34 class PageSf2; 35 } 36 37 // Add the signal editingFinished() for qTextEdit 38 class TextEdit : public QTextEdit 39 { 40 Q_OBJECT 41 public: QTextEdit(parent)42 TextEdit(QWidget *parent = nullptr) : QTextEdit(parent) {} 43 44 private: focusOutEvent(QFocusEvent * e)45 void focusOutEvent(QFocusEvent *e) 46 { 47 if (e->lostFocus()) 48 emit(editingFinished()); 49 QTextEdit::focusOutEvent(e); 50 } 51 keyPressEvent(QKeyEvent * e)52 void keyPressEvent(QKeyEvent *e) 53 { 54 int key = e->key(); 55 if (this->toPlainText().size() < 65536 || key == Qt::Key_Backspace || key == Qt::Key_Delete || 56 key == Qt::Key_Left || key == Qt::Key_Up || key == Qt::Key_Right || 57 key == Qt::Key_Down || key == Qt::Key_PageUp || key == Qt::Key_PageDown || 58 key == Qt::Key_Home || key == Qt::Key_End) 59 QTextEdit::keyPressEvent(e); 60 } 61 62 signals: 63 void editingFinished(); 64 }; 65 66 67 class PageSf2 : public Page 68 { 69 Q_OBJECT 70 71 public: 72 explicit PageSf2(QWidget *parent = nullptr); 73 ~PageSf2() override; 74 75 private slots: 76 void setName(); 77 void setCopyright(); 78 void setAuthor(); 79 void setDate(); 80 void setProduct(); 81 void setCommentaire(); 82 void dateFocussed(bool hasFocus); 83 void on_pushButton_setNow_pressed(); 84 void on_pushViewSamples_clicked(); 85 void on_pushViewInstruments_clicked(); 86 void on_pushViewPresets_clicked(); 87 void on_comboBox_currentIndexChanged(int index); 88 89 protected: 90 // Update the interface 91 bool updateInterface(QString editingSource, IdList selectedIds, int displayOption) override; 92 93 // Refresh things after a page is shown 94 void onShow() override; 95 96 private: 97 EltID _currentID; 98 Ui::PageSf2 *ui; 99 100 void countElements(); 101 void countElements(int &unusedSmpl, int &unusedInst, int &usedSmpl, int &usedInst, int &usedPrst, 102 int &instGen, int &prstGen, int &instMod, int &prstMod); 103 }; 104 105 #endif // PAGE_SF2_H 106