kwave
18.07.70
|
#include <TopWidget.h>
Public Slots | |
void | updateRecentFiles () |
int | executeCommand (const QString &command) |
int | forwardCommand (const QString &command) |
Signals | |
void | sigFileContextSwitched (Kwave::FileContext *context) |
Public Member Functions | |
TopWidget (Kwave::App &app) | |
bool | init () |
virtual | ~TopWidget () Q_DECL_OVERRIDE |
QList< Kwave::App::FileAndInstance > | openFiles () const |
Kwave::FileContext * | currentContext () const |
QList< Kwave::FileContext * > | detachAllContexts () |
void | insertContext (Kwave::FileContext *context) |
int | loadFile (const QUrl &url) |
Protected Slots | |
virtual void | closeEvent (QCloseEvent *e) Q_DECL_OVERRIDE |
virtual void | dragEnterEvent (QDragEnterEvent *event) Q_DECL_OVERRIDE |
virtual void | dropEvent (QDropEvent *event) Q_DECL_OVERRIDE |
Private Slots | |
void | metaDataChanged (Kwave::MetaDataList meta_data) |
void | selectionChanged (sample_index_t offset, sample_index_t length) |
void | setUndoRedoInfo (const QString &undo, const QString &redo) |
void | clipboardChanged (bool data_available) |
void | updateMenu () |
void | resetToolbarToDefaults () |
void | updateToolbar () |
void | toolbarRecord () |
void | toolbarFileNew () |
void | toolbarFileOpen () |
void | toolbarFileSave () |
void | toolbarFileSaveAs () |
void | toolbarFileClose () |
void | toolbarEditUndo () |
void | toolbarEditRedo () |
void | toolbarEditCut () |
void | toolbarEditCopy () |
void | toolbarEditPaste () |
void | toolbarEditErase () |
void | toolbarEditDelete () |
void | modifiedChanged () |
void | showInSplashSreen (const QString &message) |
void | showStatusBarMessage (const QString &msg, unsigned int ms) |
void | subWindowActivated (QMdiSubWindow *sub) |
void | subWindowDeleted (QObject *obj) |
Private Member Functions | |
int | newWindow (Kwave::FileContext *&context, const QUrl &url) |
int | newSignal (sample_index_t samples, double rate, unsigned int bits, unsigned int tracks) |
int | openFile () |
bool | closeAllSubWindows () |
int | openRecent (const QString &str) |
void | updateCaption () |
void | connectContext (Kwave::FileContext *context) |
Kwave::FileContext * | newFileContext () |
Private Attributes | |
Kwave::App & | m_application |
QMap< QMdiSubWindow *, Kwave::FileContext * > | m_context_map |
Kwave::PlayerToolBar * | m_toolbar_record_playback |
Kwave::ZoomToolBar * | m_toolbar_zoom |
Kwave::MenuManager * | m_menu_manager |
QMdiArea * | m_mdi_area |
QAction * | m_action_save |
QAction * | m_action_save_as |
QAction * | m_action_close |
QAction * | m_action_undo |
QAction * | m_action_redo |
QAction * | m_action_cut |
QAction * | m_action_copy |
QAction * | m_action_erase |
QAction * | m_action_delete |
QLabel * | m_lbl_status_size |
QLabel * | m_lbl_status_mode |
QLabel * | m_lbl_status_cursor |
Toplevel widget of the Kwave application. Holds a main widget, a menu bar, a status bar and a toolbar.
Definition at line 62 of file TopWidget.h.
|
explicit |
Constructor. Creates a new toplevel widget including menu bar, buttons, working are an s on.
app | reference to the Kwave application instance |
Definition at line 102 of file TopWidget.cpp.
References _, Kwave::App::cmdline(), m_application, m_lbl_status_cursor, m_lbl_status_mode, and m_lbl_status_size.
|
virtual |
Destructor.
Definition at line 480 of file TopWidget.cpp.
References closeAllSubWindows(), m_application, m_context_map, m_menu_manager, m_toolbar_record_playback, m_toolbar_zoom, and Kwave::App::toplevelWindowHasClosed().
|
privateslot |
updates the menus when the clipboard has become empty/full
Definition at line 1293 of file TopWidget.cpp.
References _, m_menu_manager, and Kwave::MenuManager::setItemEnabled().
Referenced by init(), and updateMenu().
|
private |
Close all the currently opened sub windows
Definition at line 887 of file TopWidget.cpp.
References Kwave::FileContext::closeFile(), and m_context_map.
Referenced by closeEvent(), and ~TopWidget().
|
protectedvirtualslot |
Definition at line 1541 of file TopWidget.cpp.
References closeAllSubWindows().
|
private |
Establishes all signal/slot connections between a context and this instance, including toolbars etc.
Definition at line 167 of file TopWidget.cpp.
References Kwave::connect(), m_toolbar_record_playback, m_toolbar_zoom, metaDataChanged(), modifiedChanged(), selectionChanged(), setUndoRedoInfo(), and showStatusBarMessage().
Referenced by insertContext(), and newFileContext().
Kwave::FileContext * Kwave::TopWidget::currentContext | ( | ) | const |
Returns the currently active file context (corresponds to a MDI sub window or tab in MDI / TAB mode). In SDI mode, m_context_map contains only one element, the current context (reachable per index null).
Definition at line 232 of file TopWidget.cpp.
References m_context_map, and m_mdi_area.
Referenced by forwardCommand(), loadFile(), newSignal(), selectionChanged(), subWindowActivated(), updateCaption(), updateMenu(), and updateToolbar().
QList< Kwave::FileContext * > Kwave::TopWidget::detachAllContexts | ( | ) |
Detaches all file contexts from this instance
Definition at line 520 of file TopWidget.cpp.
References Kwave::FileContext::isInUse(), m_context_map, m_mdi_area, Kwave::FileContext::release(), Kwave::FileContext::setParent(), and sigFileContextSwitched().
Referenced by Kwave::App::switchGuiType().
|
protectedvirtualslot |
Definition at line 1597 of file TopWidget.cpp.
References Kwave::FileDrag::canDecode().
|
protectedvirtualslot |
For dropping data into an empty signal
Definition at line 1609 of file TopWidget.cpp.
References _, Kwave::CodecManager::canDecode(), Kwave::Parser::escape(), forwardCommand(), and Kwave::CodecManager::mimeTypeOf().
|
slot |
Execute a Kwave text command
command | a text command |
0 | if succeeded |
negative | error code if failed |
ENOSYS | if the command is unknown in this component |
Definition at line 706 of file TopWidget.cpp.
References _, CASE_COMMAND, Kwave::Parser::command(), Kwave::MenuManager::executeCommand(), Kwave::PlayerToolBar::executeCommand(), Kwave::App::executeCommand(), Kwave::Parser::firstParam(), Kwave::App::GUI_MDI, Kwave::App::GUI_SDI, Kwave::App::GUI_TAB, Kwave::App::guiType(), loadFile(), m_application, m_context_map, m_mdi_area, m_menu_manager, m_toolbar_record_playback, newSignal(), Kwave::Parser::nextParam(), openFile(), openRecent(), Kwave::MessageBox::questionYesNo(), resetToolbarToDefaults(), Kwave::App::switchGuiType(), Kwave::Parser::toDouble(), Kwave::Parser::toSampleIndex(), Kwave::Parser::toUInt(), and Kwave::FileContext::windowCaption().
Referenced by loadFile().
|
slot |
forward a Kwave text command coming from an upper layer to the currently active context below us (which is the main entry point for all text commands)
command | a text command |
0 | if succeeded |
negative | error code if failed |
EAGAIN | if there is no "current" context (yet) |
ENOSYS | if the command is unknown in this component |
Definition at line 871 of file TopWidget.cpp.
References currentContext(), Kwave::FileContext::executeCommand(), Kwave::FileContext::pluginManager(), and Kwave::PluginManager::sync().
Referenced by dropEvent(), and init().
bool Kwave::TopWidget::init | ( | ) |
Does some initialization at startup of the instance
true | if this instance was successfully initialized |
false | if something went wrong during initialization |
Definition at line 267 of file TopWidget.cpp.
References _, clipboardChanged(), Kwave::connect(), Kwave::FileContext::createMainWidget(), forwardCommand(), Kwave::App::GUI_MDI, Kwave::App::GUI_SDI, Kwave::App::GUI_TAB, Kwave::App::guiType(), Kwave::ClipBoard::instance(), m_action_close, m_action_copy, m_action_cut, m_action_delete, m_action_erase, m_action_redo, m_action_save, m_action_save_as, m_action_undo, m_application, m_mdi_area, m_menu_manager, m_toolbar_record_playback, m_toolbar_zoom, Kwave::FileContext::mainWidget(), metaDataChanged(), newFileContext(), resetToolbarToDefaults(), selectionChanged(), setUndoRedoInfo(), showInSplashSreen(), sigFileContextSwitched(), subWindowActivated(), TOOLBAR_EDIT, TOOLBAR_FILE, TOOLBAR_RECORD_PLAY, TOOLBAR_ZOOM, toolbarEditCopy(), toolbarEditCut(), toolbarEditDelete(), toolbarEditErase(), toolbarEditPaste(), toolbarEditRedo(), toolbarEditUndo(), toolbarFileClose(), toolbarFileNew(), toolbarFileOpen(), toolbarFileSave(), toolbarFileSaveAs(), updateMenu(), updateRecentFiles(), and updateToolbar().
Referenced by Kwave::App::newWindow(), and Kwave::App::switchGuiType().
void Kwave::TopWidget::insertContext | ( | Kwave::FileContext * | context | ) |
Insert a new file context into this instance
context | the new file context |
Definition at line 572 of file TopWidget.cpp.
References Kwave::connect(), connectContext(), Kwave::FileContext::createMainWidget(), Kwave::App::GUI_MDI, Kwave::App::GUI_SDI, Kwave::App::GUI_TAB, Kwave::App::guiType(), m_application, m_context_map, m_mdi_area, Kwave::FileContext::mainWidget(), newFileContext(), Kwave::FileContext::release(), Kwave::FileContext::setParent(), sigFileContextSwitched(), subWindowActivated(), subWindowDeleted(), updateCaption(), updateMenu(), updateToolbar(), and Kwave::FileContext::windowCaption().
Referenced by newWindow(), and Kwave::App::switchGuiType().
int Kwave::TopWidget::loadFile | ( | const QUrl & | url | ) |
Loads a new file and updates the widget's title, menu, status bar and so on.
url | URL of the file to be loaded |
Definition at line 991 of file TopWidget.cpp.
References _, Kwave::App::addRecentFile(), Kwave::FileContext::closeFile(), currentContext(), Kwave::MessageBox::error(), executeCommand(), Kwave::FileContext::executeCommand(), Kwave::Parser::fromUrl(), Kwave::Logger::Info, Kwave::FileContext::loadBatch(), Kwave::SignalManager::loadFile(), Kwave::Logger::log(), m_application, newWindow(), Kwave::Splash::showMessage(), Kwave::FileContext::signalManager(), updateMenu(), updateToolbar(), and Kwave::urlScheme().
Referenced by executeCommand(), Kwave::App::newWindow(), openFile(), and openRecent().
|
privateslot |
Called when the meta data of the current signal has changed
meta_data | the new meta data, after the change |
Definition at line 1125 of file TopWidget.cpp.
References _, Kwave::FileInfo::bits(), Kwave::FileInfo::length(), m_lbl_status_mode, m_lbl_status_size, m_menu_manager, Kwave::ms2string(), Kwave::FileInfo::rate(), Kwave::samples2string(), selectionChanged(), Kwave::FileInfo::tracks(), updateCaption(), updateMenu(), and updateToolbar().
Referenced by connectContext(), and init().
|
privateslot |
called if the signal now or no longer is modified
Definition at line 1526 of file TopWidget.cpp.
References updateCaption(), and updateMenu().
Referenced by connectContext().
|
private |
Creates a new file context and initializes it.
Definition at line 203 of file TopWidget.cpp.
References connectContext(), Kwave::FileContext::init(), m_application, m_context_map, m_toolbar_zoom, and sigFileContextSwitched().
Referenced by init(), insertContext(), and newWindow().
|
private |
Closes the current file and creates a new empty signal.
samples | number of samples per track |
rate | sample rate |
bits | number of bits per sample |
tracks | number of tracks |
Definition at line 1102 of file TopWidget.cpp.
References _, currentContext(), Kwave::SignalManager::newSignal(), newWindow(), Kwave::FileContext::signalManager(), and Kwave::Parser::toUrl().
Referenced by executeCommand().
|
private |
Opens a new empty window.
context | reference to the pointer to the current context, can be modified in case that a new context has to be created for the new window! Must not be a null pointer |
url | URL of the file to be loaded (optional), used for opening a new SDI window |
-1 | or negative in case of an error |
0 | if succeeded and done (SDI mode) |
1 | if succeeded but window is still empty (MDI or TAB mode) |
Definition at line 930 of file TopWidget.cpp.
References Kwave::FileContext::closeFile(), Kwave::FileContext::createMainWidget(), Kwave::App::GUI_MDI, Kwave::App::GUI_SDI, Kwave::App::GUI_TAB, Kwave::App::guiType(), insertContext(), Kwave::SignalManager::isEmpty(), Kwave::FileContext::isEmpty(), m_application, m_context_map, m_mdi_area, newFileContext(), Kwave::App::newWindow(), Kwave::FileContext::release(), sigFileContextSwitched(), Kwave::FileContext::signalManager(), and Kwave::urlScheme().
Referenced by loadFile(), and newSignal().
|
private |
Shows an "open file" dialog and opens the .wav file the user has selected.
Definition at line 1082 of file TopWidget.cpp.
References _, Kwave::CodecManager::decodingFilter(), loadFile(), Kwave::FileDialog::OpenFile, and Kwave::FileDialog::selectedUrl().
Referenced by executeCommand().
QList< Kwave::App::FileAndInstance > Kwave::TopWidget::openFiles | ( | ) | const |
Returns a list of currently opened files and their instance number
Definition at line 504 of file TopWidget.cpp.
References Kwave::FileContext::instanceNr(), m_context_map, name, and Kwave::FileContext::signalName().
Referenced by Kwave::App::openFiles().
|
private |
Opens a file contained in the list of recent files.
str | the entry contained in the list |
Definition at line 1075 of file TopWidget.cpp.
References Kwave::Parser::firstParam(), and loadFile().
Referenced by executeCommand().
|
privateslot |
resets the toolbar layout to default settings
Definition at line 1453 of file TopWidget.cpp.
References TOOLBAR_EDIT, TOOLBAR_FILE, TOOLBAR_RECORD_PLAY, and TOOLBAR_ZOOM.
Referenced by executeCommand(), and init().
|
privateslot |
Updates the number of selected samples in the status bar.
offset | index of the first selected sample |
length | number of selected samples |
Definition at line 1173 of file TopWidget.cpp.
References _, currentContext(), m_lbl_status_cursor, m_menu_manager, Kwave::ms2string(), Kwave::SignalManager::rate(), Kwave::samples2string(), Kwave::MenuManager::setItemEnabled(), Kwave::FileContext::signalManager(), Kwave::SignalManager::tracks(), and updateToolbar().
Referenced by connectContext(), init(), and metaDataChanged().
|
privateslot |
Sets the descriptions of the last undo and redo action. If the name is zero or zero-length, the undo / redo is currently not available.
Definition at line 1246 of file TopWidget.cpp.
References _, m_action_redo, m_action_undo, m_menu_manager, Kwave::MenuManager::setItemEnabled(), and Kwave::MenuManager::setItemText().
Referenced by connectContext(), and init().
|
privateslot |
shows a message/progress in the splash screen
Definition at line 1547 of file TopWidget.cpp.
References Kwave::Splash::showMessage().
Referenced by init().
|
privateslot |
Show a message in the status bar
msg | the status bar message, already localized |
ms | the time in milliseconds to show the message |
Definition at line 1553 of file TopWidget.cpp.
Referenced by connectContext().
|
signal |
Emitted by us when the current file context has switched
context | the new file context |
Referenced by detachAllContexts(), init(), insertContext(), newFileContext(), newWindow(), and subWindowActivated().
|
privateslot |
called when a MDI sub window or TAB has been activated
sub | the sub window that has been activated |
Definition at line 1566 of file TopWidget.cpp.
References currentContext(), m_context_map, and sigFileContextSwitched().
Referenced by init(), and insertContext().
|
privateslot |
called when a MDI sub window or TAB is about to be deleted
obj | the sub window (not yet deleted) |
Definition at line 1573 of file TopWidget.cpp.
References m_context_map, and Kwave::FileContext::release().
Referenced by insertContext().
|
inlineprivateslot |
toolbar: "edit/copy"
Definition at line 228 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "edit/cut"
Definition at line 225 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "edit/delete"
Definition at line 237 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "edit/erase"
Definition at line 234 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "edit/paste"
Definition at line 231 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "edit/redo"
Definition at line 222 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "edit/undo"
Definition at line 219 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "file/save"
Definition at line 216 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "file/new"
Definition at line 204 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "file/open"
Definition at line 207 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "file/save"
Definition at line 210 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
toolbar: "file/save"
Definition at line 213 of file TopWidget.h.
References _.
Referenced by init().
|
inlineprivateslot |
Definition at line 201 of file TopWidget.h.
References _.
|
private |
Updates the window caption
Definition at line 1533 of file TopWidget.cpp.
References currentContext(), and Kwave::FileContext::windowCaption().
Referenced by insertContext(), metaDataChanged(), and modifiedChanged().
|
privateslot |
Updates the menu by enabling/disabling some entries
Definition at line 1316 of file TopWidget.cpp.
References _, Kwave::MenuManager::addNumberedMenuEntry(), Kwave::MenuManager::clearNumberedMenu(), clipboardChanged(), currentContext(), Kwave::App::GUI_MDI, Kwave::App::GUI_SDI, Kwave::App::GUI_TAB, Kwave::App::guiType(), Kwave::INF_FILENAME, Kwave::ClipBoard::instance(), Kwave::ClipBoard::isEmpty(), Kwave::SignalManager::isModified(), m_application, m_context_map, m_menu_manager, Kwave::SignalManager::metaData(), Kwave::Label::name(), name, Kwave::MenuManager::selectItem(), Kwave::MenuManager::setItemEnabled(), Kwave::MenuManager::setItemVisible(), Kwave::FileContext::signalManager(), Kwave::FileContext::signalName(), Kwave::SignalManager::tracks(), and Kwave::FileContext::windowCaption().
Referenced by init(), insertContext(), loadFile(), metaDataChanged(), and modifiedChanged().
|
slot |
Updates the list of recent files in the menu, maybe some other window has changed it. The list of recent files is static and global in KwaveApp.
Definition at line 1300 of file TopWidget.cpp.
References _, Kwave::MenuManager::addNumberedMenuEntry(), Kwave::MenuManager::clearNumberedMenu(), m_application, m_menu_manager, Kwave::App::recentFiles(), and Kwave::MenuManager::setItemEnabled().
Referenced by init().
|
privateslot |
updates all elements in the toolbar
Definition at line 1493 of file TopWidget.cpp.
References currentContext(), Kwave::Selection::length(), m_action_close, m_action_copy, m_action_cut, m_action_delete, m_action_erase, m_action_save, m_action_save_as, m_toolbar_zoom, Kwave::SignalManager::selection(), Kwave::FileContext::signalManager(), Kwave::SignalManager::tracks(), and Kwave::ZoomToolBar::updateToolbar().
Referenced by init(), insertContext(), loadFile(), metaDataChanged(), and selectionChanged().
|
private |
action of the "file close" toolbar button
Definition at line 371 of file TopWidget.h.
Referenced by init(), and updateToolbar().
|
private |
action of the "edit copy" toolbar button
Definition at line 383 of file TopWidget.h.
Referenced by init(), and updateToolbar().
|
private |
action of the "edit cut" toolbar button
Definition at line 380 of file TopWidget.h.
Referenced by init(), and updateToolbar().
|
private |
action of the "edit delete" toolbar button
Definition at line 389 of file TopWidget.h.
Referenced by init(), and updateToolbar().
|
private |
action of the "erase" toolbar button
Definition at line 386 of file TopWidget.h.
Referenced by init(), and updateToolbar().
|
private |
action of the "edit redo" toolbar button
Definition at line 377 of file TopWidget.h.
Referenced by init(), and setUndoRedoInfo().
|
private |
action of the "file save" toolbar button
Definition at line 365 of file TopWidget.h.
Referenced by init(), and updateToolbar().
|
private |
action of the "file save as..." toolbar button
Definition at line 368 of file TopWidget.h.
Referenced by init(), and updateToolbar().
|
private |
action of the "edit undo" toolbar button
Definition at line 374 of file TopWidget.h.
Referenced by init(), and setUndoRedoInfo().
|
private |
each TopWidget has exactly one corresponding Kwave::App instance
Definition at line 340 of file TopWidget.h.
Referenced by executeCommand(), init(), insertContext(), loadFile(), newFileContext(), newWindow(), TopWidget(), updateMenu(), updateRecentFiles(), and ~TopWidget().
|
private |
map for retrieving the file context that corresponds to a MDI sub window or TAB. In SDI mode it contains only one entry, corresponding to a null pointer as index.
Definition at line 347 of file TopWidget.h.
Referenced by closeAllSubWindows(), currentContext(), detachAllContexts(), executeCommand(), insertContext(), newFileContext(), newWindow(), openFiles(), subWindowActivated(), subWindowDeleted(), updateMenu(), and ~TopWidget().
|
private |
status bar label for cursor / playback position
Definition at line 398 of file TopWidget.h.
Referenced by selectionChanged(), and TopWidget().
|
private |
status bar label for mode information
Definition at line 395 of file TopWidget.h.
Referenced by metaDataChanged(), and TopWidget().
|
private |
status bar label for length of the signal
Definition at line 392 of file TopWidget.h.
Referenced by metaDataChanged(), and TopWidget().
|
private |
MDI area, parent of all MDI child windows (only used in MDI and TAB gui mode, null for SDI)
Definition at line 362 of file TopWidget.h.
Referenced by currentContext(), detachAllContexts(), executeCommand(), init(), insertContext(), and newWindow().
|
private |
menu manager for this window
Definition at line 356 of file TopWidget.h.
Referenced by clipboardChanged(), executeCommand(), init(), metaDataChanged(), selectionChanged(), setUndoRedoInfo(), updateMenu(), updateRecentFiles(), and ~TopWidget().
|
private |
toolbar with playback/record and seek controls
Definition at line 350 of file TopWidget.h.
Referenced by connectContext(), executeCommand(), init(), and ~TopWidget().
|
private |
toolbar with zoom controls
Definition at line 353 of file TopWidget.h.
Referenced by connectContext(), init(), newFileContext(), updateToolbar(), and ~TopWidget().