kwave  18.07.70
TopWidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  TopWidget.h - Toplevel widget of Kwave
3  -------------------
4  begin : 1999
5  copyright : (C) 1999 by Martin Wilz
6  email : Martin Wilz <mwilz@ernie.mi.uni-koeln.de>
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef TOP_WIDGET_H
20 #define TOP_WIDGET_H
21 
22 #include "config.h"
23 
24 #include <QtGlobal>
25 #include <QMap>
26 #include <QMdiArea>
27 #include <QPointer>
28 #include <QString>
29 #include <QUrl>
30 
31 #include <KMainWindow>
32 
33 #include "libkwave/Sample.h"
34 #include "libkwave/String.h"
35 
36 #include "App.h"
37 #include "FileContext.h"
38 
39 class QCloseEvent;
40 class QDragEnterEvent;
41 class QDropEvent;
42 class QLabel;
43 class QMdiSubWindow;
44 class QTimer;
45 
46 namespace Kwave
47 {
48 
49  class FileContext;
50  class MainWidget;
51  class MenuManager;
52  class SignalManager;
53  class PlayerToolBar;
54  class PluginManager;
55  class FileContext;
56  class ZoomToolBar;
57 
62  class Q_DECL_EXPORT TopWidget: public KMainWindow
63  {
64  Q_OBJECT
65 
66  public:
67 
73  explicit TopWidget(Kwave::App &app);
74 
81  bool init();
82 
86  virtual ~TopWidget() Q_DECL_OVERRIDE;
87 
92  QList<Kwave::App::FileAndInstance> openFiles() const;
93 
101  Kwave::FileContext *currentContext() const;
102 
107  QList<Kwave::FileContext *> detachAllContexts();
108 
113  void insertContext(Kwave::FileContext *context);
114 
121  int loadFile(const QUrl &url);
122 
123  public slots:
124 
130  void updateRecentFiles();
131 
139  int executeCommand(const QString &command);
140 
151  int forwardCommand(const QString &command);
152 
153  protected slots:
154 
156  virtual void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE;
157 
159  virtual void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
160 
165  virtual void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
166 
167  private slots:
168 
173  void metaDataChanged(Kwave::MetaDataList meta_data);
174 
180  void selectionChanged(sample_index_t offset, sample_index_t length);
181 
187  void setUndoRedoInfo(const QString &undo, const QString &redo);
188 
190  void clipboardChanged(bool data_available);
191 
193  void updateMenu();
194 
196  void resetToolbarToDefaults();
197 
199  void updateToolbar();
200 
201  void toolbarRecord() { forwardCommand(_("plugin(record)")); }
202 
204  void toolbarFileNew() { forwardCommand(_("plugin(newsignal)")); }
205 
207  void toolbarFileOpen() { forwardCommand(_("open () ")); }
208 
210  void toolbarFileSave() { forwardCommand(_("save () ")); }
211 
213  void toolbarFileSaveAs() { forwardCommand(_("saveas () ")); }
214 
216  void toolbarFileClose() { forwardCommand(_("close () ")); }
217 
219  void toolbarEditUndo() { forwardCommand(_("undo () ")); }
220 
222  void toolbarEditRedo() { forwardCommand(_("redo () ")); }
223 
225  void toolbarEditCut() { forwardCommand(_("cut () ")); }
226 
228  void toolbarEditCopy() { forwardCommand(_("copy () ")); }
229 
231  void toolbarEditPaste() { forwardCommand(_("paste () ")); }
232 
234  void toolbarEditErase() { forwardCommand(_("plugin(zero)")); }
235 
237  void toolbarEditDelete() { forwardCommand(_("delete () ")); }
238 
242  void modifiedChanged();
243 
245  void showInSplashSreen(const QString &message);
246 
252  void showStatusBarMessage(const QString &msg, unsigned int ms);
253 
258  void subWindowActivated(QMdiSubWindow *sub);
259 
264  void subWindowDeleted(QObject *obj);
265 
266  signals:
267 
272  void sigFileContextSwitched(Kwave::FileContext *context);
273 
274  private:
275 
288  int newWindow(Kwave::FileContext *&context, const QUrl &url);
289 
298  int newSignal(sample_index_t samples, double rate,
299  unsigned int bits, unsigned int tracks);
300 
306  int openFile();
307 
312  bool closeAllSubWindows();
313 
319  int openRecent(const QString &str);
320 
322  void updateCaption();
323 
328  void connectContext(Kwave::FileContext *context);
329 
335  Kwave::FileContext *newFileContext();
336 
337  private:
338 
341 
347  QMap<QMdiSubWindow *, Kwave::FileContext *> m_context_map;
348 
351 
354 
357 
362  QMdiArea *m_mdi_area;
363 
365  QAction *m_action_save;
366 
369 
371  QAction *m_action_close;
372 
374  QAction *m_action_undo;
375 
377  QAction *m_action_redo;
378 
380  QAction *m_action_cut;
381 
383  QAction *m_action_copy;
384 
386  QAction *m_action_erase;
387 
389  QAction *m_action_delete;
390 
393 
396 
399  };
400 }
401 
402 #endif /* TOP_WIDGET_H */
403 
404 //***************************************************************************
405 //***************************************************************************
QMdiArea * m_mdi_area
Definition: TopWidget.h:362
Definition: App.h:33
void toolbarEditRedo()
Definition: TopWidget.h:222
void toolbarEditUndo()
Definition: TopWidget.h:219
void toolbarEditPaste()
Definition: TopWidget.h:231
void toolbarFileSave()
Definition: TopWidget.h:210
QAction * m_action_erase
Definition: TopWidget.h:386
void toolbarEditCut()
Definition: TopWidget.h:225
quint64 sample_index_t
Definition: Sample.h:28
void toolbarRecord()
Definition: TopWidget.h:201
QAction * m_action_save
Definition: TopWidget.h:365
QLabel * m_lbl_status_mode
Definition: TopWidget.h:395
QAction * m_action_redo
Definition: TopWidget.h:377
Definition: App.h:44
void toolbarFileOpen()
Definition: TopWidget.h:207
Manager class for access to Kwave&#39;s menu subsystem.
Definition: MenuManager.h:46
Kwave::App & m_application
Definition: TopWidget.h:340
QAction * m_action_copy
Definition: TopWidget.h:383
QLabel * m_lbl_status_size
Definition: TopWidget.h:392
void toolbarFileSaveAs()
Definition: TopWidget.h:213
QAction * m_action_close
Definition: TopWidget.h:371
QAction * m_action_undo
Definition: TopWidget.h:374
QAction * m_action_save_as
Definition: TopWidget.h:368
void toolbarEditCopy()
Definition: TopWidget.h:228
QAction * m_action_cut
Definition: TopWidget.h:380
Kwave::MenuManager * m_menu_manager
Definition: TopWidget.h:356
void toolbarEditDelete()
Definition: TopWidget.h:237
Kwave::PlayerToolBar * m_toolbar_record_playback
Definition: TopWidget.h:350
#define _(m)
Definition: memcpy.c:66
void toolbarEditErase()
Definition: TopWidget.h:234
QMap< QMdiSubWindow *, Kwave::FileContext * > m_context_map
Definition: TopWidget.h:347
QAction * m_action_delete
Definition: TopWidget.h:389
Kwave::ZoomToolBar * m_toolbar_zoom
Definition: TopWidget.h:353
void toolbarFileNew()
Definition: TopWidget.h:204
QLabel * m_lbl_status_cursor
Definition: TopWidget.h:398
void toolbarFileClose()
Definition: TopWidget.h:216