├── .clang-format ├── .crowdin.yml ├── .github └── README.md ├── .gitignore ├── .gitlab-ci.yml ├── .kde-ci.yml ├── CMakeLists.txt ├── ChangeLog ├── LICENSE ├── LICENSES ├── BSD-3-Clause.txt └── GPL-2.0-or-later.txt ├── Messages.sh ├── README.CodingStyle.md ├── README.md ├── cmake ├── FindFFmpeg.cmake ├── FindICU.cmake └── FindPocketSphinx.cmake ├── doc ├── CMakeLists.txt └── en │ └── CMakeLists.txt ├── logo.png ├── pkg ├── flatpak │ ├── deps │ │ ├── amf-headers │ │ │ └── amf-headers.json │ │ ├── avisynthplus │ │ │ └── avisynthplus.json │ │ ├── ffmpeg │ │ │ ├── TODO.md │ │ │ ├── ffmpeg-minimal.json │ │ │ └── ffmpeg.json │ │ ├── ffnvcodec-headers │ │ │ └── ffnvcodec-headers.json │ │ ├── gsm │ │ │ ├── gsm-shared_lib.patch │ │ │ ├── gsm.json │ │ │ ├── lib32-gsm.json │ │ │ └── sources.json │ │ ├── libass │ │ │ └── libass.json │ │ ├── libiec61883 │ │ │ ├── libiec61883.json │ │ │ └── libraw1394 │ │ │ │ └── libraw1394.json │ │ ├── libmodplug │ │ │ └── libmodplug.json │ │ ├── libsoxr │ │ │ └── libsoxr.json │ │ ├── libssh │ │ │ ├── cmocka │ │ │ │ └── cmocka.json │ │ │ └── libssh.json │ │ ├── opencore-amr │ │ │ └── opencore-amr.json │ │ ├── pipewire │ │ │ ├── pipewire-0.2.json │ │ │ ├── pipewire-jack-runtime.json │ │ │ ├── pipewire-jack-runtime.pc │ │ │ └── pipewire.json │ │ ├── pocketsphinx │ │ │ └── pocketsphinx.json │ │ ├── sphinxbase │ │ │ └── sphinxbase.json │ │ ├── srt │ │ │ └── srt.json │ │ ├── svt-av1 │ │ │ └── svt-av1.json │ │ ├── v4l-utils │ │ │ ├── libv4l.json │ │ │ └── v4l-utils.json │ │ ├── vid.stab │ │ │ └── vid.stab.json │ │ ├── vmaf │ │ │ └── vmaf.json │ │ ├── x264 │ │ │ └── x264.json │ │ ├── x265 │ │ │ └── x265.json │ │ ├── xvidcore │ │ │ └── xvidcore.json │ │ └── zimg │ │ │ └── zimg.json │ ├── org.kde.subtitlecomposer-nightly.json │ └── org.kde.subtitlecomposer-stable.json ├── i18n │ ├── .gitignore │ └── fetch.sh ├── mingw │ ├── .gitignore │ ├── build.sh │ ├── deps-find.sh │ ├── docker-build.sh │ ├── github-upload-release.sh │ ├── installer.nsi │ ├── nsi-installer.sh │ ├── obs-win-release.sh │ └── setup-pacserve.sh └── misc │ ├── .gitignore │ ├── appimage.yml │ ├── build-deps.sh │ ├── copyright.sh │ ├── github-release.sh │ ├── obs-appimage-git-test.sh │ ├── setup-ubuntu-travis.sh │ ├── subtitlecomposer.sh │ ├── ubuntu-travis.sh │ └── uncrustify.cfg ├── po ├── ar │ └── subtitlecomposer.po ├── bg │ └── subtitlecomposer.po ├── ca │ └── subtitlecomposer.po ├── ca@valencia │ └── subtitlecomposer.po ├── cs │ └── subtitlecomposer.po ├── de │ └── subtitlecomposer.po ├── el │ └── subtitlecomposer.po ├── en_GB │ └── subtitlecomposer.po ├── eo │ └── subtitlecomposer.po ├── es │ └── subtitlecomposer.po ├── et │ └── subtitlecomposer.po ├── fi │ └── subtitlecomposer.po ├── fr │ └── subtitlecomposer.po ├── gl │ └── subtitlecomposer.po ├── hr │ └── subtitlecomposer.po ├── hu │ └── subtitlecomposer.po ├── ie │ └── subtitlecomposer.po ├── it │ └── subtitlecomposer.po ├── ja │ └── subtitlecomposer.po ├── ka │ └── subtitlecomposer.po ├── lt │ └── subtitlecomposer.po ├── nl │ └── subtitlecomposer.po ├── pl │ └── subtitlecomposer.po ├── pt │ └── subtitlecomposer.po ├── pt_BR │ └── subtitlecomposer.po ├── ru │ └── subtitlecomposer.po ├── sk │ └── subtitlecomposer.po ├── sl │ └── subtitlecomposer.po ├── sr │ └── subtitlecomposer.po ├── sr@latin │ └── subtitlecomposer.po ├── sv │ └── subtitlecomposer.po ├── tr │ └── subtitlecomposer.po ├── uk │ └── subtitlecomposer.po ├── zh_CN │ └── subtitlecomposer.po └── zh_TW │ └── subtitlecomposer.po ├── snapcraft.yaml └── src ├── CMakeLists.txt ├── actions ├── kcodecactionext.cpp ├── kcodecactionext.h ├── krecentfilesactionext.cpp ├── krecentfilesactionext.h ├── useraction.cpp ├── useraction.h └── useractionnames.h ├── appglobal.cpp ├── appglobal.h ├── application.cpp ├── application.h ├── application_actions.cpp ├── application_errorcheck.cpp ├── application_subtitle.cpp ├── config.h.cmake ├── configs ├── configdialog.cpp ├── configdialog.h ├── errorsconfigwidget.cpp ├── errorsconfigwidget.h ├── errorsconfigwidget.ui ├── generalconfigwidget.cpp ├── generalconfigwidget.h ├── generalconfigwidget.ui ├── playerconfigwidget.cpp ├── playerconfigwidget.h ├── playerconfigwidget.ui ├── waveformconfigwidget.cpp ├── waveformconfigwidget.h └── waveformconfigwidget.ui ├── core ├── formatdata.h ├── range.h ├── rangelist.h ├── richstring.cpp ├── richstring.h ├── richtext │ ├── richcss.cpp │ ├── richcss.h │ ├── richdocument.cpp │ ├── richdocument.h │ ├── richdocumenteditor.cpp │ ├── richdocumenteditor.h │ ├── richdocumentlayout.cpp │ ├── richdocumentlayout.h │ ├── richdom.cpp │ └── richdom.h ├── subtitle.cpp ├── subtitle.h ├── subtitleiterator.cpp ├── subtitleiterator.h ├── subtitleline.cpp ├── subtitleline.h ├── subtitletarget.h ├── time.cpp ├── time.h └── undo │ ├── subtitleactions.cpp │ ├── subtitleactions.h │ ├── subtitlelineactions.cpp │ ├── subtitlelineactions.h │ ├── undoaction.cpp │ ├── undoaction.h │ ├── undostack.cpp │ └── undostack.h ├── dialogs ├── actiondialog.cpp ├── actiondialog.h ├── actionwithtargetdialog.cpp ├── actionwithtargetdialog.h ├── adjusttimesdialog.cpp ├── adjusttimesdialog.h ├── autodurationsdialog.cpp ├── autodurationsdialog.h ├── changeframeratedialog.cpp ├── changeframeratedialog.h ├── changetextscasedialog.cpp ├── changetextscasedialog.h ├── durationlimitsdialog.cpp ├── durationlimitsdialog.h ├── encodingdetectdialog.cpp ├── encodingdetectdialog.h ├── encodingdetectdialog.ui ├── fixoverlappingtimesdialog.cpp ├── fixoverlappingtimesdialog.h ├── fixpunctuationdialog.cpp ├── fixpunctuationdialog.h ├── insertlinedialog.cpp ├── insertlinedialog.h ├── intinputdialog.cpp ├── intinputdialog.h ├── intinputdialog.ui ├── joinsubtitlesdialog.cpp ├── joinsubtitlesdialog.h ├── progressdialog.cpp ├── progressdialog.h ├── removelinesdialog.cpp ├── removelinesdialog.h ├── selectablesubtitledialog.cpp ├── selectablesubtitledialog.h ├── shifttimesdialog.cpp ├── shifttimesdialog.h ├── smarttextsadjustdialog.cpp ├── smarttextsadjustdialog.h ├── splitsubtitledialog.cpp ├── splitsubtitledialog.h ├── subtitleclassdialog.cpp ├── subtitleclassdialog.h ├── subtitleclassdialog.ui ├── subtitlecolordialog.cpp ├── subtitlecolordialog.h ├── subtitlevoicedialog.cpp ├── subtitlevoicedialog.h ├── subtitlevoicedialog.ui ├── syncsubtitlesdialog.cpp ├── syncsubtitlesdialog.h ├── textinputdialog.cpp ├── textinputdialog.h └── textinputdialog.ui ├── errors ├── errorfinder.cpp ├── errorfinder.h ├── errortracker.cpp ├── errortracker.h ├── finderrorsdialog.cpp └── finderrorsdialog.h ├── formats ├── format.h ├── formatmanager.cpp ├── formatmanager.h ├── inputformat.h ├── microdvd │ ├── microdvdinputformat.h │ └── microdvdoutputformat.h ├── mplayer │ ├── mplayerinputformat.h │ └── mplayeroutputformat.h ├── mplayer2 │ ├── mplayer2inputformat.h │ └── mplayer2outputformat.h ├── outputformat.h ├── subrip │ ├── subripinputformat.h │ └── subripoutputformat.h ├── substationalpha │ ├── substationalphainputformat.h │ └── substationalphaoutputformat.h ├── subviewer1 │ ├── subviewer1inputformat.h │ └── subviewer1outputformat.h ├── subviewer2 │ ├── subviewer2inputformat.h │ └── subviewer2outputformat.h ├── textdemux │ ├── textdemux.cpp │ └── textdemux.h ├── tmplayer │ ├── tmplayerinputformat.h │ └── tmplayeroutputformat.h ├── vobsub │ ├── vobsubinputformat.h │ ├── vobsubinputinitdialog.cpp │ ├── vobsubinputinitdialog.h │ ├── vobsubinputinitdialog.ui │ ├── vobsubinputprocessdialog.cpp │ ├── vobsubinputprocessdialog.h │ └── vobsubinputprocessdialog.ui ├── webvtt │ ├── webvttinputformat.cpp │ ├── webvttinputformat.h │ ├── webvttoutputformat.cpp │ └── webvttoutputformat.h └── youtubecaptions │ ├── youtubecaptionsinputformat.h │ └── youtubecaptionsoutputformat.h ├── gui ├── currentlinewidget.cpp ├── currentlinewidget.h ├── playerwidget.cpp ├── playerwidget.h ├── subtitlemeta │ ├── csshighlighter.cpp │ ├── csshighlighter.h │ ├── subtitlemetawidget.cpp │ ├── subtitlemetawidget.h │ ├── subtitlepositionwidget.cpp │ ├── subtitlepositionwidget.h │ └── subtitlepositionwidget.ui ├── treeview │ ├── linesitemdelegate.cpp │ ├── linesitemdelegate.h │ ├── linesmodel.cpp │ ├── linesmodel.h │ ├── linesselectionmodel.cpp │ ├── linesselectionmodel.h │ ├── lineswidget.cpp │ ├── lineswidget.h │ ├── richdocumentptr.cpp │ ├── richdocumentptr.h │ ├── richlineedit.cpp │ ├── richlineedit.h │ ├── treeview.cpp │ └── treeview.h └── waveform │ ├── wavebuffer.cpp │ ├── wavebuffer.h │ ├── waveformwidget.cpp │ ├── waveformwidget.h │ ├── waverenderer.cpp │ ├── waverenderer.h │ ├── wavesubtitle.cpp │ ├── wavesubtitle.h │ ├── zoombuffer.cpp │ └── zoombuffer.h ├── helpers ├── common.h ├── commondefs.cpp ├── commondefs.h ├── debug.cpp ├── debug.h ├── languagecode.cpp ├── languagecode.h ├── objectref.h └── pluginhelper.h ├── icons ├── 128-apps-subtitlecomposer.png ├── 16-apps-subtitlecomposer.png ├── 256-apps-subtitlecomposer.png ├── 32-apps-subtitlecomposer.png ├── 48-apps-subtitlecomposer.png ├── CMakeLists.txt ├── README ├── actions │ ├── anchor.svg │ ├── audio-extract.png │ ├── curline-follows-video.svg │ ├── playrate-minus.svg │ ├── playrate-plus.svg │ ├── select-stream.png │ ├── set-hide-time.svg │ ├── set-show-time.svg │ ├── time-from-video.png │ └── waveform.png ├── apps │ ├── mediaplayer.png │ └── pocketsphinx.png ├── breeze.theme ├── icon-bundle.qrc ├── mingw-icon.sh ├── subtitlecomposer.ico ├── subtitlecomposer.rc └── theme-icons-bundle.sh ├── main.cpp ├── main_tests.h ├── mainwindow.cpp ├── mainwindow.h ├── org.kde.subtitlecomposer.appdata.xml ├── org.kde.subtitlecomposer.desktop ├── scconfig.kcfg ├── scconfig.kcfgc ├── scripting ├── CMakeLists.txt ├── examples │ ├── README │ ├── example_capitalize_all_lines.js │ ├── example_iterate_selection.js │ ├── example_remove_odd_lines.js │ ├── example_trim_to_selection.js │ └── remove_hearing_impaired_text.js ├── scripting_list.cpp ├── scripting_list.h ├── scripting_range.cpp ├── scripting_range.h ├── scripting_rangelist.cpp ├── scripting_rangelist.h ├── scripting_rangesmodule.cpp ├── scripting_rangesmodule.h ├── scripting_richstring.cpp ├── scripting_richstring.h ├── scripting_stringsmodule.cpp ├── scripting_stringsmodule.h ├── scripting_subtitle.cpp ├── scripting_subtitle.h ├── scripting_subtitleline.cpp ├── scripting_subtitleline.h ├── scripting_subtitlelinemodule.cpp ├── scripting_subtitlelinemodule.h ├── scripting_subtitlemodule.cpp ├── scripting_subtitlemodule.h ├── scriptsmanager.cpp ├── scriptsmanager.h └── scriptsmanager.ui ├── speechplugins └── pocketsphinx │ ├── CMakeLists.txt │ ├── plugin-config.h.cmake │ ├── pocketsphinxconfig.kcfg │ ├── pocketsphinxconfig.kcfgc │ ├── pocketsphinxconfigwidget.cpp │ ├── pocketsphinxconfigwidget.h │ ├── pocketsphinxconfigwidget.ui │ ├── pocketsphinxplugin.cpp │ └── pocketsphinxplugin.h ├── speechprocessor ├── speechplugin.cpp ├── speechplugin.h ├── speechprocessor.cpp └── speechprocessor.h ├── streamprocessor ├── streamprocessor.cpp └── streamprocessor.h ├── subtitlecomposer.qrc ├── subtitlecomposer.xml ├── subtitlecomposerrc ├── subtitlecomposerui.rc ├── tests ├── CMakeLists.txt ├── rangelisttest.cpp ├── rangelisttest.h ├── rangetest.cpp ├── rangetest.h ├── richcsstest.cpp ├── richcsstest.h ├── richdocumentlayouttest.cpp ├── richdocumentlayouttest.h ├── richdocumenttest.cpp ├── richdocumenttest.h ├── richstringtest.cpp ├── richstringtest.h ├── subtitletest.cpp ├── subtitletest.h ├── timetest.cpp └── timetest.h ├── translate ├── deeplengine.cpp ├── deeplengine.h ├── deeplengine.ui ├── googlecloudengine.cpp ├── googlecloudengine.h ├── googlecloudengine.ui ├── mintengine.cpp ├── mintengine.h ├── mintengine.ui ├── translatedialog.cpp ├── translatedialog.h ├── translateengine.cpp └── translateengine.h ├── utils ├── finder.cpp ├── finder.h ├── replacer.cpp ├── replacer.h ├── speller.cpp └── speller.h ├── videoplayer ├── backend │ ├── audiodecoder.cpp │ ├── audiodecoder.h │ ├── clock.cpp │ ├── clock.h │ ├── decoder.cpp │ ├── decoder.h │ ├── ffplayer.cpp │ ├── ffplayer.h │ ├── framequeue.cpp │ ├── framequeue.h │ ├── glcolorspace.h │ ├── glcolorspace.js │ ├── glrenderer.cpp │ ├── glrenderer.h │ ├── packetqueue.cpp │ ├── packetqueue.h │ ├── renderthread.cpp │ ├── renderthread.h │ ├── streamdemuxer.cpp │ ├── streamdemuxer.h │ ├── subtitledecoder.cpp │ ├── subtitledecoder.h │ ├── videodecoder.cpp │ ├── videodecoder.h │ ├── videostate.cpp │ └── videostate.h ├── subtitletextoverlay.cpp ├── subtitletextoverlay.h ├── videoplayer.cpp ├── videoplayer.h ├── videowidget.cpp ├── videowidget.h └── waveformat.h └── widgets ├── attachablewidget.cpp ├── attachablewidget.h ├── layeredwidget.cpp ├── layeredwidget.h ├── pointingslider.cpp ├── pointingslider.h ├── simplerichtextedit.cpp ├── simplerichtextedit.h ├── textoverlaywidget.cpp ├── textoverlaywidget.h ├── timeedit.cpp └── timeedit.h /.crowdin.yml: -------------------------------------------------------------------------------- 1 | commit_message: Updated %language% translations from Crowdin 2 | append_commit_message: false 3 | files: 4 | - source: /po/*.pot 5 | translation: /po/%two_letters_code%/%file_name%.po 6 | languages_mapping: 7 | two_letters_code: 8 | sr-CS: sr@latin 9 | pt-BR: pt_BR 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the following files 2 | CMakeCache.txt 3 | CMakeFiles 4 | *.user 5 | Makefile 6 | /build*/ 7 | /compile_commands.json 8 | cmake_install.cmake 9 | install_manifest.txt 10 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | # KDE jobs 5 | include: 6 | - project: sysadmin/ci-utilities 7 | rules: 8 | - if: $CI_SERVER_HOST =~ /kde\.org$/ 9 | file: 10 | - /gitlab-templates/linux.yml 11 | - /gitlab-templates/freebsd.yml 12 | - /gitlab-templates/windows.yml 13 | - /gitlab-templates/linux-qt6.yml 14 | - /gitlab-templates/freebsd-qt6.yml 15 | 16 | # Gitlab jobs 17 | mingw-win32-build: 18 | stage: build 19 | image: maxrd2/arch-mingw 20 | only: 21 | - /^obs/.*/ 22 | - $CI_SERVER_HOST =~ /gitlab\.com$/ 23 | script: 24 | - |- 25 | git="git -C $CI_PROJECT_DIR" 26 | $git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' 27 | $git fetch origin --depth=200 28 | gitver="$($git describe --always --tags --abbrev=10 "${CI_COMMIT_SHA}")" 29 | echo "SubtitleComposer $gitver" > $CI_PROJECT_DIR/version.txt 30 | - pkg/mingw/build.sh 31 | # gitlab artifact paths are relative to CI_PROJECT_DIR 32 | - mv /home/devel/build/SubtitleComposerSetup.exe $CI_PROJECT_DIR 33 | artifacts: 34 | paths: 35 | - SubtitleComposerSetup.exe 36 | - version.txt 37 | -------------------------------------------------------------------------------- /.kde-ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | Dependencies: 5 | - 'on': ['Linux/Qt5', 'FreeBSD/Qt5', 'Windows/Qt5'] 6 | 'require': 7 | 'frameworks/extra-cmake-modules': '@stable' 8 | 'frameworks/kconfig': '@stable' 9 | 'frameworks/kconfigwidgets': '@stable' 10 | 'frameworks/kcoreaddons': '@stable' 11 | 'frameworks/ki18n': '@stable' 12 | 'frameworks/kio': '@stable' 13 | 'frameworks/kxmlgui': '@stable' 14 | 'frameworks/sonnet': '@stable' 15 | 'frameworks/kcodecs': '@stable' 16 | 'frameworks/ktextwidgets': '@stable' 17 | 'frameworks/kwidgetsaddons': '@stable' 18 | 'frameworks/breeze-icons': '@stable' 19 | 20 | - 'on': ['Linux/Qt6', 'FreeBSD/Qt6'] 21 | 'require': 22 | 'frameworks/extra-cmake-modules': '@latest-kf6' 23 | 'frameworks/kconfig': '@latest-kf6' 24 | 'frameworks/kconfigwidgets': '@latest-kf6' 25 | 'frameworks/kcoreaddons': '@latest-kf6' 26 | 'frameworks/ki18n': '@latest-kf6' 27 | 'frameworks/kio': '@latest-kf6' 28 | 'frameworks/kxmlgui': '@latest-kf6' 29 | 'frameworks/sonnet': '@latest-kf6' 30 | 'frameworks/kcodecs': '@latest-kf6' 31 | 'frameworks/ktextwidgets': '@latest-kf6' 32 | 'frameworks/kwidgetsaddons': '@latest-kf6' 33 | 'frameworks/breeze-icons': '@latest-kf6' 34 | 35 | Options: 36 | require-passing-tests-on: [ 'Linux', 'FreeBSD' ] 37 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16 FATAL_ERROR) 2 | 3 | project(subtitlecomposer VERSION "0.8.1") 4 | 5 | if(QT_MAJOR_VERSION EQUAL 6) 6 | set(QT_EXTRA_COMPONENTS OpenGLWidgets Core5Compat) 7 | set(QT_MIN_VERSION "6.0.0") 8 | set(KF_MAJOR_VERSION "6") 9 | set(KF_MIN_VERSION "5.240.0") 10 | else() 11 | set(QT_EXTRA_COMPONENTS) 12 | set(QT_MAJOR_VERSION 5) 13 | set(QT_MIN_VERSION "5.9.0") 14 | set(KF_MAJOR_VERSION "5") 15 | set(KF_MIN_VERSION "5.44.0") 16 | endif() 17 | 18 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 19 | set(CMAKE_CXX_STANDARD 17) 20 | 21 | find_package(ECM REQUIRED NO_MODULE) 22 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 23 | 24 | include(KDEInstallDirs) 25 | include(KDECMakeSettings) 26 | include(KDECompilerSettings NO_POLICY_SCOPE) 27 | 28 | include(ECMInstallIcons) 29 | include(ECMSetupVersion) 30 | include(ECMAddTests) # build tests 31 | 32 | include(FeatureSummary) 33 | 34 | find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS 35 | Core Widgets Gui Test Qml ${QT_EXTRA_COMPONENTS}) 36 | 37 | find_package(KF${KF_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS 38 | Config ConfigWidgets CoreAddons I18n KIO XmlGui 39 | Sonnet Codecs TextWidgets WidgetsAddons) 40 | 41 | find_package(OpenSSL REQUIRED) 42 | 43 | #PO_SUBDIR 44 | add_subdirectory(src) 45 | 46 | add_custom_target(nsis COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/pkg/mingw/nsi-installer.sh" `${CMAKE_C_COMPILER} -dumpmachine`) 47 | 48 | ki18n_install(po) 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LICENSES/GPL-2.0-or-later.txt -------------------------------------------------------------------------------- /LICENSES/BSD-3-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) . All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /Messages.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | $EXTRACTRC `find src -name '*ui.rc' -o -name '*.ui' -o -name '*.kcfg'` >> rc.cpp 3 | $XGETTEXT rc.cpp `find src -name '*.cpp' -o -name '*.h' -o -name '*.c'` -o $podir/subtitlecomposer.pot 4 | -------------------------------------------------------------------------------- /cmake/FindICU.cmake: -------------------------------------------------------------------------------- 1 | # Tries to find ICU library 2 | # Once done this will define 3 | # 4 | # ICU_FOUND - System has ICU library 5 | # ICU_VERSION - ICU library version 6 | # ICU_LIBRARIES - Link these to use ICU library 7 | # ICU_INCLUDE_DIRS - ICU library include dirs 8 | # ICU_DEFINITIONS - compiler switches required for using ICU library 9 | 10 | # SPDX-FileCopyrightText: 2010-2019 Mladen Milinkovic 11 | # SPDX-License-Identifier: BSD-3-Clause 12 | 13 | find_package(PkgConfig REQUIRED) 14 | 15 | pkg_check_modules(PC_ICU QUIET icu-i18n) 16 | 17 | find_path(ICU_INCLUDE_DIRS 18 | unicode/utypes.h 19 | HINTS ${PC_ICU_INCLUDEDIR} ${PC_ICU_INCLUDE_DIRS} 20 | DOC "Include directory for the ICU library") 21 | set(_required_vars ICU_INCLUDE_DIRS) 22 | 23 | foreach(_lib ${PC_ICU_LIBRARIES}) 24 | find_library(_lib_${_lib} 25 | NAMES ${_lib} 26 | HINTS ${PC_ICU_LIBDIR} ${PC_ICU_LIBRARY_DIRS}) 27 | list(APPEND ICU_LIBRARIES ${_lib_${_lib}}) 28 | list(APPEND _required_vars _lib_${_lib}) 29 | endforeach() 30 | 31 | set(_message "\n\tincludes: ${ICU_INCLUDE_DIRS}\n\tlibs: ${ICU_LIBRARIES}\n\t") 32 | 33 | include(FindPackageHandleStandardArgs) 34 | # handle the QUIETLY and REQUIRED arguments and set FFMPEG_FOUND to TRUE if all listed variables are TRUE 35 | find_package_handle_standard_args(ICU 36 | REQUIRED_VARS _message ${_required_vars} 37 | VERSION_VAR PC_ICU_VERSION) 38 | 39 | if(ICU_FOUND) 40 | set(ICU_DEFINITIONS -D_REENTRANT) 41 | endif() 42 | 43 | mark_as_advanced(ICU_INCLUDE_DIRS ICU_LIBRARIES ICU_DEFINITIONS) 44 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${QT_INCLUDES}) 2 | 3 | kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en) 4 | 5 | add_subdirectory(en) 6 | -------------------------------------------------------------------------------- /doc/en/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${QT_INCLUDES}) 2 | 3 | kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en) 4 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/logo.png -------------------------------------------------------------------------------- /pkg/flatpak/deps/amf-headers/amf-headers.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "amf-headers", 3 | "buildsystem": "simple", 4 | "build-commands": [ 5 | "install -dm755 ${FLATPAK_DEST}/include/", 6 | "cp --recursive --no-dereference --preserve=links --no-preserve=ownership amf/public/include ${FLATPAK_DEST}/include/AMF" 7 | ], 8 | "sources": [ 9 | { 10 | "type": "archive", 11 | "url": "https://github.com/GPUOpen-LibrariesAndSDKs/AMF/archive/v1.4.26/AMF-1.4.26.tar.gz", 12 | "sha256": "fe8b8f370710b159a92d75eee8a8ea557f0a6ca7d6c0436eb44db31cec06b9b7", 13 | "x-checker-data": { 14 | "type": "anitya", 15 | "project-id": 138182, 16 | "stable-only": true, 17 | "versions": { 18 | ">": "1.4.21" 19 | }, 20 | "url-template": "https://github.com/GPUOpen-LibrariesAndSDKs/AMF/archive/v$version/AMF-$version.tar.gz" 21 | } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/avisynthplus/avisynthplus.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "avisynthplus", 3 | "builddir": true, 4 | "buildsystem": "cmake", 5 | "config-opts": [ 6 | "-DCMAKE_BUILD_TYPE:STRING='None'", 7 | "-Wno-dev" 8 | ], 9 | "sources": [ 10 | { 11 | "type": "archive", 12 | "url": "https://github.com/AviSynth/AviSynthPlus/archive/v3.7.2/avisynthplus-3.7.2.tar.gz", 13 | "sha256": "6159fd976dffa62d5db5277cbb0b3b7f7a4ee92fc8667edd32da9840a669ccc1", 14 | "x-checker-data": { 15 | "type": "anitya", 16 | "project-id": 236294, 17 | "stable-only": true, 18 | "versions": { 19 | ">": "3.7.0" 20 | }, 21 | "url-template": "https://github.com/AviSynth/AviSynthPlus/archive/v$version/avisynthplus-$version.tar.gz" 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/ffmpeg/TODO.md: -------------------------------------------------------------------------------- 1 | # ffmpeg TODO 2 | 3 | * [ ] Consider enabling these features: 4 | * [libplacebo filter](https://github.com/FFmpeg/FFmpeg/commit/51e03409d74f3eb265cd4e562819daffb3645cb0) 5 | * [librist protocol](https://github.com/FFmpeg/FFmpeg/commit/4098f809d605fc540870883a9f91880e13ce1d6b) 6 | * [ ] fix x265 f-e-d-c 7 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/ffmpeg/ffmpeg-minimal.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ffmpeg-minimal", 3 | "config-opts": [ 4 | "--enable-gpl", 5 | "--enable-version3", 6 | "--disable-static", 7 | "--enable-shared", 8 | "--disable-doc", 9 | "--enable-postproc", 10 | "--enable-pthreads", 11 | "--enable-gnutls", 12 | "--enable-libdav1d", 13 | "--enable-libfontconfig", 14 | "--enable-libfreetype", 15 | "--enable-libfribidi", 16 | "--enable-libjack", 17 | "--enable-libopenjpeg", 18 | "--enable-libopus", 19 | "--enable-libpulse", 20 | "--enable-librsvg", 21 | "--enable-libspeex", 22 | "--enable-libv4l2", 23 | "--enable-libx264", 24 | "--enable-libx265", 25 | "--enable-libxml2", 26 | "--disable-libmfx", 27 | "--enable-lto", 28 | "--disable-debug", 29 | "--disable-stripping" 30 | ], 31 | "sources": [ 32 | { 33 | "type": "archive", 34 | "url": "https://ffmpeg.org/releases/ffmpeg-5.0.tar.xz", 35 | "sha256": "51e919f7d205062c0fd4fae6243a84850391115104ccf1efc451733bc0ac7298", 36 | "x-checker-data": { 37 | "type": "anitya", 38 | "project-id": 5405, 39 | "stable-only": true, 40 | "url-template": "https://ffmpeg.org/releases/ffmpeg-$version.tar.xz" 41 | } 42 | } 43 | ], 44 | "cleanup": [ 45 | "/share/ffmpeg/examples" 46 | ], 47 | "modules": [ 48 | "../pipewire/pipewire-jack-runtime.json", 49 | "ffnvcodec-headers/ffnvcodec-headers.json", 50 | "v4l-utils/libv4l.json", 51 | "x264/x264.json", 52 | "x265/x265.json" 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/ffnvcodec-headers/ffnvcodec-headers.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ffnvcodec-headers", 3 | "no-autogen": true, 4 | "make-install-args": [ 5 | "PREFIX=${FLATPAK_DEST}" 6 | ], 7 | "sources": [ 8 | { 9 | "type": "git", 10 | "url": "https://git.videolan.org/git/ffmpeg/nv-codec-headers.git", 11 | "tag": "n11.1.5.2", 12 | "commit": "f8ae7a49bfef2f99d2c931a791dc3863fda67bf3", 13 | "x-checker-data": { 14 | "type": "anitya", 15 | "project-id": 223796, 16 | "stable-only": true, 17 | "tag-template": "n$version" 18 | } 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/gsm/gsm.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gsm", 3 | "no-autogen": true, 4 | "build-commands": [ 5 | "install -dm755 ${FLATPAK_DEST}/{include,lib,man/man{1,3}}" 6 | ], 7 | "make-install-args": [ 8 | "-j1", 9 | "INSTALL_ROOT=${FLATPAK_DEST}", 10 | "GSM_INSTALL_INC=${FLATPAK_DEST}/include" 11 | ], 12 | "sources": [ 13 | "sources.json" 14 | ], 15 | "cleanup": [ 16 | "/bin", 17 | "/man" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/gsm/lib32-gsm.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lib32-gsm", 3 | "build-options": { 4 | "arch": { 5 | "x86_64": { 6 | "prepend-pkg-config-path": "/app/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig", 7 | "ldflags": "-L/app/lib32", 8 | "prepend-path": "/usr/lib/sdk/toolchain-i386/bin", 9 | "env": { 10 | "CC": "i686-unknown-linux-gnu-gcc", 11 | "CXX": "i686-unknown-linux-gnu-g++" 12 | }, 13 | "libdir": "/app/lib32" 14 | } 15 | } 16 | }, 17 | "no-autogen": true, 18 | "build-commands": [ 19 | "install -dm755 ${FLATPAK_DEST}/{include,lib32,man/man{1,3}}" 20 | ], 21 | "make-install-args": [ 22 | "-j1", 23 | "INSTALL_ROOT=${FLATPAK_DEST}", 24 | "GSM_INSTALL_INC=${FLATPAK_DEST}/include", 25 | "GSM_INSTALL_LIB=${FLATPAK_DEST}/lib32" 26 | ], 27 | "sources": [ 28 | "sources.json" 29 | ], 30 | "cleanup": [ 31 | "/bin", 32 | "/man" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/gsm/sources.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "archive", 4 | "url": "http://www.quut.com/gsm/gsm-1.0.22.tar.gz", 5 | "sha256": "f0072e91f6bb85a878b2f6dbf4a0b7c850c4deb8049d554c65340b3bf69df0ac", 6 | "x-checker-data": { 7 | "type": "anitya", 8 | "project-id": 12587, 9 | "stable-only": true, 10 | "url-template": "http://www.quut.com/gsm/gsm-$version.tar.gz" 11 | } 12 | }, 13 | { 14 | "type": "patch", 15 | "path": "gsm-shared_lib.patch" 16 | }, 17 | { 18 | "type": "shell", 19 | "commands": [ 20 | "sed -i '/^CC.*= gcc/d' Makefile", 21 | "sed -i 's/^\\(CCFLAGS .*\\)/\\1 -fPIC/' Makefile", 22 | "install -dm755 ${FLATPAK_DEST}/{bin,include,lib32}" 23 | ] 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/libass/libass.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libass", 3 | "sources": [ 4 | { 5 | "type": "archive", 6 | "url": "https://github.com/libass/libass/releases/download/0.16.0/libass-0.16.0.tar.xz", 7 | "sha256": "5dbde9e22339119cf8eed59eea6c623a0746ef5a90b689e68a090109078e3c08", 8 | "x-checker-data": { 9 | "type": "anitya", 10 | "project-id": 1560, 11 | "stable-only": true, 12 | "url-template": "https://github.com/libass/libass/releases/download/$version/libass-$version.tar.xz" 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/libiec61883/libiec61883.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libiec61883", 3 | "sources": [ 4 | { 5 | "type": "archive", 6 | "url": "https://www.kernel.org/pub/linux/libs/ieee1394/libiec61883-1.2.0.tar.xz", 7 | "sha256": "d1e02c7e276fac37313a2f8c1c33d7a9e19282ff16f32e72435428ff5121f09e", 8 | "x-checker-data": { 9 | "type": "anitya", 10 | "project-id": 1640, 11 | "stable-only": true, 12 | "url-template": "https://www.kernel.org/pub/linux/libs/ieee1394/libiec61883-$version.tar.xz" 13 | } 14 | } 15 | ], 16 | "modules": [ 17 | "libraw1394/libraw1394.json" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/libiec61883/libraw1394/libraw1394.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libraw1394", 3 | "sources": [ 4 | { 5 | "type": "archive", 6 | "url": "https://www.kernel.org/pub/linux/libs/ieee1394/libraw1394-2.1.2.tar.xz", 7 | "sha256": "03ccc69761d22c7deb1127fc301010dd13e70e44bb7134b8ff0d07590259a55e", 8 | "x-checker-data": { 9 | "type": "anitya", 10 | "project-id": 1710, 11 | "stable-only": true, 12 | "url-template": "https://www.kernel.org/pub/linux/libs/ieee1394/libraw1394-$version.tar.xz" 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/libmodplug/libmodplug.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libmodplug", 3 | "sources": [ 4 | { 5 | "type": "archive", 6 | "url": "https://downloads.sourceforge.net/modplug-xmms/libmodplug-0.8.9.0.tar.gz", 7 | "sha256": "457ca5a6c179656d66c01505c0d95fafaead4329b9dbaa0f997d00a3508ad9de", 8 | "x-checker-data": { 9 | "type": "anitya", 10 | "project-id": 5669, 11 | "stable-only": true, 12 | "url-template": "https://downloads.sourceforge.net/modplug-xmms/libmodplug-$version.tar.gz" 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/libsoxr/libsoxr.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libsoxr", 3 | "builddir": true, 4 | "buildsystem": "cmake", 5 | "config-opts": [ 6 | "-DCMAKE_BUILD_TYPE=Release", 7 | "-DBUILD_EXAMPLES=OFF", 8 | "-DBUILD_SHARED_LIBS=ON", 9 | "-DWITH_AVFFT=ON", 10 | "-DWITH_LSR_BINDINGS=ON", 11 | "-DWITH_OPENMP=ON", 12 | "-DWITH_PFFFT=ON" 13 | ], 14 | "sources": [ 15 | { 16 | "type": "archive", 17 | "url": "https://downloads.sourceforge.net/soxr/soxr-0.1.3-Source.tar.xz", 18 | "sha256": "b111c15fdc8c029989330ff559184198c161100a59312f5dc19ddeb9b5a15889", 19 | "x-checker-data": { 20 | "type": "anitya", 21 | "project-id": 4859, 22 | "stable-only": true, 23 | "url-template": "https://downloads.sourceforge.net/soxr/soxr-$version-Source.tar.xz" 24 | } 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/libssh/cmocka/cmocka.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cmocka", 3 | "builddir": true, 4 | "buildsystem": "cmake", 5 | "config-opts": [ 6 | "-DCMAKE_BUILD_TYPE=Release", 7 | "-DCMAKE_INSTALL_LIBDIR=lib", 8 | "-DUNIT_TESTING=OFF" 9 | ], 10 | "sources": [ 11 | { 12 | "type": "archive", 13 | "url": "https://cmocka.org/files/1.1/cmocka-1.1.5.tar.xz", 14 | "sha256": "f0ccd8242d55e2fd74b16ba518359151f6f8383ff8aef4976e48393f77bba8b6", 15 | "x-checker-data": { 16 | "type": "anitya", 17 | "project-id": 11779, 18 | "stable-only": true, 19 | "url-template": "https://cmocka.org/files/$version0.$version1/cmocka-$version.tar.xz" 20 | } 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/libssh/libssh.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libssh", 3 | "builddir": true, 4 | "buildsystem": "cmake", 5 | "config-opts": [ 6 | "-DWITH_GSSAPI=OFF", 7 | "-DUNIT_TESTING=OFF" 8 | ], 9 | "sources": [ 10 | { 11 | "type": "archive", 12 | "url": "https://www.libssh.org/files/0.10/libssh-0.10.4.tar.xz", 13 | "sha256": "07392c54ab61476288d1c1f0a7c557b50211797ad00c34c3af2bbc4dbc4bd97d", 14 | "x-checker-data": { 15 | "type": "anitya", 16 | "project-id": 1729, 17 | "stable-only": true, 18 | "url-template": "https://www.libssh.org/files/$version0.$version1/libssh-$version.tar.xz" 19 | } 20 | } 21 | ], 22 | "modules": [ 23 | "cmocka/cmocka.json" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/opencore-amr/opencore-amr.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "opencore-amr", 3 | "config-opts": [ 4 | "--disable-static", 5 | "--disable-examples" 6 | ], 7 | "sources": [ 8 | { 9 | "type": "archive", 10 | "url": "https://downloads.sourceforge.net/opencore-amr/opencore-amr-0.1.6.tar.gz", 11 | "sha256": "483eb4061088e2b34b358e47540b5d495a96cd468e361050fae615b1809dc4a1", 12 | "x-checker-data": { 13 | "type": "anitya", 14 | "project-id": 21548, 15 | "stable-only": true, 16 | "url-template": "https://downloads.sourceforge.net/opencore-amr/opencore-amr-$version.tar.gz" 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/pipewire/pipewire-0.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pipewire-0.2", 3 | "buildsystem": "meson", 4 | "config-opts": [ 5 | "-D docs=false", 6 | "-D gstreamer=disabled", 7 | "-D man=false", 8 | "-D systemd=false" 9 | ], 10 | "sources": [ 11 | { 12 | "type": "archive", 13 | "url": "https://github.com/PipeWire/pipewire/archive/0.2.7.tar.gz", 14 | "sha256": "bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1" 15 | } 16 | ], 17 | "cleanup": [ 18 | "/bin", 19 | "/etc", 20 | "/lib/gstreamer-1.0", 21 | "/lib/pipewire-0.2/libpipewire-module-audio-dsp.so", 22 | "/lib/pipewire-0.2/libpipewire-module-autolink.so", 23 | "/lib/pipewire-0.2/libpipewire-module-link-factory.so", 24 | "/lib/pipewire-0.2/libpipewire-module-mixer.so", 25 | "/lib/pipewire-0.2/libpipewire-module-portal.so", 26 | "/lib/pipewire-0.2/libpipewire-module-rtkit.so", 27 | "/lib/pipewire-0.2/libpipewire-module-spa-monitor.so", 28 | "/lib/pipewire-0.2/libpipewire-module-spa-node-factory.so", 29 | "/lib/pipewire-0.2/libpipewire-module-spa-node.so", 30 | "/lib/pipewire-0.2/libpipewire-module-suspend-on-idle.so", 31 | "/lib/spa/alsa", 32 | "/lib/spa/audiomixer", 33 | "/lib/spa/audiotestsrc", 34 | "/lib/spa/ffmpeg", 35 | "/lib/spa/test", 36 | "/lib/spa/v4l2", 37 | "/lib/spa/videotestsrc", 38 | "/lib/spa/volume" 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/pipewire/pipewire-jack-runtime.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pipewire-jack-runtime", 3 | "buildsystem": "simple", 4 | "build-commands": [ 5 | "install -Dm644 *.h -t ${FLATPAK_DEST}/include/jack/", 6 | "sed -i \"s|@@PREFIX@@|\"${FLATPAK_DEST}\"|;s|@@ARCH@@|\"${FLATPAK_ARCH}\"|\" pipewire-jack-runtime.pc", 7 | "_LIBDIR=${FLATPAK_DEST}/lib; [ ${FLATPAK_DEST} == '/usr' ] && _LIBDIR+=/${FLATPAK_ARCH}-linux-gnu; install -Dm644 pipewire-jack-runtime.pc ${_LIBDIR}/pkgconfig/jack.pc" 8 | ], 9 | "sources": [ 10 | { 11 | "type": "git", 12 | "url": "https://github.com/jackaudio/headers", 13 | "branch": "master", 14 | "commit": "2bfa5069718ca4f4dc091e0be845958f2d8a5ba8" 15 | }, 16 | { 17 | "type": "file", 18 | "path": "pipewire-jack-runtime.pc" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/pipewire/pipewire-jack-runtime.pc: -------------------------------------------------------------------------------- 1 | prefix=@@PREFIX@@ 2 | exec_prefix=${prefix} 3 | libdir=/usr/lib/@@ARCH@@-linux-gnu/pipewire-0.3/jack 4 | includedir=${prefix}/include 5 | server_libs=-L${libdir} -ljackserver 6 | 7 | Name: jack 8 | Description: the Jack Audio Connection Kit: a low-latency synchronous callback-based media server 9 | Version: 1.9.16 10 | Libs: -L${libdir} -ljack 11 | Cflags: -I${prefix}/include 12 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/pipewire/pipewire.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pipewire", 3 | "buildsystem": "meson", 4 | "config-opts": [ 5 | "-Ddocs=disabled", 6 | "-Dexamples=disabled", 7 | "-Dmedia-session=disabled", 8 | "-Dman=disabled", 9 | "-Dtests=disabled", 10 | "-Dgstreamer=disabled", 11 | "-Dsystemd=disabled", 12 | "-Dpipewire-alsa=disabled", 13 | "-Dpipewire-jack=enabled", 14 | "-Djack-devel=enabled", 15 | "-Dlibjack-path=/app/lib", 16 | "-Dalsa=disabled", 17 | "-Dbluez5=disabled", 18 | "-Djack=disabled", 19 | "-Dlibcamera=disabled", 20 | "-Dvideoconvert=disabled", 21 | "-Dvulkan=disabled", 22 | "-Dpw-cat=disabled", 23 | "-Dudev=disabled" 24 | ], 25 | "sources": [ 26 | { 27 | "type": "git", 28 | "url": "https://gitlab.freedesktop.org/pipewire/pipewire.git", 29 | "tag": "0.3.43", 30 | "commit": "07724b7aefa8a23a016727b53f4e426ecd63d248", 31 | "x-checker-data": { 32 | "type": "anitya", 33 | "project-id": 57357, 34 | "stable-only": true, 35 | "tag-template": "$version" 36 | } 37 | } 38 | ], 39 | "cleanup": [ 40 | "/bin" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/pocketsphinx/pocketsphinx.json: -------------------------------------------------------------------------------- 1 | { 2 | "buildsystem": "autotools", 3 | "name": "PocketSphinx", 4 | "config-opts": [ 5 | "--without-python" 6 | ], 7 | "sources": [ 8 | { 9 | "type": "git", 10 | "url": "https://github.com/cmusphinx/pocketsphinx.git", 11 | "commit": "588ab6371a1e1c94c10d4ad772b0c4732e1905e6" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/sphinxbase/sphinxbase.json: -------------------------------------------------------------------------------- 1 | { 2 | "buildsystem": "autotools", 3 | "name": "SphinxBase", 4 | "config-opts": [ 5 | "--without-python" 6 | ], 7 | "sources": [ 8 | { 9 | "type": "git", 10 | "url": "https://github.com/cmusphinx/sphinxbase.git", 11 | "commit": "9e901850ee4cd1c0b22f2d3b3c15f162564ca283" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/srt/srt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "srt", 3 | "builddir": true, 4 | "buildsystem": "cmake", 5 | "sources": [ 6 | { 7 | "type": "archive", 8 | "url": "https://github.com/Haivision/srt/archive/v1.5.1/srt-1.5.1.tar.gz", 9 | "sha256": "af891e7a7ffab61aa76b296982038b3159da690f69ade7c119f445d924b3cf53", 10 | "x-checker-data": { 11 | "type": "anitya", 12 | "project-id": 236296, 13 | "stable-only": true, 14 | "url-template": "https://github.com/Haivision/srt/archive/v$version/srt-$version.tar.gz" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/svt-av1/svt-av1.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svt-av1", 3 | "builddir": true, 4 | "buildsystem": "cmake", 5 | "config-opts": [ 6 | "-DBUILD_SHARED_LIBS=ON", 7 | "-DNATIVE=OFF" 8 | ], 9 | "sources": [ 10 | { 11 | "type": "archive", 12 | "url": "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v1.3.0/SVT-AV1-v1.3.0.tar.gz", 13 | "sha256": "841408b92c7b09957340112775369ea6fa763eaf4a8c10974cfa48f33c47a122", 14 | "x-checker-data": { 15 | "type": "anitya", 16 | "project-id": 24271, 17 | "stable-only": true, 18 | "url-template": "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$version/SVT-AV1-v$version.tar.gz" 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/v4l-utils/libv4l.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libv4l", 3 | "cleanup": [ 4 | "/bin", 5 | "/share/man" 6 | ], 7 | "config-opts": [ 8 | "--sbindir=${FLATPAK_DEST}/bin", 9 | "--disable-static", 10 | "--with-udevdir=${FLATPAK_DEST}/lib/udev" 11 | ], 12 | "sources": [ 13 | { 14 | "type": "archive", 15 | "url": "https://linuxtv.org/downloads/v4l-utils/v4l-utils-1.22.1.tar.bz2", 16 | "sha256": "65c6fbe830a44ca105c443b027182c1b2c9053a91d1e72ad849dfab388b94e31", 17 | "x-checker-data": { 18 | "type": "anitya", 19 | "project-id": 9998, 20 | "stable-only": true, 21 | "url-template": "https://linuxtv.org/downloads/v4l-utils/v4l-utils-$version.tar.bz2" 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/v4l-utils/v4l-utils.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "v4l-utils", 3 | "cleanup": [ 4 | "/share/man" 5 | ], 6 | "config-opts": [ 7 | "--sbindir=${FLATPAK_DEST}/bin", 8 | "--disable-static", 9 | "--with-udevdir=${FLATPAK_DEST}/lib/udev" 10 | ], 11 | "sources": [ 12 | { 13 | "type": "archive", 14 | "url": "https://linuxtv.org/downloads/v4l-utils/v4l-utils-1.22.1.tar.bz2", 15 | "sha256": "65c6fbe830a44ca105c443b027182c1b2c9053a91d1e72ad849dfab388b94e31", 16 | "x-checker-data": { 17 | "type": "anitya", 18 | "project-id": 9998, 19 | "stable-only": true, 20 | "url-template": "https://linuxtv.org/downloads/v4l-utils/v4l-utils-$version.tar.bz2" 21 | } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/vid.stab/vid.stab.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vid.stab", 3 | "builddir": true, 4 | "buildsystem": "cmake", 5 | "sources": [ 6 | { 7 | "type": "archive", 8 | "url": "https://github.com/georgmartius/vid.stab/archive/v1.1.0/vid.stab-1.1.0.tar.gz", 9 | "sha256": "14d2a053e56edad4f397be0cb3ef8eb1ec3150404ce99a426c4eb641861dc0bb", 10 | "x-checker-data": { 11 | "type": "anitya", 12 | "project-id": 15959, 13 | "stable-only": true, 14 | "url-template": "https://github.com/georgmartius/vid.stab/archive/v$version/vid.stab-$version.tar.gz" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/vmaf/vmaf.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vmaf", 3 | "builddir": true, 4 | "subdir": "libvmaf", 5 | "buildsystem": "meson", 6 | "sources": [ 7 | { 8 | "type": "archive", 9 | "url": "https://github.com/Netflix/vmaf/archive/v2.3.1/vmaf-2.3.1.tar.gz", 10 | "sha256": "8d60b1ddab043ada25ff11ced821da6e0c37fd7730dd81c24f1fc12be7293ef2", 11 | "x-checker-data": { 12 | "type": "anitya", 13 | "project-id": 178322, 14 | "stable-only": true, 15 | "url-template": "https://github.com/Netflix/vmaf/archive/v$version/vmaf-$version.tar.gz" 16 | } 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/x264/x264.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "x264", 3 | "config-opts": [ 4 | "--enable-shared", 5 | "--enable-pic", 6 | "--enable-lto", 7 | "--disable-avs" 8 | ], 9 | "make-install-args": [ 10 | "install-cli", 11 | "install-lib-shared" 12 | ], 13 | "sources": [ 14 | { 15 | "type": "archive", 16 | "url": "https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.gz", 17 | "sha256": "830c3679c6d7072b0cbf93d38b5cab5b076d597aa1842765c9ccd830dfe15e9b", 18 | "x-checker-data": { 19 | "type": "anitya", 20 | "project-id": 15280, 21 | "stable-only": true, 22 | "url-template": "https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.gz" 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/xvidcore/xvidcore.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xvidcore", 3 | "subdir": "build/generic", 4 | "sources": [ 5 | { 6 | "type": "archive", 7 | "url": "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz", 8 | "sha256": "abbdcbd39555691dd1c9b4d08f0a031376a3b211652c0d8b3b8aa9be1303ce2d", 9 | "x-checker-data": { 10 | "type": "anitya", 11 | "project-id": 14474, 12 | "stable-only": true, 13 | "url-template": "https://downloads.xvid.com/downloads/xvidcore-$version.tar.gz" 14 | } 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /pkg/flatpak/deps/zimg/zimg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zimg", 3 | "config-opts": [ 4 | "--disable-static", 5 | "--enable-x86simd" 6 | ], 7 | "sources": [ 8 | { 9 | "type": "archive", 10 | "url": "https://github.com/sekrit-twc/zimg/archive/release-3.0.4/zimg-release-3.0.4.tar.gz", 11 | "sha256": "219d1bc6b7fde1355d72c9b406ebd730a4aed9c21da779660f0a4c851243e32f", 12 | "x-checker-data": { 13 | "type": "anitya", 14 | "project-id": 13685, 15 | "stable-only": true, 16 | "url-template": "https://github.com/sekrit-twc/zimg/archive/release-$version/zimg-release-$version.tar.gz" 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /pkg/i18n/.gitignore: -------------------------------------------------------------------------------- 1 | releaseme 2 | -------------------------------------------------------------------------------- /pkg/mingw/.gitignore: -------------------------------------------------------------------------------- 1 | /.dockerhome 2 | -------------------------------------------------------------------------------- /pkg/mingw/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | project_root="$(readlink -f "$(dirname "$0")/../..")" 6 | cd "$project_root" 7 | 8 | rm -rf /home/devel/build 9 | mkdir -p /home/devel/build/nsis 10 | 11 | sudo pacman -Sy --noconfirm --needed archlinux-keyring 12 | sudo pacman -Su --noconfirm 13 | sudo pacman -S --noconfirm --needed \ 14 | mingw-w64-toolchain mingw-w64-cmake mingw-w64-configure mingw-w64-pkg-config \ 15 | mingw-w64-ffmpeg mingw-w64-qt5 mingw-w64-kf5 nsis \ 16 | mingw-w64-kinit mingw-w64-pango mingw-w64-libvisual \ 17 | mingw-w64-aspell mingw-w64-hunspell mingw-w64-icu \ 18 | mingw-w64-libidn2 mingw-w64-openal \ 19 | kconfig5 kcoreaddons5 breeze-icons icu 20 | sudo pacman -Sdd --noconfirm --needed kauth5 kbookmarks5 kcodecs5 kcompletion5 \ 21 | kconfig5 kconfigwidgets5 kcoreaddons5 kglobalaccel5 kitemviews5 kjobwidgets5 \ 22 | knotifications5 ktextwidgets5 kwidgetsaddons5 kwindowsystem5 kxmlgui5 \ 23 | solid5 sonnet5 24 | 25 | i686-w64-mingw32-cmake -B /home/devel/build \ 26 | -DCMAKE_BUILD_TYPE=Release \ 27 | -DKDE_INSTALL_LIBDIR=lib \ 28 | -DKDE_INSTALL_USE_QT_SYS_PATHS=ON \ 29 | -DBUILD_TESTING=OFF \ 30 | -DKF5_HOST_TOOLING=/usr/lib/cmake \ 31 | -DKCONFIGCOMPILER_PATH=/usr/lib/cmake/KF5Config/KF5ConfigCompilerTargets.cmake \ 32 | -DTARGETSFILE=/usr/lib/cmake/KF5CoreAddons/KF5CoreAddonsToolingTargets.cmake 33 | cmake --build /home/devel/build -j$(nproc) 34 | DESTDIR="/home/devel/build/nsis" cmake --build /home/devel/build --target nsis 35 | -------------------------------------------------------------------------------- /pkg/mingw/docker-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | _gitroot="$(cd $(dirname "$0") && echo $PWD)" 6 | while [[ ! -d "$_gitroot/.git" ]]; do _gitroot="$(dirname "$_gitroot")" ; [[ "$_gitroot" == "/" ]] && echo "ERROR: cannot find .git directory" && exit 1 ; done 7 | cd "$_gitroot" 8 | 9 | sudo docker run --rm -v "$PWD":/home/devel -it maxrd2/arch-mingw /bin/bash -c 'bash pkg/mingw/build.sh' 10 | -------------------------------------------------------------------------------- /pkg/mingw/github-upload-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Build 4 | build=pkg/mingw/docker-build.sh 5 | echo -e "Starting docker build '\e[1;39m$build\e[m'..." 6 | $build 7 | 8 | pkg/misc/github-release.sh win32 "$PWD/build/SubtitleComposerSetup.exe" 9 | -------------------------------------------------------------------------------- /pkg/mingw/setup-pacserve.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | [ -z "$1" ] && { echo "Usage: setup-cache.sh " 1>&2 ; exit 1 ; } 6 | [ "$UID" == "0" ] || { echo "Run me as root" 1>&2 ; exit 1 ; } 7 | 8 | use_cache="$1" 9 | sed -r -e '1 i Server = http://'$use_cache':15678/pacman/$repo/$arch' -i /etc/pacman.d/mirrorlist 10 | sed -r -e '/^Server\s*=/ i Server = http://'$use_cache':15678/pacman/$repo' -i /etc/pacman.conf 11 | -------------------------------------------------------------------------------- /pkg/misc/.gitignore: -------------------------------------------------------------------------------- 1 | *.qcow2 2 | -------------------------------------------------------------------------------- /pkg/misc/copyright.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$1" == "" ]; then 4 | echo "Usage: copy.sh " 5 | exit 6 | fi 7 | 8 | textc=-$(date +%Y)' Mladen Milinkovic ' 9 | text1=':a;N;$!ba;s/\/\*[^\/]+SPDX-FileCopyrightText:([^\/]+|[^\*]\/)+\*\//\/*\n' 10 | text2='\n SPDX-License-Identifier: GPL-2.0-or-later\n*\//' 11 | 12 | update_copyright() { 13 | f="$1" 14 | if [[ ! -f "$f" ]]; then 15 | return 16 | fi 17 | echo -e '\e[01;33mProcessing \e[01;39m'$f'\e[01;33m\e[00m' 18 | 19 | copy=$(perl -pe 'BEGIN{undef $/;} s!^.*?/\*[^/]*?(([\t *]*?SPDX-FileCopyrightText[^\n]*?[\t *]*?\n)+).*?$!$1!sg' "$f"\ 20 | | perl -pe 's!\(([^)>]+@[^)>]+)\)!<$1>!' \ 21 | | perl -pe "s!(-\d+)? Mladen Milinkovic [<(][^>]+[>)]!$textc!g" \ 22 | | perl -pe 's!(\d{4})(-\1)!$1!g' \ 23 | | perl -pe 'BEGIN{undef $/;} s!\n+!\\n!sg') 24 | 25 | if [[ $copy == *"Sergio Pistone"* || $copy == *"Mladen Milinkovic"* ]]; then 26 | if [[ $copy != *"Mladen Milinkovic"* ]]; then 27 | copy="$copy * Copyright (C) 2010-${textc:1}\n" 28 | fi 29 | sed -r "$text1$copy$text2" --in-place "$f" 30 | fi 31 | } 32 | 33 | if [ "$1" == "all" ]; then 34 | export -f update_copyright 35 | for f in `find . \( -name \*.cpp -or -name \*.h \)`; do 36 | update_copyright "$f" 37 | done 38 | elif [ "$1" == "git" ]; then 39 | for f in `git diff --name-only "${@:2}" | grep -Pe '\.[ch](pp)?$'`; do 40 | update_copyright "$f" 41 | done 42 | else 43 | for f in "${@:1}"; do 44 | update_copyright "$f" 45 | done 46 | fi 47 | -------------------------------------------------------------------------------- /pkg/misc/setup-ubuntu-travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | cd "$(dirname "$0")" 5 | 6 | [[ "$1" == "" ]] && echo "Usage: $0 " && exit 1 7 | 8 | # get list of required apt-get packages 9 | lc= 10 | pkgs=() 11 | while IFS='' read -r line || [[ -n "$line" ]]; do 12 | if [[ ! "$line" =~ ^[\ \t]*# && "$line" =~ ^.*apt-get\ install.*$ || "$lc" == "1" ]]; then 13 | lc=; [[ "$line" =~ ^.*\\$ ]] && lc=1 14 | line=${line##*apt-get install} 15 | line=${line%\\} 16 | for p in $line; do [[ ! $p =~ ^- ]] && pkgs+=($p) ; done 17 | fi 18 | done < ./build-deps.sh 19 | 20 | # setup ssh login 21 | ssh -t "$1" "mkdir -p ~/.ssh ; chmod 700 ~/.ssh ; echo '$(cat ~/.ssh/id_rsa.pub)' >~/.ssh/authorized_keys" 22 | 23 | cat >temp.sh <> /etc/sudoers' 28 | 29 | # setup color prompt 30 | sed -E -i \\ 31 | -e 's/^#force_color_prompt=yes/force_color_prompt=yes/' \\ 32 | -e 's/(PS1=.*01);32m/\1;33m/' \\ 33 | \$HOME/.bashrc 34 | 35 | # add cdrom to apt 36 | #[ "$(grep /cdrom /etc/fstab)" == "" ] && sudo bash -c 'echo -e "\n/dev/cdrom /cdrom auto ro,user,noauto,exec,utf8 0 0" >>/etc/fstab 37 | #sudo mkdir -p /cdrom 38 | #sudo ln -fs /cdrom /media/cdrom 39 | #(mount /cdrom || exit 0) 40 | #/usr/bin/apt-cdrom add --no-auto-detect -d /cdrom' 41 | 42 | # add apt mount 43 | [ "$(grep /apt /etc/fstab)" == "" ] && sudo bash -c 'echo -e "\napt /var/cache/apt/archives 9p trans=virtio,version=9p2000.L,posixacl,msize=104857600 0 0" >>/etc/fstab 44 | mount /var/cache/apt/archives' 45 | 46 | # update apt 47 | sudo apt-get update 48 | sudo apt-get dist-upgrade -y 49 | sudo apt-get clean -y 50 | sudo apt-get install -yd ${pkgs[@]} 51 | 52 | # delete temp script 53 | rm ~/temp.sh 54 | EOF 55 | 56 | scp temp.sh build-deps.sh "$1:" 57 | rm temp.sh 58 | ssh -t "$1" "bash ~/temp.sh" 59 | -------------------------------------------------------------------------------- /pkg/misc/subtitlecomposer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | appdir="$(dirname "$(readlink -f "$0")")" 4 | 5 | export PATH="${appdir}/usr/bin:$PATH" 6 | export LD_LIBRARY_PATH="${appdir}/usr/lib:$LD_LIBRARY_PATH" 7 | export XDG_DATA_DIRS="${appdir}/usr/share:$XDG_DATA_DIRS" 8 | 9 | export QT_PLUGIN_PATH="${appdir}/usr/plugins" 10 | # QT_PLUGIN_PATH - setting system's plugin path will cause crashes on many platforms 11 | # echo export QT_PLUGIN_PATH="${appdir}/usr/plugins:$QT_PLUGIN_PATH:/usr/lib/qt/plugins:/usr/lib/$(uname -m)-linux-gnu/qt5/plugins" 12 | # echo QT_PLUGIN_PATH=$QT_PLUGIN_PATH 13 | 14 | # export QT_DEBUG_PLUGINS=1 15 | 16 | # Arch Linux KDE; KUbuntu 18.04/20.04/20.10/21.04 LiveCD 17 | # XDG_SESSION_DESKTOP="KDE" 18 | # XDG_CURRENT_DESKTOP="KDE" 19 | 20 | # Ubuntu 18.04/20.04/20.10/21.04 LiveCD - had to QT_QPA_PLATFORMTHEME=gtk3 for file dialogs and -style=breeze|oxygen 21 | # XDG_SESSION_DESKTOP="ubuntu" 22 | # XDG_CURRENT_DESKTOP="ubuntu:GNOME" 23 | 24 | # Ubuntu Mate 21.04 LiveCD - had to QT_QPA_PLATFORMTHEME=gtk3 for file dialogs and -style=breeze|oxygen 25 | # XDG_SESSION_DESKTOP="mate" 26 | # XDG_CURRENT_DESKTOP="MATE" 27 | 28 | # ICON THEME: 29 | # https://openapplibrary.org/dev-tutorials/qt-icon-themes 30 | 31 | app="${appdir}/usr/bin/subtitlecomposer" 32 | 33 | case "$XDG_CURRENT_DESKTOP" in 34 | "MATE") 35 | exec "${app}" -platformtheme gtk3 -style=adwaita "$@" 36 | ;; 37 | "ubuntu:GNOME") 38 | exec "${app}" -platformtheme gtk3 -style=adwaita "$@" 39 | ;; 40 | "KDE") 41 | exec "${app}" "$@" 42 | ;; 43 | *) 44 | exec "${app}" -platformtheme gtk2 -style=oxygen "$@" 45 | ;; 46 | esac 47 | 48 | -------------------------------------------------------------------------------- /src/actions/kcodecactionext.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef KCODECACTIONEXT_H 9 | #define KCODECACTIONEXT_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | QT_FORWARD_DECLARE_CLASS(QTextCodec) 16 | 17 | class KCodecActionExt : public KSelectAction 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | enum Mode { Open, Save }; 23 | explicit KCodecActionExt(QObject *parent, Mode mode); 24 | KCodecActionExt(const QString &text, QObject *parent, Mode mode); 25 | KCodecActionExt(const QIcon &icon, const QString &text, QObject *parent, Mode mode); 26 | 27 | public: 28 | bool setCurrentCodec(QTextCodec *codec); 29 | 30 | Q_SIGNALS: 31 | void triggered(QTextCodec *codec); 32 | 33 | protected Q_SLOTS: 34 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 35 | void slotActionTriggered(QAction *) override {} 36 | #else 37 | void actionTriggered(QAction *) override {} 38 | #endif 39 | 40 | private: 41 | void init(); 42 | 43 | Mode m_mode; 44 | QAction *m_defaultCodecAction; 45 | QAction *m_currentCodecAction; 46 | QAction *m_autodetectAction; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/actions/krecentfilesactionext.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef KRECENTFILESACTIONEXT_H 8 | #define KRECENTFILESACTIONEXT_H 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | class KRecentFilesActionExt : public KRecentFilesAction 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit KRecentFilesActionExt(QObject *parent); 21 | virtual ~KRecentFilesActionExt(); 22 | 23 | static QString encodingForUrl(const QUrl &url); 24 | 25 | void loadEntries(const KConfigGroup &configGroup); 26 | void saveEntries(const KConfigGroup &configGroup); 27 | 28 | void addUrl(const QUrl &url, const QString &encoding, const QString &name); 29 | inline void addUrl(const QUrl &url, const QString &encoding) { addUrl(url, encoding, QString()); } 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/appglobal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "appglobal.h" 8 | 9 | #include "core/subtitle.h" 10 | 11 | #include "application.h" 12 | #include "gui/playerwidget.h" 13 | #include "mainwindow.h" 14 | 15 | using namespace SubtitleComposer; 16 | 17 | Application * AppGlobal::app = nullptr; 18 | QExplicitlySharedDataPointer AppGlobal::subtitle; 19 | UndoStack * AppGlobal::undoStack = nullptr; 20 | 21 | VideoPlayer * 22 | SubtitleComposer::videoPlayer() 23 | { 24 | return app()->mainWindow()->m_playerWidget->m_videoPlayer; 25 | } 26 | -------------------------------------------------------------------------------- /src/appglobal.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef APPGLOBAL_H 8 | #define APPGLOBAL_H 9 | 10 | #include 11 | 12 | namespace SubtitleComposer { 13 | class Application; 14 | class Subtitle; 15 | class UndoStack; 16 | class VideoPlayer; 17 | 18 | class AppGlobal 19 | { 20 | friend class Application; 21 | friend Application * app(); 22 | friend Subtitle *appSubtitle(); 23 | friend UndoStack * appUndoStack(); 24 | 25 | static Application *app; 26 | static QExplicitlySharedDataPointer subtitle; 27 | static UndoStack *undoStack; 28 | }; 29 | 30 | inline Application * app() { return AppGlobal::app; } 31 | inline Subtitle * appSubtitle() { return AppGlobal::subtitle.data(); } 32 | inline UndoStack * appUndoStack() { return AppGlobal::undoStack; } 33 | VideoPlayer * videoPlayer(); 34 | 35 | } 36 | 37 | #endif // APPGLOBAL_H 38 | -------------------------------------------------------------------------------- /src/application_errorcheck.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "config.h" 8 | 9 | #include "appglobal.h" 10 | #include "application.h" 11 | #include "core/subtitleiterator.h" 12 | #include "errors/finderrorsdialog.h" 13 | #include "errors/errorfinder.h" 14 | #include "gui/treeview/lineswidget.h" 15 | 16 | using namespace SubtitleComposer; 17 | 18 | void 19 | Application::selectNextError() 20 | { 21 | const int idx = m_mainWindow->m_linesWidget->currentLineIndex(); 22 | if(!m_errorFinder->findNext(idx)) { 23 | m_lastFoundLine = nullptr; 24 | m_errorFinder->find(idx, false); 25 | } 26 | } 27 | 28 | void 29 | Application::selectPreviousError() 30 | { 31 | const int idx = m_mainWindow->m_linesWidget->currentLineIndex(); 32 | if(!m_errorFinder->findPrevious(idx)) { 33 | m_lastFoundLine = nullptr; 34 | m_errorFinder->find(idx, true); 35 | } 36 | } 37 | 38 | void 39 | Application::detectErrors() 40 | { 41 | m_lastFoundLine = nullptr; 42 | m_errorFinder->find(m_mainWindow->m_linesWidget->currentLineIndex()); 43 | } 44 | 45 | void 46 | Application::clearErrors() 47 | { 48 | appSubtitle()->clearErrors(RangeList(Range::full()), SubtitleLine::AllErrors); 49 | } 50 | 51 | void 52 | Application::toggleSelectedLinesMark() 53 | { 54 | appSubtitle()->toggleMarked(m_mainWindow->m_linesWidget->selectionRanges()); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/config.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | #define SC_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" 5 | #define SC_INSTALL_BIN "@CMAKE_INSTALL_PREFIX@/@KDE_INSTALL_BINDIR@" 6 | #define SC_INSTALL_PLUGIN "@SC_PLUGIN_INSTALL_DIR@" 7 | 8 | // Building AppImage distro 9 | #cmakedefine SC_APPIMAGE 10 | 11 | // Whether system icon theme is bundled 12 | #cmakedefine SC_BUNDLE_SYSTEM_THEME 13 | 14 | // Whether ICU was found 15 | #cmakedefine HAVE_ICU 16 | 17 | // fallback path to locate icons under non-KDE desktop environments 18 | #define CUSTOM_ICON_INSTALL_PATH "@CMAKE_INSTALL_PREFIX@/@KDE_INSTALL_DATADIR@/subtitlecomposer/icons" 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/configs/configdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2015 Martin Steghöfer 3 | SPDX-FileCopyrightText: 2015-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef CONFIGDIALOG_H 9 | #define CONFIGDIALOG_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace SubtitleComposer { 16 | 17 | class ConfigDialog : public KConfigDialog 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | ConfigDialog(QWidget *parent, const QString &name, KCoreConfigSkeleton *config); 23 | 24 | public slots: 25 | void widgetChanged(); 26 | 27 | public: 28 | void updateSettings() override; 29 | 30 | protected: 31 | bool hasChanged() override; 32 | 33 | private: 34 | bool m_hasWidgetChanged; 35 | Sonnet::ConfigWidget *m_sonnetConfigWidget; 36 | }; 37 | 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/configs/errorsconfigwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef ERRORSCONFIGWIDGET_H 9 | #define ERRORSCONFIGWIDGET_H 10 | 11 | #include "ui_errorsconfigwidget.h" 12 | 13 | namespace SubtitleComposer { 14 | class ErrorsConfigWidget : public QWidget, private Ui::ErrorsConfigWidget 15 | { 16 | Q_OBJECT 17 | 18 | friend class ConfigDialog; 19 | 20 | public: 21 | explicit ErrorsConfigWidget(QWidget *parent = 0); 22 | virtual ~ErrorsConfigWidget(); 23 | }; 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/configs/generalconfigwidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "generalconfigwidget.h" 9 | 10 | #include "appglobal.h" 11 | #include "application.h" 12 | 13 | using namespace SubtitleComposer; 14 | 15 | GeneralConfigWidget::GeneralConfigWidget(QWidget *parent) 16 | : QWidget(parent) 17 | { 18 | setupUi(this); 19 | 20 | kcfg_DefaultSubtitlesEncoding->addItems(app()->availableEncodingNames()); 21 | kcfg_DefaultSubtitlesEncoding->setProperty("kcfg_property", QByteArray("currentText")); 22 | } 23 | 24 | GeneralConfigWidget::~GeneralConfigWidget() 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/configs/generalconfigwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef GENERALCONFIGWIDGET_H 9 | #define GENERALCONFIGWIDGET_H 10 | 11 | #include "ui_generalconfigwidget.h" 12 | 13 | namespace SubtitleComposer { 14 | class GeneralConfigWidget : public QWidget, private Ui::GeneralConfigWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit GeneralConfigWidget(QWidget *parent=NULL); 20 | virtual ~GeneralConfigWidget(); 21 | }; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/configs/playerconfigwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef PLAYERCONFIGWIDGET_H 9 | #define PLAYERCONFIGWIDGET_H 10 | 11 | #include "ui_playerconfigwidget.h" 12 | 13 | namespace SubtitleComposer { 14 | class PlayerConfigWidget : public QWidget, private Ui::PlayerConfigWidget 15 | { 16 | Q_OBJECT 17 | 18 | friend class ConfigDialog; 19 | 20 | public: 21 | explicit PlayerConfigWidget(QWidget *parent=nullptr); 22 | virtual ~PlayerConfigWidget(); 23 | 24 | private slots: 25 | void onFamilyChanged(const QString &family); 26 | void onSizeChanged(int size); 27 | void onPrimaryColorChanged(const QColor &color); 28 | void onOutlineColorChanged(const QColor &color); 29 | void onOutlineWidthChanged(int width); 30 | }; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/configs/waveformconfigwidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "waveformconfigwidget.h" 8 | 9 | using namespace SubtitleComposer; 10 | 11 | WaveformConfigWidget::WaveformConfigWidget(QWidget *parent) 12 | : QWidget(parent) 13 | { 14 | setupUi(this); 15 | } 16 | -------------------------------------------------------------------------------- /src/configs/waveformconfigwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef WAVEFORMCONFIGWIDGET_H 8 | #define WAVEFORMCONFIGWIDGET_H 9 | 10 | #include "ui_waveformconfigwidget.h" 11 | 12 | namespace SubtitleComposer { 13 | class WaveformConfigWidget : public QWidget, private Ui::WaveformConfigWidget 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit WaveformConfigWidget(QWidget *parent = 0); 18 | 19 | signals: 20 | 21 | public slots: 22 | }; 23 | } 24 | 25 | #endif // WAVEFORMCONFIGWIDGET_H 26 | -------------------------------------------------------------------------------- /src/core/formatdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef FORMATDATA_H 9 | #define FORMATDATA_H 10 | 11 | #include 12 | #include 13 | 14 | namespace SubtitleComposer { 15 | class FormatData 16 | { 17 | friend class Format; 18 | 19 | public: 20 | FormatData(const FormatData &formatData) : 21 | m_formatName(formatData.m_formatName), 22 | m_data(formatData.m_data) {} 23 | 24 | FormatData & operator=(const FormatData &formatData) 25 | { 26 | if(this == &formatData) 27 | return *this; 28 | 29 | m_formatName = formatData.m_formatName; 30 | m_data = formatData.m_data; 31 | 32 | return *this; 33 | } 34 | 35 | inline const QString & formatName() 36 | { 37 | return m_formatName; 38 | } 39 | 40 | inline const QString & value(const QString &key) 41 | { 42 | static const QString empty; 43 | return m_data.contains(key) ? m_data[key] : empty; 44 | } 45 | 46 | inline void setValue(const QString &key, const QString &value) 47 | { 48 | m_data[key] = value; 49 | } 50 | 51 | inline void clear() 52 | { 53 | m_data.clear(); 54 | } 55 | 56 | private: 57 | FormatData(const QString &formatName) : m_formatName(formatName) {} 58 | 59 | QString m_formatName; 60 | QMap m_data; 61 | }; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/core/richtext/richdom.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef RICHDOM_H 8 | #define RICHDOM_H 9 | 10 | #include 11 | 12 | namespace SubtitleComposer { 13 | 14 | class RichDocument; 15 | 16 | class RichDOM 17 | { 18 | public: 19 | RichDOM(); 20 | ~RichDOM(); 21 | 22 | enum NodeType { 23 | Root, 24 | Bold, 25 | Italic, 26 | Underline, 27 | Strikethrough, 28 | Font, 29 | Class, 30 | Voice, 31 | Invalid = -1 32 | }; 33 | 34 | struct Node { 35 | Node(NodeType type_=Invalid, const QString &klass_=QString(), const QString &id_=QString()); 36 | ~Node(); 37 | 38 | Node(const Node &other); 39 | Node & operator=(const Node &other); 40 | 41 | QString cssSel(); 42 | 43 | void debugDump(QString pfx=QString()); 44 | 45 | NodeType type; 46 | QString id; 47 | QString klass; 48 | quint32 nodeStart; 49 | quint32 nodeEnd; 50 | Node *next; 51 | Node *parent; 52 | Node *children; 53 | }; 54 | 55 | void update(const RichDocument *doc); 56 | 57 | private: 58 | friend class RichDocument; 59 | Node *m_root; 60 | }; 61 | 62 | } 63 | 64 | #endif // RICHDOM_H 65 | -------------------------------------------------------------------------------- /src/core/subtitletarget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef SUBTITLETARGET_H 8 | #define SUBTITLETARGET_H 9 | 10 | namespace SubtitleComposer { 11 | 12 | enum SubtitleTarget { 13 | Primary = 0, 14 | Secondary, 15 | Both, 16 | SubtitleTargetSize 17 | }; 18 | 19 | } 20 | 21 | #endif // SUBTITLETARGET_H 22 | -------------------------------------------------------------------------------- /src/core/undo/undoaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "core/undo/undoaction.h" 8 | #include "core/subtitle.h" 9 | 10 | using namespace SubtitleComposer; 11 | 12 | UndoAction::UndoAction(UndoStack::DirtyMode dirtyMode, Subtitle *subtitle, const QString &desc) 13 | : QUndoCommand(desc), 14 | m_dirtyMode(dirtyMode), 15 | m_subtitle(subtitle) 16 | { 17 | } 18 | 19 | UndoAction::~UndoAction() 20 | { 21 | } 22 | 23 | void 24 | UndoAction::undo() 25 | { 26 | redo(); 27 | } 28 | -------------------------------------------------------------------------------- /src/core/undo/undoaction.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2018-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef UNDOACTION_H 8 | #define UNDOACTION_H 9 | 10 | #include 11 | #include 12 | 13 | #include "core/undo/undostack.h" 14 | 15 | namespace SubtitleComposer { 16 | 17 | class Subtitle; 18 | 19 | class UndoAction : public QUndoCommand 20 | { 21 | friend class UndoStack; 22 | 23 | public: 24 | enum { 25 | // subtitle actions 26 | SetFramesPerSecond = 1, 27 | InsertLines, 28 | RemoveLines, 29 | MoveLine, 30 | SwapLinesTexts, 31 | ChangeStylesheet, 32 | 33 | // subtitle line actions 34 | SetLinePrimaryText, 35 | SetLineSecondaryText, 36 | SetLineTexts, 37 | SetLineShowTime, 38 | SetLineHideTime, 39 | SetLineTimes, 40 | SetLineErrors, 41 | } ActionID; 42 | 43 | 44 | UndoAction(UndoStack::DirtyMode dirtyMode, Subtitle *subtitle=nullptr, const QString &desc=QString()); 45 | virtual ~UndoAction(); 46 | 47 | void redo() override = 0; 48 | void undo() override; 49 | 50 | protected: 51 | const UndoStack::DirtyMode m_dirtyMode; 52 | QExplicitlySharedDataPointer m_subtitle; 53 | }; 54 | 55 | } 56 | 57 | #endif /*UNDOACTION_H*/ 58 | -------------------------------------------------------------------------------- /src/dialogs/actiondialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef ACTIONDIALOG_H 9 | #define ACTIONDIALOG_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | QT_FORWARD_DECLARE_CLASS(QGridLayout) 16 | QT_FORWARD_DECLARE_CLASS(QVBoxLayout) 17 | QT_FORWARD_DECLARE_CLASS(QGroupBox) 18 | 19 | namespace SubtitleComposer { 20 | class ActionDialog : public QDialog 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit ActionDialog(const QString &title, QWidget *parent = 0); 26 | 27 | public slots: 28 | virtual int exec() override; 29 | virtual void show(); 30 | 31 | protected: 32 | QGroupBox * createGroupBox(const QString &title = QString(), bool addToLayout = true); 33 | QGridLayout * createLayout(QGroupBox *groupBox); 34 | 35 | protected: 36 | QWidget *m_mainWidget; 37 | QVBoxLayout *m_mainLayout; 38 | QDialogButtonBox *m_buttonBox; 39 | }; 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /src/dialogs/adjusttimesdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef ADJUSTTIMESDIALOG_H 9 | #define ADJUSTTIMESDIALOG_H 10 | 11 | #include "actiondialog.h" 12 | #include "core/time.h" 13 | 14 | class TimeEdit; 15 | 16 | namespace SubtitleComposer { 17 | class AdjustTimesDialog : public ActionDialog 18 | { 19 | public: 20 | AdjustTimesDialog(QWidget *parent = 0); 21 | 22 | Time firstLineTime() const; 23 | void setFirstLineTime(const Time &time); 24 | 25 | Time lastLineTime() const; 26 | void setLastLineTime(const Time &time); 27 | 28 | private: 29 | TimeEdit *m_firstLineTimeEdit; 30 | TimeEdit *m_lastLineTimeEdit; 31 | }; 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /src/dialogs/autodurationsdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef AUTODURATIONSDIALOG_H 9 | #define AUTODURATIONSDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | QT_FORWARD_DECLARE_CLASS(QCheckBox) 14 | QT_FORWARD_DECLARE_CLASS(QSpinBox) 15 | QT_FORWARD_DECLARE_CLASS(QButtonGroup) 16 | 17 | namespace SubtitleComposer { 18 | class AutoDurationsDialog : public ActionWithTargetDialog 19 | { 20 | public: 21 | AutoDurationsDialog(unsigned charMillis, unsigned wordMillis, unsigned lineMillis, QWidget *parent = 0); 22 | 23 | unsigned charMillis() const; 24 | unsigned wordMillis() const; 25 | unsigned lineMillis() const; 26 | 27 | bool preventOverlap() const; 28 | 29 | SubtitleTarget calculationMode() const; 30 | 31 | bool translationMode() const; 32 | void setTranslationMode(bool enabled) override; 33 | 34 | private: 35 | QSpinBox *m_charMillisSpinBox; 36 | QSpinBox *m_wordMillisSpinBox; 37 | QSpinBox *m_lineMillisSpinBox; 38 | 39 | QCheckBox *m_preventOverlapCheckBox; 40 | 41 | bool m_translationMode; 42 | QButtonGroup *m_calculationButtonGroup; 43 | }; 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /src/dialogs/changeframeratedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef CHANGEFRAMERATEDIALOG_H 9 | #define CHANGEFRAMERATEDIALOG_H 10 | 11 | #include "actiondialog.h" 12 | 13 | class KComboBox; 14 | 15 | namespace SubtitleComposer { 16 | class ChangeFrameRateDialog : public ActionDialog 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit ChangeFrameRateDialog(double fromFramesPerSecond, QWidget *parent = 0); 22 | 23 | double fromFramesPerSecond() const; 24 | void setFromFramesPerSecond(double framesPerSecond); 25 | 26 | double toFramesPerSecond() const; 27 | void setNewFramesPerSecond(double framesPerSecond); 28 | 29 | private slots: 30 | void onTextChanged(); 31 | 32 | private: 33 | KComboBox *m_fromFramesPerSecondComboBox; 34 | KComboBox *m_toFramesPerSecondComboBox; 35 | }; 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /src/dialogs/changetextscasedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef CHANGETEXTSCASEDIALOG_H 9 | #define CHANGETEXTSCASEDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | QT_FORWARD_DECLARE_CLASS(QCheckBox) 14 | QT_FORWARD_DECLARE_CLASS(QRadioButton) 15 | 16 | namespace SubtitleComposer { 17 | class ChangeTextsCaseDialog : public ActionWithTargetDialog 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | typedef enum { Upper = 0, Lower, Title, Sentence } CaseOp; 23 | 24 | ChangeTextsCaseDialog(QWidget *parent = 0); 25 | 26 | CaseOp caseOperation() const; 27 | bool lowerFirst() const; 28 | 29 | private slots: 30 | void onCaseButtonGroupClicked(int id); 31 | 32 | private: 33 | QCheckBox *m_lowerFirstCheckBox; 34 | 35 | QRadioButton *m_lowerRadioButton; 36 | QRadioButton *m_upperRadioButton; 37 | QRadioButton *m_titleRadioButton; 38 | QRadioButton *m_sentenceRadioButton; 39 | }; 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /src/dialogs/durationlimitsdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef DURATIONLIMITSDIALOG_H 9 | #define DURATIONLIMITSDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | #include "core/time.h" 13 | 14 | QT_FORWARD_DECLARE_CLASS(QGroupBox) 15 | QT_FORWARD_DECLARE_CLASS(QCheckBox) 16 | QT_FORWARD_DECLARE_CLASS(QCheckBox) 17 | class TimeEdit; 18 | 19 | namespace SubtitleComposer { 20 | class DurationLimitsDialog : public ActionWithTargetDialog 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | DurationLimitsDialog(const Time &minDuration, const Time &maxDuration, QWidget *parent = 0); 26 | 27 | Time minDuration() const; 28 | Time maxDuration() const; 29 | 30 | bool enforceMaxDuration() const; 31 | bool enforceMinDuration() const; 32 | bool preventOverlap() const; 33 | 34 | private slots: 35 | void onMinDurationValueChanged(int value); 36 | void onMaxDurationValueChanged(int value); 37 | 38 | private: 39 | QGroupBox *m_maxGroupBox; 40 | TimeEdit *m_maxDurationTimeEdit; 41 | 42 | QGroupBox *m_minGroupBox; 43 | QCheckBox *m_preventOverlapCheckBox; 44 | TimeEdit *m_minDurationTimeEdit; 45 | }; 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /src/dialogs/encodingdetectdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODINGDETECTDIALOG_H 2 | #define ENCODINGDETECTDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class EncodingDetectDialog; 8 | } 9 | 10 | namespace SubtitleComposer { 11 | class EncodingDetectDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit EncodingDetectDialog(const QByteArray &text, QWidget *parent = nullptr); 17 | ~EncodingDetectDialog(); 18 | 19 | void addEncoding(const QString &name, int confidence); 20 | inline const QString & selectedEncoding() { return m_selectedEncoding; } 21 | 22 | private: 23 | Ui::EncodingDetectDialog *ui; 24 | QByteArray m_text; 25 | QString m_selectedEncoding; 26 | }; 27 | } 28 | 29 | #endif // ENCODINGDETECTDIALOG_H 30 | -------------------------------------------------------------------------------- /src/dialogs/fixoverlappingtimesdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "fixoverlappingtimesdialog.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace SubtitleComposer; 16 | 17 | FixOverlappingTimesDialog::FixOverlappingTimesDialog(QWidget *parent) : 18 | ActionWithTargetDialog(i18n("Fix Overlapping Times"), parent) 19 | { 20 | QGroupBox *settingsGroupBox = createGroupBox(i18nc("@title:group", "Settings")); 21 | 22 | m_minIntervalSpinBox = new QSpinBox(settingsGroupBox); 23 | m_minIntervalSpinBox->setSuffix(i18n(" msecs")); 24 | m_minIntervalSpinBox->setMinimum(1); 25 | m_minIntervalSpinBox->setMaximum(1000); 26 | m_minIntervalSpinBox->setValue(50); 27 | 28 | QLabel *minIntervalLabel = new QLabel(settingsGroupBox); 29 | minIntervalLabel->setText(i18n("Minimum interval between lines:")); 30 | minIntervalLabel->setBuddy(m_minIntervalSpinBox); 31 | 32 | createLineTargetsButtonGroup(); 33 | 34 | QGridLayout *settingsLayout = createLayout(settingsGroupBox); 35 | settingsLayout->addWidget(minIntervalLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter); 36 | settingsLayout->addWidget(m_minIntervalSpinBox, 0, 1); 37 | } 38 | 39 | Time 40 | FixOverlappingTimesDialog::minimumInterval() const 41 | { 42 | return Time(m_minIntervalSpinBox->value()); 43 | } 44 | 45 | void 46 | FixOverlappingTimesDialog::setMinimumInterval(const Time &time) 47 | { 48 | m_minIntervalSpinBox->setValue(time.toMillis()); 49 | } 50 | -------------------------------------------------------------------------------- /src/dialogs/fixoverlappingtimesdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef FIXOVERLAPPINGTIMESDIALOG_H 9 | #define FIXOVERLAPPINGTIMESDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | #include "core/time.h" 13 | 14 | QT_FORWARD_DECLARE_CLASS(QSpinBox) 15 | 16 | namespace SubtitleComposer { 17 | class FixOverlappingTimesDialog : public ActionWithTargetDialog 18 | { 19 | public: 20 | FixOverlappingTimesDialog(QWidget *parent = 0); 21 | 22 | Time minimumInterval() const; 23 | void setMinimumInterval(const Time &time); 24 | 25 | private: 26 | QSpinBox *m_minIntervalSpinBox; 27 | }; 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /src/dialogs/fixpunctuationdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef FIXPUNCTUATIONDIALOG_H 9 | #define FIXPUNCTUATIONDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | QT_FORWARD_DECLARE_CLASS(QCheckBox) 14 | 15 | namespace SubtitleComposer { 16 | class FixPunctuationDialog : public ActionWithTargetDialog 17 | { 18 | public: 19 | FixPunctuationDialog(QWidget *parent = 0); 20 | 21 | bool spaces() const; 22 | bool quotes() const; 23 | bool englishI() const; 24 | bool ellipsis() const; 25 | 26 | private: 27 | QCheckBox *m_spacesCheckBox; 28 | QCheckBox *m_quotesCheckBox; 29 | QCheckBox *m_englishICheckBox; 30 | QCheckBox *m_ellipsisCheckBox; 31 | }; 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /src/dialogs/insertlinedialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "insertlinedialog.h" 9 | 10 | using namespace SubtitleComposer; 11 | 12 | InsertLineDialog::InsertLineDialog(bool insertBefore, QWidget *parent) 13 | : ActionWithTextsTargetDialog(insertBefore ? i18n("Insert Line Before Current") : i18n("Insert Line After Current"), i18n("Insert Into"), parent) 14 | { 15 | setNonTranslationModeTarget(Both); 16 | } 17 | -------------------------------------------------------------------------------- /src/dialogs/insertlinedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef INSERTLINEDIALOG_H 9 | #define INSERTLINEDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | namespace SubtitleComposer { 14 | class InsertLineDialog : public ActionWithTextsTargetDialog 15 | { 16 | public: 17 | explicit InsertLineDialog(bool insertAfter, QWidget *parent = 0); 18 | }; 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /src/dialogs/intinputdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef INTINPUTDIALOG_H 9 | #define INTINPUTDIALOG_H 10 | 11 | #include "ui_intinputdialog.h" 12 | #include 13 | 14 | QT_FORWARD_DECLARE_CLASS(QLineEdit) 15 | QT_FORWARD_DECLARE_CLASS(QDialogButtonBox) 16 | class KIntNumInput; 17 | 18 | namespace SubtitleComposer { 19 | class IntInputDialog : public QDialog, private Ui::IntInputDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | IntInputDialog(const QString &caption, const QString &label, QWidget *parent = 0); 25 | IntInputDialog(const QString &caption, const QString &label, int min, int max, QWidget *parent = 0); 26 | IntInputDialog(const QString &caption, const QString &label, int min, int max, int value, QWidget *parent = 0); 27 | 28 | int minimum() const; 29 | int maximum() const; 30 | int value() const; 31 | 32 | public slots: 33 | void setMinimum(int minimum); 34 | void setMaximum(int maximum); 35 | void setValue(int value); 36 | 37 | private: 38 | void init(const QString &caption, const QString &label, int min, int max, int value); 39 | }; 40 | } 41 | #endif /*INTINPUTDIALOG_H*/ 42 | -------------------------------------------------------------------------------- /src/dialogs/joinsubtitlesdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef JOINSUBTITLESDIALOG_H 9 | #define JOINSUBTITLESDIALOG_H 10 | 11 | #include "selectablesubtitledialog.h" 12 | #include "core/time.h" 13 | 14 | QT_FORWARD_DECLARE_CLASS(QCheckBox) 15 | QT_FORWARD_DECLARE_CLASS(QPushButton) 16 | class TimeEdit; 17 | 18 | namespace SubtitleComposer { 19 | class JoinSubtitlesDialog : public SelectableSubtitleDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit JoinSubtitlesDialog(QWidget *parent = 0); 25 | 26 | Time shiftTime() const; 27 | 28 | void show() override; 29 | 30 | private slots: 31 | void setShiftTimeFromVideo(); 32 | 33 | private: 34 | TimeEdit *m_shiftTimeEdit; 35 | QPushButton *m_shiftTimeFromVideoButton; 36 | QCheckBox *m_shiftSubtitleCheckBox; 37 | }; 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /src/dialogs/progressdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef PROGRESSDIALOG_H 9 | #define PROGRESSDIALOG_H 10 | 11 | #include 12 | 13 | QT_FORWARD_DECLARE_CLASS(QLabel) 14 | QT_FORWARD_DECLARE_CLASS(QProgressBar) 15 | QT_FORWARD_DECLARE_CLASS(QCloseEvent) 16 | QT_FORWARD_DECLARE_CLASS(QDialogButtonBox) 17 | 18 | namespace SubtitleComposer { 19 | class ProgressDialog : public QDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | ProgressDialog(const QString &caption, const QString &description, bool allowCancel, QWidget *parent = 0); 25 | 26 | int value() const; 27 | int minimum() const; 28 | int maximum() const; 29 | QString description() const; 30 | bool isCancellable() const; 31 | 32 | protected: 33 | void closeEvent(QCloseEvent *event) override; 34 | 35 | public slots: 36 | void setMinimum(int minimum); 37 | void incrementMinimum(int delta); 38 | void setMaximum(int maximum); 39 | void incrementMaximum(int delta); 40 | void setValue(int value); 41 | void setDescription(const QString &description); 42 | void setCancellable(bool cancellable); 43 | 44 | private: 45 | QLabel *m_label; 46 | QProgressBar *m_progressBar; 47 | QDialogButtonBox *m_buttonBox; 48 | }; 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/dialogs/removelinesdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "removelinesdialog.h" 9 | 10 | using namespace SubtitleComposer; 11 | 12 | RemoveLinesDialog::RemoveLinesDialog(QWidget *parent) 13 | : ActionWithTextsTargetDialog(i18n("Remove Selected Lines"), i18n("Remove From"), parent) 14 | { 15 | setNonTranslationModeTarget(Both); 16 | } 17 | -------------------------------------------------------------------------------- /src/dialogs/removelinesdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef REMOVELINESDIALOG_H 9 | #define REMOVELINESDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | namespace SubtitleComposer { 14 | class RemoveLinesDialog : public ActionWithTextsTargetDialog 15 | { 16 | public: 17 | RemoveLinesDialog(QWidget *parent = 0); 18 | }; 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /src/dialogs/selectablesubtitledialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SELECTABLESUBTITLEDIALOG_H 9 | #define SELECTABLESUBTITLEDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | #include 14 | 15 | QT_FORWARD_DECLARE_CLASS(QGridLayout) 16 | QT_FORWARD_DECLARE_CLASS(QGroupBox) 17 | class KLineEdit; 18 | 19 | namespace SubtitleComposer { 20 | class SelectableSubtitleDialog : public ActionWithTargetDialog 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | SelectableSubtitleDialog(const QString &title, QWidget *parent = 0); 26 | 27 | QUrl subtitleUrl() const; 28 | 29 | protected: 30 | QGroupBox * createSubtitleGroupBox(const QString &title = i18n("Subtitle"), bool addToLayout = true); 31 | 32 | private slots: 33 | void selectSubtitle(); 34 | 35 | protected: 36 | QGroupBox *m_subtitleGroupBox; 37 | QGridLayout *m_subtitleLayout; 38 | 39 | KLineEdit *m_subtitleUrlLineEdit; 40 | }; 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /src/dialogs/shifttimesdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "shifttimesdialog.h" 9 | #include "widgets/timeedit.h" 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | using namespace SubtitleComposer; 17 | 18 | ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) : 19 | ActionWithTargetDialog(i18n("Shift"), parent) 20 | { 21 | QGroupBox *settingsGroupBox = createGroupBox(i18nc("@title:group", "Shifting")); 22 | 23 | m_directionComboBox = new KComboBox(false, settingsGroupBox); 24 | m_directionComboBox->clear(); 25 | m_directionComboBox->addItem(i18n("Forwards (+)")); 26 | m_directionComboBox->addItem(i18n("Backwards (−)")); 27 | m_directionComboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 28 | 29 | m_shiftTimeEdit = new TimeEdit(settingsGroupBox); 30 | 31 | createLineTargetsButtonGroup(); 32 | 33 | QGridLayout *settingsLayout = createLayout(settingsGroupBox); 34 | settingsLayout->addWidget(m_directionComboBox, 0, 0); 35 | settingsLayout->addWidget(m_shiftTimeEdit, 0, 1); 36 | } 37 | 38 | void 39 | ShiftTimesDialog::resetShiftTime() 40 | { 41 | m_shiftTimeEdit->setValue(0); 42 | } 43 | 44 | int 45 | ShiftTimesDialog::shiftTimeMillis() const 46 | { 47 | return m_directionComboBox->currentIndex() == 0 ? m_shiftTimeEdit->value() : -m_shiftTimeEdit->value(); 48 | } 49 | -------------------------------------------------------------------------------- /src/dialogs/shifttimesdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SHIFTTIMESDIALOG_H 9 | #define SHIFTTIMESDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | class TimeEdit; 14 | class KComboBox; 15 | 16 | namespace SubtitleComposer { 17 | class ShiftTimesDialog : public ActionWithTargetDialog 18 | { 19 | public: 20 | ShiftTimesDialog(QWidget *parent = 0); 21 | 22 | void resetShiftTime(); 23 | 24 | int shiftTimeMillis() const; 25 | 26 | private: 27 | KComboBox *m_directionComboBox; 28 | TimeEdit *m_shiftTimeEdit; 29 | }; 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /src/dialogs/smarttextsadjustdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "smarttextsadjustdialog.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace SubtitleComposer; 16 | 17 | SmartTextsAdjustDialog::SmartTextsAdjustDialog(unsigned minLengthForLineBreak, QWidget *parent) : 18 | ActionWithTargetDialog(i18n("Break Lines"), parent) 19 | { 20 | QGroupBox *settingsGroupBox = createGroupBox(i18nc("@title:group", "Settings")); 21 | 22 | m_minLengthForLineBreakSpinBox = new QSpinBox(settingsGroupBox); 23 | m_minLengthForLineBreakSpinBox->setMinimum(0); 24 | m_minLengthForLineBreakSpinBox->setMaximum(1000); 25 | m_minLengthForLineBreakSpinBox->setValue(minLengthForLineBreak); 26 | m_minLengthForLineBreakSpinBox->setSuffix(i18n(" characters")); 27 | 28 | QLabel *minLengthForLineBreakLabel = new QLabel(settingsGroupBox); 29 | minLengthForLineBreakLabel->setText(i18n("Minimum length for line break:")); 30 | minLengthForLineBreakLabel->setBuddy(m_minLengthForLineBreakSpinBox); 31 | 32 | createLineTargetsButtonGroup(); 33 | createTextTargetsButtonGroup(); 34 | 35 | QGridLayout *settingsLayout = createLayout(settingsGroupBox); 36 | settingsLayout->addWidget(minLengthForLineBreakLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter); 37 | settingsLayout->addWidget(m_minLengthForLineBreakSpinBox, 0, 1); 38 | } 39 | 40 | unsigned 41 | SmartTextsAdjustDialog::minLengthForLineBreak() const 42 | { 43 | return m_minLengthForLineBreakSpinBox->value(); 44 | } 45 | -------------------------------------------------------------------------------- /src/dialogs/smarttextsadjustdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SMARTTEXTSADJUSTDIALOG_H 9 | #define SMARTTEXTSADJUSTDIALOG_H 10 | 11 | #include "actionwithtargetdialog.h" 12 | 13 | QT_FORWARD_DECLARE_CLASS(QSpinBox) 14 | 15 | namespace SubtitleComposer { 16 | class SmartTextsAdjustDialog : public ActionWithTargetDialog 17 | { 18 | public: 19 | explicit SmartTextsAdjustDialog(unsigned minLengthForLineBreak, QWidget *parent = 0); 20 | 21 | unsigned minLengthForLineBreak() const; 22 | 23 | private: 24 | QSpinBox *m_minLengthForLineBreakSpinBox; 25 | }; 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /src/dialogs/splitsubtitledialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SPLITSUBTITLEDIALOG_H 9 | #define SPLITSUBTITLEDIALOG_H 10 | 11 | #include "actiondialog.h" 12 | #include "core/time.h" 13 | 14 | QT_FORWARD_DECLARE_CLASS(QCheckBox) 15 | QT_FORWARD_DECLARE_CLASS(QPushButton) 16 | class TimeEdit; 17 | 18 | namespace SubtitleComposer { 19 | class SplitSubtitleDialog : public ActionDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | SplitSubtitleDialog(QWidget *parent = 0); 25 | 26 | Time splitTime() const; 27 | bool shiftNewSubtitle() const; 28 | 29 | void show() override; 30 | 31 | private slots: 32 | void setSplitTimeFromVideo(); 33 | 34 | private: 35 | TimeEdit *m_splitTimeEdit; 36 | QPushButton *m_splitTimeFromVideoButton; 37 | QCheckBox *m_shiftNewSubtitleCheckBox; 38 | }; 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /src/dialogs/subtitleclassdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #include "subtitleclassdialog.h" 7 | #include "ui_subtitleclassdialog.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | using namespace SubtitleComposer; 18 | 19 | 20 | SubtitleClassDialog::SubtitleClassDialog(QWidget *parent, Qt::WindowFlags flags) 21 | : QDialog(parent, flags), 22 | ui(new Ui::SubtitleClassDialog) 23 | { 24 | ui->setupUi(this); 25 | 26 | connect(ui->classList, &QComboBox::currentTextChanged, this, [&](){ emit currentClassChanged(currentClass()); }); 27 | connect(this, &QDialog::accepted, this, [&](){ emit classSelected(currentClass()); }); 28 | } 29 | 30 | SubtitleClassDialog::SubtitleClassDialog(const QString &initial, QWidget *parent, Qt::WindowFlags flags) 31 | : SubtitleClassDialog(parent, flags) 32 | { 33 | QSignalBlocker sb(this); 34 | setCurrentClass(initial); 35 | } 36 | 37 | SubtitleClassDialog::~SubtitleClassDialog() 38 | { 39 | delete ui; 40 | } 41 | 42 | void 43 | SubtitleClassDialog::setCurrentClass(const QString &cssClass) 44 | { 45 | ui->classList->setCurrentText(cssClass); 46 | } 47 | 48 | QString 49 | SubtitleClassDialog::currentClass() const 50 | { 51 | return ui->classList->currentText(); 52 | } 53 | 54 | QString 55 | SubtitleClassDialog::getClass(const QStringList &classes, const QString &initial, QWidget *parent, const QString &title) 56 | { 57 | SubtitleClassDialog dlg(parent); 58 | if(!title.isEmpty()) 59 | dlg.setWindowTitle(title); 60 | dlg.ui->classList->addItems(classes); 61 | dlg.setCurrentClass(initial); 62 | return dlg.exec() == QDialog::Accepted ? dlg.selectedClass() : QString(); 63 | } 64 | -------------------------------------------------------------------------------- /src/dialogs/subtitleclassdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef SUBTITLECOMPOSER_SUBTITLECLASSDIALOG_H 7 | #define SUBTITLECOMPOSER_SUBTITLECLASSDIALOG_H 8 | 9 | #include 10 | 11 | namespace Ui { 12 | class SubtitleClassDialog; 13 | } 14 | 15 | namespace SubtitleComposer { 16 | 17 | class SubtitleClassDialog : public QDialog 18 | { 19 | Q_OBJECT 20 | 21 | Q_PROPERTY(QString currentClass READ currentClass WRITE setCurrentClass 22 | NOTIFY currentClassChanged) 23 | 24 | public: 25 | SubtitleClassDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); 26 | SubtitleClassDialog(const QString &initial, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); 27 | virtual ~SubtitleClassDialog(); 28 | 29 | static QString getClass(const QStringList &classes, 30 | const QString &initial = QString(), 31 | QWidget *parent = nullptr, 32 | const QString &title = QString()); 33 | 34 | void setCurrentClass(const QString &cssClass); 35 | QString currentClass() const; 36 | 37 | inline QString selectedClass() const { return currentClass(); } 38 | 39 | signals: 40 | void currentClassChanged(const QString &cssClass); 41 | void classSelected(const QString &cssClass); 42 | 43 | private: 44 | Ui::SubtitleClassDialog *ui; 45 | }; 46 | } // namespace SubtitleComposer 47 | 48 | #endif // SUBTITLECOMPOSER_SUBTITLECLASSDIALOG_H 49 | -------------------------------------------------------------------------------- /src/dialogs/subtitlecolordialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2012 Sergio Pistone 3 | SPDX-FileCopyrightText: 2013-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "subtitlecolordialog.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | using namespace SubtitleComposer; 17 | 18 | SubtitleColorDialog::SubtitleColorDialog(QWidget *parent) 19 | : QColorDialog(parent), 20 | m_defaultColorSelected(false) 21 | { 22 | QDialogButtonBox *buttons = findChild(); 23 | 24 | QPushButton *defaultColor = buttons->addButton(i18n("Default Color"), QDialogButtonBox::AcceptRole); 25 | connect(defaultColor, &QAbstractButton::clicked, this, [&](){ 26 | m_defaultColorSelected = true; 27 | accept(); 28 | }); 29 | 30 | setOption(DontUseNativeDialog, true); 31 | } 32 | 33 | SubtitleColorDialog::SubtitleColorDialog(const QColor &initial, QWidget *parent) 34 | : SubtitleColorDialog(parent) 35 | { 36 | QSignalBlocker sb(this); 37 | setCurrentColor(initial); 38 | } 39 | 40 | QColor 41 | SubtitleColorDialog::selectedColor() const 42 | { 43 | return m_defaultColorSelected ? QColor(0, 0, 0, 0) : QColorDialog::selectedColor(); 44 | } 45 | 46 | QColor 47 | SubtitleColorDialog::getColor(const QColor &initial, QWidget *parent, const QString &title, ColorDialogOptions options) 48 | { 49 | SubtitleColorDialog dlg(initial, parent); 50 | if(!title.isEmpty()) 51 | dlg.setWindowTitle(title); 52 | dlg.setOptions(options | DontUseNativeDialog); 53 | return dlg.exec() == QDialog::Accepted ? dlg.selectedColor() : QColor(); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/dialogs/subtitlecolordialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2012 Sergio Pistone 3 | SPDX-FileCopyrightText: 2013-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SUBTITLECOLORDIALOG_H 9 | #define SUBTITLECOLORDIALOG_H 10 | 11 | #include 12 | 13 | namespace SubtitleComposer { 14 | class SubtitleColorDialog : public QColorDialog 15 | { 16 | public: 17 | explicit SubtitleColorDialog(QWidget *parent = nullptr); 18 | explicit SubtitleColorDialog(const QColor &initial, QWidget *parent = nullptr); 19 | 20 | static QColor getColor(const QColor &initial = Qt::white, 21 | QWidget *parent = nullptr, 22 | const QString &title = QString(), 23 | ColorDialogOptions options = ColorDialogOptions()); 24 | 25 | QColor selectedColor() const; 26 | 27 | private: 28 | bool m_defaultColorSelected; 29 | }; 30 | } 31 | 32 | #endif /* SUBTITLECOLORDIALOG_H */ 33 | -------------------------------------------------------------------------------- /src/dialogs/subtitlevoicedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef SUBTITLEVOICEDIALOG_H 7 | #define SUBTITLEVOICEDIALOG_H 8 | 9 | #include 10 | 11 | namespace Ui { 12 | class SubtitleVoiceDialog; 13 | } 14 | 15 | namespace SubtitleComposer { 16 | 17 | class SubtitleVoiceDialog : public QDialog 18 | { 19 | Q_OBJECT 20 | 21 | Q_PROPERTY(QString currentVoice READ currentVoice WRITE setCurrentVoice 22 | NOTIFY currentVoiceChanged) 23 | 24 | public: 25 | SubtitleVoiceDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); 26 | SubtitleVoiceDialog(const QString &initial, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); 27 | virtual ~SubtitleVoiceDialog(); 28 | 29 | static QString getVoice(const QStringList &voices, 30 | const QString &initial = QString(), 31 | QWidget *parent = nullptr, 32 | const QString &title = QString()); 33 | 34 | void setCurrentVoice(const QString &cssVoice); 35 | QString currentVoice() const; 36 | 37 | inline QString selectedVoice() const { return currentVoice(); } 38 | 39 | signals: 40 | void currentVoiceChanged(const QString &cssVoice); 41 | void voiceSelected(const QString &cssVoice); 42 | 43 | private: 44 | Ui::SubtitleVoiceDialog *ui; 45 | }; 46 | } // namespace SubtitleComposer 47 | 48 | #endif // SUBTITLEVOICEDIALOG_H 49 | -------------------------------------------------------------------------------- /src/dialogs/syncsubtitlesdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "syncsubtitlesdialog.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace SubtitleComposer; 15 | 16 | SyncSubtitlesDialog::SyncSubtitlesDialog(QWidget *parent) : 17 | SelectableSubtitleDialog(i18n("Synchronize with Subtitle"), parent) 18 | { 19 | createSubtitleGroupBox(i18n("Reference Subtitle")); 20 | 21 | QGroupBox *syncModeGroupBox = createGroupBox(i18nc("@title:group", "Synchronization Mode")); 22 | 23 | m_adjustRadioButton = new QRadioButton(syncModeGroupBox); 24 | m_adjustRadioButton->setText(i18n("Adjust to reference's first and last lines")); 25 | m_adjustRadioButton->setChecked(true); 26 | 27 | m_synchronizeRadioButton = new QRadioButton(syncModeGroupBox); 28 | m_synchronizeRadioButton->setText(i18n("Copy timing information from reference line by line")); 29 | 30 | QGridLayout *syncModeLayout = createLayout(syncModeGroupBox); 31 | syncModeLayout->addWidget(m_adjustRadioButton, 0, 0); 32 | syncModeLayout->addWidget(m_synchronizeRadioButton, 1, 0); 33 | } 34 | 35 | bool 36 | SyncSubtitlesDialog::adjustToReferenceSubtitle() const 37 | { 38 | return m_adjustRadioButton->isChecked(); 39 | } 40 | 41 | bool 42 | SyncSubtitlesDialog::synchronizeToReferenceTimes() const 43 | { 44 | return m_synchronizeRadioButton->isChecked(); 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/dialogs/syncsubtitlesdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SYNCSUBTITLESDIALOG_H 9 | #define SYNCSUBTITLESDIALOG_H 10 | 11 | #include "selectablesubtitledialog.h" 12 | 13 | QT_FORWARD_DECLARE_CLASS(QRadioButton) 14 | 15 | namespace SubtitleComposer { 16 | class SyncSubtitlesDialog : public SelectableSubtitleDialog 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit SyncSubtitlesDialog(QWidget *parent = 0); 22 | 23 | bool adjustToReferenceSubtitle() const; 24 | bool synchronizeToReferenceTimes() const; 25 | 26 | private: 27 | QRadioButton *m_adjustRadioButton; 28 | QRadioButton *m_synchronizeRadioButton; 29 | }; 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /src/dialogs/textinputdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "textinputdialog.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace SubtitleComposer; 16 | 17 | TextInputDialog::TextInputDialog(const QString &caption, const QString &label, QWidget *parent) 18 | : QDialog(parent) 19 | { 20 | init(caption, label, QString()); 21 | } 22 | 23 | TextInputDialog::TextInputDialog(const QString &caption, const QString &label, const QString &value, QWidget *parent) 24 | : QDialog(parent) 25 | { 26 | init(caption, label, value); 27 | } 28 | 29 | void 30 | TextInputDialog::init(const QString &caption, const QString &labelText, const QString &value) 31 | { 32 | setupUi(this); 33 | 34 | setWindowTitle(caption); 35 | 36 | lineEdit->setText(value); 37 | lineEdit->setFocus(); 38 | 39 | label->setText(labelText); 40 | 41 | buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 42 | 43 | resize(300, 10); 44 | 45 | connect(lineEdit, &QLineEdit::textChanged, this, &TextInputDialog::onLineEditTextChanged); 46 | } 47 | 48 | const QString 49 | TextInputDialog::value() const 50 | { 51 | return lineEdit->text(); 52 | } 53 | 54 | void 55 | TextInputDialog::setValue(const QString &value) 56 | { 57 | lineEdit->setText(value); 58 | } 59 | 60 | void 61 | TextInputDialog::onLineEditTextChanged(const QString &text) 62 | { 63 | buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); 64 | } 65 | -------------------------------------------------------------------------------- /src/dialogs/textinputdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef TEXTINPUTDIALOG_H 9 | #define TEXTINPUTDIALOG_H 10 | 11 | #include "ui_textinputdialog.h" 12 | #include 13 | 14 | namespace SubtitleComposer { 15 | class TextInputDialog : public QDialog, private Ui::TextInputDialog 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | TextInputDialog(const QString &caption, const QString &label, QWidget *parent = 0); 21 | TextInputDialog(const QString &caption, const QString &label, const QString &value, QWidget *parent = 0); 22 | 23 | const QString value() const; 24 | 25 | public slots: 26 | void setValue(const QString &value); 27 | 28 | private: 29 | void init(const QString &caption, const QString &label, const QString &value); 30 | 31 | private slots: 32 | void onLineEditTextChanged(const QString &text); 33 | }; 34 | } 35 | #endif /*TEXTINPUTDIALOG_H*/ 36 | -------------------------------------------------------------------------------- /src/errors/errorfinder.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef ERRORFINDER_H 9 | #define ERRORFINDER_H 10 | 11 | #include "core/subtitle.h" 12 | 13 | #include 14 | 15 | namespace SubtitleComposer { 16 | class FindErrorsDialog; 17 | class SubtitleIterator; 18 | 19 | class ErrorFinder : public QObject 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit ErrorFinder(QWidget *parent = 0); 25 | virtual ~ErrorFinder(); 26 | 27 | QWidget * parentWidget(); 28 | 29 | public slots: 30 | void setSubtitle(Subtitle *subtitle = 0); 31 | void setTranslationMode(bool enabled); 32 | 33 | void find(int searchFromIndex, bool findBackwards = false); 34 | bool findNext(int fromIndex = -1); 35 | bool findPrevious(int fromIndex = -1); 36 | 37 | signals: 38 | void found(SubtitleLine *line); 39 | 40 | private: 41 | void advance(bool advanceIteratorOnFirstStep); 42 | 43 | private slots: 44 | void invalidate(); 45 | 46 | private: 47 | QExplicitlySharedDataPointer m_subtitle; 48 | FindErrorsDialog *m_dialog; 49 | bool m_translationMode; 50 | 51 | int m_targetErrorFlags; 52 | bool m_findBackwards; 53 | SubtitleIterator *m_iterator; 54 | }; 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/errors/errortracker.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef ERRORTRACKER_H 9 | #define ERRORTRACKER_H 10 | 11 | #include "core/subtitle.h" 12 | 13 | namespace SubtitleComposer { 14 | class SubtitleLine; 15 | 16 | class ErrorTracker : public QObject 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit ErrorTracker(QObject *parent = 0); 22 | virtual ~ErrorTracker(); 23 | 24 | bool isTracking() const; 25 | 26 | public slots: 27 | void setSubtitle(Subtitle *subtitle = 0); 28 | 29 | private: 30 | void connectSlots(); 31 | void disconnectSlots(); 32 | 33 | void updateLineErrors(SubtitleLine *line, int errorFlags) const; 34 | 35 | private slots: 36 | void onLinePrimaryTextChanged(SubtitleLine *line); 37 | void onLineSecondaryTextChanged(SubtitleLine *line); 38 | void onLineTimesChanged(SubtitleLine *line); 39 | 40 | void onConfigChanged(); 41 | 42 | private: 43 | QExplicitlySharedDataPointer m_subtitle; 44 | bool m_autoClearFixed; 45 | }; 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /src/errors/finderrorsdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef FINDERRORSDIALOG_H 9 | #define FINDERRORSDIALOG_H 10 | 11 | #include "dialogs/actionwithtargetdialog.h" 12 | 13 | #include 14 | 15 | QT_FORWARD_DECLARE_CLASS(QGroupBox) 16 | QT_FORWARD_DECLARE_CLASS(QGridLayout) 17 | 18 | namespace SubtitleComposer { 19 | class FindErrorsDialog : public ActionWithTargetDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | FindErrorsDialog(QWidget *parent); 25 | virtual ~FindErrorsDialog(); 26 | 27 | inline bool clearOtherErrors() const { return m_clearOtherErrorsCheckBox->isChecked(); } 28 | inline bool clearMarks() const { return m_clearMarksCheckBox->isChecked(); } 29 | 30 | int selectedErrorFlags() const; 31 | 32 | protected: 33 | void setTranslationMode(bool value) override; 34 | QGroupBox * createErrorsGroupBox(const QString &title); 35 | void createErrorsButtons(bool showUserMarks, bool showMissingTranslation); 36 | 37 | private slots: 38 | void selectAllErrorFlags(); 39 | void deselectAllErrorFlags(); 40 | 41 | private: 42 | QGroupBox *m_errorsGroupBox; 43 | QCheckBox **m_errorsCheckBox; 44 | QGridLayout *m_errorsLayout; 45 | QCheckBox *m_clearOtherErrorsCheckBox; 46 | QCheckBox *m_clearMarksCheckBox; 47 | }; 48 | } 49 | 50 | #endif // FINDERRORSDIALOG_H 51 | -------------------------------------------------------------------------------- /src/formats/formatmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef FORMATMANAGER_H 9 | #define FORMATMANAGER_H 10 | 11 | #include "format.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | QT_FORWARD_DECLARE_CLASS(QTextCodec) 21 | 22 | namespace SubtitleComposer { 23 | class InputFormat; 24 | class OutputFormat; 25 | class Subtitle; 26 | class FormatManager 27 | { 28 | public: 29 | enum Status { 30 | SUCCESS = 1, 31 | CANCEL = 0, 32 | ERROR = -1 33 | }; 34 | static FormatManager & instance(); 35 | 36 | bool hasInput(const QString &name) const; 37 | const InputFormat * input(const QString &name) const; 38 | QStringList inputNames() const; 39 | 40 | Status readSubtitle(Subtitle &subtitle, bool primary, const QUrl &url, 41 | QTextCodec **codec, QString *format = nullptr) const; 42 | 43 | bool hasOutput(const QString &name) const; 44 | const OutputFormat * output(const QString &name) const; 45 | const OutputFormat * defaultOutput() const; 46 | QStringList outputNames() const; 47 | 48 | bool writeSubtitle(const Subtitle &subtitle, bool primary, const QUrl &url, 49 | QTextCodec *codec, const QString &format, bool overwrite) const; 50 | 51 | protected: 52 | FormatManager(); 53 | ~FormatManager(); 54 | 55 | Status readBinary(Subtitle &subtitle, const QUrl &url, bool primary, 56 | QTextCodec **codec, QString *format) const; 57 | Status readText(Subtitle &subtitle, const QUrl &url, bool primary, 58 | QTextCodec **codec, QString *formatName) const; 59 | 60 | QMap m_inputFormats; 61 | QMap m_outputFormats; 62 | }; 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /src/formats/inputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef INPUTFORMAT_H 9 | #define INPUTFORMAT_H 10 | 11 | #include "format.h" 12 | #include "formatmanager.h" 13 | 14 | namespace SubtitleComposer { 15 | class InputFormat : public Format 16 | { 17 | public: 18 | bool readSubtitle(Subtitle &subtitle, bool primary, const QString &data) const 19 | { 20 | QExplicitlySharedDataPointer newSubtitle(new Subtitle()); 21 | 22 | if(!parseSubtitles(*newSubtitle, data)) 23 | return false; 24 | 25 | if(primary) 26 | subtitle.setPrimaryData(*newSubtitle, true); 27 | else 28 | subtitle.setSecondaryData(*newSubtitle, true); 29 | 30 | return true; 31 | } 32 | 33 | virtual bool isBinary() const { return false; } 34 | virtual FormatManager::Status readBinary(Subtitle &, const QUrl &) { return FormatManager::ERROR; } 35 | 36 | protected: 37 | virtual bool parseSubtitles(Subtitle &subtitle, const QString &data) const = 0; 38 | 39 | InputFormat(const QString &name, const QStringList &extensions) : Format(name, extensions) {} 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/formats/mplayer/mplayerinputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef MPLAYERINPUTFORMAT_H 9 | #define MPLAYERINPUTFORMAT_H 10 | 11 | #include "core/richtext/richdocument.h" 12 | #include "helpers/common.h" 13 | #include "formats/inputformat.h" 14 | 15 | #include 16 | 17 | namespace SubtitleComposer { 18 | class MPlayerInputFormat : public InputFormat 19 | { 20 | friend class FormatManager; 21 | 22 | protected: 23 | MPlayerInputFormat() 24 | : InputFormat($("MPlayer"), QStringList($("mpl"))) 25 | {} 26 | 27 | bool parseSubtitles(Subtitle &subtitle, const QString &data) const override 28 | { 29 | staticRE$(lineRE, "(^|\n)(\\d+),(\\d+),0,([^\n]+)[^\n]", REu | REi); 30 | 31 | const double fps = subtitle.framesPerSecond(); 32 | 33 | QRegularExpressionMatchIterator itLine = lineRE.globalMatch(data); 34 | if(!itLine.hasNext()) 35 | return false; 36 | 37 | do { 38 | const QRegularExpressionMatch mLine = itLine.next(); 39 | const Time showTime(static_cast((mLine.captured(1).toLong() / fps) * 1000)); 40 | const Time hideTime(static_cast((mLine.captured(2).toLong() / fps) * 1000)); 41 | const QString text = mLine.captured(3).replace(QChar('|'), QChar('\n')); 42 | 43 | SubtitleLine *line = new SubtitleLine(showTime, hideTime); 44 | line->primaryDoc()->setPlainText(text); 45 | subtitle.insertLine(line); 46 | } while(itLine.hasNext()); 47 | 48 | return true; 49 | } 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/formats/mplayer/mplayeroutputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef MPLAYEROUTPUTFORMAT_H 9 | #define MPLAYEROUTPUTFORMAT_H 10 | 11 | #include "formats/outputformat.h" 12 | #include "core/richtext/richdocument.h" 13 | #include "core/subtitleiterator.h" 14 | 15 | namespace SubtitleComposer { 16 | class MPlayerOutputFormat : public OutputFormat 17 | { 18 | friend class FormatManager; 19 | 20 | protected: 21 | QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override 22 | { 23 | QString ret; 24 | 25 | double framesPerSecond = subtitle.framesPerSecond(); 26 | 27 | for(SubtitleIterator it(subtitle); it.current(); ++it) { 28 | const SubtitleLine *line = it.current(); 29 | 30 | QString text = (primary ? line->primaryDoc() : line->secondaryDoc())->toPlainText(); 31 | 32 | ret += m_lineBuilder.arg(static_cast((line->showTime().toMillis() / 1000.0) * framesPerSecond + 0.5)) 33 | .arg(static_cast((line->hideTime().toMillis() / 1000.0) * framesPerSecond + 0.5)) 34 | .arg(text.replace('\n', '|')); 35 | } 36 | return ret; 37 | } 38 | 39 | MPlayerOutputFormat() : 40 | OutputFormat(QStringLiteral("MPlayer"), QStringList(QStringLiteral("mpl"))), 41 | m_lineBuilder(QStringLiteral("%1,%2,0,%3\n")) 42 | {} 43 | 44 | const QString m_lineBuilder; 45 | }; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/formats/mplayer2/mplayer2inputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef MPLAYER2INPUTFORMAT_H 9 | #define MPLAYER2INPUTFORMAT_H 10 | 11 | #include "core/richtext/richdocument.h" 12 | #include "helpers/common.h" 13 | #include "formats/inputformat.h" 14 | 15 | #include 16 | 17 | namespace SubtitleComposer { 18 | class MPlayer2InputFormat : public InputFormat 19 | { 20 | friend class FormatManager; 21 | 22 | protected: 23 | MPlayer2InputFormat() 24 | : InputFormat($("MPlayer2"), QStringList($("mpl"))) 25 | {} 26 | 27 | bool parseSubtitles(Subtitle &subtitle, const QString &data) const override 28 | { 29 | staticRE$(lineRE, "\\[(\\d+)\\]\\[(\\d+)\\]([^\n]+)\n", REu | REi); 30 | 31 | QRegularExpressionMatchIterator itLine = lineRE.globalMatch(data); 32 | if(!itLine.hasNext()) 33 | return false; 34 | 35 | do { 36 | const QRegularExpressionMatch mLine = itLine.next(); 37 | const Time showTime(mLine.captured(1).toInt() * 100); 38 | const Time hideTime(mLine.captured(2).toInt() * 100); 39 | const QString text = mLine.captured(3).replace(QChar('|'), QChar('\n')); 40 | 41 | SubtitleLine *line = new SubtitleLine(showTime, hideTime); 42 | line->primaryDoc()->setPlainText(text); 43 | subtitle.insertLine(line); 44 | } while(itLine.hasNext()); 45 | 46 | return true; 47 | } 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/formats/mplayer2/mplayer2outputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef MPLAYER2OUTPUTFORMAT_H 9 | #define MPLAYER2OUTPUTFORMAT_H 10 | 11 | #include "formats/outputformat.h" 12 | #include "core/richtext/richdocument.h" 13 | #include "core/subtitleiterator.h" 14 | 15 | namespace SubtitleComposer { 16 | class MPlayer2OutputFormat : public OutputFormat 17 | { 18 | friend class FormatManager; 19 | 20 | protected: 21 | QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override 22 | { 23 | QString ret; 24 | 25 | for(SubtitleIterator it(subtitle); it.current(); ++it) { 26 | const SubtitleLine *line = it.current(); 27 | 28 | QString text = (primary ? line->primaryDoc() : line->secondaryDoc())->toPlainText(); 29 | 30 | ret += m_lineBuilder.arg(static_cast((line->showTime().toMillis() / 100.0) + 0.5)) 31 | .arg(static_cast((line->hideTime().toMillis() / 100.0) + 0.5)) 32 | .arg(text.replace('\n', '|')); 33 | } 34 | return ret; 35 | } 36 | 37 | MPlayer2OutputFormat() : 38 | OutputFormat(QStringLiteral("MPlayer2"), QStringList(QStringLiteral("mpl"))), 39 | m_lineBuilder(QStringLiteral("[%1][%2]%3\n")) 40 | {} 41 | 42 | const QString m_lineBuilder; 43 | }; 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/formats/outputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef OUTPUTFORMAT_H 9 | #define OUTPUTFORMAT_H 10 | 11 | #include "format.h" 12 | 13 | namespace SubtitleComposer { 14 | class OutputFormat : public Format 15 | { 16 | public: 17 | 18 | QString writeSubtitle(const Subtitle &subtitle, bool primary) const 19 | { 20 | return dumpSubtitles(subtitle, primary); 21 | } 22 | 23 | protected: 24 | virtual QString dumpSubtitles(const Subtitle &subtitle, bool primary) const = 0; 25 | 26 | OutputFormat(const QString &name, const QStringList &extensions) : Format(name, extensions) {} 27 | }; 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/formats/subrip/subripoutputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SUBRIPOUTPUTFORMAT_H 9 | #define SUBRIPOUTPUTFORMAT_H 10 | 11 | #include "formats/outputformat.h" 12 | #include "core/richtext/richdocument.h" 13 | #include "core/subtitleiterator.h" 14 | 15 | namespace SubtitleComposer { 16 | class SubRipOutputFormat : public OutputFormat 17 | { 18 | friend class FormatManager; 19 | 20 | protected: 21 | QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override 22 | { 23 | QString ret; 24 | 25 | for(SubtitleIterator it(subtitle); it.current(); ++it) { 26 | const SubtitleLine *line = it.current(); 27 | 28 | Time showTime = line->showTime(); 29 | Time hideTime = line->hideTime(); 30 | ret += QString::asprintf("%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n", it.index() + 1, showTime.hours(), showTime.minutes(), showTime.seconds(), showTime.millis(), hideTime.hours(), hideTime.minutes(), hideTime.seconds(), hideTime.millis()); 31 | 32 | const RichString text = (primary ? line->primaryDoc() : line->secondaryDoc())->toRichText(); 33 | 34 | ret += text.richString().replace(QLatin1String("&"), QLatin1String("&")).replace(QLatin1String("<"), QLatin1String("<")).replace(QLatin1String(">"), QLatin1String(">")); 35 | 36 | ret += QStringLiteral("\n\n"); 37 | } 38 | return ret; 39 | } 40 | 41 | SubRipOutputFormat() : 42 | OutputFormat(QStringLiteral("SubRip"), QStringList(QStringLiteral("srt"))), 43 | m_dialogueBuilder(QStringLiteral("%1%2%3%4%5%6%7\n\n")) 44 | {} 45 | 46 | const QString m_dialogueBuilder; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/formats/subviewer1/subviewer1inputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SUBVIEWER1INPUTFORMAT_H 9 | #define SUBVIEWER1INPUTFORMAT_H 10 | 11 | #include "core/richtext/richdocument.h" 12 | #include "helpers/common.h" 13 | #include "formats/inputformat.h" 14 | 15 | #include 16 | 17 | namespace SubtitleComposer { 18 | class SubViewer1InputFormat : public InputFormat 19 | { 20 | friend class FormatManager; 21 | 22 | protected: 23 | SubViewer1InputFormat() 24 | : InputFormat($("SubViewer 1.0"), QStringList($("sub"))) 25 | {} 26 | 27 | bool parseSubtitles(Subtitle &subtitle, const QString &data) const override 28 | { 29 | staticRE$(reTime, "\\[([0-2][0-9]):([0-5][0-9]):([0-5][0-9])\\]\\n([^\n]*)\\n", REu); 30 | QRegularExpressionMatchIterator itTime = reTime.globalMatch(data); 31 | if(!itTime.hasNext()) 32 | return false; 33 | 34 | for(;;) { 35 | QRegularExpressionMatch mTime = itTime.next(); 36 | 37 | const Time showTime(mTime.captured(1).toInt(), mTime.captured(2).toInt(), mTime.captured(3).toInt(), 0); 38 | const QString text(mTime.captured(4).replace('|', '\n').trimmed()); 39 | 40 | if(!itTime.hasNext()) 41 | break; 42 | mTime = itTime.peekNext(); 43 | 44 | const Time hideTime(mTime.captured(1).toInt(), mTime.captured(2).toInt(), mTime.captured(3).toInt(), 0); 45 | 46 | SubtitleLine *l = new SubtitleLine(showTime, hideTime); 47 | l->primaryDoc()->setPlainText(text); 48 | subtitle.insertLine(l); 49 | 50 | } 51 | 52 | return subtitle.count() > 0; 53 | } 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/formats/subviewer1/subviewer1outputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SUBVIEWER1OUTPUTFORMAT_H 9 | #define SUBVIEWER1OUTPUTFORMAT_H 10 | 11 | #include "formats/outputformat.h" 12 | #include "core/richtext/richdocument.h" 13 | #include "core/subtitleiterator.h" 14 | 15 | namespace SubtitleComposer { 16 | class SubViewer1OutputFormat : public OutputFormat 17 | { 18 | friend class FormatManager; 19 | 20 | protected: 21 | QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override 22 | { 23 | QString ret(QStringLiteral("[TITLE]\n\n[AUTHOR]\n\n[SOURCE]\n\n[PRG]\n\n[FILEPATH]\n\n[DELAY]\n0\n[CD TRACK]\n0\n[BEGIN]\n" "******** START SCRIPT ********\n")); 24 | 25 | for(SubtitleIterator it(subtitle); it.current(); ++it) { 26 | const SubtitleLine *line = it.current(); 27 | 28 | Time showTime = line->showTime(); 29 | ret += QString::asprintf("[%02d:%02d:%02d]\n", showTime.hours(), showTime.minutes(), showTime.seconds()); 30 | 31 | QString text = (primary ? line->primaryDoc() : line->secondaryDoc())->toPlainText(); 32 | ret += text.replace('\n', '|'); 33 | 34 | Time hideTime = line->hideTime(); 35 | ret += QString::asprintf("\n[%02d:%02d:%02d]\n\n", hideTime.hours(), hideTime.minutes(), hideTime.seconds()); 36 | } 37 | ret += "[END]\n" "******** END SCRIPT ********\n"; 38 | 39 | return ret; 40 | } 41 | 42 | SubViewer1OutputFormat() : 43 | OutputFormat(QStringLiteral("SubViewer 1.0"), QStringList(QStringLiteral("sub"))) 44 | {} 45 | }; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/formats/textdemux/textdemux.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef TEXTDEMUX_H 8 | #define TEXTDEMUX_H 9 | 10 | #include 11 | #include 12 | 13 | QT_FORWARD_DECLARE_CLASS(QWidget) 14 | QT_FORWARD_DECLARE_CLASS(QProgressBar) 15 | 16 | namespace SubtitleComposer { 17 | class Subtitle; 18 | class StreamProcessor; 19 | 20 | class TextDemux : public QObject 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit TextDemux(QWidget *parent=NULL); 26 | 27 | void demuxFile(Subtitle *subtitle, const QString filename, int textStreamIndex); 28 | 29 | QWidget * progressWidget(); 30 | 31 | signals: 32 | void onError(const QString &message); 33 | 34 | private slots: 35 | void onStreamData(const QString &text, quint64 msecStart, quint64 msecDuration); 36 | void onStreamProgress(quint64 msecPos, quint64 msecLength); 37 | void onStreamError(int code, const QString &message, const QString &debug); 38 | void onStreamFinished(); 39 | 40 | private: 41 | QExplicitlySharedDataPointer m_subtitle; 42 | QExplicitlySharedDataPointer m_subtitleTemp; 43 | StreamProcessor *m_streamProcessor; 44 | 45 | QWidget *m_progressWidget; 46 | QProgressBar *m_progressBar; 47 | }; 48 | } 49 | 50 | #endif // TEXTDEMUX_H 51 | -------------------------------------------------------------------------------- /src/formats/vobsub/vobsubinputinitdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2017-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "vobsubinputinitdialog.h" 8 | #include "ui_vobsubinputinitdialog.h" 9 | 10 | using namespace SubtitleComposer; 11 | 12 | VobSubInputInitDialog::VobSubInputInitDialog(QWidget *parent) : 13 | QDialog(parent), 14 | ui(new Ui::VobSubInputInitDialog) 15 | { 16 | ui->setupUi(this); 17 | } 18 | 19 | VobSubInputInitDialog::~VobSubInputInitDialog() 20 | { 21 | delete ui; 22 | } 23 | 24 | void 25 | VobSubInputInitDialog::streamListSet(const QStringList streams) 26 | { 27 | ui->comboStream->addItems(streams); 28 | } 29 | 30 | int 31 | VobSubInputInitDialog::streamIndex() const 32 | { 33 | return ui->comboStream->currentIndex(); 34 | } 35 | 36 | qint32 37 | VobSubInputInitDialog::whitespaceThreshold() const 38 | { 39 | return ui->hsWhitespace->value() - ui->hsWhitespace->maximum() / 2; 40 | } 41 | 42 | quint32 43 | VobSubInputInitDialog::postProcessingFlags() const 44 | { 45 | quint32 flags = 0; 46 | 47 | if(ui->ppAposQuote->isChecked()) 48 | flags |= APOSTROPHE_TO_QUOTES; 49 | if(ui->ppSpacePunct->isChecked()) 50 | flags |= SPACE_PUNCTUATION; 51 | if(ui->ppSpaceNumber->isChecked()) 52 | flags |= SPACE_NUMBERS; 53 | if(ui->ppSpaceParen->isChecked()) 54 | flags |= SPACE_PARENTHESES; 55 | if(ui->ppCharsOCR->isChecked()) 56 | flags |= CHARS_OCR; 57 | 58 | return flags; 59 | } 60 | -------------------------------------------------------------------------------- /src/formats/vobsub/vobsubinputinitdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2017-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef VOBSUBINPUTINITDIALOG_H 8 | #define VOBSUBINPUTINITDIALOG_H 9 | 10 | #include 11 | 12 | namespace Ui { 13 | class VobSubInputInitDialog; 14 | } 15 | 16 | namespace SubtitleComposer { 17 | class VobSubInputInitDialog : public QDialog 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | enum PostProcessFlags { 23 | APOSTROPHE_TO_QUOTES = 1, 24 | SPACE_PUNCTUATION = 2, 25 | SPACE_NUMBERS = 4, 26 | SPACE_PARENTHESES = 8, 27 | CHARS_OCR = 16 28 | }; 29 | 30 | VobSubInputInitDialog(QWidget *parent = 0); 31 | ~VobSubInputInitDialog(); 32 | 33 | void streamListSet(const QStringList streams); 34 | int streamIndex() const; 35 | 36 | qint32 whitespaceThreshold() const; 37 | 38 | quint32 postProcessingFlags() const; 39 | 40 | private: 41 | Ui::VobSubInputInitDialog *ui; 42 | }; 43 | } 44 | 45 | #endif // VOBSUBINPUTINITDIALOG_H 46 | -------------------------------------------------------------------------------- /src/formats/webvtt/webvttinputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2021-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef WEBVTTINPUTFORMAT_H 8 | #define WEBVTTINPUTFORMAT_H 9 | 10 | #include "formats/inputformat.h" 11 | 12 | namespace SubtitleComposer { 13 | class WebVTTInputFormat : public InputFormat 14 | { 15 | friend class FormatManager; 16 | 17 | protected: 18 | bool parseSubtitles(Subtitle &subtitle, const QString &data) const override; 19 | 20 | WebVTTInputFormat(); 21 | }; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/formats/webvtt/webvttoutputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2021-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef WEBVTTOUTPUTFORMAT_H 8 | #define WEBVTTOUTPUTFORMAT_H 9 | 10 | #include "formats/outputformat.h" 11 | 12 | namespace SubtitleComposer { 13 | class WebVTTOutputFormat : public OutputFormat 14 | { 15 | friend class FormatManager; 16 | 17 | protected: 18 | QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override; 19 | 20 | WebVTTOutputFormat(); 21 | }; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/formats/youtubecaptions/youtubecaptionsoutputformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef YOUTUBECAPTIONSOUTPUTFORMAT_H 9 | #define YOUTUBECAPTIONSOUTPUTFORMAT_H 10 | 11 | #include "core/richtext/richdocument.h" 12 | #include "core/subtitleiterator.h" 13 | #include "formats/outputformat.h" 14 | #include "helpers/common.h" 15 | 16 | namespace SubtitleComposer { 17 | class YouTubeCaptionsOutputFormat : public OutputFormat 18 | { 19 | friend class FormatManager; 20 | 21 | protected: 22 | QString dumpSubtitles(const Subtitle &subtitle, bool primary) const override 23 | { 24 | QString ret; 25 | 26 | for(SubtitleIterator it(subtitle); it.current(); ++it) { 27 | const SubtitleLine *ln = it.current(); 28 | const Time ts = ln->showTime(); 29 | const Time th = ln->hideTime(); 30 | ret += QString::asprintf("%d:%02d:%02d.%03d,%d:%02d:%02d.%03d\n", 31 | ts.hours(), ts.minutes(), ts.seconds(), ts.millis(), 32 | th.hours(), th.minutes(), th.seconds(), th.millis()); 33 | 34 | const RichString text = (primary ? ln->primaryDoc() : ln->secondaryDoc())->toRichText(); 35 | 36 | // TODO does the format actually supports styled text? 37 | // if so, does it use standard HTML style tags? 38 | ret += text.richString(); 39 | 40 | ret += $("\n\n"); 41 | } 42 | return ret; 43 | } 44 | 45 | YouTubeCaptionsOutputFormat() 46 | : OutputFormat($("YouTube Captions"), QStringList($("sbv"))) 47 | {} 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/gui/subtitlemeta/csshighlighter.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef CSSHIGHLIGHTER_H 8 | #define CSSHIGHLIGHTER_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | QT_FORWARD_DECLARE_CLASS(QTextDocument); 15 | 16 | namespace SubtitleComposer { 17 | 18 | class CSSHighlighter : public QSyntaxHighlighter 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | CSSHighlighter(QTextDocument *parent = 0); 24 | 25 | bool event(QEvent *ev) override; 26 | 27 | protected: 28 | void highlightBlock(const QString &text) override; 29 | 30 | private: 31 | void onPaletteChanged(); 32 | 33 | private: 34 | QTextCharFormat m_commentFormat; 35 | QTextCharFormat m_attributeFormat; 36 | QTextCharFormat m_styleFormat; 37 | QTextCharFormat m_stringFormat; 38 | QTextCharFormat m_valueFormat; 39 | }; 40 | 41 | } 42 | #endif // CSSHIGHLIGHTER_H 43 | -------------------------------------------------------------------------------- /src/gui/subtitlemeta/subtitlemetawidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef SUBTITLEMETAWIDGET_H 8 | #define SUBTITLEMETAWIDGET_H 9 | 10 | #include 11 | #include 12 | 13 | #include "gui/subtitlemeta/subtitlepositionwidget.h" 14 | 15 | QT_FORWARD_DECLARE_CLASS(QTabBar); 16 | QT_FORWARD_DECLARE_CLASS(QTextEdit); 17 | class KTextEdit; 18 | 19 | namespace SubtitleComposer { 20 | class Subtitle; 21 | class SubtitleLine; 22 | 23 | class SubtitleMetaWidget : public QWidget 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | SubtitleMetaWidget(QWidget *parent); 29 | virtual ~SubtitleMetaWidget(); 30 | 31 | void setSubtitle(Subtitle *subtitle = nullptr); 32 | inline void setCurrentLine(SubtitleLine *line) { m_subPosition->setCurrentLine(line); } 33 | 34 | inline QWidget *dockTitleBar() const { return m_dockTitleWidget; }; 35 | 36 | protected: 37 | bool eventFilter(QObject *obj, QEvent *event) override; 38 | 39 | private: 40 | QExplicitlySharedDataPointer m_subtitle; 41 | QWidget *m_dockTitleWidget; 42 | QTabBar *m_tabBar; 43 | QTextEdit *m_cssEdit; 44 | KTextEdit *m_commentIntroEdit; 45 | KTextEdit *m_commentTopEdit; 46 | KTextEdit *m_commentBottomEdit; 47 | SubtitlePositionWidget *m_subPosition; 48 | }; 49 | 50 | } 51 | #endif // SUBTITLEMETAWIDGET_H 52 | -------------------------------------------------------------------------------- /src/gui/subtitlemeta/subtitlepositionwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef SUBTITLEPOSITIONWIDGET_H 7 | #define SUBTITLEPOSITIONWIDGET_H 8 | 9 | #include 10 | #include 11 | 12 | namespace Ui { 13 | class SubtitlePositionWidget; 14 | } 15 | 16 | namespace SubtitleComposer { 17 | class SubtitleLine; 18 | struct SubtitleRect; 19 | 20 | class SubtitlePositionWidget : public QWidget 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit SubtitlePositionWidget(QWidget *parent = nullptr); 26 | ~SubtitlePositionWidget(); 27 | 28 | void setCurrentLine(SubtitleLine *line); 29 | 30 | void updatePosition(const SubtitleRect &pos); 31 | 32 | private: 33 | void onPosTop(double value); 34 | void onPosBottom(double value); 35 | void onPosLeft(double value); 36 | void onPosRight(double value); 37 | void onHAlignLeft(bool checked); 38 | void onHAlignCenter(bool checked); 39 | void onHAlignRight(bool checked); 40 | void onVAlignTop(bool checked); 41 | void onVAlignBottom(bool checked); 42 | 43 | private: 44 | Ui::SubtitlePositionWidget *ui; 45 | 46 | QPointer m_currentLine; 47 | }; 48 | 49 | } 50 | 51 | #endif // SUBTITLEPOSITIONWIDGET_H 52 | -------------------------------------------------------------------------------- /src/gui/treeview/linesitemdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef LINESITEMDELEGATE_H 9 | #define LINESITEMDELEGATE_H 10 | 11 | #include 12 | 13 | QT_FORWARD_DECLARE_CLASS(QTextDocument) 14 | 15 | namespace SubtitleComposer { 16 | class LinesWidget; 17 | 18 | class LinesItemDelegate : public QStyledItemDelegate 19 | { 20 | public: 21 | typedef enum { 22 | NoHint = QAbstractItemDelegate::NoHint, 23 | EditNextItem = QAbstractItemDelegate::EditNextItem, 24 | EditPreviousItem = QAbstractItemDelegate::EditPreviousItem, 25 | SubmitModelCache = QAbstractItemDelegate::SubmitModelCache, 26 | RevertModelCache = QAbstractItemDelegate::RevertModelCache, 27 | EditUpperItem, 28 | EditLowerItem, 29 | } ExtendedEditHint; 30 | 31 | LinesItemDelegate(LinesWidget *parent); 32 | virtual ~LinesItemDelegate(); 33 | 34 | inline LinesWidget * linesWidget() const { return qobject_cast(parent()); } 35 | 36 | QString displayText(const QVariant &value, const QLocale &locale) const override; 37 | QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 38 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 39 | 40 | protected: 41 | bool eventFilter(QObject *object, QEvent *event) override; 42 | 43 | void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 44 | }; 45 | } 46 | 47 | #endif // LINESITEMDELEGATE_H 48 | -------------------------------------------------------------------------------- /src/gui/treeview/linesselectionmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef LINESSELECTIONMODEL_H 9 | #define LINESSELECTIONMODEL_H 10 | 11 | #include 12 | #include 13 | 14 | namespace SubtitleComposer { 15 | class LinesModel; 16 | class SubtitleLine; 17 | 18 | class LinesSelectionModel : public QItemSelectionModel 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | LinesSelectionModel(LinesModel *model = nullptr); 24 | 25 | inline SubtitleLine * currentLine() { return m_currentLine; } 26 | 27 | public slots: 28 | void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override; 29 | void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override; 30 | void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) override; 31 | void clear() override; 32 | void reset() override; 33 | 34 | private: 35 | bool m_resetInProgress; 36 | SubtitleLine *m_currentLine; 37 | QSet m_selection; 38 | }; 39 | } 40 | 41 | #endif // LINESSELECTIONMODEL_H 42 | -------------------------------------------------------------------------------- /src/gui/treeview/richdocumentptr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "richdocumentptr.h" 8 | 9 | using namespace SubtitleComposer; 10 | 11 | 12 | RichDocumentPtr::RichDocumentPtr(RichDocument *doc) 13 | : m_doc(doc) 14 | { 15 | qRegisterMetaType("RichDocumentPtr"); 16 | } 17 | 18 | RichDocumentPtr::RichDocumentPtr(const RichDocumentPtr &other) 19 | : m_doc(other.m_doc) 20 | { 21 | } 22 | 23 | RichDocumentPtr::~RichDocumentPtr() 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /src/gui/treeview/richdocumentptr.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef RICHDOCUMENTPTR_H 8 | #define RICHDOCUMENTPTR_H 9 | 10 | #include "core/richtext/richdocument.h" 11 | 12 | namespace SubtitleComposer { 13 | 14 | class RichDocumentPtr { 15 | public: 16 | explicit RichDocumentPtr(RichDocument *doc=nullptr); 17 | RichDocumentPtr(const RichDocumentPtr &other); 18 | virtual ~RichDocumentPtr(); 19 | 20 | inline RichDocument * operator->() { return m_doc; } 21 | inline operator RichDocument *() { return m_doc; } 22 | inline RichDocumentPtr & operator=(const RichDocumentPtr &other) { m_doc = other.m_doc; return *this; } 23 | 24 | private: 25 | RichDocument *m_doc; 26 | }; 27 | 28 | } 29 | 30 | Q_DECLARE_METATYPE(SubtitleComposer::RichDocumentPtr) 31 | 32 | #endif // RICHDOCUMENTPTR_H 33 | -------------------------------------------------------------------------------- /src/gui/treeview/treeview.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef TREEVIEW_H 9 | #define TREEVIEW_H 10 | 11 | #include 12 | 13 | QT_FORWARD_DECLARE_CLASS(QTimer) 14 | 15 | class TreeView : public QTreeView 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit TreeView(QWidget *parent); 21 | virtual ~TreeView(); 22 | 23 | public slots: 24 | void setModel(QAbstractItemModel *model) override; 25 | 26 | protected slots: 27 | void onRowsAboutToBeInserted(const QModelIndex &parent, int start, int end); 28 | void onRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); 29 | 30 | void updateGeometries() override; 31 | 32 | void onUpdateGeometriesTimeout(); 33 | 34 | protected: 35 | QTimer *m_updateGeometriesTimer; 36 | int m_currentModelRows; 37 | int m_instantGeometryUpdate; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/gui/waveform/waverenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef WAVERENDERER_H 8 | #define WAVERENDERER_H 9 | 10 | #include "core/time.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace SubtitleComposer { 18 | class RichDocument; 19 | class WaveformWidget; 20 | 21 | class WaveRenderer : public QWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | explicit WaveRenderer(WaveformWidget *parent); 27 | 28 | inline int span() const { return m_vertical ? height() : width(); } 29 | inline bool vertical() const { return m_vertical; } 30 | 31 | inline const QFont & fontText() const { return m_fontText; } 32 | inline const QPen & subTextColor() const { return m_subTextColor; } 33 | 34 | bool showTranslation() const; 35 | 36 | private: 37 | bool event(QEvent *evt) override; 38 | 39 | void paintGraphics(QPainter &painter); 40 | void paintWaveform(QPainter &painter, quint32 widgetWidth, quint32 widgetHeight); 41 | 42 | void onConfigChanged(); 43 | 44 | private: 45 | WaveformWidget *m_wfw; 46 | 47 | bool m_vertical = false; 48 | 49 | QFont m_fontNumber; 50 | int m_fontNumberHeight; 51 | QFont m_fontText; 52 | 53 | int m_subBorderWidth; 54 | 55 | QPen m_subNumberColor; 56 | QPen m_subTextColor; 57 | 58 | QPen m_waveInner; 59 | QPen m_waveOuter; 60 | 61 | QColor m_subtitleBack; 62 | QColor m_subtitleBorder; 63 | 64 | QColor m_selectedBack; 65 | QColor m_selectedBorder; 66 | 67 | QPen m_playColor; 68 | QPen m_mouseColor; 69 | }; 70 | } 71 | 72 | #endif // WAVERENDERER_H 73 | -------------------------------------------------------------------------------- /src/gui/waveform/wavesubtitle.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef WAVESUBTITLE_H 8 | #define WAVESUBTITLE_H 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | QT_FORWARD_DECLARE_CLASS(QTextLayout) 16 | 17 | namespace SubtitleComposer { 18 | class RichDocument; 19 | class SubtitleLine; 20 | class WaveRenderer; 21 | 22 | enum DragPosition { 23 | DRAG_NONE = 0, 24 | DRAG_FORBIDDEN, 25 | DRAG_SHOW, 26 | DRAG_LINE, 27 | DRAG_HIDE 28 | }; 29 | 30 | class WaveSubtitle : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit WaveSubtitle(SubtitleLine *line, WaveRenderer *parent); 36 | 37 | virtual ~WaveSubtitle(); 38 | 39 | inline SubtitleLine * line() const { return m_line; } 40 | 41 | DragPosition draggableAt(double time, double msTolerance) const; 42 | 43 | void dragStart(DragPosition dragMode, double dragTime); 44 | inline void dragUpdate(double dragTime) { m_dragTime = dragTime; } 45 | DragPosition dragEnd(double dragTime); 46 | 47 | Time showTime() const; 48 | Time hideTime() const; 49 | 50 | const QImage & image() const; 51 | 52 | private: 53 | SubtitleLine *m_line; 54 | WaveRenderer *m_rend; 55 | 56 | mutable QImage m_image; 57 | mutable bool m_imageDirty = true; 58 | 59 | DragPosition m_dragMode = DRAG_NONE; 60 | double m_dragTime = 0.; 61 | double m_dragTimeOffset = 0.; 62 | }; 63 | } 64 | 65 | #endif // WAVESUBTITLE_H 66 | -------------------------------------------------------------------------------- /src/gui/waveform/zoombuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef ZOOMBUFFER_H 8 | #define ZOOMBUFFER_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "gui/waveform/wavebuffer.h" 15 | 16 | namespace SubtitleComposer { 17 | class ZoomBuffer : public QThread 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | explicit ZoomBuffer(WaveBuffer *parent); 23 | virtual ~ZoomBuffer(); 24 | 25 | void setWaveform(const SAMPLE_TYPE * const *waveform); 26 | void setZoomScale(quint32 samplesPerPixel); 27 | void zoomedBuffer(quint32 timeStart, quint32 timeEnd, WaveZoomData **buffers, quint32 *bufLen); 28 | 29 | inline quint32 samplesPerPixel() const { return m_samplesPerPixel; } 30 | 31 | private: 32 | void run() override; 33 | void updateZoomRange(quint32 *start, quint32 end); 34 | void stopAndClear(); 35 | void start(); 36 | 37 | signals: 38 | void zoomedBufferReady(); 39 | 40 | private: 41 | WaveBuffer *m_waveBuffer; 42 | 43 | quint32 m_samplesPerPixel; 44 | WaveZoomData **m_waveformZoomed; 45 | quint32 m_waveformZoomedSize; 46 | const SAMPLE_TYPE * const *m_waveform; 47 | 48 | QMutex m_publicMutex; 49 | 50 | bool m_restartProcessing; 51 | 52 | QMutex m_reqMutex; 53 | quint32 m_reqStart = 0; 54 | quint32 m_reqEnd = 0; 55 | quint32 *m_reqLen = nullptr; 56 | }; 57 | } 58 | 59 | #endif // ZOOMBUFFER_H 60 | -------------------------------------------------------------------------------- /src/helpers/commondefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef COMMONDEFS_H 9 | #define COMMONDEFS_H 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | class String 17 | { 18 | public: 19 | static QString title(const QString &text); 20 | static QString capitalize(const QString &text); 21 | static QString sentence(const QString &text); 22 | 23 | protected: 24 | static int rfindFunctionStart(const QString &text); 25 | static int rfindFunctionEnd(const QString &text, int startPos); 26 | }; 27 | 28 | class System 29 | { 30 | public: 31 | // returns false on error 32 | static bool copy(const QString &srcPath, const QString &dstPath); 33 | static bool move(const QString &srcPath, const QString &dstPath); 34 | static bool remove(const QString &path); 35 | static bool recursiveMakeDir(const QString &path, QStringList *createdDirsList = 0); 36 | 37 | static bool isReadable(const QString &path); 38 | static bool isWritable(const QString &path); 39 | 40 | static QString homeDir(); 41 | static QString tempDir(); 42 | 43 | static QUrl urlFromPath(const QString &path); 44 | 45 | static QUrl newUrl(const QUrl &baseUrl, const QString &fileName = QStringLiteral("tempfile"), const QString &extension = QString(), int retries = 10); 46 | 47 | static bool urlIsInside(const QUrl &url, const QString &path); 48 | static bool urlIsInside(const QUrl &url, QStringList &path); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/helpers/debug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #include "debug.h" 7 | 8 | #include "helpers/common.h" 9 | 10 | #include 11 | #include 12 | 13 | using namespace SubtitleComposer; 14 | 15 | 16 | QString 17 | SubtitleComposer::propertyName(QTextFormat::Property key) 18 | { 19 | if(key >= QTextFormat::UserProperty) 20 | return $("UserProperty+") % QString::number(key - QTextFormat::UserProperty); 21 | const char *keyName = QMetaEnum::fromType().valueToKey(static_cast(key)); 22 | return keyName ? keyName : QString::number(key); 23 | } 24 | 25 | QString 26 | SubtitleComposer::textFormatString(const QTextFormat &format) 27 | { 28 | QString res; 29 | const QMap &props = format.properties(); 30 | for(auto it = props.cbegin(); it != props.cend(); ++it) 31 | res.append(propertyName(QTextFormat::Property(it.key())) % QChar(':') % it.value().toString() % $("; ")); 32 | return res; 33 | } 34 | 35 | QString 36 | SubtitleComposer::dumpFormatRanges(const QString &text, const QVector &ranges) 37 | { 38 | QString res; 39 | for(const QTextLayout::FormatRange &r: ranges) { 40 | res.append(QChar::LineFeed % QChar('"') % QString(text).mid(r.start, r.length) % QChar('"') % QChar::Space % textFormatString(r.format)); 41 | } 42 | return res; 43 | } 44 | -------------------------------------------------------------------------------- /src/helpers/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef DEBUG_H 7 | #define DEBUG_H 8 | 9 | #include 10 | #include 11 | 12 | namespace SubtitleComposer { 13 | 14 | QString propertyName(QTextFormat::Property key); 15 | QString textFormatString(const QTextFormat &format); 16 | QString dumpFormatRanges(const QString &text, const QVector &ranges); 17 | 18 | } 19 | 20 | #endif // DEBUG_H 21 | -------------------------------------------------------------------------------- /src/helpers/languagecode.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef LANGCODES_H 9 | #define LANGCODES_H 10 | 11 | #include 12 | 13 | class LanguageCode 14 | { 15 | public: 16 | /** 17 | * @brief toIso2 18 | * @param iso3Code ISO-3 language code 19 | * @return ISO-2 language code 20 | */ 21 | static QString toIso2(const QString &iso3Code); 22 | /** 23 | * @brief toIso3 24 | * @param iso2Code ISO-2 language code 25 | * @return ISO-3 language code 26 | */ 27 | static QString toIso3(const QString &iso2Code); 28 | 29 | /** 30 | * @brief nameFromIso2 31 | * @param iso2Code ISO-2 language code 32 | * @return Localized language name or "Unknown" 33 | */ 34 | static QString nameFromIso2(const QString &iso2Code); 35 | /** 36 | * @brief nameFromIso3 37 | * @param iso3Code ISO-3 language code 38 | * @return Localized language name or "Unknown" 39 | */ 40 | static QString nameFromIso3(const QString &iso3Code); 41 | /** 42 | * @brief nameFromIso 43 | * @param isoCode ISO-2 or ISO-3 language code 44 | * @return Localized language name or "Unknown (isoCode)" 45 | */ 46 | static QString nameFromIso(const QString &isoCode); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/icons/128-apps-subtitlecomposer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/128-apps-subtitlecomposer.png -------------------------------------------------------------------------------- /src/icons/16-apps-subtitlecomposer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/16-apps-subtitlecomposer.png -------------------------------------------------------------------------------- /src/icons/256-apps-subtitlecomposer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/256-apps-subtitlecomposer.png -------------------------------------------------------------------------------- /src/icons/32-apps-subtitlecomposer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/32-apps-subtitlecomposer.png -------------------------------------------------------------------------------- /src/icons/48-apps-subtitlecomposer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/48-apps-subtitlecomposer.png -------------------------------------------------------------------------------- /src/icons/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND subtitlecomposer_RES ${CMAKE_CURRENT_SOURCE_DIR}/icon-bundle.qrc) 2 | 3 | if(MINGW) 4 | list(APPEND subtitlecomposer_RES_SRC ${CMAKE_CURRENT_SOURCE_DIR}/subtitlecomposer.rc) 5 | set(BUNDLE_THEME_ICONS 1) 6 | elseif(APPIMAGE) 7 | ecm_install_icons(ICONS 8 | 256-apps-subtitlecomposer.png 9 | DESTINATION ${KDE_INSTALL_ICONDIR} 10 | THEME hicolor) 11 | set(BUNDLE_THEME_ICONS 1) 12 | else() 13 | ecm_install_icons(ICONS 14 | 16-apps-subtitlecomposer.png 32-apps-subtitlecomposer.png 128-apps-subtitlecomposer.png 256-apps-subtitlecomposer.png 15 | DESTINATION ${KDE_INSTALL_ICONDIR} 16 | THEME hicolor) 17 | endif() 18 | 19 | if(BUNDLE_THEME_ICONS) 20 | if(BUNDLE_THEME_ICONS EQUAL 1) 21 | if(CMAKE_CROSSCOMPILING) 22 | set(BUNDLE_THEME_ICONS "/usr/share/icons/breeze") # how do you get host's install_prefix when cross compiling? 23 | else() 24 | set(BUNDLE_THEME_ICONS "${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_ICONDIR}/breeze") 25 | endif() 26 | endif() 27 | message(STATUS "Bundling system icon theme...'") 28 | execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/theme-icons-bundle.sh" "${BUNDLE_THEME_ICONS}" 29 | OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/theme-icons-bundle.qrc) 30 | list(APPEND subtitlecomposer_RES ${CMAKE_CURRENT_BINARY_DIR}/theme-icons-bundle.qrc) 31 | set(SC_BUNDLE_SYSTEM_THEME 1 CACHE INTERNAL EXPORTEDVARIABLE) 32 | endif() 33 | 34 | # export vars 35 | set(subtitlecomposer_RES_SRC "${subtitlecomposer_RES_SRC}" PARENT_SCOPE) 36 | set(subtitlecomposer_RES "${subtitlecomposer_RES}" PARENT_SCOPE) 37 | -------------------------------------------------------------------------------- /src/icons/README: -------------------------------------------------------------------------------- 1 | mediaplayer.png modified from KDE4 Oxygen theme 2 | time-from-video.png modified from KDE4 Oxygen theme 3 | set-hide-time.svg modified from KDE Breeze theme 4 | set-show-time.svg modified from KDE Breeze theme 5 | current-line-follows-video.svg modified from KDE Breeze theme 6 | -------------------------------------------------------------------------------- /src/icons/actions/anchor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/icons/actions/audio-extract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/actions/audio-extract.png -------------------------------------------------------------------------------- /src/icons/actions/curline-follows-video.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/actions/playrate-minus.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/actions/playrate-plus.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/actions/select-stream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/actions/select-stream.png -------------------------------------------------------------------------------- /src/icons/actions/set-hide-time.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/actions/set-show-time.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/actions/time-from-video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/actions/time-from-video.png -------------------------------------------------------------------------------- /src/icons/actions/waveform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/actions/waveform.png -------------------------------------------------------------------------------- /src/icons/apps/mediaplayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/apps/mediaplayer.png -------------------------------------------------------------------------------- /src/icons/apps/pocketsphinx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/apps/pocketsphinx.png -------------------------------------------------------------------------------- /src/icons/breeze.theme: -------------------------------------------------------------------------------- 1 | [Icon Theme] 2 | Name=Breeze 3 | Directories=actions/22,apps/16,apps/32,apps/48,apps/128,apps/256 4 | 5 | [actions/22] 6 | Size=22 7 | Context=Actions 8 | Type=Fixed 9 | 10 | [apps/16] 11 | Size=16 12 | Context=Applications 13 | Type=Fixed 14 | 15 | [apps/32] 16 | Size=32 17 | Context=Applications 18 | Type=Fixed 19 | 20 | [apps/48] 21 | Size=48 22 | Context=Applications 23 | Type=Fixed 24 | 25 | [apps/128] 26 | Size=128 27 | Context=Applications 28 | Type=Fixed 29 | 30 | [apps/256] 31 | Size=256 32 | Context=Applications 33 | Type=Fixed 34 | -------------------------------------------------------------------------------- /src/icons/icon-bundle.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | breeze.theme 5 | 6 | 7 | 16-apps-subtitlecomposer.png 8 | 32-apps-subtitlecomposer.png 9 | 48-apps-subtitlecomposer.png 10 | 128-apps-subtitlecomposer.png 11 | 256-apps-subtitlecomposer.png 12 | apps/pocketsphinx.png 13 | apps/mediaplayer.png 14 | 15 | 16 | actions/anchor.svg 17 | actions/audio-extract.png 18 | actions/curline-follows-video.svg 19 | actions/playrate-minus.svg 20 | actions/playrate-plus.svg 21 | actions/select-stream.png 22 | actions/set-hide-time.svg 23 | actions/set-show-time.svg 24 | actions/time-from-video.png 25 | actions/waveform.png 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/icons/mingw-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "$0")" 4 | icotool -c {16,32,48,256}-apps-subtitlecomposer.png -o subtitlecomposer.ico 5 | 6 | -------------------------------------------------------------------------------- /src/icons/subtitlecomposer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxrd2/SubtitleComposer/2736b7bed69149a639acf8445aded344d9d29fc7/src/icons/subtitlecomposer.ico -------------------------------------------------------------------------------- /src/icons/subtitlecomposer.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "subtitlecomposer.ico" 2 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef MAINWINDOW_H 9 | #define MAINWINDOW_H 10 | 11 | #include "appglobal.h" 12 | #include "core/subtitle.h" 13 | 14 | #include 15 | 16 | namespace SubtitleComposer { 17 | class PlayerWidget; 18 | class SubtitleMetaWidget; 19 | class LinesWidget; 20 | class CurrentLineWidget; 21 | class VideoPlayer; 22 | class WaveformWidget; 23 | 24 | class MainWindow : public KXmlGuiWindow 25 | { 26 | Q_OBJECT 27 | 28 | friend class Application; 29 | 30 | public: 31 | MainWindow(); 32 | virtual ~MainWindow(); 33 | 34 | void loadConfig(); 35 | void saveConfig(); 36 | 37 | QMenu *createPopupMenu() override; 38 | 39 | protected: 40 | bool queryClose() override; 41 | 42 | protected: 43 | friend VideoPlayer * videoPlayer(); 44 | PlayerWidget *m_playerWidget; 45 | SubtitleMetaWidget *m_metaWidget; 46 | LinesWidget *m_linesWidget; 47 | CurrentLineWidget *m_curLineWidget; 48 | WaveformWidget *m_waveformWidget; 49 | }; 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /src/scconfig.kcfgc: -------------------------------------------------------------------------------- 1 | File=scconfig.kcfg 2 | ClassName=SCConfig 3 | Singleton=true 4 | Mutators=true 5 | -------------------------------------------------------------------------------- /src/scripting/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB javascript_examples examples/*.js) 2 | FILE(GLOB header_files scripting_*.h) 3 | 4 | INSTALL(FILES 5 | ${javascript_examples} examples/README 6 | DESTINATION ${KDE_INSTALL_DATADIR}/subtitlecomposer/scripts 7 | ) 8 | 9 | INSTALL(FILES 10 | ${header_files} 11 | DESTINATION ${KDE_INSTALL_DATADIR}/subtitlecomposer/scripts/api 12 | ) 13 | -------------------------------------------------------------------------------- /src/scripting/examples/README: -------------------------------------------------------------------------------- 1 | SUBTITLE COMPOSER SCRIPTING README 2 | ================================== 3 | 4 | There's currently no real documentation but the examples and the included API 5 | (see 'api' directory) should give you enough information to get started. 6 | 7 | Besides the corresponding interpreter framework and Kross defined modules (i18n, 8 | forms, etc.), scripts can access some modules specific to Subtitle Composer that 9 | provide methods to access global objects, enum values and/or create other objects: 10 | 11 | ranges: 12 | contains methods to create ranges and ranges lists, including a range list 13 | describing the current selection ranges. 14 | 15 | strings: 16 | contains only one method for creating styled string objects and provides 17 | access to the StyleFlag enum values, used to get/set styling information 18 | (see SString class *StyleFlag* methods). 19 | 20 | subtitle: 21 | contains methods to access the subtitle instance and query the translation 22 | mode state (true when there's an open translation, false otherwise). It also 23 | provides access to TextTarget enum values, used to specify the target (primary 24 | text, secondary text/translation, or both) in subtitle operations that modify 25 | text (i.e., lowerCase(...) or breakLines(...) methods). 26 | 27 | subtitleline: 28 | provides access to the ErrorFlag enum values, used to specify errors bits in 29 | error manipulation methods on both Subtitle and SubtitleLine classes. 30 | 31 | debug: 32 | contains three functions (information, warning and error) that can be used 33 | while debuging scripts 34 | 35 | Using these modules you can access objects to do pretty much anything the main 36 | application can do. Included are some basic examples showcasing some of the 37 | things you can do. If you have other scripts you consider worth sharing then send 38 | them to me and I'll consider them for inclusion with the program. 39 | -------------------------------------------------------------------------------- /src/scripting/examples/example_capitalize_all_lines.js: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | 6 | @category Examples 7 | @name Capitalize All Lines 8 | @version 1.0 9 | @summary Example script to capitalize first letter of each subtitle line. 10 | @author SubtitleComposer Team 11 | */ 12 | 13 | let s = subtitle.instance(); 14 | for(let i = 0, n = s.linesCount(); i < n; i++) { 15 | let line = s.line(i); 16 | let text = line.primaryText(); 17 | line.setPrimaryText(text.left(1).toUpper().append(text.mid(1))); 18 | } 19 | -------------------------------------------------------------------------------- /src/scripting/examples/example_remove_odd_lines.js: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | 6 | @category Examples 7 | @name Remove Odd Lines 8 | @version 1.0 9 | @summary Example script to remove odd lines. 10 | @author SubtitleComposer Team 11 | */ 12 | 13 | let s = subtitle.instance(); 14 | for(let i = s.linesCount() - 1; i >= 0; i--) { 15 | if(i % 2 == 0) 16 | s.removeLine(i); 17 | } 18 | -------------------------------------------------------------------------------- /src/scripting/examples/example_trim_to_selection.js: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | 6 | @category Examples 7 | @name Remove Unselected Lines 8 | @version 1.0 9 | @summary Example script to remove all lines except the selected ones. 10 | @author SubtitleComposer Team 11 | */ 12 | 13 | subtitle.instance().removeLines(ranges.newSelectionRangeList().complement()); 14 | -------------------------------------------------------------------------------- /src/scripting/examples/remove_hearing_impaired_text.js: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2021-2023 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | 7 | @name Remove Hearing Impaired Text 8 | @version 1.0 9 | @summary Remove hearing impaired text from subtitle lines. 10 | @author SubtitleComposer Team 11 | */ 12 | 13 | const s = subtitle.instance(); 14 | for(let i = s.linesCount() - 1; i >= 0; i--) { 15 | let line = s.line(i), 16 | text = line.richPrimaryText() 17 | .replace(/\s*\([^)]+\)\s*/g, ' ') 18 | .replace(/\s*\[[^\]]+\]\s*/g, ' ') 19 | .replace(/^(<.*>)?.*:\s+/gm, '$1') 20 | .replace(/(^\s*|\s*$)/gm, ''); 21 | 22 | if(text.replace(/(<[^>]+>|\s)/g, '') === '') 23 | s.removeLine(i); 24 | else 25 | line.setRichPrimaryText(text); 26 | } 27 | -------------------------------------------------------------------------------- /src/scripting/scripting_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTING_LIST_H 9 | #define SCRIPTING_LIST_H 10 | 11 | #include 12 | 13 | namespace SubtitleComposer { 14 | namespace Scripting { 15 | class List : public QObject 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | List(const char *contentClass, QObject *parent); 21 | List(const QObjectList &backend, const char *contentClass, QObject *parent); 22 | 23 | public slots: 24 | bool isEmpty() const; 25 | 26 | int length() const; 27 | int size() const; 28 | int count() const; 29 | 30 | QObject * at(int index) const; 31 | 32 | void insert(int index, QObject *object); 33 | void append(QObject *object); 34 | void prepend(QObject *object); 35 | 36 | void removeFirst(); 37 | void removeLast(); 38 | void removeAt(int index); 39 | 40 | void clear(); 41 | 42 | private: 43 | const char *m_contentClass; 44 | QObjectList m_backend; 45 | }; 46 | } 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/scripting/scripting_range.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "scripting_range.h" 9 | 10 | using namespace SubtitleComposer; 11 | 12 | /// RANGE IMPLEMENTATION 13 | /// ==================== 14 | 15 | Scripting::Range::Range(const SubtitleComposer::Range &range, QObject *parent) : 16 | QObject(parent), 17 | m_backend(range) 18 | {} 19 | 20 | int 21 | Scripting::Range::start() const 22 | { 23 | return m_backend.start(); 24 | } 25 | 26 | int 27 | Scripting::Range::end() const 28 | { 29 | return m_backend.end(); 30 | } 31 | 32 | int 33 | Scripting::Range::length() const 34 | { 35 | return m_backend.length(); 36 | } 37 | 38 | bool 39 | Scripting::Range::contains(int index) const 40 | { 41 | return m_backend.contains(index); 42 | } 43 | 44 | bool 45 | Scripting::Range::contains(const QObject *object) const 46 | { 47 | if(const Scripting::Range * range = qobject_cast(object)) 48 | return m_backend.contains(range->m_backend); 49 | else 50 | return false; 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/scripting/scripting_range.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTING_RANGE_H 9 | #define SCRIPTING_RANGE_H 10 | 11 | #include "core/range.h" 12 | 13 | #include 14 | 15 | namespace SubtitleComposer { 16 | namespace Scripting { 17 | class Range : public QObject 18 | { 19 | Q_OBJECT 20 | 21 | public slots: 22 | int start() const; 23 | int end() const; 24 | int length() const; 25 | 26 | bool contains(int index) const; 27 | bool contains(const QObject *range) const; 28 | 29 | private: 30 | friend class RangesModule; 31 | friend class RangeList; 32 | friend class Subtitle; 33 | 34 | Range(const SubtitleComposer::Range &range, QObject *parent); 35 | 36 | SubtitleComposer::Range m_backend; 37 | }; 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /src/scripting/scripting_rangelist.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTING_RANGELIST_H 9 | #define SCRIPTING_RANGELIST_H 10 | 11 | #include "core/rangelist.h" 12 | 13 | #include 14 | 15 | namespace SubtitleComposer { 16 | namespace Scripting { 17 | class RangeList : public QObject 18 | { 19 | Q_OBJECT 20 | 21 | public slots: 22 | QObject * complement() const; 23 | 24 | bool isEmpty() const; 25 | 26 | int rangesCount() const; 27 | int indexesCount() const; 28 | 29 | int firstIndex() const; 30 | int lastIndex() const; 31 | 32 | QObject * range(int rangeIndex) const; 33 | 34 | bool contains(int index) const; 35 | 36 | void clear(); 37 | 38 | void trimToIndex(int index); 39 | void trimToRange(QObject *range); 40 | 41 | QObject * addIndex(int index); 42 | QObject * addRange(QObject *range); 43 | 44 | void shiftIndexesForwards(int fromIndex, int delta, bool fillSplitGap); 45 | void shiftIndexesBackwards(int fromIndex, int delta); 46 | 47 | private: 48 | friend class RangesModule; 49 | friend class Subtitle; 50 | 51 | RangeList(const SubtitleComposer::RangeList &backend, QObject *parent); 52 | 53 | SubtitleComposer::RangeList m_backend; 54 | }; 55 | } 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /src/scripting/scripting_rangesmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTING_RANGESMODULE_H 9 | #define SCRIPTING_RANGESMODULE_H 10 | 11 | #include 12 | 13 | namespace SubtitleComposer { 14 | namespace Scripting { 15 | class RangesModule : public QObject 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | RangesModule(QObject *parent = 0); 21 | 22 | public slots: 23 | QObject * newRange(int firstIndex, int lastIndex); 24 | 25 | QObject * newLowerRange(int index); 26 | QObject * newUpperRange(int index); 27 | 28 | QObject * newUptoLastSelectedRange(); 29 | QObject * newFromFirstSelectedRange(); 30 | 31 | QObject * newEmptyRangeList(); 32 | QObject * newSelectionRangeList(); 33 | }; 34 | } 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /src/scripting/scripting_stringsmodule.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "scripting_stringsmodule.h" 9 | #include "scripting_richstring.h" 10 | 11 | using namespace SubtitleComposer; 12 | 13 | Scripting::StringsModule::StringsModule(QObject *parent) : 14 | QObject(parent) 15 | {} 16 | 17 | QObject * 18 | Scripting::StringsModule::newString(const QString &text) 19 | { 20 | return new RichString(SubtitleComposer::RichString(text), this); 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/scripting/scripting_stringsmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTING_STRINGSMODULE_H 9 | #define SCRIPTING_STRINGSMODULE_H 10 | 11 | #include "core/richstring.h" 12 | #include "scripting_list.h" 13 | 14 | #include 15 | #include 16 | 17 | namespace SubtitleComposer { 18 | namespace Scripting { 19 | class StringsModule : public QObject 20 | { 21 | Q_OBJECT 22 | 23 | Q_ENUMS(StyleFlag) 24 | 25 | public: 26 | using StyleFlag = SubtitleComposer::RichString::StyleFlag; 27 | 28 | StringsModule(QObject *parent = 0); 29 | 30 | public slots: 31 | QObject * newString(const QString &text = QString()); 32 | }; 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /src/scripting/scripting_subtitlelinemodule.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "scripting_subtitlelinemodule.h" 9 | 10 | #include 11 | 12 | using namespace SubtitleComposer; 13 | 14 | Scripting::SubtitleLineModule::SubtitleLineModule(QObject *parent) : 15 | QObject(parent) 16 | {} 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/scripting/scripting_subtitlelinemodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTING_SUBTITLELINEMODULE_H 9 | #define SCRIPTING_SUBTITLELINEMODULE_H 10 | 11 | #include "core/subtitleline.h" 12 | #include "core/subtitletarget.h" 13 | 14 | #include 15 | 16 | namespace SubtitleComposer { 17 | namespace Scripting { 18 | class SubtitleLineModule : public QObject 19 | { 20 | Q_OBJECT 21 | 22 | Q_ENUMS(TextTarget) 23 | Q_ENUMS(ErrorFlag) 24 | 25 | public: 26 | using TextTarget = SubtitleComposer::SubtitleTarget; 27 | using ErrorFlag = SubtitleComposer::SubtitleLine::ErrorFlag; 28 | 29 | SubtitleLineModule(QObject *parent = 0); 30 | }; 31 | } 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /src/scripting/scripting_subtitlemodule.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "scripting_subtitlemodule.h" 9 | 10 | #include "appglobal.h" 11 | #include "application.h" 12 | #include "scripting_subtitle.h" 13 | 14 | using namespace SubtitleComposer; 15 | 16 | Scripting::SubtitleModule::SubtitleModule(QObject *parent) : 17 | QObject(parent) 18 | {} 19 | 20 | QObject * 21 | Scripting::SubtitleModule::instance() 22 | { 23 | return appSubtitle() ? new Scripting::Subtitle(appSubtitle(), this) : nullptr; 24 | } 25 | 26 | bool 27 | Scripting::SubtitleModule::translationMode() 28 | { 29 | return app()->translationMode(); 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/scripting/scripting_subtitlemodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTING_SUBTITLEMODULE_H 9 | #define SCRIPTING_SUBTITLEMODULE_H 10 | 11 | #include "core/subtitletarget.h" 12 | 13 | #include 14 | 15 | namespace SubtitleComposer { 16 | namespace Scripting { 17 | class SubtitleModule : public QObject 18 | { 19 | Q_OBJECT 20 | 21 | Q_ENUMS(TextTarget) 22 | 23 | public: 24 | SubtitleModule(QObject *parent = 0); 25 | 26 | using TextTarget = SubtitleComposer::SubtitleTarget; 27 | 28 | public slots: 29 | QObject * instance(); 30 | 31 | bool translationMode(); 32 | }; 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /src/scripting/scriptsmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SCRIPTSMANAGER_H 9 | #define SCRIPTSMANAGER_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "ui_scriptsmanager.h" 16 | 17 | QT_FORWARD_DECLARE_CLASS(QAction) 18 | QT_FORWARD_DECLARE_CLASS(QDialog) 19 | QT_FORWARD_DECLARE_CLASS(QMenu) 20 | QT_FORWARD_DECLARE_CLASS(QPushButton) 21 | class TreeView; 22 | 23 | namespace SubtitleComposer { 24 | class SCScript; 25 | class Subtitle; 26 | 27 | class ScriptsManager : public QObject, private Ui::ScriptsManager 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit ScriptsManager(QObject *parent = 0); 33 | virtual ~ScriptsManager(); 34 | 35 | bool eventFilter(QObject *object, QEvent *event) override; 36 | 37 | public slots: 38 | void setSubtitle(Subtitle *subtitle = 0); 39 | 40 | void showDialog(); 41 | 42 | void createScript(const QString &scriptName = QString()); 43 | void addScript(const QUrl &srcScriptUrl = QUrl()); 44 | void removeScript(const QString &scriptName = QString()); 45 | void editScript(const QString &scriptName = QString()); 46 | void runScript(const QString &scriptName = QString()); 47 | void reloadScripts(); 48 | 49 | private: 50 | static const QStringList & mimeTypes(); 51 | QMenu * toolsMenu(); 52 | const SCScript * currentScript() const; 53 | const SCScript * findScript(const QString filename) const; 54 | 55 | static void findAllFiles(QString path, QStringList &findAllFiles); 56 | 57 | private slots: 58 | void onToolsMenuActionTriggered(QAction *action); 59 | 60 | private: 61 | QDialog *m_dialog; 62 | }; 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /src/speechplugins/pocketsphinx/plugin-config.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | #define POCKETSPHINX_MODELDIR "@POCKETSPHINX_MODELDIR@" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/speechplugins/pocketsphinx/pocketsphinxconfig.kcfgc: -------------------------------------------------------------------------------- 1 | File=pocketsphinxconfig.kcfg 2 | ClassName=PocketSphinxConfig 3 | Singleton=true 4 | Mutators=true 5 | -------------------------------------------------------------------------------- /src/speechplugins/pocketsphinx/pocketsphinxconfigwidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "pocketsphinxconfigwidget.h" 8 | 9 | #include 10 | #include 11 | 12 | using namespace SubtitleComposer; 13 | 14 | PocketSphinxConfigWidget::PocketSphinxConfigWidget(QWidget *parent) 15 | : QWidget(parent) 16 | { 17 | setupUi(this); 18 | #if KIO_VERSION >= QT_VERSION_CHECK(5, 108, 0) 19 | kcfg_lexiconFile->setNameFilters({ 20 | i18n("Sphinx Dictionaries") + QLatin1String(" (*.dict *.dic)"), 21 | i18n("All Files") + QLatin1String(" (*)"), 22 | }); 23 | kcfg_trigramModelFile->setNameFilters({ 24 | i18n("Trigram Models") + QStringLiteral(" (*.lm.bin *.lm)"), 25 | i18n("All Files") + QLatin1String(" (*)"), 26 | }); 27 | #else 28 | kcfg_lexiconFile->setFilter(QLatin1String("*.dict *.dic|") + i18n("Sphinx Dictionaries") + QLatin1String("\n*|") + i18n("All Files")); 29 | kcfg_trigramModelFile->setFilter(QStringLiteral("*.lm.bin *.lm|") + i18n("Trigram Models") + QLatin1String("\n*|") + i18n("All Files")); 30 | #endif 31 | } 32 | 33 | PocketSphinxConfigWidget::~PocketSphinxConfigWidget() 34 | { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/speechplugins/pocketsphinx/pocketsphinxconfigwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef MPLAYERCONFIGWIDGET_H 8 | #define MPLAYERCONFIGWIDGET_H 9 | 10 | #include "ui_pocketsphinxconfigwidget.h" 11 | 12 | namespace SubtitleComposer { 13 | class PocketSphinxConfigWidget : public QWidget, Ui::PocketSphinxConfigWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit PocketSphinxConfigWidget(QWidget *parent = nullptr); 19 | virtual ~PocketSphinxConfigWidget(); 20 | }; 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/speechplugins/pocketsphinx/pocketsphinxplugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef POCKETSPHINXPLUGIN_H 8 | #define POCKETSPHINXPLUGIN_H 9 | 10 | #include "speechprocessor/speechplugin.h" 11 | 12 | typedef struct ps_decoder_s ps_decoder_t; 13 | typedef struct cmd_ln_s cmd_ln_t; 14 | typedef struct SpeexPreprocessState_ SpeexPreprocessState; 15 | 16 | namespace SubtitleComposer { 17 | class PocketSphinxPlugin : public SpeechPlugin 18 | { 19 | Q_OBJECT 20 | 21 | Q_PLUGIN_METADATA(IID SpeechPlugin_iid) 22 | Q_INTERFACES(SubtitleComposer::SpeechPlugin) 23 | 24 | public: 25 | PocketSphinxPlugin(); 26 | 27 | QWidget * newConfigWidget(QWidget *parent) override; 28 | KCoreConfigSkeleton * config() const override; 29 | 30 | private: 31 | const QString & name() override; 32 | 33 | const WaveFormat & waveFormat() const override; 34 | bool init() override; 35 | void cleanup() override; 36 | 37 | void processSamples(const void *sampleData, qint32 sampleCount) override; 38 | void processComplete() override; 39 | 40 | void processUtterance(); 41 | 42 | private: 43 | cmd_ln_t *m_psConfig; 44 | ps_decoder_t *m_psDecoder; 45 | qint32 m_psFrameRate; 46 | 47 | QString m_lineText; 48 | int m_lineIn; 49 | int m_lineOut; 50 | 51 | bool m_utteranceStarted; 52 | bool m_speechStarted; 53 | }; 54 | } 55 | 56 | #endif // POCKETSPHINXPLUGIN_H 57 | -------------------------------------------------------------------------------- /src/speechprocessor/speechplugin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "speechplugin.h" 8 | 9 | using namespace SubtitleComposer; 10 | 11 | SpeechPlugin::SpeechPlugin() 12 | : QObject(nullptr) 13 | { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/speechprocessor/speechplugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef SPEECHPLUGIN_H 8 | #define SPEECHPLUGIN_H 9 | 10 | #include 11 | 12 | #define SpeechPlugin_iid "org.kde.SubtitleComposer.SpeechPlugin" 13 | 14 | class KCoreConfigSkeleton; 15 | class WaveFormat; 16 | 17 | namespace SubtitleComposer { 18 | class SpeechPlugin : public QObject 19 | { 20 | Q_OBJECT 21 | 22 | friend class SpeechProcessor; 23 | friend class ConfigDialog; 24 | template friend class PluginHelper; 25 | 26 | protected: 27 | explicit SpeechPlugin(); 28 | 29 | virtual QWidget * newConfigWidget(QWidget *parent) = 0; 30 | virtual KCoreConfigSkeleton * config() const = 0; 31 | 32 | private: 33 | virtual const QString & name() = 0; 34 | 35 | virtual const WaveFormat & waveFormat() const = 0; 36 | 37 | virtual bool init() = 0; 38 | virtual void cleanup() = 0; 39 | 40 | virtual void processSamples(const void *sampleData, qint32 sampleCount) = 0; 41 | virtual void processComplete() = 0; 42 | 43 | signals: 44 | void error(int code, const QString &message); 45 | void textRecognized(const QString &text, const double milliShow, const double milliHide); 46 | }; 47 | } 48 | 49 | Q_DECLARE_INTERFACE(SubtitleComposer::SpeechPlugin, SpeechPlugin_iid) 50 | 51 | #endif // SPEECHPLUGIN_H 52 | -------------------------------------------------------------------------------- /src/subtitlecomposer.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | subtitlecomposerui.rc 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/subtitlecomposerrc: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | Height 768=769 3 | Width 1024=1025 4 | LastDir=$HOME 5 | 6 | [MainWindow Toolbar mainToolBar] 7 | Index=0 8 | NewLine=false 9 | -------------------------------------------------------------------------------- /src/tests/rangelisttest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef RANGELISTTEST_H 9 | #define RANGELISTTEST_H 10 | 11 | #include 12 | 13 | class RangeListTest : public QObject 14 | { 15 | Q_OBJECT 16 | private slots: 17 | void testConstructors(); 18 | void testJoinAndTrim(); 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/tests/rangetest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef RANGETEST_H 9 | #define RANGETEST_H 10 | 11 | #include 12 | 13 | class RangeTest : public QObject 14 | { 15 | Q_OBJECT 16 | 17 | private slots: 18 | void testConstructors(); 19 | void testLimits(); 20 | void testOperators(); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/tests/richcsstest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2021-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef RICHCSSTEST_H 8 | #define RICHCSSTEST_H 9 | 10 | #include "core/richtext/richcss.h" 11 | 12 | #include 13 | 14 | class RichCssTest : public QObject 15 | { 16 | Q_OBJECT 17 | 18 | SubtitleComposer::RichCSS css; 19 | 20 | private slots: 21 | void testParseSelector_data(); 22 | void testParseSelector(); 23 | 24 | void testParseRules_data(); 25 | void testParseRules(); 26 | }; 27 | 28 | #endif // RICHCSSTEST_H 29 | -------------------------------------------------------------------------------- /src/tests/richdocumentlayouttest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef RICHDOCUMENTLAYOUTTEST_H 8 | #define RICHDOCUMENTLAYOUTTEST_H 9 | 10 | #include "core/richtext/richdocumentlayout.h" 11 | 12 | #include 13 | 14 | class RichDocumentLayoutTest : public QObject 15 | { 16 | Q_OBJECT 17 | 18 | SubtitleComposer::RichDocumentLayout richLayout; 19 | 20 | public: 21 | RichDocumentLayoutTest(); 22 | 23 | private slots: 24 | void testMerge_data(); 25 | void testMerge(); 26 | }; 27 | 28 | #endif // RICHDOCUMENTLAYOUTTEST_H 29 | -------------------------------------------------------------------------------- /src/tests/richdocumenttest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef RICHDOCUMENTTEST_H 8 | #define RICHDOCUMENTTEST_H 9 | 10 | #include "core/richtext/richdocument.h" 11 | 12 | class RichDocumentTest : public QObject 13 | { 14 | Q_OBJECT 15 | 16 | SubtitleComposer::RichDocument doc; 17 | 18 | private slots: 19 | void testCursor(); 20 | 21 | void testHtml_data(); 22 | void testHtml(); 23 | 24 | void testRegExpReplace_data(); 25 | void testRegExpReplace(); 26 | 27 | void testIndexReplace_data(); 28 | void testIndexReplace(); 29 | 30 | void testCleanupSpaces_data(); 31 | void testCleanupSpaces(); 32 | 33 | void testUpperLower(); 34 | 35 | void testSentence_data(); 36 | void testSentence(); 37 | 38 | void testTitle_data(); 39 | void testTitle(); 40 | 41 | void testClass(); 42 | }; 43 | 44 | #endif // RICHDOCUMENTTEST_H 45 | -------------------------------------------------------------------------------- /src/tests/richstringtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef RICHSTRINGTEST_H 9 | #define RICHSTRINGTEST_H 10 | 11 | #include 12 | 13 | class RichStringTest : public QObject 14 | { 15 | Q_OBJECT 16 | 17 | private slots: 18 | void testStyleFlags(); 19 | void testLeftMidRight(); 20 | void testInsert(); 21 | void testReplace(); 22 | void testStyleMerge(); 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/tests/subtitletest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2021-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #include "subtitletest.h" 8 | 9 | #include 10 | 11 | #include "core/richtext/richdocument.h" 12 | 13 | #include 14 | 15 | using namespace SubtitleComposer; 16 | 17 | 18 | SubtitleTest::SubtitleTest() 19 | : sub(new SubtitleComposer::Subtitle) 20 | { 21 | KLocalizedString::setApplicationDomain("subtitlecomposer"); 22 | } 23 | 24 | SubtitleTest::~SubtitleTest() 25 | { 26 | sub.reset(); 27 | } 28 | 29 | void 30 | SubtitleTest::testSort_data() 31 | { 32 | QTest::addColumn>("lines"); 33 | 34 | QTest::newRow("ordered") 35 | << (QVector() << 1 << 2 << 3 << 4 << 5 << 6); 36 | QTest::newRow("inverse") 37 | << (QVector() << 6 << 5 << 4 << 3 << 2 << 1); 38 | QTest::newRow("random1") 39 | << (QVector() << 3 << 4 << 2 << 1 << 5 << 6); 40 | QTest::newRow("random2") 41 | << (QVector() << 3 << 4 << 1 << 2 << 6 << 5); 42 | } 43 | 44 | void 45 | SubtitleTest::testSort() 46 | { 47 | QFETCH(QVector, lines); 48 | 49 | sub->removeLines(RangeList(Range::full()), SubtitleTarget::Both); 50 | 51 | for(int n: lines) { 52 | SubtitleLine *l = new SubtitleLine(n * 1000, n * 1000 + 500); 53 | l->primaryDoc()->setPlainText(QString::number(n)); 54 | sub->insertLine(l); 55 | } 56 | 57 | QVERIFY(sub->count() == lines.size()); 58 | for(int i = 0; i < sub->count(); i++) 59 | QVERIFY(qRound(sub->at(i)->showTime().toSeconds()) == i + 1); 60 | } 61 | 62 | QTEST_MAIN(SubtitleTest); 63 | -------------------------------------------------------------------------------- /src/tests/subtitletest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2021-2022 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef SUBTITLESORTTEST_H 8 | #define SUBTITLESORTTEST_H 9 | 10 | #include "core/subtitle.h" 11 | 12 | #include 13 | 14 | class SubtitleTest : public QObject 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | SubtitleTest(); 20 | virtual ~SubtitleTest(); 21 | 22 | private slots: 23 | void testSort_data(); 24 | void testSort(); 25 | 26 | private: 27 | QExplicitlySharedDataPointer sub; 28 | }; 29 | 30 | #endif // SUBTITLESORTTEST_H 31 | -------------------------------------------------------------------------------- /src/tests/timetest.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef TIMETEST_H 9 | #define TIMETEST_H 10 | 11 | #include 12 | 13 | class TimeTest : public QObject 14 | { 15 | Q_OBJECT 16 | 17 | private slots: 18 | void testConstructors(); 19 | void testSetters(); 20 | void testOperators(); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/translate/deeplengine.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef DEEPLENGINE_H 7 | #define DEEPLENGINE_H 8 | 9 | #include "ui_deeplengine.h" 10 | 11 | #include "translate/translateengine.h" 12 | 13 | #include 14 | #include 15 | 16 | QT_FORWARD_DECLARE_CLASS(QNetworkAccessManager) 17 | 18 | namespace SubtitleComposer { 19 | 20 | class DeepLEngine : public TranslateEngine 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit DeepLEngine(QObject *parent = nullptr); 26 | virtual ~DeepLEngine(); 27 | 28 | QString name() const override { return QStringLiteral("DeepL"); } 29 | 30 | void settings(QWidget *widget) override; 31 | void translate(QVector &textLines) override; 32 | 33 | private: 34 | bool languagesUpdate(); 35 | void languagesUpdated(QNetworkReply *res); 36 | 37 | private: 38 | QNetworkAccessManager *m_netManager; 39 | Ui::DeepLEngine *m_ui; 40 | }; 41 | } // namespace SubtitleComposer 42 | 43 | #endif // DEEPLENGINE_H 44 | -------------------------------------------------------------------------------- /src/translate/googlecloudengine.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef GOOGLECLOUDENGINE_H 7 | #define GOOGLECLOUDENGINE_H 8 | 9 | #include "ui_googlecloudengine.h" 10 | 11 | #include "translate/translateengine.h" 12 | 13 | #include 14 | #include 15 | 16 | QT_FORWARD_DECLARE_CLASS(QNetworkAccessManager) 17 | 18 | namespace SubtitleComposer { 19 | 20 | class GoogleCloudEngine : public TranslateEngine 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit GoogleCloudEngine(QObject *parent = nullptr); 26 | virtual ~GoogleCloudEngine(); 27 | 28 | QString name() const override { return QStringLiteral("Google Cloud"); } 29 | 30 | void settings(QWidget *widget) override; 31 | void translate(QVector &textLines) override; 32 | 33 | private: 34 | bool parseJSON(const QString &serviceJSONFile); 35 | void login(); 36 | bool authenticate(); 37 | void authenticated(); 38 | bool languagesUpdate(); 39 | void languagesUpdated(QNetworkReply *res); 40 | 41 | private: 42 | QNetworkAccessManager *m_netManager; 43 | Ui::GoogleCloudEngine *m_ui; 44 | 45 | QString m_projectId; 46 | QString m_clientEmail; 47 | QString m_privateKeyId; 48 | QString m_privateKey; 49 | QString m_subject; 50 | QString m_tokenUrl; 51 | }; 52 | } // namespace SubtitleComposer 53 | 54 | #endif // GOOGLECLOUDENGINE_H 55 | -------------------------------------------------------------------------------- /src/translate/mintengine.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef MINTENGINE_H 7 | #define MINTENGINE_H 8 | 9 | #include "ui_mintengine.h" 10 | 11 | #include "translate/translateengine.h" 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | QT_FORWARD_DECLARE_CLASS(QJsonObject) 19 | QT_FORWARD_DECLARE_CLASS(QNetworkAccessManager) 20 | 21 | namespace SubtitleComposer { 22 | 23 | class MinTEngine : public TranslateEngine 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit MinTEngine(QObject *parent = nullptr); 29 | virtual ~MinTEngine(); 30 | 31 | QString name() const override { return QStringLiteral("MinT machine translation"); } 32 | 33 | void settings(QWidget *widget) override; 34 | void translate(QVector &textLines) override; 35 | 36 | private: 37 | void languagesUpdate(); 38 | void languagesRefreshUI(); 39 | QString languageTitle(const QString &code) const; 40 | 41 | private: 42 | QNetworkAccessManager *m_netManager; 43 | const QJsonObject *m_langs; 44 | std::map m_langName; 45 | Ui::MinTEngine *m_ui; 46 | }; 47 | } // namespace SubtitleComposer 48 | 49 | #endif // MINTENGINE_H 50 | -------------------------------------------------------------------------------- /src/translate/translatedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | 7 | #ifndef TRANSLATEDIALOG_H 8 | #define TRANSLATEDIALOG_H 9 | 10 | #include "dialogs/actionwithtargetdialog.h" 11 | 12 | #include 13 | 14 | QT_FORWARD_DECLARE_CLASS(QWidget) 15 | 16 | namespace SubtitleComposer { 17 | 18 | class TranslateEngine; 19 | 20 | class TranslateDialog : public ActionWithTargetDialog 21 | { 22 | public: 23 | TranslateDialog(QWidget *parent = nullptr); 24 | 25 | static void performTranslation(); 26 | 27 | private: 28 | void updateEngineUI(int index); 29 | 30 | public Q_SLOTS: 31 | void accept() override; 32 | 33 | private: 34 | QVector m_engines; 35 | QWidget *m_settings; 36 | TranslateEngine *m_engine; 37 | }; 38 | } // namespace SubtitleComposer 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/translate/translateengine.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2023 Mladen Milinkovic 3 | 4 | SPDX-License-Identifier: GPL-2.0-or-later 5 | */ 6 | #ifndef TRANSLATEENGINE_H 7 | #define TRANSLATEENGINE_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | 19 | QT_FORWARD_DECLARE_CLASS(QNetworkAccessManager); 20 | QT_FORWARD_DECLARE_CLASS(QNetworkRequest) 21 | QT_FORWARD_DECLARE_CLASS(QNetworkReply) 22 | 23 | namespace SubtitleComposer { 24 | 25 | class TranslateEngine : public QObject 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit TranslateEngine(QObject *parent=nullptr); 31 | 32 | virtual QString name() const = 0; 33 | 34 | virtual void settings(QWidget *widget) = 0; 35 | virtual void translate(QVector &textLines) = 0; 36 | 37 | signals: 38 | void engineReady(bool status); 39 | void translated(); 40 | 41 | protected: 42 | void sendRequest(QNetworkAccessManager *nm, const QNetworkRequest &request, const QByteArray &data, std::function callback); 43 | 44 | struct ProgressLock { 45 | ProgressLock(TranslateEngine *e, const QString &progressText); 46 | ~ProgressLock(); 47 | TranslateEngine *te; 48 | }; 49 | 50 | private: 51 | void translateStart(); 52 | void translateDone(); 53 | 54 | struct ProgressHelper; 55 | 56 | QProgressDialog *m_progress; 57 | ProgressHelper *m_ph; 58 | }; 59 | } // namespace SubtitleComposer 60 | 61 | #endif // TRANSLATEENGINE_H 62 | -------------------------------------------------------------------------------- /src/utils/speller.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SPELLER_H 9 | #define SPELLER_H 10 | 11 | #include "core/subtitle.h" 12 | #include "core/subtitleline.h" 13 | 14 | #include 15 | #include 16 | 17 | namespace Sonnet { 18 | class Dialog; 19 | } 20 | namespace SubtitleComposer { 21 | class SubtitleIterator; 22 | 23 | class Speller : public QObject 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit Speller(QWidget *parent = 0); 29 | virtual ~Speller(); 30 | 31 | QWidget * parentWidget(); 32 | 33 | public slots: 34 | void setSubtitle(Subtitle *subtitle = 0); 35 | void setTranslationMode(bool enabled); 36 | void setUseTranslation(bool useTranslation); 37 | 38 | void spellCheck(int currentIndex); 39 | 40 | signals: 41 | void misspelled(SubtitleLine *line, bool primary, int startIndex, int endIndex); 42 | 43 | private: 44 | void invalidate(); 45 | bool advance(); 46 | void updateBuffer(); 47 | 48 | private slots: 49 | void onBufferDone(); 50 | void onMisspelling(const QString &before, int pos); 51 | void onCorrected(const QString &before, int pos, const QString &after); 52 | 53 | void onConfigChanged(); 54 | 55 | private: 56 | QExplicitlySharedDataPointer m_subtitle; 57 | bool m_translationMode; 58 | bool m_useTranslation; 59 | 60 | Sonnet::Dialog *m_sonnetDialog; 61 | SubtitleIterator *m_iterator; 62 | int m_firstIndex; 63 | }; 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /src/videoplayer/backend/clock.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2003 Fabrice Bellard 3 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef CLOCK_H 9 | #define CLOCK_H 10 | 11 | // no AV correction is done if too big error 12 | #define AV_NOSYNC_THRESHOLD 10.0 13 | 14 | namespace SubtitleComposer { 15 | class PacketQueue; 16 | 17 | class Clock 18 | { 19 | public: 20 | Clock(); 21 | 22 | double get() const; 23 | void setAt(double pts, int serial, double time); 24 | void set(double pts, int serial); 25 | void setSpeed(double speed); 26 | void init(const PacketQueue *queue); 27 | void syncTo(Clock *other); 28 | 29 | inline double pts() const { return m_pts; } 30 | inline double lastUpdated() const { return m_lastUpdated; } 31 | inline double speed() const { return m_speed; } 32 | inline int serial() const { return m_serial; } 33 | inline int paused() const { return m_paused; } 34 | inline void pause(bool pause) { m_paused = pause; } 35 | 36 | private: 37 | double m_pts; // clock base 38 | double m_ptsDrift; // clock base minus time at which we updated the clock 39 | double m_lastUpdated; 40 | double m_speed; 41 | int m_serial; // clock is based on a packet with this serial 42 | bool m_paused; 43 | const int *m_queueSerial; // pointer to the current packet queue serial, used for obsolete clock detection 44 | }; 45 | } 46 | 47 | #endif // CLOCK_H 48 | -------------------------------------------------------------------------------- /src/videoplayer/backend/decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2003 Fabrice Bellard 3 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef DECODER_H 9 | #define DECODER_H 10 | 11 | #include 12 | 13 | extern "C" { 14 | #include "libavcodec/avcodec.h" 15 | #include "libavformat/avformat.h" 16 | } 17 | 18 | QT_FORWARD_DECLARE_CLASS(QWaitCondition) 19 | 20 | namespace SubtitleComposer { 21 | class PacketQueue; 22 | class FrameQueue; 23 | class FFPlayer; 24 | 25 | class Decoder : public QThread 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | Decoder(QObject *parent = nullptr); 31 | 32 | void init(AVCodecContext *avctx, PacketQueue *pq, FrameQueue *fq, QWaitCondition *emptyQueueCond); 33 | void start(); 34 | int decodeFrame(AVFrame *frame, AVSubtitle *sub); 35 | virtual void destroy(); 36 | virtual void abort(); 37 | 38 | inline int pktSerial() const { return m_pktSerial; } 39 | inline int width() const { return m_avCtx->width; } 40 | inline int height() const { return m_avCtx->height; } 41 | inline int finished() const { return m_finished; } 42 | 43 | inline void startPts(int64_t pts, const AVRational &tb) { m_startPts = pts; m_startPtsTb = tb; } 44 | 45 | protected: 46 | int m_reorderPts; 47 | AVPacket *m_pkt; 48 | PacketQueue *m_queue; 49 | FrameQueue *m_frameQueue; 50 | AVCodecContext *m_avCtx; 51 | int m_pktSerial; 52 | int m_finished; 53 | QWaitCondition *m_emptyQueueCond; 54 | int64_t m_startPts; 55 | AVRational m_startPtsTb; 56 | int64_t m_nextPts; 57 | AVRational m_nextPtsTb; 58 | 59 | struct FrameData { 60 | int64_t pkt_pos; 61 | }; 62 | }; 63 | } 64 | 65 | #endif // DECODER_H 66 | -------------------------------------------------------------------------------- /src/videoplayer/backend/renderthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2003 Fabrice Bellard 3 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef RENDERTHREAD_H 9 | #define RENDERTHREAD_H 10 | 11 | #include 12 | 13 | struct SwsContext; 14 | struct AVFrame; 15 | struct AVPixFmtDescriptor; 16 | 17 | namespace SubtitleComposer { 18 | class VideoState; 19 | struct Frame; 20 | 21 | class RenderThread : public QThread 22 | { 23 | Q_OBJECT 24 | 25 | friend class AudioDecoder; 26 | 27 | public: 28 | explicit RenderThread(VideoState *state, QObject *parent = nullptr); 29 | 30 | void run() override; 31 | 32 | private: 33 | void videoRefresh(double *remainingTime); 34 | void videoDisplay(); 35 | double vpDuration(Frame *vp, Frame *nextvp); 36 | void updateVideoPts(double pts, int serial); 37 | double computeTargetDelay(double delay); 38 | void updateSampleDisplay(short *samples, int samplesSize); 39 | void toggleAudioDisplay(); 40 | void videoImageDisplay(); 41 | void videoAudioDisplay(); 42 | 43 | private: 44 | VideoState *m_vs; 45 | bool m_isYUV; 46 | bool m_isPlanar; 47 | }; 48 | } 49 | 50 | #endif // RENDERTHREAD_H 51 | -------------------------------------------------------------------------------- /src/videoplayer/backend/streamdemuxer.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2003 Fabrice Bellard 3 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef STREAMDEMUXER_H 9 | #define STREAMDEMUXER_H 10 | 11 | #include 12 | 13 | namespace SubtitleComposer { 14 | class VideoState; 15 | class FFPlayer; 16 | 17 | class StreamDemuxer : public QThread 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | static VideoState * open(const char *filename); 23 | static void close(VideoState *vs); 24 | void pauseToggle(); 25 | void seek(qint64 time); 26 | void stepFrame(); 27 | bool abortRequested(); 28 | int relativeStreamIndex(int codecType, int absoluteIndex); 29 | int absoluteStreamIndex(int codecType, int relativeIndex); 30 | void selectStream(int codecType, int streamIndex); 31 | 32 | private: 33 | StreamDemuxer(VideoState *vs, QObject *parent = nullptr); 34 | 35 | VideoState *m_vs; 36 | 37 | void run() override; 38 | 39 | int componentOpen(int streamIndex); 40 | void componentClose(int streamIndex); 41 | void cycleStream(int codecType); 42 | }; 43 | } 44 | 45 | #endif // STREAMDEMUXER_H 46 | -------------------------------------------------------------------------------- /src/videoplayer/backend/subtitledecoder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2003 Fabrice Bellard 3 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "subtitledecoder.h" 9 | 10 | #include "videoplayer/backend/ffplayer.h" 11 | 12 | using namespace SubtitleComposer; 13 | 14 | SubtitleDecoder::SubtitleDecoder(QObject *parent) 15 | : Decoder(parent) 16 | { 17 | 18 | } 19 | 20 | void 21 | SubtitleDecoder::run() 22 | { 23 | for(;;) { 24 | Frame *sp = m_frameQueue->peekWritable(); 25 | if(!sp) 26 | break; 27 | 28 | int gotSubtitle = decodeFrame(nullptr, &sp->sub); 29 | if(gotSubtitle < 0) 30 | break; 31 | 32 | double pts = 0; 33 | 34 | if(gotSubtitle && sp->sub.format == 0) { 35 | if(sp->sub.pts != AV_NOPTS_VALUE) 36 | pts = sp->sub.pts / (double)AV_TIME_BASE; 37 | sp->pts = pts; 38 | sp->serial = pktSerial(); 39 | sp->width = width(); 40 | sp->height = height(); 41 | sp->uploaded = false; 42 | 43 | // now we can update the picture count 44 | m_frameQueue->push(); 45 | } else if(gotSubtitle) { 46 | avsubtitle_free(&sp->sub); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/videoplayer/backend/subtitledecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2003 Fabrice Bellard 3 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef SUBTITLEDECODER_H 9 | #define SUBTITLEDECODER_H 10 | 11 | #include "videoplayer/backend/decoder.h" 12 | 13 | namespace SubtitleComposer { 14 | class SubtitleDecoder : public Decoder 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | SubtitleDecoder(QObject *parent = nullptr); 20 | 21 | private: 22 | void run() override; 23 | }; 24 | } 25 | 26 | #endif // SUBTITLEDECODER_H 27 | -------------------------------------------------------------------------------- /src/videoplayer/backend/videodecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2003 Fabrice Bellard 3 | SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef VIDEODECODER_H 9 | #define VIDEODECODER_H 10 | 11 | #include "videoplayer/backend/decoder.h" 12 | 13 | namespace SubtitleComposer { 14 | class VideoState; 15 | 16 | class VideoDecoder : public Decoder 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | VideoDecoder(VideoState *state, QObject *parent = nullptr); 22 | 23 | private: 24 | void run() override; 25 | 26 | int getVideoFrame(AVFrame *frame); 27 | int queuePicture(AVFrame *srcFrame, double pts, double duration, int64_t pos, int serial); 28 | 29 | VideoState *m_vs; 30 | 31 | double m_timeBase; 32 | 33 | int m_frameDropsEarly; 34 | }; 35 | } 36 | 37 | #endif // VIDEODECODER_H 38 | -------------------------------------------------------------------------------- /src/widgets/attachablewidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | smplayer, GUI front-end for mplayer 3 | SPDX-FileCopyrightText: 2006-2008 Ricardo Villalba 4 | 5 | modified for inclusion in Subtitle Composer 6 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 7 | 8 | SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #ifndef ATTACHABLEWIDGET_H 12 | #define ATTACHABLEWIDGET_H 13 | 14 | #include 15 | 16 | class AttachableWidget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | typedef enum { Top, Bottom } Place; 22 | 23 | explicit AttachableWidget(Place place = Bottom, unsigned animStepDuration = 4); 24 | virtual ~AttachableWidget(); 25 | 26 | bool isAttached() const; 27 | 28 | bool isAnimated() const; 29 | int animStepDuration() const; 30 | 31 | bool eventFilter(QObject *object, QEvent *event) override; 32 | 33 | public slots: 34 | void attach(QWidget *target); 35 | void dettach(); 36 | 37 | void setAnimStepDuration(int stepDuration); 38 | 39 | void toggleVisible(bool visible); 40 | 41 | protected: 42 | void timerEvent(QTimerEvent *event) override; 43 | 44 | private: 45 | void toggleVisible(bool visible, bool force); 46 | 47 | private: 48 | QWidget *m_targetWidget; 49 | Place m_place; 50 | int m_animStepDuration; 51 | 52 | typedef enum { Upward, Downward } Direction; 53 | 54 | int m_animTID; 55 | bool m_animHiding; 56 | int m_animFinalY; 57 | int m_animCurrentY; 58 | Direction m_animDirection; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/widgets/layeredwidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "layeredwidget.h" 9 | 10 | #include 11 | 12 | #include 13 | 14 | LayeredWidget::LayeredWidget(QWidget *parent, Qt::WindowFlags f) : 15 | QWidget(parent, f) 16 | {} 17 | 18 | void 19 | LayeredWidget::setWidgetMode(QWidget *widget, LayeredWidget::Mode mode) 20 | { 21 | m_ignoredWidgets.removeAll(widget); 22 | if(mode == IgnoreResize) 23 | m_ignoredWidgets.append(widget); 24 | } 25 | 26 | void 27 | LayeredWidget::setMouseTracking(bool enable) 28 | { 29 | // propagates to our children and our children children's 30 | QWidget::setMouseTracking(enable); 31 | QList children = findChildren(); 32 | for(QList::ConstIterator it = children.constBegin(), end = children.constEnd(); it != end; ++it) 33 | (*it)->setMouseTracking(enable); 34 | } 35 | 36 | void 37 | LayeredWidget::resizeEvent(QResizeEvent *) 38 | { 39 | // propagated to our children but not our children children's 40 | QSize size = this->size(); 41 | const QObjectList &children = this->children(); 42 | for(QObjectList::ConstIterator it = children.begin(), end = children.end(); it != end; ++it) { 43 | if(!(*it)->isWidgetType() || m_ignoredWidgets.contains(*it)) 44 | continue; 45 | (static_cast(*it))->resize(size); 46 | } 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/widgets/layeredwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef LAYEREDWIDGET_H 9 | #define LAYEREDWIDGET_H 10 | 11 | #include 12 | #include 13 | 14 | /// a class used to show varios widgets simultaneously one in top 15 | /// of the another (unlike QStackWidget which shows one at a time) 16 | 17 | class LayeredWidget : public QWidget 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | typedef enum { HandleResize, IgnoreResize } Mode; 23 | 24 | explicit LayeredWidget(QWidget *parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); 25 | 26 | void setWidgetMode(QWidget *widget, Mode mode); 27 | 28 | public slots: 29 | void setMouseTracking(bool enable); 30 | 31 | protected: 32 | void resizeEvent(QResizeEvent *e) override; 33 | 34 | private: 35 | QList m_ignoredWidgets; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/widgets/pointingslider.h: -------------------------------------------------------------------------------- 1 | /* 2 | smplayer, GUI front-end for mplayer. 3 | SPDX-FileCopyrightText: 2007 Ricardo Villalba 4 | 5 | modified for inclusion in Subtitle Composer 6 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 7 | 8 | SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #ifndef POINTINGSLIDER_H 12 | #define POINTINGSLIDER_H 13 | 14 | #include 15 | 16 | class PointingSlider : public QSlider 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit PointingSlider(QWidget *parent = 0); 22 | explicit PointingSlider(Qt::Orientation orientation, QWidget *parent = 0); 23 | 24 | virtual ~PointingSlider(); 25 | 26 | protected: 27 | void mousePressEvent(QMouseEvent *e) override; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/widgets/textoverlaywidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #include "textoverlaywidget.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace SubtitleComposer; 17 | 18 | TextOverlayWidget::TextOverlayWidget(QWidget *parent) 19 | : QWidget(parent) 20 | { 21 | } 22 | 23 | TextOverlayWidget::~TextOverlayWidget() 24 | { 25 | } 26 | 27 | QSize 28 | TextOverlayWidget::minimumSizeHint() const 29 | { 30 | return QSize(100, m_overlay.textSize().height()); 31 | } 32 | 33 | QSize 34 | TextOverlayWidget::sizeHint() const 35 | { 36 | return m_overlay.textSize(); 37 | } 38 | 39 | void 40 | TextOverlayWidget::resizeEvent(QResizeEvent *event) 41 | { 42 | m_overlay.setImageSize(event->size()); 43 | } 44 | 45 | void 46 | TextOverlayWidget::paintEvent(QPaintEvent * /*event */) 47 | { 48 | QPainter painter(this); 49 | painter.fillRect(rect(), Qt::transparent); 50 | const QImage &img = m_overlay.image(); 51 | const int imgCenterX = img.width() / 2; 52 | const int widgetHalfWidth = width() / 2; 53 | const QRect src(imgCenterX - widgetHalfWidth, height() - m_overlay.textSize().height(), 54 | imgCenterX + widgetHalfWidth, height()); 55 | painter.drawImage(rect(), img, src); 56 | } 57 | -------------------------------------------------------------------------------- /src/widgets/timeedit.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPDX-FileCopyrightText: 2007-2009 Sergio Pistone 3 | SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic 4 | 5 | SPDX-License-Identifier: GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef TIMEEDIT_H 9 | #define TIMEEDIT_H 10 | 11 | #include 12 | 13 | QT_FORWARD_DECLARE_CLASS(QEvent) 14 | 15 | class TimeEdit : public QTimeEdit 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | TimeEdit(QWidget *parent = 0); 21 | 22 | int msecsStep() const; 23 | 24 | int value() const; 25 | 26 | void stepBy(int steps) override; 27 | 28 | public slots: 29 | void setMSecsStep(int msecs); 30 | void setValue(int value); 31 | 32 | signals: 33 | void valueChanged(int value); 34 | void valueEntered(int value); 35 | 36 | protected slots: 37 | void onTimeChanged(const QTime &time); 38 | 39 | protected: 40 | StepEnabled stepEnabled() const override; 41 | void keyPressEvent(QKeyEvent *event) override; 42 | 43 | private: 44 | int m_secsStep; 45 | }; 46 | 47 | #endif 48 | --------------------------------------------------------------------------------