[920a14]: src / TopWidget.h Maximize Restore History

Download this file

TopWidget.h    286 lines (212 with data), 7.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/***************************************************************************
TopWidget.h - Toplevel widget of Kwave
-------------------
begin : 1999
copyright : (C) 1999 by Martin Wilz
email : Martin Wilz <mwilz@ernie.mi.uni-koeln.de>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _TOP_WIDGET_H_
#define _TOP_WIDGET_H_ 1
#include <qlist.h>
#include <ktmainwindow.h>
class QCloseEvent;
class QStrList;
class QTimer;
class KCombo;
class KDNDDropZone;
class KToolBar;
class KStatusBar;
class MenuManager;
class MainWidget;
class PluginManager;
class SignalManager;
class KwaveApp;
class TopWidget : public KTMainWindow
{
Q_OBJECT
public:
/**
* Constructor. Creates a new toplevel widget including menu bar,
* buttons, working are an s on.
* @param main_app reference to the main kwave aplication object
* @param recent_files reference to the global list of recent files
*/
TopWidget(KwaveApp &main_app, QStrList &recent_files);
/**
* Returns true if this instance was successfully initialized, or
* false if something went wrong during initialization.
*/
virtual bool isOK();
/**
* Destructor.
*/
~TopWidget();
/**
* Returns the reference to the Kwave application
*/
inline KwaveApp &getKwaveApp() { return app; };
void setSignal(const char *name);
/**
* Returns a reference to the current name of the signal. If no signal is
* loaded the string is zero-length.
*/
const QString &getSignalName();
void setSignal(SignalManager *);
void parseCommands(const char *);
void loadBatch(const char *);
/**
* Returns a pointer to the current signal manager or zero if
* no signal is loaded.
*/
SignalManager *getSignalManager();
public slots:
void executeCommand(const char *command);
void dropEvent (KDNDDropZone *);
void updateRecentFiles();
private slots:
/** called on changes in the zoom selection combo box */
void selectZoom(int index);
/** called to set a new zoom factor */
void setZoom(double zoom);
/** updates all elements in the toolbar */
void updateToolbar();
/** called if the playback has been paused */
void playbackPaused();
/** connected to the clicked() signal of the pause button */
void pausePressed();
/** toggles the state of the pause button */
void blinkPause();
/** toolbar: "file/new" */
inline void toolbarFileNew() { executeCommand("dialog (newsignal) "); };
/** toolbar: "file/open" */
inline void toolbarFileOpen() { executeCommand("open () "); };
/** toolbar: "file/save" */
inline void toolbarFileSave() { executeCommand("save () "); };
/** toolbar: "file/save as.." */
inline void toolbarFileSaveAs() { executeCommand("saveas () "); };
/** toolbar: "edit/cut" */
inline void toolbarEditCut() { executeCommand("cut () "); };
/** toolbar: "edit/copy" */
inline void toolbarEditCopy() { executeCommand("copy () "); };
/** toolbar: "edit/paste" */
inline void toolbarEditPaste() { executeCommand("paste () "); };
/** toolbar: "edit/erase" */
inline void toolbarEditErase() { executeCommand("zero () "); };
/** toolbar: "edit/delete" */
inline void toolbarEditDelete() { executeCommand("delete () "); };
signals:
/**
* Tells this TopWidget's parent to execute a command
*/
void sigCommand(const char *command);
/**
* Emitted it the name of the signal has changed.
*/
void sigSignalNameChanged(const QString &name);
protected:
void updateMenu();
/**
* Sets a new caption of the this toplevel widget's window.
* If a file is loaded, the caption is set to the
* application's name + " - " + the filename. If no file is
* loaded the caption consists only of the application's name.
* @param filename path of the loaded file or 0 if no file loaded
*/
virtual void setCaption(char *filename);
/**
* Loads a new file and updates the widget's title, menu, status bar
* and so on.
* @param filename path to the file to be loaded
* @param type format of the file (WAV or ASCII)
* @return 0 if successful
*/
int loadFile(const char *filename, int type);
/**
* Discards all changes to the current file and loads
* it again.
*/
void revert();
void openFile();
/**
* Closes the current file and updates the menu and other controls.
* If the file has been modified and the user wanted to break
* the close operation, the file will not get closed and the
* function returns with false.
* @return true if closing is allowed
*/
bool closeFile();
void importAsciiFile();
void exportAsciiFile();
void openRecent (const char *str);
void saveFile();
void saveFileAs(bool selection = false);
void resolution (const char *str);
private:
/** reference to the main kwave application */
KwaveApp &app;
/** reference to the application's list of recent files */
QStrList &recentFiles;
/** our internal plugin manager */
PluginManager *plugin_manager;
/** caption of the main window */
char *caption;
QDir *saveDir;
QDir *loadDir;
/**
* the main widget with all views and controls (except menu and
* toolbar)
*/
MainWidget *mainwidget;
/** combo box for selection of the zoom factor */
KCombo *m_zoomselect;
/**
* toolbar for controlling file operations, copy&paste,
* playback and zoom
*/
KToolBar *m_toolbar;
/** reference to the main window's status bar */
KStatusBar *status_bar;
KDNDDropZone *dropZone;
/** Name of the current signal or file. Zero-Length if nothing loaded */
QString signalName;
/** the window's menu bar */
KMenuBar *menu_bar;
/** menu manager for this window */
MenuManager *menu;
/** bits per sample to save with */
int bits;
/** Timer used to let the pause button blink... */
QTimer *m_pause_timer;
/** determines the state of blinking toolbar buttons */
bool m_blink_on;
/** member id of the "start playback" toolbar button */
int m_id_play;
/** member id of the "start playback and loop" toolbar button */
int m_id_loop;
/** member id of the "pause playback" toolbar button */
int m_id_pause;
/** member id of the "stop playback" toolbar button */
int m_id_stop;
/** member id of the "zoom to selection" toolbar button */
int m_id_zoomrange;
/** member id of the "zoom in" toolbar button */
int m_id_zoomin;
/** member id of the "zoom out" toolbar button */
int m_id_zoomout;
/** member id of the "zoom to 100%" toolbar button */
int m_id_zoomnormal;
/** member id of the "zoom to all" toolbar button */
int m_id_zoomall;
/** member id of the "zoom factor" combobox in the toolbar */
int m_id_zoomselect;
}
;
#endif // _TOP_WIDGET_H_