Debian Codegraph @

src/qutewidget.h

raw symbols SCIP
1 /*
2 Copyright (C) 2008, 2009 Andres Cabrera
3 [email protected]
4
5 This file is part of CsoundQt.
6
7 CsoundQt is free software; you can redistribute it
8 and/or modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 CsoundQt is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with Csound; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA
21 */
22
23 #ifndef QUTEWIDGET_H
24 #define QUTEWIDGET_H
25
26 #include <QtWidgets>
27 #include <QtXml>
28
29 #define QCS_CURRENT_XML_VERSION "2"
30 #define QCS_CURVE_BUFFER_SIZE 256
31 //#define USE_WIDGET_MUTEX
32
33 #include "csoundengine.h"
34
35 enum QuteWidgetType { UNKNOWN=0, SPINBOX=1, LINEEDIT, CHECKBOX, SLIDER, KNOB, SCROLLNUMBER,
36 BUTTON, DROPDOWN, CONTROLLER, GRAPH, SCOPE, CONSOLE,
37 TABLEDISPLAY };
38
39 class QuteWidget : public QWidget
40 {
41 Q_OBJECT
42 public:
43 QuteWidget(QWidget* parent);
44 ~QuteWidget();
45
46 virtual void setWidgetGeometry(int x, int y, int w, int h);
47 virtual void setValue(double); // These should only be reimplemented if something special needs to be done with the value.
48 virtual void setValue2(double);
49 virtual void setValue(QString);
50 virtual void setMidiValue(int value);
51 virtual void setMidiValue2(int value);
52 virtual bool acceptsMidi() {return false;}
53 virtual void setLocked(bool locked) {m_locked = locked;}
54
55 virtual void widgetMessage(QString path, QString text);
56 virtual void widgetMessage(QString path, double value);
57
58 virtual QString getWidgetLine() = 0;
59 virtual QString getCabbageLine();
60 virtual QString getCsladspaLine();
61 virtual QString getQml();
62 virtual QString getWidgetXmlText() = 0;
63 virtual QString getChannelName();
64 virtual QString getChannel2Name();
65 virtual double getValue();
66 virtual double getValue2();
67 virtual QString getStringValue();
68 virtual QString getDescription();
69
70 QString getUuid();
71 virtual QString getWidgetType() = 0;
72 virtual void refreshWidget() { ;}
73
74 virtual void applyInternalProperties();
75
76 void createXmlWriter(QXmlStreamWriter &s);
77 void markChanged();
78 void canFocus(bool can);
79 void updateDialogWindow(int cc, int channel);
80 virtual void setCsoundUserData(CsoundUserData *ud) { m_csoundUserData = ud; }
81 double getSr(double defaultSr=0.0) {
82 if(m_csoundUserData == nullptr) {
83 QDEBUG << "csoundUserData: null";
84 return defaultSr;
85 }
86 auto engine = m_csoundUserData->csEngine;
87 if(engine == nullptr) {
88 QDEBUG << "engine null";
89 return defaultSr;
90 }
91 if(!engine->isRunning()) {
92 QDEBUG << "not running";
93 return defaultSr;
94 }
95 return csoundGetSr(engine->getCsound());
96 }
97
98 bool m_valueChanged;
99 bool m_value2Changed;
100
101
102 public slots:
103 void popUpMenu(QPoint pos);
104 void openProperties();
105
106 protected:
107 QSpinBox *xSpinBox;
108 QSpinBox *ySpinBox;
109 QSpinBox *wSpinBox;
110 QSpinBox *hSpinBox;
111 QLabel *channelLabel;
112 QLineEdit *nameLineEdit;
113 QLineEdit *descriptionLineEdit;
114
115 QSpinBox *midiccSpinBox;
116 QSpinBox *midichanSpinBox;
117 QPushButton *midiLearnButton;
118 QWidget *m_widget;
119 QDialog *dialog;
120 QGridLayout *layout; // For preference dialog
121 double m_value, m_value2;
122 QString m_stringValue;
123 QString m_channel, m_channel2;
124 int m_midicc, m_midichan;
125 bool m_locked; // Allow modification of widget (properties, alignment, etc.)
126 CsoundUserData *m_csoundUserData;
127 QString m_description;
128
129
130 #ifdef USE_WIDGET_MUTEX
131 QReadWriteLock widgetLock;
132 #endif
133 QString xmlText;
134
135 virtual void contextMenuEvent(QContextMenuEvent *event);
136
137 virtual void createPropertiesDialog();
138 virtual void applyProperties();
139
140 QList<QAction *> getParentActionList();
141 QList<QAction *> getParentPresetList();
142
143 protected slots:
144 void apply();
145 void deleteWidget();
146 void openMidiDialog();
147
148 private:
149
150 QAction *propertiesAct;
151 QAction *addChn_kAct;
152
153
154 QPushButton *applyButton;
155 QPushButton *cancelButton;
156 QPushButton *acceptButton;
157
158 private slots:
159 void addChn_k();
160
161 signals:
162 void newValue(QPair<QString,double> channelValue);
163 void newValue(QPair<QString,QString> channelValue);
164 void widgetChanged(QuteWidget* widget);
165 void deleteThisWidget(QuteWidget *thisWidget);
166 void propertiesAccepted();
167 void showMidiLearn(QuteWidget* widget);
168 void addChn_kSignal(QString channel);
169
170 };
171
172 #endif