diff --git a/CHANGES b/CHANGES index 70f988a1..2dc9221f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,1268 +1,1269 @@ * enabled support for high dpi displays (icon scaling) + * show error message if no plugins were found and terminate 18.03 [2017-11-13] * do not reset undo/redo information when saving blocks or selection only * ask for confirmation (Continue/Cancel) before doing a revert * switched on MP3 support per default * bugfix: crash in pulseaudio playback * fixed some untranslated menu entries of plugins (missing context) * bugfix for sporadic fail of libaudiofile when seeking at EOF * improved C++11 compatibility 17.08.2 [2017-10-08] * new plugin: export to K3b project file * reduced flicker of position widget * bugfix: deleting labels per menu did not work * bugfix: wrong text in file progress dialog when saving * bugfix: compression type lookup did not work when using static functions * bugfix: distinguish ogg/vorbis and ogg/opus by mime type * changed license of audio samples to CC BY-SA 4.0 17.04.0 [2017-03-19] * use KDE versioning scheme * removed kwave.lsm and some now unneeded scripts (filter-pot.pl, get_lsm_entry.pl and set_version.sh) * simplified version number handling * eliminated cmake/FindOggVorbis.cmake * changed licenses of all cmake files to BSD license * bugfix: wrong assert in Stripe.cpp * OggOpus decoder: fixed unwanted data duplication (may lead to out-of-memory) * saveblocks: special handling for slashes in parts of a generated file name, e.g. title or meta data item - replace with similar unicode character * saveblocks: special handling for (multiple) whitespaces in parts of a generated file name - replace with single spaces * saveblocks: do not ask on every file in case that not all file properties are supported by the chosen encoder * saveblocks: use the block title (description of the left side label) as tile of saved block * bugfix: file was left in "modified" state after adding a label and canceling * re-activated the "label" menu * renamed command "add_label" -> "label:add" * renamed command "delete_label" -> "label:delete" * renamed command "edit_label" -> "label:edit" * implemented loading and saving of labels * allow special value -1 as index for label:delete(...) to delete _all_ labels * doc: split off developer sections from handbook into separate file, to reduce load of translators. new make target "html_doc_devel" (included in "apidoc") * label edit: avoid position from snapping too much away when adding a label in the gui while last edit was in percent mode * implemented moving of labels per mouse * show cursor line for orientation during drag&drop 16.12.0 [2016-11-28] * project moved from kdereview to kdemultimedia * added genre types 126..191 * record plugin: fixed crash when restarting record in MDI or tab mode * record plugin: reset did not work when clicking the "New" button shortly after starting the recording * record plugin: selection of default recording method did not work * revised use of signal handler in WorkerThread * WorkerThread: no longer use "bool" for signaling the wish to terminate, use QAtomicInt instead (also applies to Plugin class) * changed order of application object creation and setting up command line parser + about data * got rid of I18N_NOOP in main.cpp * bugfix: untranslated strings in menu * LICENSES file still mentioned Qt-4/KDE-4 libraries * CMakeLists.txt: remove RPATH settings * fixed small memory leak in menu group handling * fixed i18n of application AboutData * bugfix: internal name of "goto" plugin was wrong * bugfix: wrapper script did not work * fixed wrong encoding of error messages received via strerror and libs * bugfix: handling of File/Revert was wrong in case of newly created file 0.9.2 [2016-06-26] * recording via Qt Multimedia * using KDE service API for loading plugins * bugfix: screenshot function sometimes returned 1x1 image only (bug in Qt QWidget::frameGeometry is broken, but QWindow::frameGeometry works) * Gentoo ebuild updated to EAPI=6 * removed unneeded build and runtime dependencies * removed optimized memcpy for PowerPC * record plugin: improved handling of error messages * record plugin: added retry mechanism in case of device busy * added menu entries for recording and record setup * import of Core Audio Format (*.caf), using ALAC, A-LAW, U-LAW and IMA compression * import of Sample Vision Format (*.smp) * import of NIST SPHERE Audio File Format (*.nist) * import of Creative Voice files (*.voc) * import Audio Visual Research File Format (*.avr) * import of Amiga IFF/8SVX Sound File Format (*.8svx) * handbook: description of parameters of the record plugin was missing * handbook: fixed duplicate ":" in header of plugin parameter descriptions * made Kwave::SampleFormat and Kwave::Compression independent from libaudiofile 0.9.1 [2016-02-21] * ported to KDE Frameworks 5 (KF5) / Qt5 * playback via Qt Multimedia * bugfix: saved plugin parameter lists with escaped characters were not unescaped when loading again * compile fix for armv7l * codec_mp3: added missing "help" button to encoder setup dialog * fixed invocation of file dialog, as suggested by EBN * support for cmake > 3.3, fix for policy CMP0063 * cmdline option "--nofork" no longer exists * bugfix: multiple issues in context of switching the GUI type in scripts * bugfix: fixed issues in saveblocks plugin with special characters in filenames and patterns, format strings of second and later invocations of patterns were ignored * saveblocks: allow path separators in filename patterns to make it possible to create subdirectories * saveblocks: added patterns to include file info (file meta data) or the title of the current block * workaround for bug in KDE #345320 (missing translators in help/about dialog) * about plugin: added info about translation team * added screenshot of the edit_label dialog * bugfix: tooltips of the fileinfo dialog were not translated * new make target: "make msgstats" to show the progress of translations * compile fix for armv7l * playback: dropped Phonon support (was broken and no longer supported by KF5) * bugfix: hourglass cursor was not taken back in playback setup dialog * RPM: format of changelog has changed * changed plugin install directory and prefix/suffix * curve widget: use same colors as in frequency response widget, for better readability on bright color themes 0.9.0 [2015-05-25] * first version hosted on KDE (kdereview) and SourceForge * added command line parameter for selecting the GUI type * in MDI mode: new menu entry + function to arrange sub windows vertically * handbook: added text command reference * handbook: added plugin reference * enabled the "Help" buttons of all plugins and let them open the corresponding section in the handbook * make system: new target "update-handbook" (updates command, file info and plugin cross references) * make system: fixed dependency problem in translation * new commands: "window:sendkey", "window:screenshot", "window:close" and "window:resize" * built-in variable ${LANG} for kwave commands * support for delayed command execution * debug plugin: always compiled in, but only visible in debug build * new command sync(): wait for commands scheduled with delayed * bugfix: exporting a mono file as MP3 produced a stereo MP3 file * MP3: emphasis, copyrighted, original got lost during save/load * file info dialog: MPEG settings were not handled properly * bugfix: assert/numeric overflow in selectnextlabels() at end of file * new plugin: stringenter * bugfix: minimized windows were not migrated properly when switching GUI type * new command: window:minimize * bugfix: missing range check in noise generator (when used per script) * bugfix: saveblocks plugin did not work when omitting file extension * saveblocks plugin: use escaped strings for storing settings instead of base64 0.8.99-2 [2015-01-02] * bugfix: wrong sub window mode when switching to tab mode when having only one sub window (workaround for bug in Qt) * bugfix: recording did not work in MDI and Tab mode (wrong file context) * bugfix: fixed passing a text command as first command line parameter * new commands: delayed, window:click, window:sendkey, window:close, window:resize, window:screenshot 0.8.99 [2014-12-28] * GUI: implemented SDI, MDI and Tab GUI modes * bugfix: deadlock in class Track * bugfix: segfault during shutdown of logger * bugfix: segfault when unloading plugins (on some systems) * bugfix: "zoom to selection" was not disabled if nothing was selected * bugfix: toolbar buttons for cut/copy/erase/delete did not properly get enabled/disabled on change of selection * bugfix: overview widget did not properly refresh after deleting all tracks * bugfix: assert in vorbis decoder when opening file with bitrate -1 * menu subsystem: added support for lists within a menu * menu subsystem: show/hide toplevel menu entries * menu subsystem: added support for exclusive selection (radio buttons) * menu subsystem: let KDE chose shortcuts automatically * added menu entry to clear "recently opened files" list * implemented URL scheme for passing text commands from the command line example: kwave --iconic --disable-splashscreen test.wav \ kwave:plugin%3Aexecute?normalize \ kwave:save \ kwave:quit * using perl scripts creating for i18n from menus.config and for getting entries from lsm files, no longer need awk, sort, uniq * creating menu translation template directly per perl script instead of generated dummy cpp file (requires "msgcat") * menu translations: assign a context to each menu entry * bugfix: division through zero on ogg files with invalid bitrate info * manual: added section about GUI types * i18n: translations were missing in kwave.desktop 0.8.12 [2014-06-04] * recording via PulseAudio, by Joerg-Christan Boehme * bugfix: "Close" button of the record dialog did not save settings * bugfix: amplify free plugin: untranslated action names in progress bar * bugfix: sonagram plugin did not honor the windowing function parameter * bugfix: coherency problems in overview cache * bugfix: metadata got lost after cut/undo/redo * bugfix: save/as check against overwriting existing files failed * bugfix: undo/redo did not work after recording * bugfix: signal was "modified" after canceled record (empty) / done * bugfix: wrong calculation of zoom and window geometry at startup * bugfix: wrong scaling of overview in sonagram window * bugfix: playback pointer did not update synchronously across tracks * bugfix: brought back support for optimized memcpy (from xine-lib) * updated memcpy.c + cpu detection, including AVX assembler support * new command line option: "--logfile=" for logging to a file * brought back the horizontal scroll bar * support for swap files to store undo data * speedup: too many copy-on-write operations, use more const data * improved robustness against out of memory situations * memory manager: added statistics for debugging * memory settings: only use up to 25% of process address space * internal cleanups: renamed openSampleReader -> openReader, fixed signature of Signal/SignalManager::openWriter * speedup: use stripe list instead of raw data for saving undo data * debug plugin: added functions "labels_at_stripes", "sawtooth_verify" and "dump_metadata" * automatic defragmentation of stripes * sonagram plugin: use Qt Concurrent framework -> more than factor 40 faster on a quad core cpu * got rid of KDE ThreadWeaver, replaced with Qt Concurrent framework * debug plugin: added function "fm_sweep" * workaround for broken WAV files with zeroed fact chunk * fixed many 32/64 bit issues * new build target "make wrapper": creates a wrapper script to start Kwave for test/debug purpose * new build target "make dep": creates a binary debian package (for personal use and testing purposes) * mouse wheel + Ctrl: zoom in/out aligns signal to mouse position * record plugin: level meter is always enabled, simplified dialog * PulseAudio playback: fixed wrong timeout calculation * requires at least Qt-4.7 + FLAC-1.2.0 0.8.11 [2013-11-24] * added spanish translation, provided by Carlos R. * bugfix: file names were not properly escaped in context of file/open, file/openrecent and drag&drop * bugfix: saveblocks() did not abort properly when pressing cancel * unclean shutdown of the file progress dialog when saving * noise plugin: add noise (mix) instead of overwrite, with adjustable level in percent or dB * pause button: change tooltip to "continue" if paused * new command line option: "--disable-splashscreen" * new command line option: "--iconic" to start minimized * fixed quoting errors in CMakeLists.txt (cmake-2.8.12 complained) * bugfix: ASCII encoder: escape special characters in meta data * implementation of ASCII import * memory settings: raised default memory limits * bugfix: crash in file info dialog / auto generate keywords * MP3 plugin: use ID3 tag TSSE for software version * ASCII codec: implemented support for labels 0.8.10 [2013-02-09] * file name cleanup: removed "Kwave" prefix * bugfix: added range checks for track selection commands * reverted changes in sample writer due to problems in debug mode (commits ee54660d4380d264b7346a904eff9dd8d8d00a93 and 6fba04db879ea7ae1fdf79141dd93d47f9c1d403) * bugfix: unwanted termination if splash screen closed while the first toplevel widget still was starting up * moved code into namespace "Kwave" * cleanup: remove support for outdated FLAC API versions below 1.1.3 * removed unused code: libkwave/FileFormat.* * renamed source files with "Kwave" in the name * added subsystem prefix to inclusion of Qt header files * using bit types from qt (e.g. u_int32_t => quint32) * compile with DQT_NO_CAST_TO_ASCII and QT_NO_CAST_FROM_ASCII * bugfix: recording via OSS did not handle invalid devices properly * improved auto detect of svg-to-png conversion, added support for "rsvg-convert" (SF bug #38) * removed dependency to ImageMagick if "rsvg" is available * replaced libkwave/byteswap.h with generic Qt functions * replaced some Qt classes with their KDE equivalent: KLineEdit, KComboBox, KDialogButtonBox, KPushButton, KTabWidget, KTextEdit * using KDE standard buttons in dialogs * simplified plugin loading mechanism, do load/unload only at start/end of the program * delete plugin settings of old versions when detected * using QLibrary instead of functions from libdl * bugfix: shutdown sequence was incomplete * bugfix: keyboard shortcut for first menu entry did not work * bugfix: ambiguous keyboard shortcut for "File/New Window" * bugfix: undo of "modify label" caused loss of other labels * bugfix: use timeout for phonon playback, to avoid hang on unusable devices * using klocale for formating numbers of samples * added common base class for all codec plugins * reduced quality level of sample rate converter from "best" to "medium", to improve speed * refactored playback handling (controller vs. plugin) * workaround for bug in Phonon: no device names available in first call to Phonon::BackendCapabilities::availableAudioOutputDevices() * moved playback test into worker thread, for better GUI responsiveness * Phonon playback: changed to own mainloop with timeout support to avoid application hang on broken audio devices * bugfix: data loss in sample rate converter when processing streams * vorbis encoder: call to deprecated API (now use OV_ECTL_RATEMANAGE2_SET) * using estimated length for streaming file formats without length info * made sample rate conversion (libsamplerate) mandantory * increased default memory sizes * added toolbar buttons for "File/SaveAs" and "File/Close" * reordered toolbars 0.8.9 [2012-11-06] * new feature: MP3 export via external program "lame", "toolame" and "twolame", with configurable command line options * new feature: allow change of compression type via file info * fix for SF #3528848, removed -Wl,--add-needed from plugin LINK_FLAGS * speedup: improved performance of sample writer * wav import/export: support for some more meta data tags * bugfix: meta data lost when writing wav files that had meta data for product/album or subject/track at the same time * bugfix: broken signal/slot connection in SaveBlocks plugin * workaround for bug in id3lib, SF #3534143: ignore id3lib crc check result for MPEG Layer II files * bugfix: Gentoo ebuild lacked required svg use flag for media-gfx/imagemagick and media-gfx/graphicsmagick * bugfix: File/SaveAs now uses last recently used directory and extension together with the user defined file name * bugfix: PluginManager::sync caused application slowdown or stale GUI 0.8.8 [2012-05-20] * new feature: seek functionality for playback * new feature: added toolbar with record/playback/scroll functions * migration to GIT as source code management * documentation update * allowing zoom and scroll while a plugin is running * allow "close" and "quit" while playback is running * allow track selection change during playback * fix for namespace collision with libaudiofile * bugfix: mouse selection update with negative offset failed * bugfix: wrong focus of progress dialog when repairing damaged wav files * bugfix: missing updates of zoom selection combo box * bugfix: when viewing with full zoom, scroll by 1 sample was possible * bugfix: focus was wrong on program start (zoom combo box) * bugfix: wrong view when moving slider of overview widget to negative value * bugfix: playback pointer did not disappear after play - pause - stop * bugfix: creating a label without text was not possible * bugfix: saving WAV with G.711 and non-16bits/sample produced broken output * bugfix: handling of shortened tracks in encoders 0.8.7 [2011-11-27] * ebuild update for media-gfx/imagemagick <-> media-gfx/graphicsmagick (see gentoo bug #314325) * new feature: "insert at", paste clipboard at given position * fix for API change in libaudiofile v0.3.1 * speedup: loading ogg/mp3 is much faster now (up to factor 2) * bugfix: stream name of pulse audio playback used wrong encoding * update of the Kwave spec file (synced with OpenSuSE build service version) * new build target "distfiles" * updated version of the GPL v2 document (GNU-LICENSE) * support for visualization plugins 0.8.6 [2011-03-07] * bugfix: copy/paste with partial track selection failed * bugfix: labels update after undo of copy&paste failed on multitrack signals * string/i18n update from Panagiotis Papadopoulos * bugfix: invocation of xgettext was wrong, left untranslated strings * plugin API change: support for translateable short description * about plugin: use plugin info from PluginManager * bugfix: last directory of file dialogs sometimes got lost * bugfix: wrong message when canceling Ogg import * replaced sched_yield() with QThread::yieldCurrentThread() * added cmake parameter for disabling optimized memcpy support -D WITH_OPTIMIZED_MEMCPY=OFF, default is ON * integrated patch #3021795 for Qt-4.7 compatibility * bugfix: optimized memcpy for PPC (SF bug #3068664) * doc: upgrade to DocBook XML V4.2 / V1.1 * build fixes for qt-4.7 * no longer using QSplashScreen (has side effects, operates as modal window) * bugfix: startup as unique application did not work correctly * bugfix: potential crash in message loop of progress dialog * bugfix: handling of track selection was wrong in reverse plugin * workaround for bug in libaudiofile: some files have sampe rate zero, falling back to 8000 samples/sec in that case (audio/x-ircam, sun, BE) * bugfix: reverse failed on files smaller than the internal block size * using entities for URLs in handbook, to simplify maintenance * bugfix in cmake files: some invocations of STREQUAL lacked quotes 0.8.5 [2009-12-24] * new feature: playback via PulseAudio * applied kwave-0.8.2-nolinguas.patch (see gentoo bug #267702) * support for the Gentoo build system that steals .po files * no longer default to english language for documentation and gui l10n * fixed use count mismatch of plugins * bugfix: playback control: continuing after pause continued from start * bugfix: G.711 encoded wav files support only 16 bit signed format * new assignment for mouse wheel: - without modifier key: scroll left/right - with Shift: page left/right - with Ctrl: zoom in/out - with Alt: vertical zoom in/out * bugfix: support sysinfo.mem_unit when >= 4GB RAM are installed * bugfix: crash in progress dialog handling (crashed when closing a plugin after finishing it's work) * new ebuild for Gentoo 0.8.4 [2009-09-26] * new feature: support for primitive macros (batch files), playback only * new plugin: change sample rate * using libsamplerate (new dependency) * new feature: sample rate conversion on clipboard data * new feature: ability to set recording start time in advance (feature requested by John David Thompson) * bugfix: drag&drop of files on the main window was broken * workaround for bug in id3lib which crashed in ID3_Tag::GetSize() with some MP3 files (see id3lib upstream bug at SF #2821464) * bugfix: recording via ALSA, crash on snd_pcm_close(), see SF bug #2816544 * bugfix: playback plugin: infinite loop when switching from OSS to ALSA * bugfix: forcing clipboard and drag&drop data to uncompressed mode * bugfix: deadlock in progress bar handling * bugfix: crash when unloading plugins with queued events * help/about dialog: hide "translators" tab if no translator available * help/about dialog: hack to allow web addresses of translators * bugfix: selection was not set after "paste" and undo of other operations * bugfix: label handling in context of "delete" and "undo" was broken * bugfix: invalidation of overview cache after delete was not correct * bugfix: artifacts in track display in min/max overview mode * bugfix: add/delete/modify of labels did not set the state of the current file to "modified" * bugfix: record dialog caused shutdown to hang when closed while recording * bugfix: decoding 32bit/sample was broken * bugfix: recording level meter consumed 100% cpu * new make target: "make apidoc" for internal doxygen documentation * bugfix: some images and icons in non-english documentation were missing * volume plugin: preview was not updated on first use of plugin 0.8.3-2 [2009-07-04] * bugfix: re-enabled detection of optimized memcpy function * bugfix: deadlock in recording plugin and plugin management (see SF bug #2816544) * bugfix: ID3 tag import did not work * taking ID3 tag for "album" as "product" in wav meta data * taking ID3 tag for "track" as "subject" in wav meta data 0.8.3 [2009-06-28] * integrated 05-do-not-install-so-symlinks.diff from Debian (thanks to Aurelien) * cs i18n update from Pavel Fric * new plugin: normalize * progress bar in volume plugin did not work * flattened "Fx" menu, no submenus for amplify and filter * bugfix: workaround for libaudiofile bug produced wrong header in 24bit/sample mode * bugfix: "fade outro" was broken * bugfix: the dialog when playing the test sound in the playback setup dialog did not appear * replaced qreal with double (fixes build problems on arm) * show hourglass / progress bar when undo/redo is running * flattened "Calculate" menu, no submenus for "Frequencies" * wav encoder: auto-switch to unsigned format for <= 8bit and signed format for > 8 bit per sample * volume plugin: show a little "preview" for guessing the level * bugfix: after deleting a track, file info was not updated * about plugin: separate tab for translators * made plugin API version configurable per plugin * recognize mime type "audio/x-vorbis+ogg" (found in KDE-4) * updated czech gui translation and user manual from Pavel Fric * bugfix: crashes when deleting objects that still have event queued with Qt::QueuedConnection -> now using Qt::BlockingQueuedConnection * new plugin: reverse * speedup: limiting the number of progress bar updates per second * memory manager: fixed multithreading issues, improved OOM behavior * bugfix: received SIGBUS in SwapFile when disk was full * improved performance of memory management * require Qt4 v4.5.0 or newer 0.8.2 [2009-04-25] * bugfix: minor off-by-one bug in buffer handling * wav/RIFF parser: be more robust if the file has not been correctly padded * bugfix in wav encoder: padding for info and label chunk was missing * bugfix: if two markers were too close and displayed at the same pixel position they eliminated each other through XOR mode * bugfix: numeric overflow when trying to select labels in high zoom factors * bugfix: not all positions were selectable due to internal rounding errors * silence plugin now supports all modes * use "unsigned" sample format per default when creating new files with <= 8 bits/sample * bugfix: playback position was shown on startup * bugfix: show correct file size in progress dialog * bugfix: crash when deleting label from end of signal * bugfix: overview was wrong when deleted space after signal was visible * bugfix: overview was not always synchronized after delete/insert * bugfix: "modified" state got lost during undo * use ALSA per default for playback/record if nothing has been selected yet * fixed calculation of undo/redo sizes * undo/redo handling for sample range and track selection * processing updates of overview widget in a background thread * memory management: no longer evaluate RLIMIT_RSS, gives more available physical memory * portability fix: swapfile creation/destruction went wrong * feature: memory for undo/redo can now be configured * bugfix: handling of "continue without undo" produced wrong undo/redo states and asked several times * bugfix: file progress did not do GUI updates, cancel button did not work * bugfix: assert in record plugin if no valid sample rate available * speedup for generation of signal overviews in min/max mode * bugfix: MultiTrackWriter produced one extra sample (off by one error) * workaround for bug in libaudiofile: sometimes libaudiofile produces broken files as it uses 'float' for internal calculations (wrong size of 'data' and 'RIFF' chunk) => see ubuntu bug #327018 * implemented "debug" plugin, with internal functions for test and verification (quality improvement) * added czech gui translation from Pavel Fric * bugfix: after creating a new empty file, "revert" was possible * speed optimizations in buffer handling * speedup: limiting the rate of progress updates when loading and saving files * fixed displayed names of actions based on the "amplifyfree" plugin * bugfix: menu entry translation did not work correctly * bugfix: deleteLater on menu nodes did not work, implemented own garbage collector * speedup: use different block sizes for interactive and non-interactive mode * i18n fix: texts in help/about menu were untranslated * about plugin: new tab for translators 0.8.1 [2008-12-23] * replaced application icon, now using a scalable svg image * replaced GSL with FFTW3, which is license compatible with Kwave * use implicit sharing for Label class * new clipboard implementation, using the clipboard of KDE (X11) * fixed enable/disable of copy/paste functions depending on clipboard state * re-enabled function "flush clipboard" * re-enabled function "invert track selection" * re-enabled function "select all tracks" * implemented plugin for "go to position..." * added status bar item for current cursor position * show current playback position in status bar * show selection in overview widget * bugfix: mode switch in time selection widget did not work properly * bugfix: handle situation when adding or moving a label to a location that is already occupied by another label * show labels in overview widget * show current playback position in overview widget * overview widget: dimming parts that are out of view * no longer needing built in copy of libaudiofile, removed 0.8.0 [2008-09-27] * ported to KDE4 / Qt4 * dropped support for FLAC API v1.1.1 and older * support for ALSA lib API v1.0.16 * made MP3 decoder disabled per default due to legal issues * fixed bug in cue list parsing of .wav files * fixed bugs in recording plugin, recorded too much if recording time limit was activated or in prerecording mode * a much nicer splash screen * bugfix in label handling: support labels with zero-length names * re-arranged source files for cleaner library interfaces * re-enabled accelerator keys for 0..9 * using horizontal scrollbar instead of overview widget * implemented vertical zoom (Ctrl + MouseWheelUp/Down) * using more standard KDE keyboard shortcuts * nicer icons for the menus * using more icons from the crystal icon collection (to clearify the license situation) * removed aRts support * now also available through the openSUSE build service for various platforms * respect the LINGUAS environment variable to build only needed languages (defaulting to all) * removed changelog from online manual to simplify the work of translators * no longer dependent from "recode" * recording plugin: show current recording time in status bar * fixed infinite loop on undo/redo of channel selection * usage of GSL can be disabled through cmake parameter -DWITH_GSL=OFF * support for OSS v4 (integrated sf feature request #1870434) 0.7.11 [2007-12-09] * new internal streaming architecture, based on Qt instead of aRts * aRts support is now disabled per default * some minor bugfixes for x86_64 support * band pass plugin 0.7.10 [2007-08-08] * build system: using 'METASOURCES=AUTO' (which simplifies a lot) * ported the build system to cmake * support for newer APIs of FLAC v1.1.3 and v1.1.4 (closes SF bugs #1713655 and #1757716 + debian bugs #427747, #426668 and #431199) * replaced problematic code in libaudiofile with new code under the LGPL, contributed by Bertrand Songis (partially fixes debian bug #419124) * update of the online documentation to reflect the change of the make system 0.7.9 [2007-05-01] * playback via ALSA: offer the "default" device, if no devices found offer the "null" device * implemented import and export of labels, currently only for uncompressed wav files * new plugin for saving blocks between labels as separate files * new function: expand selection to labels * new function: select next/previous range between labels * bugfix: don't change the file name when saving only the selection * new configure option: --enable-doc=yes/no to enable/disable the generation of the online documentation (default=yes) 0.7.8 [2006-12-31] * bugfix: workaround for bug in ALSA, crashed when initializing the dsnoop plugin * bugfix: error in swap file handling, one sample was destroyed when resizing. Affects cut, delete, crop and many other functions. * fixed the incorrect usage of the word "loose" (thanks to J.T. Hundley) * bugfix: went back to old implementation of ThreadsafeX11Guard class in order to fix a deadlock (closes sourceforge bug #1623357) * documentation update: mention Subversion instead of CVS * zero plugin: new mode, support for inserting a range filled with silence * fixed the macro functions "Fade Leadin" and "Fade Leadout", using the new mode of the 'zero' plugin * export of ASCII format files 0.7.7 [2006-09-17] * new feature: implemented a small widget that shows the current selection position and the selection borders * new feature: context menu for the signal widget (right mouse button) * improved file open dialog: show "All Files" and "All Supported Files" * bugfix: error in handling of mouse selection * bugfix: recording only used the first channel (closes sourceforge bug #1551050) * install plugins kde_moduledir/plugins/kwave instead of kde_datadir/kwave/plugins 0.7.6 [2006-06-05] * bugfix: recording setup crashed when called for the first time * bugfix: do no longer crash when recording device is not present or opening failed * bugfix: fixed generation of rpm dependency for libmad * bugfix: update the size of the level meter if the dialog size has changed * record plugin: added a fancy status bar * record plugin: added autodetect/scanning for OSS devices * record plugin: added dsnoop plugin as ALSA source * record plugin: fewer annoying message boxes, instead show a short notice in the status bar for some seconds * record plugin: add logarithmic scale to the level meter and use 3 colors * playback plugin: added autodetect/scanning for OSS devices * playback plugin / ALSA: support for 18 and 20 bits/sample * playback plugin / ALSA: support for big endian 0.7.5 [2005-12-31] * draw signal in a different color set when not selected * bugfix: solved deadlock situation when starting a plugin while another plugin was still running * workaround for deadlock when trying to close the current file while a plugin is still running * bugfix: delete range only in selected tracks * thrown over board the idea of using gstreamer due to serious license issues, we will wait until KDEMM is out (KDE-4) instead. 0.7.4 [2005-10-16] * recording via ALSA * support for the silently changed API of libFLAC++ v1.1.2 (closes sourceforge bug #1243707 + debian bug #289953) * fixed support of MMX / SSE detection on X64_64 architecture (closes sourceforge bug #1244320 and debian bugs #288781 + #327501) * decided to support gstreamer as streaming engine in future versions (will make v0.8 if Kwave is aRts-free) * fixed some German translations (closes debian bug #313790 and bug #314000) 0.7.3 [2005-05-26] * playback via ALSA * completely new playback settings dialog, with support for aRts, ALSA and OSS * playback plugin: play a test sound * record plugin: detect when device is alread open, now no longer blocks. Show an error message. * smoother signal display in overview mode (no gaps) and improved polyline mode * replaced some of Kwave's multithreading classes with classes from Qt * compiles under SuSE-9.3 * ebuild file for Gentoo Linux 0.7.2 [2004-12-31] * big rework of the internal streaming/storage subsystem, support for multiple stripes. Makes a big speedup when handling large files! Creating an empty 512MB file before: over 350 sec, now: about 25 sec (on my system) * optimized versions of memcpy() for ix86 (using MMX, MMXEXT, 3DNOW, SSE, SSE2) and for PowerPC, copied from the xine project * some support for X86_64 * bugfix: in memory setup plugin, set virtual memory limit only if the limit has been enabled (checkbox is clicked) * bugfix: clipping in Ogg import filter was incorrect * speedups: import of Ogg and MP3 files improved * removed code copied from the GSL library, link against the shared library instead * added target "package-messages" to the toplevel Makefile, for translators 0.7.1 [2004-07-10] * FLAC (Free Lossness Audio Codec) import/export plugin * speedups for loading / saving files * removed our own copy of libmad from the source tree, now it should be available in all common distributions * implemented pre-recording * implemented recording time limit * bugfix: minor bug in the recording state machine * bugfix: solved some layout issues in the about- and sonagram plugins * bugfix: cancel while saving to .ogg works now * update of the online documentation, many screenshots * improved Makefile dependencies of the plugins, now parallel builds also work and speed up the creation of plugins 0.7.0 [2003-12-01] * first version with recording functionality (still alpha) * removed workaround for uic invocation * bugfix: handling of persistent and unique plugins was wrong, which caused playback to work only in the first main window instance * added project files for kdevelop-3 0.6.7 [2003-06-28] * new plugin: "pitch_shift" * new plugin: "lowpass" * new plugin: "notch_filter", contrinuted by Dave Flogeras * included a bugfixed version of the synth_pitch_shift aRts plugin * new feature: "pre-listen", first implementation in pitch_shift plugin * ported to work with Qt-3.1 without Qt-2 compatibility, also compiles with -DQT_NO_COMPAT -DQT_CLEAN_NAMESPACE 0.6.6 [2003-03-29] * works with KDE-3.1 * many improvements on the build system. Now compiles under Debian, Mandrake, RedHat, Gentoo and SuSE * starting up with last window size * Xt toolkit option for geometry works again, including workaround for bug in KDE3's geometry management. example: "kwave -geometry 800x600" * bugfix: select to left selected one sample less then needed * volume plugin: simple clipping * volume plugin: mode for "multiply with /divide through factor" * newsignal and selectrange plugin: got rid of KDoubleNumInput and it's weird display and entry behavior * selectrange plugin: also select start position of selection * can use libmad and libaudiofile from the host system if usable * show the fileinfo plugin when saving under a different mime type 0.6.5 [2002-11-09] * MP3 import with ID3 tag support through id3lib and libmad * Ogg/Vorbis import and export (only ABR mode) * new plugin "volume" * show selected range as time (feature requested by Christian Hollaender) * support for saving compressed .wav files * thrown away Qt2/KDE2 compatibility, now only supports Qt3/KDE3 * playback plugin: enabled the "select..." button for choosing other playback devices (feature requested by Len Ovens) * solved problem with name mangling in plugins and different gcc versions * works with gcc-3.2 / solved __dso_handle problem * stricter checks for programs in configure script 0.6.4 [2002-06-30] * support for different file formats / integrated libaudiofile * drag and drop bugfix: dropping into the same signal left from the selection removed wrong range * auto-repair for structurally damaged wav files * bugfix: save selection works again * integrated libkwavemt into libkwave * using time instead of zoom factor, e.g. set zoom to "1 minute" (feature requested by Gilles Caulier) * menu entries for playback control * some more icons in the menus * replaced KFileDialog with subclass KwaveFileDialog (works around some bugs in KDE) * added a little chapter about digital audio basics to online help * added "select range" plugin 0.6.3 [2002-03-01] * simple drag and drop * french translation * handling of "signal modified" * shows error message and aborts if loading failed 0.6.2 [2001-12-24] * new plugin "amplifyfree" * new plugin "noise" * >>> new aRts plugin adapter framework <<< now Kwave is able to use existing aRts plugins in it's own plugins for sound processing * changed documentation to XML / Docbook-4.1 * recovery of damaged files if non-zero file length but data length entry in the wav header is zero (e.g. happens when krecord crashes during recording) * bugfix: freeing virtual memory fixed in MemoryManager * bugfix: problem with TSS in TSS_Object cleanup 0.6.1-1 [2001-09-01] * bugfix: class Track made duplicate entry in stripe list when inserting signals into an empty track * fixed that weird layout behavior in dialogs, seems that Qt has problems with complex nested layouts :( 0.6.1 [2001-08-24] * >>> USE OF VIRTUAL MEMORY <<< * changed Makefiles: html docu stays in distribution due to too much trouble with the KDE documentation tools * when inserting from clipboard into a signal with a different number of tracks, the result will be mixed (still not optimized/slow) * fixed compile problem with gcc-2.96 / gcc-3.0 * fixed missing header file in NewSigDlg.ui * the RPM should be relocatable again * fixed bug in shutdown sequence, now clipboard is flushed before the application closes. 0.6.0 [2001-07-29] * >>> PORTED TO QT-2 AND KDE2 <<< * completely new internal architecture * plugins can be located in a user directory * libkwave is included and no longer supported (at least by me) as a separate package * playback via aRts * many more bugfixes, too many to mention here... 0.5.5-1 [2001-02-23] * bugfix: selection across end of file no longer possible * bugfix: no overflow in wav header when saving large wav files above 268MB (bug reported by Sven-Steffen Arndt, ssa29@gmx.de ) 0.5.5 [2000-12-01] * new playback handling, allows pause/continue * limited the playback buffer to be between 256 and 65536 bytes due to problems (system hang) with small playback buffers with 16..64 bytes (might be a hardware problem) * introduced a toolbar for some standard operations * fixed some bugs concerning selection with the mouse * rework of the overview widget (used in main window and sonagram) * fixed menu command "zoom selection" * sonagram: saving to file, auto-brightness adjust * replaced QFileDialog with KFileDialog * tested with AMD Athlon-optimized compiler (patched pegcs) * some fixes for safer multithreading * checking for much more header files at configure time (due to a problem reported by issiac@evcom.net ) 0.5.4-4 [2000-10-03] * added classes Mutex and MutexGuard * sonagram: set a transparent background for the image * added sizeHint() and minimumSize() to ScaleWidget and OverViewWidget * sonagram: removed (need for) SonagramContainer, using QGridLayout instead * moved SignalProxy to the mt subdirectory * fixed X11 synchronization problem with SignalProxy * added TSS (thread-specific-storage) support to the mt classes * added some multithreading support classes: Thread, AsynchObject, ... * removed the "get" prefix from all member functions. This is the new KDE/QT coding style. * updated the online documentation to point to the new Kwave homepage on http://kwave.sourceforge.net/ * class ImageView: always repaints (maybe image data has changed) * bugfix: selection and playpointer will not be drawn if no signal is loaded 0.5.4-3 [2000-09-09] * the sonagram window updates it's title if the signal's name changed * found a solution for the problem of synchronizing X11 and QT in a multithreaded environment * fixed bug in the "Halt" function (playback) 0.5.4-2 [2000-08-20] * geometry/layout management for the MainWidget * limited the displayed height of a signal. If not all signals fit onto the screen, a scrollbar appears on the right side of the signal. * limited the size of the TopWidget to a reasonable minimum size * automatic dependencies for the plugins work again 0.5.4-1 [2000-07-29] * fixed layout of playback dialog * started to implement a new plugin interface * geometry/layout management for the sonagram settings dialog * formatting of selection and file time (KwavePlugin::ms2string) * plugins can now consist of multiple source files 0.5.4 [2000-07-12] * some more minor changes to the Makefiles * split the documentation output into "de" and "en" part * made symbolic links to the english help directory from the "de" and "default" directory during make install and uninstall and also in the post and postun scripts of the specfile The user should at least get the english help... * alpha version of english documentation done * automatic update of the revision history in the docbook file if this file is modified (only english version) * CVS is up on sourceforge.net * changed some header lines in this file * started on writing a new documentation / online help using docbook 0.5.3 [2000-06-12] * if a file with invalid size (e.g. recorded by "arecord") is loaded, shows a message and truncates the input at the end of the file * found out that we need ALSA support for 24 and 32 bits/sample * >>> playback in stereo <<< * selected channels (x) are mixed to the output device's channels (y) at playback using a x:y translation matrix with linear scaling, all values for x and y except zero are allowed * playback only for selected channels * rework of the settings/playback dialog (plugin) * heavy reword on the playback code * fixed severe bug in SignalManager::readWavChunk(), chrashed if there was data after the wav chunk 0.5.2-12 [2000-06-02] * copied the AsyncSync class into libgui, should be used for threadsafe usage of the qt library * moved handling of the "selected" flag from class SignalManager to class Signal * fixed selection of channels if appended or deleted 0.5.2-11 [2000-05-28] * included config.h in each source file (except the plugins) * export to ASCII for multi-channel signal (multi-channel import has still to be done, currently only mono) * fixed many memory leaks and inconsistent delete operations (e.g. used "delete" instead of "delete[]") * included support for (and tested with) the error detection and memory debugging tool "Insure++ Lite 4.1" (./configure --enable-insure=yes ...) -> thanks to ParaSoft Corporation for making this limited version of the tool available (http://www.parasoft.com) * SignalWidget uses three layers for drawing, speeds up the redraws after mouse selection by about factor 14(!!!) on my system :-)) 0.5.2-10 [2000-05-21] * some minor bugfixes in the Makefiles * save the kwave.spec and include it into the source archive, this lets "rpm -ta kwave-x.x.x-x.tar.gz" work * wrote a new README file, moved Martin's version to README.OLD * RPM_OPT_FLAGS are appended to the compiler options, this lets pentium optimizations work :-) * shows a message box if loading of a file failed 0.5.2-9 [2000-05-19] * list of recent files is synchronized across all toplevel windows * fixed dozens of memory leaks, missing ASSERT constructions, missing variable initializations and possible divisions through zero * Help menu aligned to the right side (MenuRoot now is able to process the special command "#separator") 0.5.2-8 [2000-05-18] * replaced all occurances of sprintf with snprintf, strcpy with strncpy (in 92 places) ! * doesn't show any zoom factor if no signal is loaded * handling of channel add/delete: selection/speakers are shifted * changed some variables/parameters to "unsigned" (simplifies range checks) * beautified this file * beautified the whole source code according to my favorite coding style. -> thanks to the developers of the "Artistic Style" package, astyle-1.11.4-1 made good work :-) * fixed that annoying flicker in the help/about dialog * checking for sizes of char, short and int at configure time * globals.app will not be used (obsolete, should be removed from libkwave) * MessagePort will not be used (obsolete, should be removed from libkwave) * multiple toplevel windows are possible * made X toolkit parameters work (especially "-geometry") * bugfix concerning loading/saving 8 bit .wav-files (always unsigned !) * >>> COMPLETE REWORK OF THE INTERNAL COMMAND STRUCTURE <<< - made use of a combination of signals/slots and string messages - hierarchical processing: commands are are forwarded "upwards" until they reach a TopWidget - the TopWidget (highest level) dispatches the commands and forwards them to the lower levels 0.5.2 [2000-04-24] * rpm package should now be installable without conflicts and compile without any previous installation of kwave * removed the "${KDEDIR}/share/doc/HTML/default" directory from the rpm so that it doesn't conflict with the already existing one * shift+Home/shift+End selects from the current left/right position up to the start/end of the signal * bugfix in display of signal: signal is no longer inverted * selectrange() works now * the zoom factor combo box reflects the current "real" zoom factor * some bugfixes in menu handling / cleanups * complete rework of zoom and offset handling: - simple poly-lines instead of lowpass interpolation if zoom factor has less than 10 pixels per sample - lowpass interpolation if more than 10 pixels per sample * bugfix in KWaveApp: now sets globals.app to this if it was null before, now doesn't crash if it loads a file specified at cmdline 0.5.1-4 [2000-04-16] * >>> now compiles and runs under RedHat 6.1 / Halloween IV <<< >>> as well as under SuSE 6.2 <<< * version info of libkwavegui.so is set to the package's version * bugfix in plugins/template/Makefile.am: will not create .moc files on make distclean and other targets * compiler flags are passed through to plugin compilation * compiling with --no-rtti. This was necessary to compile against the kde libraries of RedHat that seem to contain no rtti. As a side effect all warnings on linking programs/libs disappeared :-) * configure-parameter --enable-debug has effect again * >>> ASCII import and export works now (mono only) <<< * bugfixes in some plugins, all compile now without warnings/errors * plugins are processed in alphabetical order * all plugins are automatically found and compiled * new target "make src.rpm" makes only the source rpm 0.5.1-3 [2000-04-03] * display will be scrolled left or zoomed if something from the end of the signal is deleted * curve parameters of fade in / fade out work again 0.5.1-2 [2000-03-16] * converted many "klocale->translate(...)"s into "i18n(...)" * target "make messages" works again * converter for menus.config, creates a dummy .cpp-file that is handled by i18n 0.5.1-1 [2000-03-13] * new target "make rpm" creates binary and source RPM packages * fixed the shared-library-problem in the build system 0.5.1 [2000-02-28] * menu items can belong to groups * renamed SignalWidget::info to "refresh" * many cleanups in the header-Files in src and libgui * the menu management has completely been rewritten: - Menu, NumberedMenu and MenuCommand classes are deleted - new classes: MenuNode, MenuItem, MenuSub, MenuToplevel and MenuRoot * menu items can have icons * menu nodes can have unique string ids * special menu commands start with a "#" * first attempts for internationalization * list of recent files is sorted by time of last usage 0.5.0-1 [1999-12-27] * moved my modifications from the Makefiles to Makefile.am * included targets "make release", "make patchlevel" and some scripts 1999-12-19 (by Thomas.Eschenbacher@gmx.de) * remade my modifications of some Makefiles and of the configure script that were lost during Martin's changes * changed shortcut for mixpaste from CTRL-SHIFT-X to CTRL-SHIFT-C * added the "crop" command to the edit menu * made the "mixpaste" command work * corrected the call of "delete", now really deletes instead of cutting and copying the selection to the clipboard (saves clipboard content) 1999-12-18 (by Martin Wilz ) * changed filenames to reflect class names * one class per file is now the standard * stripped leading "Kwave" in class names for most classes 1999-12-10 (by Thomas.Eschenbacher@gmx.de) * removed -Werror compiler option (caused trouble with configure script) * fixed a nasty bug in SignalManager::save that caused crashes on several positions in the program and libstdc++ 1999-12-09 (by Thomas.Eschenbacher@gmx.de) * gave the destructor of SignalManager some code, this fixes a huge memory leak ! * added a TODO file * added -Werror to the c++ compiler options when debugging enabled * some include file cleanups in libgui 1999-12-07 (by Thomas.Eschenbacher@gmx.de) * SignalManager::writeWavChunk uses buffers for writing (much faster!) * bugfix: caption of main window changes after "SaveAs" * bugfix: selected resolution takes effect * bugfix: caption of main window changes after "SaveAs" * bugfix: SignalManager::writeWavChunk now doesn't destroy the signal's data while saving * make distclean in the projekt root directory also removes zero-length files, *.orig, *.rej and *~ (just makes cleaner than before) * symbolic links to Makefile, Makefile.in and Makefile.am in the plugins directory are deleted with "make distclean" and rebuilt on "make" (changes in the referenced Makefiles in the template directory will not be reflected thousand times when creating a patch with diff) * cleanups, removed some old backup files * improved support for debugging accessible through * "configure --enable-debug=yes" (-g and -DDEBUG compiler flags) * rewritten big parts of Makefile.in for the plugins * added -O2 compiler optimization 1999-12-03 (by Thomas.Eschenbacher@gmx.de) * merged with Martin Wilz's version 1999-11-12 (by Martin Wilz ) * version numbering script donated by Thomas Eschenbacher * now using KTMainwindow for top level widgets * using timer to check message port -> alternative (threadsafe) message passing instead of signal/slot * labeling code rewritten, now incompatible with old releases * batch loading routines 1999-09-07 (by Martin Wilz ) * deleting channels works again * fixed savelabel dialog * corrected envelope dialog, string handling * connected many functions via the new string-based way of invocation * fixed some dependencies between old code and new classes (there's still more to do !) * saving should now work again * trimmed down Clipboard class * Color class as wrapper to QColor (may become independent later) * reworking Curve Class for creation via string, interpolation now uses curve objects * moved gui functions into a new library (libkwavegui) * new Classes: Parser DynamicLoader Filter (previously was a struct) * moved gui-independent functions into a library (libkwave) * rework of dialogs into single files and single plugins * new calling scheme via string commands. This will allow scripting and macro definitions. Threading is made a whole lot easier, because a only a string has to be passed and gets expanded into the needed set of parameters in each thread * io functions and playback adapted to SignalManager * Introduction of SignalManager class for multiple channel management 0.29.5 [1998-12-25] (by Martin Wilz ) * Just a fix for an annoying bug while zooming out 0.29.4 [1998-12-22] (by Martin Wilz ) * removed a memory leak in playback * triple-checked the missing Accelerators in the Menumanager. It seems to be a bug in qpopmenu, I'll wait for qt to be fixed, or until a workaround is known * recent Files are updated again, while the program is running * kwave now keeps track of last directory saved to; for user convenience * reestablished selection mechanism to match versions before 0.29.3 and corrected some otherwise screwed-up behavior * _now_ all parameters to destructors should have vanished 0.29.3 [1998-12-18] (by Martin Wilz ) * developement has slowed down a bit, this release is not as complete as I wished but since 0.29.2 has a destructor with parameters accidentally left in, and so does not compile on all systems -> here we go again... * reworked selection routines into a new class, code is still rather confusing, but seems to work * added checkmark functionality again * converted file-menus to new menu-scheme * added gui to mix channels together, the needed functions for mixing are still missing * Halt button by Gerhard Zintel 0.29.2 [1998-12-15] (by Martin Wilz ) * moved clipboard functionality to its own class * dynamic allocation of menu entries used by all classes but TopWidget * import of ascii data files 0.29.1 [1998-12-13] (by Martin Wilz ) * Bugfix for multichannel save. Now the saved files should work with other prgs * local snap to peak by Gerhard Zintel 0.29.0 [1998-11-12] (by Martin Wilz ) * changed version numbering and filename as suggested by Version 1.1 of "How To Name Things" from sunsite. The last digit will always mark be 0 for releases uploaded to ftp.kde.org. * added windowing (Hamming Hanning, Blackmann) functions * contribution from Gerhard Zintel displaying notes in fftview * Added pitch display window * implemented cursor and db scale for fft-view * added reselection and cursor change * added possibility of different display modes in Frequency representation * fixed severe quantization bug in saving 16Bit routine, reported by ? * mmaping support contributed by Juhana Kouhia * added as new Possibility to generate Signals: pulse trains * added wrapper for systems with no posixthreads -> still needs handling by configure script (change Makefile for not linking libpthread and doing a define) * First use of multiple threads (pthreads) in some functions * Pitch generation now independent of additive synthesis * added import function for ascii files * Ascii label saving now also by frequency * Label generation according to Period Detection (autocorellation) * Sonagram, FFTView and Distortion-Dialog now use ScaleWidgets * New ScaleWidget gives the user more information * Improved ProgressDialog and Interpolation class to allow multiple threads * fixed some minor bugs 0.28 [1998-07-15] (by Martin Wilz ) * changes in curvewidget (recent point has another pixmap). * sorting of labels now works without overwriting of QGList::compareItems. * bug fix for saving selection. * save Block function added. * signal finding function in markers.cpp: gui improved. * some smaller bug fixes. 0.27 [1998-07-14] (by Martin Wilz ) * first release, but never uploaded, because ftp.kde.org was down. diff --git a/kwave/FileContext.cpp b/kwave/FileContext.cpp index 3c58109e..29f3f63c 100644 --- a/kwave/FileContext.cpp +++ b/kwave/FileContext.cpp @@ -1,1096 +1,1105 @@ /*************************************************************************** kwave/FileContext.cpp - Context of a Loaded File ------------------- begin : 2010-01-02 copyright : (C) 2010 by Thomas.Eschenbacher email : Thomas.Eschenbacher@gmx.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. * * * ***************************************************************************/ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include "libkwave/CodecManager.h" #include "libkwave/Encoder.h" #include "libkwave/Logger.h" #include "libkwave/MessageBox.h" #include "libkwave/Parser.h" #include "libkwave/PlaybackController.h" #include "libkwave/PluginManager.h" #include "libkwave/SignalManager.h" #include "libkwave/Utils.h" #include "libgui/FileDialog.h" #include "App.h" #include "FileContext.h" #include "MainWidget.h" #include "Splash.h" #include "TopWidget.h" /** * useful macro for command parsing */ #define CASE_COMMAND(x) } else if (parser.command() == _(x)) { //*************************************************************************** /** * struct for info about a label within a Kwave script * @internal */ namespace Kwave { typedef struct { qint64 pos; /**< position within the stream */ unsigned int hits; /**< number of "goto"s to this label */ } label_t; } //*************************************************************************** Kwave::FileContext::FileContext(Kwave::App &app) :QObject(), m_use_count(1), m_application(app), m_top_widget(Q_NULLPTR), m_main_widget(Q_NULLPTR), m_signal_manager(Q_NULLPTR), m_plugin_manager(Q_NULLPTR), m_active(true), m_last_zoom(0), m_last_playback_pos(0), m_last_status_message_text(), m_last_status_message_timer(), m_last_status_message_ms(0), m_last_undo(QString()), m_last_redo(QString()), m_instance_nr(-1), m_delayed_command_timer(), m_delayed_command_queue() { m_delayed_command_timer.setSingleShot(true); connect(&m_delayed_command_timer, SIGNAL(timeout()), this, SLOT(processDelayedCommand())); } //*************************************************************************** Kwave::FileContext::~FileContext() { if (m_main_widget) delete m_main_widget; m_main_widget = Q_NULLPTR; m_top_widget = Q_NULLPTR; if (m_plugin_manager) delete m_plugin_manager; m_plugin_manager = Q_NULLPTR; if (m_signal_manager) delete m_signal_manager; m_signal_manager = Q_NULLPTR; } //*************************************************************************** void Kwave::FileContext::use() { Q_ASSERT(int(m_use_count) > 0); m_use_count.ref(); } //*************************************************************************** void Kwave::FileContext::release() { Q_ASSERT(int(m_use_count) > 0); if (m_use_count.deref() == false) { disconnect(); deleteLater(); } } //*************************************************************************** bool Kwave::FileContext::createMainWidget(const QSize &preferred_size) { Q_ASSERT(!m_main_widget); // create the main widget m_main_widget = new(std::nothrow) Kwave::MainWidget( m_top_widget, *this, preferred_size ); Q_ASSERT(m_main_widget); if (!m_main_widget) return false; if (!(m_main_widget->isOK())) { delete m_main_widget; m_main_widget = Q_NULLPTR; return false; } // connect the main widget connect(&(m_signal_manager->playbackController()), SIGNAL(sigSeekDone(sample_index_t)), m_main_widget, SLOT(scrollTo(sample_index_t))); connect(m_main_widget, SIGNAL(sigCommand(QString)), this, SLOT(executeCommand(QString))); connect(m_main_widget, SIGNAL(sigZoomChanged(double)), this, SLOT(forwardZoomChanged(double))); connect(m_main_widget, SIGNAL(sigVisibleRangeChanged(sample_index_t, sample_index_t, sample_index_t)), this, SLOT(visibleRangeChanged(sample_index_t, sample_index_t, sample_index_t)) ); return true; } //*************************************************************************** bool Kwave::FileContext::init(Kwave::TopWidget *top_widget) { Kwave::FileContext::UsageGuard _keep(this); m_top_widget = top_widget; Q_ASSERT(m_top_widget); if (!m_top_widget) return false; m_signal_manager = new(std::nothrow) Kwave::SignalManager(m_top_widget); Q_ASSERT(m_signal_manager); if (!m_signal_manager) return false; m_plugin_manager = new(std::nothrow) Kwave::PluginManager(m_top_widget, *m_signal_manager); Q_ASSERT(m_plugin_manager); if (!m_plugin_manager) return false; // connect the signal manager connect(m_signal_manager, SIGNAL(sigMetaDataChanged(Kwave::MetaDataList)), this, SLOT(metaDataChanged(Kwave::MetaDataList))); connect(&(m_signal_manager->selection()), SIGNAL(changed(sample_index_t,sample_index_t)), this, SLOT(selectionChanged(sample_index_t,sample_index_t))); connect(m_signal_manager, SIGNAL(sigUndoRedoInfo(const QString&, const QString&)), this, SLOT(setUndoRedoInfo(QString,QString))); connect(m_signal_manager, SIGNAL(sigModified()), this, SLOT(modifiedChanged())); // connect the plugin manager connect(m_plugin_manager, SIGNAL(sigCommand(QString)), this, SLOT(executeCommand(QString))); // connect the playback controller connect(&(m_signal_manager->playbackController()), SIGNAL(sigPlaybackPos(sample_index_t)), this, SLOT(updatePlaybackPos(sample_index_t))); setParent(top_widget); Kwave::Splash::showMessage(i18n("Scanning plugins...")); m_plugin_manager->searchPluginModules(); // load the menu from file QFile menufile(QStandardPaths::locate( QStandardPaths::GenericDataLocation, _("kwave/menus.config") )); menufile.open(QIODevice::ReadOnly); QTextStream stream(&menufile); Q_ASSERT(!stream.atEnd()); if (!stream.atEnd()) parseCommands(stream); menufile.close(); // now we are initialized, load all plugins Kwave::Splash::showMessage(i18n("Loading plugins...")); statusBarMessage(i18n("Loading plugins..."), 0); - m_plugin_manager->loadAllPlugins(); + if (!m_plugin_manager->loadAllPlugins()) { + statusBarMessage(i18n("Failed"), 1000); + QApplication::restoreOverrideCursor(); + Kwave::MessageBox::error(top_widget, + i18n("Kwave has not been properly installed. "\ + "No plugins found!") + ); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + return false; + } statusBarMessage(i18n("Ready"), 1000); return true; } //*************************************************************************** void Kwave::FileContext::setParent(Kwave::TopWidget *top_widget) { if (m_top_widget) { Kwave::TopWidget *old = m_top_widget; // disconnect all old signal/slot relationships disconnect(m_plugin_manager, SIGNAL(sigProgress(QString)), old, SLOT(showInSplashSreen(QString))); disconnect(old, SIGNAL(sigFileContextSwitched(Kwave::FileContext*)), this, SLOT(contextSwitched(Kwave::FileContext*))); if (m_signal_manager) m_signal_manager->setParentWidget(Q_NULLPTR); if (m_plugin_manager) m_plugin_manager->setParentWidget(Q_NULLPTR); if (m_main_widget) m_main_widget->setParent(Q_NULLPTR); m_active = false; } // set the new top widget m_top_widget = top_widget; if (m_top_widget) { QWidget *top = m_top_widget; connect(top, SIGNAL(sigFileContextSwitched(Kwave::FileContext*)), this, SLOT(contextSwitched(Kwave::FileContext*))); connect(m_plugin_manager, SIGNAL(sigProgress(QString)), top, SLOT(showInSplashSreen(QString))); if (m_signal_manager) m_signal_manager->setParentWidget(m_top_widget); if (m_plugin_manager) m_plugin_manager->setParentWidget(m_top_widget); if (m_main_widget) m_main_widget->setParent(m_top_widget); } } //*************************************************************************** QWidget *Kwave::FileContext::mainWidget() const { return static_cast(m_main_widget); } //*************************************************************************** Kwave::SignalManager *Kwave::FileContext::signalManager() const { Q_ASSERT(m_signal_manager); return m_signal_manager; } //*************************************************************************** Kwave::PluginManager *Kwave::FileContext::pluginManager() const { return m_plugin_manager; } //*************************************************************************** Kwave::Zoomable* Kwave::FileContext::zoomable() const { return m_main_widget; } //*************************************************************************** int Kwave::FileContext::delegateCommand(const char *plugin, Kwave::Parser &parser, unsigned int param_count) { if (!m_plugin_manager) return -1; if (parser.count() != param_count) return -EINVAL; QStringList params; params.append(parser.command()); params.append(parser.remainingParams()); int result = m_plugin_manager->setupPlugin(_(plugin), params); if (result > 0) result = 0; return result; } //*************************************************************************** int Kwave::FileContext::executeCommand(const QString &line) { Kwave::FileContext::UsageGuard _keep(this); int result = 0; bool use_recorder = true; QString command = line; // qDebug("Kwave::FileContext[%p]::executeCommand(%s)", this, DBG(command)); Q_ASSERT(m_plugin_manager); Q_ASSERT(m_top_widget); if (!m_plugin_manager || !m_top_widget) return -ENOMEM; if (!command.length()) return 0; // empty line -> nothing to do if (command.trimmed().startsWith(_("#"))) return 0; // only a comment // special case: if the command contains ";" it is a list of // commands -> macro ! Kwave::Parser parse_list(command); if (parse_list.hasMultipleCommands()) { QStringList macro = parse_list.commandList(); foreach (const QString &it, macro) { result = executeCommand(_("nomacro:") + it); Q_ASSERT(!result); if (result) { qWarning("macro execution of '%s' failed: %d", DBG(it), result); return result; // macro failed :-( } // wait until the command has completed ! m_plugin_manager->sync(); } return result; } // check if the macro recorder has to be disabled for this command if (command.startsWith(_("nomacro:"))) { use_recorder = false; command = command.mid(QString(_("nomacro:")).length()); } // expand variables if (command.contains(_("${"))) { // current language if (command.contains(_("${LANG}"))) { QLocale locale; if (!m_main_widget.isNull()) locale = m_main_widget->locale(); QString lang = locale.name().split(_("-")).at(0); command.replace(_("${LANG}"), lang); } } // log all commands to the log file if enabled Kwave::Logger::log(this, Kwave::Logger::Info, _("CMD: ") + line); // parse one single command Kwave::Parser parser(command); QString cmd = parser.command(); // exclude menu commands from the recorder if (cmd == _("menu")) use_recorder = false; // only record plugin:execute, not plugin without parameters if (cmd == _("plugin")) use_recorder = false; // let through all commands that handle zoom/view or playback like fwd/rew bool allow_always = (cmd == _("playback")) || cmd.startsWith(_("view:")) || cmd.startsWith(_("playback:")) || cmd.startsWith(_("select_track:")) || (cmd == _("close")) || (cmd == _("quit")) || (cmd == _("window:screenshot")) || (cmd == _("window:sendkey")) ; // all others only if no plugin is currently running if (!allow_always && m_plugin_manager->onePluginRunning()) { qWarning("FileContext::executeCommand('%s') - currently not possible, " "a plugin is running :-(", DBG(cmd)); return -1; } if (use_recorder) { // append the command to the macro recorder // @TODO macro recording... qDebug("# %s ", DBG(command)); } if ((result = m_top_widget->executeCommand(command)) != ENOSYS) return result; if (false) { CASE_COMMAND("close") result = closeFile() ? 0 : 1; CASE_COMMAND("delayed") if (parser.count() != 2) return -EINVAL; unsigned int delay = parser.firstParam().toUInt(); QString delayed_cmd = parser.nextParam(); enqueueCommand(delay, delayed_cmd); result = 0; CASE_COMMAND("loadbatch") result = loadBatch(QUrl(parser.nextParam())); CASE_COMMAND("plugin") QString name(parser.firstParam()); QStringList params(parser.remainingParams()); qDebug("FileContext::executeCommand(): loading plugin '%s'", DBG(name)); qDebug("FileContext::executeCommand(): with %d parameter(s)", params.count()); result = m_plugin_manager->executePlugin( name, params.count() ? ¶ms : Q_NULLPTR); CASE_COMMAND("plugin:execute") QString name(parser.firstParam()); QStringList params(parser.remainingParams()); result = m_plugin_manager->executePlugin(name, ¶ms); CASE_COMMAND("plugin:setup") QString name(parser.firstParam()); QStringList params(parser.remainingParams()); result = m_plugin_manager->setupPlugin(name, params); if (result > 0) result = 0; CASE_COMMAND("revert") result = revert(); CASE_COMMAND("save") result = saveFile(); CASE_COMMAND("saveas") result = saveFileAs(parser.nextParam(), false); CASE_COMMAND("saveselect") result = saveFileAs(QString(), true); CASE_COMMAND("sync") while (!m_delayed_command_queue.isEmpty()) { qApp->processEvents(QEventLoop::ExcludeUserInputEvents); } result = 0; CASE_COMMAND("window:click") result = delegateCommand("debug", parser, 3); CASE_COMMAND("window:close") result = delegateCommand("debug", parser, 1); CASE_COMMAND("window:mousemove") result = delegateCommand("debug", parser, 3); CASE_COMMAND("window:resize") result = delegateCommand("debug", parser, 3); CASE_COMMAND("window:sendkey") result = delegateCommand("debug", parser, 2); CASE_COMMAND("window:screenshot") result = delegateCommand("debug", parser, 2); } else { // pass the command to the layer below (main widget) Kwave::CommandHandler *layer_below = m_main_widget; result = (layer_below) ? layer_below->executeCommand(command) : -ENOSYS; } return result; } //*************************************************************************** void Kwave::FileContext::forwardZoomChanged(double zoom) { m_last_zoom = zoom; emit sigZoomChanged(this, zoom); } //*************************************************************************** void Kwave::FileContext::statusBarMessage(const QString &msg, unsigned int ms) { m_last_status_message_text = msg; m_last_status_message_ms = ms; if (ms) m_last_status_message_timer.start(); else m_last_status_message_timer.invalidate(); if (isActive()) emit sigStatusBarMessage(msg, ms); } //*************************************************************************** void Kwave::FileContext::updatePlaybackPos(sample_index_t offset) { if (!m_plugin_manager) return; if (!m_main_widget) return; bool playing = m_signal_manager->playbackController().running(); if (!playing) return; QString txt; double rate = m_plugin_manager->signalRate(); if (rate > 0) { double ms = static_cast(offset) * 1E3 / rate; txt = i18n("Playback: %1", Kwave::ms2string(ms)); } else { txt = i18n("Playback: %1 samples", Kwave::samples2string(offset)); } statusBarMessage(txt, 2000); // make sure that the current playback position is visible m_last_playback_pos = offset; Kwave::Zoomable *z = zoomable(); if (z) z->scrollTo(offset); } //*************************************************************************** void Kwave::FileContext::metaDataChanged(Kwave::MetaDataList meta_data) { // find out the instance ID if (m_instance_nr == -1) { // build a list of all currently open files/instances (including this) QList files = m_application.openFiles(); // filter out all instances of our file name QString our_name = signalName(); QList existing_instances; foreach (const Kwave::App::FileAndInstance &it, files) { const QString &name = it.first; int inst = it.second; if (name == our_name) existing_instances.append(inst); } // remove our own entry if (existing_instances.contains(m_instance_nr)) existing_instances.removeOne(m_instance_nr); // find an empty slot if (!existing_instances.isEmpty()) while (existing_instances.contains(m_instance_nr)) m_instance_nr = (m_instance_nr != -1) ? (m_instance_nr + 1) : 2; } if (isActive()) { // we are active -> emit the meta data immediately emit sigMetaDataChanged(meta_data); } // else: we are inactive -> emit the meta data later, when activated // update the caption of the sub window if (m_main_widget && (m_application.guiType() != Kwave::App::GUI_SDI)) m_main_widget->setWindowTitle(windowCaption(true)); } //*************************************************************************** void Kwave::FileContext::selectionChanged(sample_index_t offset, sample_index_t length) { if (isActive()) { // we are active -> emit the selection change immediately emit sigSelectionChanged(offset, length); } // else: we are inactive -> not of interest / ignore } //*************************************************************************** void Kwave::FileContext::setUndoRedoInfo(const QString &undo, const QString &redo) { m_last_undo = undo; m_last_redo = redo; if (isActive()) { // we are active -> emit the undo/redo info immediately emit sigUndoRedoInfo(undo, redo); } // else: we are inactive -> emit the undo/redo info later, when activated } //*************************************************************************** void Kwave::FileContext::visibleRangeChanged(sample_index_t offset, sample_index_t visible, sample_index_t total) { if (isActive()) { // we are active -> emit the view info immediately emit sigVisibleRangeChanged(offset, visible, total); } // else: we are inactive -> emit the view info later, when activated } //*************************************************************************** void Kwave::FileContext::modifiedChanged() { if (isActive()) { // we are active -> emit the modified state immediately emit sigModified(); } // else: we are inactive -> emit the modified state later, when activated // update the caption of our main widget if (m_main_widget && (m_application.guiType() != Kwave::App::GUI_SDI)) m_main_widget->setWindowTitle(windowCaption(true)); } //*************************************************************************** void Kwave::FileContext::contextSwitched(Kwave::FileContext *context) { Kwave::FileContext::UsageGuard _keep(this); if (context == this) { if (!m_active) { m_active = true; activated(); } } else m_active = false; } //*************************************************************************** void Kwave::FileContext::activated() { // let our plugin manager be the active one if (m_plugin_manager) m_plugin_manager->setActive(); // emit last playback position if playback is running if (m_signal_manager && m_signal_manager->playbackController().running()) updatePlaybackPos(m_last_playback_pos); // emit last zoom factor forwardZoomChanged(m_last_zoom); // erase the status message of the previous context emit sigStatusBarMessage(QString(), 0); // emit our last status bar message if it has not expired if (m_last_status_message_timer.isValid()) { quint64 elapsed = m_last_status_message_timer.elapsed(); if (elapsed < m_last_status_message_ms) { unsigned int remaining = Kwave::toUint(m_last_status_message_ms - elapsed); emit sigStatusBarMessage(m_last_status_message_text, remaining); } else m_last_status_message_timer.invalidate(); } else if (m_last_status_message_ms == 0) { // static message without expiration if (m_last_status_message_text.length()) { emit sigStatusBarMessage(m_last_status_message_text, 0); } } // emit latest meta data if (m_signal_manager) emit sigMetaDataChanged(m_signal_manager->metaData()); // emit latest view range change if (m_main_widget && m_signal_manager) { sample_index_t offset = m_main_widget->visibleOffset(); sample_index_t visible = m_main_widget->visibleSamples(); sample_index_t total = m_signal_manager->length(); emit sigVisibleRangeChanged(offset, visible, total); } // force update of the "modified" state emit sigModified(); // emit last undo/redo info emit sigUndoRedoInfo(m_last_undo, m_last_redo); } //*************************************************************************** int Kwave::FileContext::parseCommands(QTextStream &stream) { Kwave::FileContext::UsageGuard _keep(this); int result = 0; QMap labels; // set hourglass cursor QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QString label; // label, jump target of a "GOTO" while (!stream.atEnd() && !result) { QString line = stream.readLine().simplified(); if (line.startsWith(_("#"))) continue; // skip comments if (!line.length()) continue; // skip empty lines if (line.endsWith(QLatin1Char(':'))) { // this line seems to be a "label" QString name = line.left(line.length() - 1).simplified(); if (!labels.contains(name)) { // qDebug("new label '%s' at %llu", DBG(name), stream.pos()); label_t label_pos; label_pos.pos = stream.pos(); label_pos.hits = 0; labels[name] = label_pos; } // special handling for a label at the end of the file if (label.length() && (label == name)) { // label found label = QString(); } continue; } Kwave::Parser parser(line); // the "GOTO" command if ( !label.length() && (line.split(QLatin1Char(' ')).at(0) == _("GOTO")) ) { label = line.split(QLatin1Char(' ')).at(1).simplified(); } // jump to a label, scan/seek mode if (label.length()) { if (labels.contains(label)) { labels[label].hits++; qDebug(">>> GOTO '%s' @ offset %llu (pass #%d)", DBG(label), labels[label].pos, labels[label].hits ); stream.seek(labels[label].pos); // reset the label to search for label = QString(); } // else: maybe the label will follow somewhere below, // scan forward... continue; } // synchronize before the command if (m_plugin_manager) m_plugin_manager->sync(); // the "msgbox" command (useful for debugging) if (false) { ; CASE_COMMAND("msgbox") QApplication::restoreOverrideCursor(); result = (Kwave::MessageBox::questionYesNo(mainWidget(), parser.firstParam()) == KMessageBox::Yes) ? 0 : 1; QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); continue; } // prevent this command from being re-added to the macro recorder if (!line.startsWith(_("nomacro:"), Qt::CaseInsensitive)) line.prepend(_("nomacro:")); // process the command in the current context // NOTE: this could theoretically also be a command that modifies // or even deletes the current context! result = EAGAIN; Kwave::FileContext *current_ctx = (m_top_widget) ? m_top_widget->currentContext() : Q_NULLPTR; if (current_ctx && (current_ctx != this)) result = m_top_widget->forwardCommand(line); // If the call returned with EAGAIN, then the context in duty is // different from this instance but not yet completely set up. // In that case this context is still responsible for executing the // current command. if (result == EAGAIN) result = executeCommand(line); if (result) qDebug(">>> '%s' - result=%d", DBG(line), result); qApp->processEvents(QEventLoop::ExcludeUserInputEvents); // synchronize after the command if (m_plugin_manager) m_plugin_manager->sync(); // special handling of the "quit" command if (parser.command() == _("quit")) { result = ECANCELED; break; } } if (label.length()) { // oops, if we get here then we have searched for a non-exising label qWarning("label '%s' not found", DBG(label)); result = -ENOENT; } // remove hourglass QApplication::restoreOverrideCursor(); return result; } //*************************************************************************** void Kwave::FileContext::enqueueCommand(unsigned int delay, const QString &command) { use(); m_delayed_command_queue.append( QPair(delay, command) ); if (!m_delayed_command_timer.isActive()) m_delayed_command_timer.start(delay); } //*************************************************************************** void Kwave::FileContext::processDelayedCommand() { if (m_delayed_command_queue.isEmpty()) return; QPair current = m_delayed_command_queue.takeFirst(); executeCommand(current.second); if (m_delayed_command_queue.isEmpty()) return; QPair next = m_delayed_command_queue.first(); m_delayed_command_timer.start(next.first); release(); } //*************************************************************************** bool Kwave::FileContext::isInUse() const { if (m_use_count >= 2) return true; return (m_signal_manager && !m_signal_manager->isEmpty()); } //*************************************************************************** QString Kwave::FileContext::signalName() const { return (m_signal_manager) ? m_signal_manager->signalName() : QString(); } //*************************************************************************** QString Kwave::FileContext::windowCaption(bool with_modified) const { QString name = signalName(); // shortcut if no file loaded if (!name.length()) return QString(); // if not in SDI mode we have to take care of multiple instances on our // own and append a " " manually ! if (m_application.guiType() != Kwave::App::GUI_SDI) if (m_instance_nr != -1) name = i18nc( "for window title: " "%1 = Name of the file, " "%2 = Instance number when opened multiple times", "%1 <%2>", name, m_instance_nr); if (with_modified) { bool modified = (m_signal_manager) ? m_signal_manager->isModified() : false; if (modified) return i18nc("%1 = Path to modified file", "* %1 (modified)", name); } return name; } //*************************************************************************** int Kwave::FileContext::loadBatch(const QUrl &url) { Kwave::FileContext::UsageGuard _keep(this); // open the URL, read-only mode is enough QFile file(url.path()); if (!file.open(QIODevice::ReadOnly)) { qWarning("unable to open source in read-only mode!"); return -EIO; } // use a text stream for parsing the commands QTextStream stream(&file); int result = parseCommands(stream); file.close(); return result; } //*************************************************************************** int Kwave::FileContext::revert() { Kwave::FileContext::UsageGuard _keep(this); QUrl url(signalName()); if (!url.isValid() || !m_signal_manager) return -EINVAL; if (m_signal_manager->isModified()) { int res = Kwave::MessageBox::warningContinueCancel(m_top_widget, i18n("This file has been modified, changes will be lost.\n" "Do you want to continue?")); if (res == KMessageBox::Cancel) return ECANCELED; } return m_signal_manager->loadFile(url); } //*************************************************************************** int Kwave::FileContext::saveFile() { if (!m_signal_manager) return -EINVAL; int res = 0; if (signalName() != NEW_FILENAME) { QUrl url; url = QUrl(signalName()); res = m_signal_manager->save(url, false); // if saving in current format is not possible (no encoder), // then try to "save/as" instead... if (res == -EINVAL) res = saveFileAs(QString(), false); } else res = saveFileAs(QString(), false); return res; } //*************************************************************************** int Kwave::FileContext::saveFileAs(const QString &filename, bool selection) { if (!m_signal_manager) return -EINVAL; QString name = filename; QUrl url; int res = 0; if (name.length()) { /* name given -> take it */ url = QUrl(name); } else { /* * no name given -> show the File/SaveAs dialog... */ QUrl current_url; current_url = QUrl(signalName()); QString what = Kwave::CodecManager::mimeTypeOf(current_url); Kwave::Encoder *encoder = Kwave::CodecManager::encoder(what); QString extension; // = "*.wav"; if (!encoder) { // no extension selected yet, use mime type from file info QString mime_type = Kwave::FileInfo( m_signal_manager->metaData()).get( Kwave::INF_MIMETYPE).toString(); encoder = Kwave::CodecManager::encoder(mime_type); if (encoder) { QStringList extensions = encoder->extensions(mime_type); if (!extensions.isEmpty()) { QString ext = extensions.first().split(_(" ")).first(); if (ext.length()) { extension = ext; QString new_filename = current_url.fileName(); new_filename += extension.mid(1); // remove the "*" current_url = current_url.adjusted(QUrl::RemoveFilename); current_url.setPath(current_url.path() + new_filename); } } } } QString filter = Kwave::CodecManager::encodingFilter(); QPointer dlg = new(std::nothrow)Kwave::FileDialog( _("kfiledialog:///kwave_save_as"), Kwave::FileDialog::SaveFile, filter, m_top_widget, current_url, extension ); if (!dlg) return 0; dlg->setWindowTitle(i18n("Save As")); if (dlg->exec() != QDialog::Accepted) { delete dlg; return -1; } url = dlg->selectedUrl(); if (url.isEmpty()) { delete dlg; return 0; } QString new_name = url.path(); QFileInfo path(new_name); // add the correct extension if necessary if (!path.suffix().length()) { QString ext = dlg->selectedExtension(); QStringList extensions = ext.split(_(" ")); ext = extensions.first(); new_name += ext.mid(1); path = new_name; url.setPath(new_name); } delete dlg; } // check if the file exists and ask before overwriting it // if it is not the old filename name = url.path(); if ((url.toDisplayString() != QUrl(signalName()).toDisplayString()) && (QFileInfo(name).exists())) { if (Kwave::MessageBox::warningYesNo(m_top_widget, i18n("The file '%1' already exists.\n" "Do you really want to overwrite it?", name)) != KMessageBox::Yes) { return -1; } } // maybe we now have a new mime type QString previous_mimetype_name = Kwave::FileInfo(m_signal_manager->metaData()).get( Kwave::INF_MIMETYPE).toString(); QString new_mimetype_name = Kwave::CodecManager::mimeTypeOf(url); if (new_mimetype_name != previous_mimetype_name) { // saving to a different mime type // now we have to do as if the mime type and file name // has already been selected to satisfy the fileinfo // plugin qDebug("TopWidget::saveAs(%s) - [%s] (previous:'%s')", DBG(url.toDisplayString()), DBG(new_mimetype_name), DBG(previous_mimetype_name) ); // set the new mimetype Kwave::FileInfo info(m_signal_manager->metaData()); info.set(Kwave::INF_MIMETYPE, new_mimetype_name); // set the new filename info.set(Kwave::INF_FILENAME, url.toDisplayString()); m_signal_manager->setFileInfo(info, false); // now call the fileinfo plugin with the new filename and // mimetype res = (m_plugin_manager) ? m_plugin_manager->setupPlugin(_("fileinfo"), QStringList()) : -1; // restore the mime type and the filename info = Kwave::FileInfo(m_signal_manager->metaData()); info.set(Kwave::INF_MIMETYPE, previous_mimetype_name); info.set(Kwave::INF_FILENAME, url.toDisplayString()); m_signal_manager->setFileInfo(info, false); } // now we have a file name -> do the "save" operation if (!res) res = m_signal_manager->save(url, selection); // if saving was successful, add the file to the list of recent files if (!res) m_application.addRecentFile(signalName()); return res; } //*************************************************************************** bool Kwave::FileContext::closeFile() { Kwave::FileContext::UsageGuard _keep(this); if (m_plugin_manager && !m_plugin_manager->canClose()) { qWarning("FileContext::closeFile() - currently not possible, "\ "a plugin is running :-("); return false; } if (m_signal_manager && m_signal_manager->isModified()) { int res = Kwave::MessageBox::warningYesNoCancel(m_top_widget, i18n("This file has been modified.\nDo you want to save it?")); if (res == KMessageBox::Cancel) return false; if (res == KMessageBox::Yes) { // user decided to save res = saveFile(); qDebug("FileContext::closeFile()::saveFile, res=%d",res); if (res) return false; } } // close all plugins that still might use the current signal if (m_plugin_manager) { m_plugin_manager->stopAllPlugins(); m_plugin_manager->signalClosed(); } if (m_signal_manager) m_signal_manager->close(); switch (m_application.guiType()) { case Kwave::App::GUI_MDI: /* FALLTHROUGH */ case Kwave::App::GUI_TAB: // close the main widget if (m_main_widget) delete m_main_widget; break; case Kwave::App::GUI_SDI: break; } return true; } //*************************************************************************** //*************************************************************************** diff --git a/libkwave/PluginManager.cpp b/libkwave/PluginManager.cpp index cc20c4b7..c9455479 100644 --- a/libkwave/PluginManager.cpp +++ b/libkwave/PluginManager.cpp @@ -1,709 +1,711 @@ /*************************************************************************** PluginManager.cpp - manager class for Kwave's plugins ------------------- begin : Sun Aug 27 2000 copyright : (C) 2000 by Thomas Eschenbacher email : Thomas.Eschenbacher@gmx.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. * * * ***************************************************************************/ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "libkwave/MessageBox.h" #include "libkwave/MultiPlaybackSink.h" #include "libkwave/PlayBackDevice.h" #include "libkwave/PlaybackDeviceFactory.h" #include "libkwave/Plugin.h" #include "libkwave/PluginManager.h" #include "libkwave/SignalManager.h" #include "libkwave/Utils.h" #include "libkwave/Writer.h" #include "libkwave/undo/UndoAction.h" #include "libkwave/undo/UndoModifyAction.h" #include "libkwave/undo/UndoTransactionGuard.h" //*************************************************************************** // static initializers QMap Kwave::PluginManager::m_plugin_modules; Kwave::PluginManager *Kwave::PluginManager::m_active_instance = Q_NULLPTR; //*************************************************************************** Kwave::PluginManager::PluginManager(QWidget *parent, Kwave::SignalManager &signal_manager) :m_plugin_instances(), m_running_plugins(), m_parent_widget(parent), m_signal_manager(signal_manager), m_view_manager(Q_NULLPTR) { } //*************************************************************************** Kwave::PluginManager::~PluginManager() { // inform all plugins and client windows that we close now emit sigClosed(); // wait until all plugins are really closed this->sync(); // give all plugins that still are loaded the chance to do some cleanups // or unregistration tasks. Ideally this should also trigger a "release" // of these remaining plugins, so that afterwards we have no more // plugin instances left. while (!m_plugin_instances.isEmpty()) { KwavePluginPointer p = m_plugin_instances.takeLast(); Q_ASSERT(p); if (p) p->unload(); } // this should make the cleanup handlers run (deferred delete) QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); // release all loaded modules foreach (const QString &name, m_plugin_modules.keys()) { PluginModule &p = m_plugin_modules[name]; p.m_use_count--; // qDebug("PluginManager: releasing module '%s' [refcnt=%d]", // DBG(name), p.m_use_count); if (p.m_use_count == 0) { // take out the pointer to the loadable module KPluginFactory *factory = p.m_factory; p.m_factory = Q_NULLPTR; // remove the module from the list m_plugin_modules.remove(name); // now the handle of the shared object can be released too if (factory) delete factory; } else { // still in use } } // we are no longer the active instance if (m_active_instance == this) m_active_instance = Q_NULLPTR; } //*************************************************************************** -void Kwave::PluginManager::loadAllPlugins() +bool Kwave::PluginManager::loadAllPlugins() { // Try to load all plugins. This has to be called only once per // instance of the main window! // NOTE: this also gives each plugin the chance to stay in memory // if necessary (e.g. for codecs) foreach (const QString &name, m_plugin_modules.keys()) { KwavePluginPointer plugin = createPluginInstance(name); if (plugin) { // qDebug("PluginManager::loadAllPlugins(): plugin '%s'", // DBG(plugin->name())); // get the last settings and call the "load" function // now the plugin is present and loaded QStringList last_params = defaultParams(name); plugin->load(last_params); // reduce use count again, we loaded the plugin only to give // it a chance to register some service if necessary (e.g. a // codec) // Most plugins fall back to use count zero and will be // deleted again. plugin->release(); } else { // loading failed => remove it from the list qWarning("PluginManager::loadAllPlugins(): removing '%s' " "from list", DBG(name)); m_plugin_modules.remove(name); } } + + return !m_plugin_modules.isEmpty(); } //*************************************************************************** void Kwave::PluginManager::stopAllPlugins() { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); if (!m_plugin_instances.isEmpty()) foreach (const KwavePluginPointer &plugin, m_plugin_instances) if (plugin && plugin->isRunning()) plugin->stop() ; sync(); } //*************************************************************************** Kwave::Plugin *Kwave::PluginManager::createPluginInstance(const QString &name) { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); // show an error message and abort if the plugin is unknown if (!(m_plugin_modules.contains(name))) { Kwave::MessageBox::error(m_parent_widget, i18n("The plugin '%1' is unknown or invalid.", name), i18n("Error On Loading Plugin")); return Q_NULLPTR; } PluginModule &info = m_plugin_modules[name]; // qDebug("loadPlugin(%s) [module use count=%d]", // DBG(name), info.m_use_count); KPluginFactory *factory = info.m_factory; Q_ASSERT(factory); // call the loader function to create an instance QVariantList args; args << info.m_name; args << info.m_description; Kwave::Plugin *plugin = factory->create(this, args); Q_ASSERT(plugin); if (!plugin) { qWarning("PluginManager::loadPlugin('%s'): out of memory", DBG(name)); return Q_NULLPTR; } // now we have a newly created plugin, the use count is 1 // append to our list of loaded plugins m_plugin_instances.append(plugin); // connect all necessary signals/slots connectPlugin(plugin); return plugin; } //*************************************************************************** int Kwave::PluginManager::executePlugin(const QString &name, QStringList *params) { QString command; int result = 0; // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); // synchronize: wait until any currently running plugins are done this->sync(); // load the new plugin KwavePluginPointer plugin = createPluginInstance(name); if (!plugin) return -ENOMEM; if (params) { // parameters were specified -> call directly // without setup dialog result = plugin->start(*params); // maybe the start() function has called close() ? if (!m_plugin_instances.contains(plugin)) { qDebug("PluginManager: plugin closed itself in start()"); result = -1; plugin = Q_NULLPTR; } if (plugin && (result >= 0)) { plugin->execute(*params); } } else { // load previous parameters from config QStringList last_params = defaultParams(name); // call the plugin's setup function params = plugin->setup(last_params); if (params) { // we have a non-zero parameter list, so // the setup function has not been aborted. // Now we can create a command string and // emit a new command. // store parameters for the next time savePluginDefaults(name, *params); // We DO NOT call the plugin's "execute" // function directly, as it should be possible // to record all function calls in the // macro recorder command = _("plugin:execute("); command += name; foreach (const QString &p, *params) command += _(", ") + p; delete params; command += _(")"); // qDebug("PluginManager: command='%s'",command.data()); } } // now the plugin is no longer needed here, release it if (plugin) plugin->release(); // emit a command, let the toplevel window (and macro recorder) get // it and call us again later... if (command.length()) emit sigCommand(command); return result; } //*************************************************************************** bool Kwave::PluginManager::canClose() { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); if (!m_plugin_instances.isEmpty()) foreach (const KwavePluginPointer &plugin, m_plugin_instances) if (plugin && !plugin->canClose()) return false; return true; } //*************************************************************************** bool Kwave::PluginManager::onePluginRunning() { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); if (!m_plugin_instances.isEmpty()) foreach (const KwavePluginPointer &plugin, m_plugin_instances) if (plugin && plugin->isRunning()) return true; return false; } //*************************************************************************** void Kwave::PluginManager::sync() { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); // this triggers all kinds of garbage collector (objects queued for // deletion through obj->deleteLater() qApp->processEvents(QEventLoop::ExcludeUserInputEvents); // wait until all plugins have finished their work... while (onePluginRunning()) { Kwave::yield(); qApp->processEvents(QEventLoop::ExcludeUserInputEvents); usleep(100000); } } //*************************************************************************** int Kwave::PluginManager::setupPlugin(const QString &name, const QStringList ¶ms) { // load the plugin Kwave::Plugin *plugin = createPluginInstance(name); if (!plugin) return -ENOMEM; // now the plugin is present and loaded QStringList prev_params = (params.isEmpty()) ? defaultParams(name) : params; // call the plugins' setup function QStringList *new_params = plugin->setup(prev_params); if (new_params) { // we have a non-zero parameter list, so // the setup function has not been aborted. savePluginDefaults(name, *new_params); delete new_params; } else { plugin->release(); return 1; } plugin->release(); return 0; } //*************************************************************************** QStringList Kwave::PluginManager::defaultParams(const QString &name) { QString def_version; QString section = _("plugin "); QStringList list; section += name; // get the plugin version if (!m_plugin_modules.contains(name)) return list; const PluginModule &info = m_plugin_modules[name]; QString version = info.m_version; Q_ASSERT(KSharedConfig::openConfig()); if (!KSharedConfig::openConfig()) return list; KConfigGroup cfg = KSharedConfig::openConfig()->group(section); cfg.sync(); def_version = cfg.readEntry("version"); if (!def_version.length()) { return list; } if (!(def_version == version)) { qDebug("PluginManager::defaultParams: " "plugin '%s': defaults for version '%s' not loaded, found " "old ones of version '%s'.", DBG(name), DBG(version), DBG(def_version)); // delete the old settings cfg.deleteEntry("version"); cfg.deleteEntry("defaults"); return list; } list = cfg.readEntry("defaults").split(QLatin1Char(',')); return list; } //*************************************************************************** void Kwave::PluginManager::savePluginDefaults(const QString &name, QStringList ¶ms) { // get the plugin version if (!m_plugin_modules.contains(name)) return; const PluginModule &info = m_plugin_modules[name]; QString version = info.m_version; QString section = _("plugin "); section += name; Q_ASSERT(KSharedConfig::openConfig()); if (!KSharedConfig::openConfig()) return; KConfigGroup cfg = KSharedConfig::openConfig()->group(section); cfg.sync(); cfg.writeEntry("version", version); cfg.writeEntry("defaults", params.join(QLatin1Char(','))); cfg.sync(); } //*************************************************************************** sample_index_t Kwave::PluginManager::signalLength() { return m_signal_manager.length(); } //*************************************************************************** double Kwave::PluginManager::signalRate() { return m_signal_manager.rate(); } //*************************************************************************** sample_index_t Kwave::PluginManager::selectionStart() { return m_signal_manager.selection().first(); } //*************************************************************************** sample_index_t Kwave::PluginManager::selectionEnd() { return m_signal_manager.selection().last(); } //*************************************************************************** void Kwave::PluginManager::selectRange(sample_index_t offset, sample_index_t length) { m_signal_manager.selectRange(offset, length); } //*************************************************************************** Kwave::SampleSink *Kwave::PluginManager::openMultiTrackPlayback( unsigned int tracks, const Kwave::PlayBackParam *playback_params ) { Kwave::PlayBackDevice *device = m_signal_manager.playbackController().openDevice( tracks, playback_params); if (!device) return Q_NULLPTR; // create the multi track playback sink Kwave::SampleSink *sink = new Kwave::MultiPlaybackSink(tracks, device); Q_ASSERT(sink); return sink; } //*************************************************************************** Kwave::PlaybackController &Kwave::PluginManager::playbackController() { return m_signal_manager.playbackController(); } //*************************************************************************** void Kwave::PluginManager::insertView(Kwave::SignalView *view, QWidget *controls) { if (m_view_manager) m_view_manager->insertView(view, controls); } //*************************************************************************** void Kwave::PluginManager::registerViewManager(Kwave::ViewManager *view_manager) { Q_ASSERT(!view_manager || !m_view_manager); m_view_manager = view_manager; } //*************************************************************************** void Kwave::PluginManager::enqueueCommand(const QString &command) { emit sigCommand(command); } //*************************************************************************** void Kwave::PluginManager::signalClosed() { emit sigClosed(); } //*************************************************************************** void Kwave::PluginManager::pluginClosed(Kwave::Plugin *p) { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); Q_ASSERT(p); if (!p) return; // disconnect the signals to avoid recursion disconnectPlugin(p); if (m_plugin_instances.contains(p)) m_plugin_instances.removeAll(p); // schedule the deferred delete/unload of the plugin p->deleteLater(); } //*************************************************************************** void Kwave::PluginManager::pluginStarted(Kwave::Plugin *p) { Q_ASSERT(p); if (!p) return; // the plugin is running -> increase the usage count in order to // prevent our lists from containing invalid entries p->use(); // add the plugin to the list of running plugins m_running_plugins.append(p); } //*************************************************************************** void Kwave::PluginManager::pluginDone(Kwave::Plugin *p) { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); Q_ASSERT(p); if (!p) return; // remove the plugin from the list of running plugins m_running_plugins.removeAll(p); // release the plugin, at least we do no longer need it p->release(); } //*************************************************************************** void Kwave::PluginManager::connectPlugin(Kwave::Plugin *plugin) { Q_ASSERT(plugin); if (!plugin) return; connect(this, SIGNAL(sigClosed()), plugin, SLOT(close())); connect(plugin, SIGNAL(sigClosed(Kwave::Plugin*)), this, SLOT(pluginClosed(Kwave::Plugin*)), Qt::QueuedConnection); connect(plugin, SIGNAL(sigRunning(Kwave::Plugin*)), this, SLOT(pluginStarted(Kwave::Plugin*)), Qt::DirectConnection); connect(plugin, SIGNAL(sigDone(Kwave::Plugin*)), this, SLOT(pluginDone(Kwave::Plugin*)), Qt::QueuedConnection); } //*************************************************************************** void Kwave::PluginManager::disconnectPlugin(Kwave::Plugin *plugin) { Q_ASSERT(plugin); if (!plugin) return; disconnect(plugin, SIGNAL(sigDone(Kwave::Plugin*)), this, SLOT(pluginDone(Kwave::Plugin*))); disconnect(plugin, SIGNAL(sigRunning(Kwave::Plugin*)), this, SLOT(pluginStarted(Kwave::Plugin*))); disconnect(this, SIGNAL(sigClosed()), plugin, SLOT(close())); disconnect(plugin, SIGNAL(sigClosed(Kwave::Plugin*)), this, SLOT(pluginClosed(Kwave::Plugin*))); } //*************************************************************************** void Kwave::PluginManager::setSignalName(const QString &name) { emit sigSignalNameChanged(name); } //*************************************************************************** void Kwave::PluginManager::searchPluginModules() { if (!m_plugin_modules.isEmpty()) { // this is not the first call -> increment module use count only foreach (const QString &name, m_plugin_modules.keys()) { PluginModule &p = m_plugin_modules[name]; p.m_use_count++; } return; } KPluginInfo::List plugins = KPluginTrader::self()->query( _("kwave"), _("Kwave/Plugin") ); foreach (const KPluginInfo &i, plugins) { QString library = i.libraryPath(); QString description = i.name(); QString name = i.pluginName(); QString version_raw = i.version(); QString version; QString settings; QString author = i.author(); if (version_raw.contains(_(":"))) { version = version_raw.split(_(":")).at(0); settings = version_raw.split(_(":")).at(1); } // qDebug("file='%s', name='%s', description='%s', binary_version='%s', " // "settings_version='%s', author='%s'", // DBG(library), DBG(name), DBG(description), DBG(version), // DBG(settings), DBG(author) // ); if ( library.isEmpty() || description.isEmpty() || name.isEmpty() || version.isEmpty() ) { qWarning("plugin '%s' has no library, name or version", DBG(name)); continue; } if (version != _(KWAVE_VERSION)) { qWarning("plugin '%s' has wrong ABI version: '%s' (should be %s)", DBG(name), DBG(version), KWAVE_VERSION); continue; } KPluginLoader loader(library); KPluginFactory* factory = loader.factory(); if (!factory) { qWarning("plugin '%s': loading failed", DBG(name)); continue; } emit sigProgress(i18n("Loading plugin %1...", name)); QApplication::processEvents(); PluginModule info; info.m_name = name; info.m_author = author; info.m_description = i18n(description.toUtf8()); info.m_version = settings; info.m_factory = factory; info.m_use_count = 1; m_plugin_modules.insert(info.m_name, info); qDebug("%16s %5s written by %s", DBG(name), DBG(settings), DBG(author)); } qDebug("--- \n found %d plugins\n", m_plugin_modules.count()); } //*************************************************************************** const QList Kwave::PluginManager::pluginInfoList() const { return m_plugin_modules.values(); } //*************************************************************************** void Kwave::PluginManager::migratePluginToActiveContext(Kwave::Plugin *plugin) { // check: this must be called from the GUI thread only! Q_ASSERT(this->thread() == QThread::currentThread()); Q_ASSERT(this->thread() == qApp->thread()); Q_ASSERT(plugin); if (!plugin) return; if (m_active_instance == this) return; // nothing to do Q_ASSERT(m_active_instance); if (!m_active_instance) return; // should never happen Kwave::PluginManager *old_mgr = this; old_mgr->m_plugin_instances.removeAll(plugin); old_mgr->m_running_plugins.removeAll(plugin); old_mgr->disconnectPlugin(plugin); Kwave::PluginManager *new_mgr = m_active_instance; new_mgr->m_plugin_instances.append(plugin); new_mgr->m_running_plugins.append(plugin); new_mgr->connectPlugin(plugin); plugin->setPluginManager(new_mgr); } //*************************************************************************** //*************************************************************************** diff --git a/libkwave/PluginManager.h b/libkwave/PluginManager.h index 7d9306d2..3eac77f0 100644 --- a/libkwave/PluginManager.h +++ b/libkwave/PluginManager.h @@ -1,390 +1,391 @@ /*************************************************************************** PluginManager.h - manager class for kwave's plugins ------------------- begin : Sun Aug 27 2000 copyright : (C) 2000 by Thomas Eschenbacher email : Thomas.Eschenbacher@gmx.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 PLUGIN_MANAGER_H #define PLUGIN_MANAGER_H #include "config.h" #include #include #include #include #include #include #include #include #include "libkwave/InsertMode.h" #include "libkwave/Sample.h" #include "libkwave/ViewManager.h" class QLibrary; class QString; class QStringList; class KPluginFactory; namespace Kwave { class PlaybackController; class PlaybackDeviceFactory; class PlayBackParam; class Plugin; class PluginContext; class SampleSink; class SignalManager; class Writer; /** * Manages the loading, initializing, starting, running and closing * of the plugins of kwave. Each instance of a TopWidget creates a * new instance of the PluginManager to be independent from other * toplevel widgets. */ class Q_DECL_EXPORT PluginManager: public QObject { Q_OBJECT public: /** * Constructor. * @param parent reference to the toplevel widget (our parent) * @param signal_manager reference to a SignalManager */ PluginManager(QWidget *parent, Kwave::SignalManager &signal_manager); /** * Default destructor */ virtual ~PluginManager(); /** * Tries to load all plugins. If a pesistent plugin is found, * it will stay loaded in memory, all other (non-persistent) * plugins will be unloaded afterwards. This also filters out * all plugins that do not correctly load. * @internal used once by each toplevel window at startup + * @return true if at least one plugin was loaded, false if none */ - void loadAllPlugins(); + bool loadAllPlugins(); /** * Stops all currently running plugins */ void stopAllPlugins(); /** * Executes a plugin in the context of a given parent widget. * @param name the name of the plugin * @param params pointer to a parameter list * or null if defaults should be used * @return zero on success or negative error code */ int executePlugin(const QString &name, QStringList *params); /** * Returns true if there is no running plugin that blocks * a "close" operation. */ bool canClose(); /** Returns true if at least one plugin is currently running */ bool onePluginRunning(); /** * Waits until all currently running actions have completed. */ void sync(); /** * Loads a plugin, calls it's setup function and then closes * it again. The parameters will be loaded before the setup * and saved if the setup has not been aborted. * @param name the name of the plugin * @param params pointer to a parameter list * or null if defaults should be used * @retval 0 if succeeded and accepted * @retval 1 if canceled * @retval -1 if failed */ int setupPlugin(const QString &name, const QStringList ¶ms); /** * loads a plugin's default parameters from the user's * configuration file. If nothing is found in the config file, * the return value will be 0. If the current version number of * the plugin does not match the version number in the config file, * the return value will also be 0. * @param name the name of the plugin * @return list of strings */ QStringList defaultParams(const QString &name); /** * Returns the length of the current signal in samples. * If no signal is present the return value will be 0. */ sample_index_t signalLength(); /** * Returns the current sample rate in samples per second. * If no signal is present the return value will be 0. */ double signalRate(); /** * Returns the start of the selection. If nothing is currently * selected this will be the first sample (0). */ sample_index_t selectionStart(); /** * Returns the end of the selection. If nothing is currently * selected this will be the last sample (length-1). */ sample_index_t selectionEnd(); /** * Sets the current start and length of the selection to new values. * @param offset index of the first sample * @param length number of samples */ void selectRange(sample_index_t offset, sample_index_t length); /** * Opens a Kwave::MultiTrackSink for playback purposes. * @param tracks number of tracks * @param playback_params points to a class that holds all playback * parameters. If null, the default parameters * of the current signal will be used * @return a multitrack sink that receives the playback stream */ Kwave::SampleSink *openMultiTrackPlayback( unsigned int tracks, const Kwave::PlayBackParam *playback_params = Q_NULLPTR ); /** * Returns a reference to the current playback controller. This is * only needed for plugins doing playback. */ Kwave::PlaybackController &playbackController(); /** * assigns a new parent widget, to be used for messages * @param new_parent pointer to a QWidget */ inline void setParentWidget(QWidget *new_parent) { m_parent_widget = new_parent; } /** returns a pointer to the parent widget */ inline QPointer parentWidget() { return m_parent_widget; } /** returns a reference to our signal manager */ inline Kwave::SignalManager &signalManager() { return m_signal_manager; } /** * Insert a new signal view into this widget (or the upper/lower * dock area. * @param view the signal view, must not be a null pointer * @param controls a widget with controls, optionally, can be null */ void insertView(Kwave::SignalView *view, QWidget *controls); /** * registers a view manager, must only be called once! */ void registerViewManager(Kwave::ViewManager *view_manager); /** * Enqueues a command that will be processed threadsafe in the X11 * thread. */ void enqueueCommand(const QString &command); /** * Searches the standard KDE data directories for plugins (through * the KDE's standard search algorithm) and creates a map of * plugin names and file names. First it collects a list of * filenames and then filters it to sort out invalid entries. */ void searchPluginModules(); /** structure with information about a plugin */ typedef struct { QString m_name; /**< name of the plugin */ QString m_author; /**< name of the author */ QString m_description; /**< short description */ QString m_version; /**< settings version */ KPluginFactory *m_factory; /**< plugin factory */ int m_use_count; /**< usage counter */ } PluginModule; /** * returns a list with info of all known plugins * @todo rename to pluginModuleList */ const QList pluginInfoList() const; /** * Migrate a plugin to the currently active file context (which * might be different from the one that is currently executing * the plugin). The plugin will be removed from our lists and * inserted into the currently active plugin manager instance. * @param plugin the plugin to migrate */ void migratePluginToActiveContext(Kwave::Plugin *plugin); /** Let this instance be the active one */ void setActive() { m_active_instance = this; } signals: /** * Forwards commands to the parent TopWidget execute a command */ void sigCommand(const QString &command); /** * Informs all plugins and client windows that we close down */ void sigClosed(); /** * Informs the plugins that the name of the signal has changed. * This might be used to update the caption of a window. */ void sigSignalNameChanged(const QString &name); /** * informs about progress, e.g. for showing a message in * a splash screen or status bar. */ void sigProgress(const QString &message); public slots: /** * Notify all plugins that the signal or file is to be closed */ void signalClosed(); /** * Called if the name of the current signal has changed. This will be * forwarded to all plugins by emitting the signal sigSignalNameChanged. * @see sigSignalNameChanged() */ void setSignalName(const QString &name); private slots: /** * Will be connected to the plugin's "closed" signal. * @param p pointer to the plugin to be closed */ void pluginClosed(Kwave::Plugin *p); /** called when a plugin has started (running) it's worker thread */ void pluginStarted(Kwave::Plugin *p); /** called when a plugin has finished it's worker thread */ void pluginDone(Kwave::Plugin *p); private: /** typedef: QPointer to a Kwave::Plugin */ typedef QPointer KwavePluginPointer; /** typedef: list of pointers to kwave plugins */ typedef QList< KwavePluginPointer > PluginList; /** typedef: mutable iterator for PluginList */ typedef QMutableListIterator< KwavePluginPointer > PluginListMutableIterator; /** typedef: const iterator for PluginList */ typedef QListIterator< KwavePluginPointer > PluginListIterator; private: /** * Creates an instance of a plugin. * @param name the name of the plugin (filename) * @return pointer to the loaded plugin or zero if the * plugin was not found or invalid */ Kwave::Plugin *createPluginInstance(const QString &name); /** * Saves a plugin's default parameters to the user's configuration * file. The whole section in the configuration file will be deleted * before saving the new settings in order to wipe out invalid * entries and settings that belong to an older version. * @param name the name of the plugin * @param params a list of configuration strings */ void savePluginDefaults(const QString &name, QStringList ¶ms); /** connects all signals of and for a plugin */ void connectPlugin(Kwave::Plugin *plugin); /** connects all signals from and to a plugin */ void disconnectPlugin(Kwave::Plugin *plugin); private: /** pointer to the currently active instance */ static Kwave::PluginManager *m_active_instance; /** * map with plugin information: key = short name of the plugin, * data = plugin info (description, author, version etc...) */ static QMap m_plugin_modules; /** list of all plugins that were loaded by this instance */ PluginList m_plugin_instances; /** list of currently running plugins */ PluginList m_running_plugins; /** reference to our parent toplevel widget */ QPointer m_parent_widget; /** reference to our signal manager */ Kwave::SignalManager &m_signal_manager; /** interface for registering a SignalView */ ViewManager *m_view_manager; }; } #endif /* PLUGIN_MANAGER_H */ //*************************************************************************** //***************************************************************************