File indexing completed on 2024-05-26 04:59:28
0001 /* 0002 SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar> 0003 SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef ACTIONWITHTARGETDIALOG_H 0009 #define ACTIONWITHTARGETDIALOG_H 0010 0011 #include "actiondialog.h" 0012 #include "core/subtitle.h" 0013 0014 #include <QWidget> 0015 0016 #include <KLocalizedString> 0017 0018 QT_FORWARD_DECLARE_CLASS(QGridLayout) 0019 QT_FORWARD_DECLARE_CLASS(QGroupBox) 0020 QT_FORWARD_DECLARE_CLASS(QButtonGroup) 0021 0022 namespace SubtitleComposer { 0023 class ActionWithTargetDialog : public ActionDialog 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 typedef enum { AllLines = 0, Selection, FromSelected, UpToSelected, None } LinesTarget; 0029 0030 /// LINES TARGET 0031 LinesTarget selectedLinesTarget() const; 0032 void setSelectedLinesTarget(ActionWithTargetDialog::LinesTarget target); 0033 0034 bool isLinesTargetEnabled(LinesTarget target) const; 0035 void setLinesTargetEnabled(LinesTarget target, bool enabled); 0036 0037 /// TEXTS TARGET 0038 // the active text target when translationMode is false 0039 SubtitleTarget nonTranslationModeTarget() const; 0040 void setNonTranslationModeTarget(SubtitleTarget target); 0041 0042 SubtitleTarget selectedTextsTarget() const; 0043 void setSelectedTextsTarget(SubtitleTarget target); 0044 0045 bool isTextsTargetEnabled(SubtitleTarget target) const; 0046 void setTextsTargetEnabled(SubtitleTarget target, bool enabled); 0047 0048 public slots: 0049 int exec() override; 0050 void show() override; 0051 0052 protected: 0053 explicit ActionWithTargetDialog(const QString &title, QWidget *parent = 0); 0054 0055 bool selectionTargetOnlyMode() const; 0056 bool translationMode() const; 0057 0058 QGroupBox * createTargetsGroupBox(const QString &title = i18n("Apply to"), bool addToLayout = true); 0059 0060 void setTargetsButtonsHiddenState(QButtonGroup *targetButtonGroup, bool hidden); 0061 void updateTargetsGroupBoxHiddenState(); 0062 0063 void createLineTargetsButtonGroup(); 0064 void createTextTargetsButtonGroup(); 0065 0066 virtual void setSelectionTargetOnlyMode(bool value); 0067 virtual void setTranslationMode(bool value); 0068 0069 private: 0070 void _setSelectionTargetOnlyMode(bool value, bool force); 0071 void _setTranslationMode(bool enabled, bool force); 0072 0073 private slots: 0074 void onDefaultButtonClicked(); 0075 0076 protected: 0077 QGroupBox *m_targetGroupBox; 0078 QGridLayout *m_targetLayout; 0079 0080 QButtonGroup *m_lineTargetsButtonGroup; 0081 QButtonGroup *m_textTargetsButtonGroup; 0082 0083 private: 0084 bool m_selectionTargetOnlyMode; 0085 bool m_selectionTargetWasChecked; 0086 0087 bool m_translationMode; 0088 SubtitleTarget m_nonTranslationModeTarget; 0089 }; 0090 0091 class ActionWithLinesTargetDialog : public ActionWithTargetDialog 0092 { 0093 Q_OBJECT 0094 0095 public: 0096 explicit ActionWithLinesTargetDialog(const QString &title, QWidget *parent = 0); 0097 ActionWithLinesTargetDialog(const QString &title, const QString &desc, QWidget *parent = 0); 0098 0099 public slots: 0100 int exec() override; 0101 }; 0102 0103 class ActionWithTextsTargetDialog : public ActionWithTargetDialog 0104 { 0105 Q_OBJECT 0106 0107 public: 0108 explicit ActionWithTextsTargetDialog(const QString &title, QWidget *parent = 0); 0109 ActionWithTextsTargetDialog(const QString &title, const QString &desc, QWidget *parent = 0); 0110 0111 public slots: 0112 int exec() override; 0113 }; 0114 0115 class ActionWithLinesAndTextsTargetDialog : public ActionWithTargetDialog 0116 { 0117 Q_OBJECT 0118 0119 public: 0120 explicit ActionWithLinesAndTextsTargetDialog(const QString &title, QWidget *parent = 0); 0121 ActionWithLinesAndTextsTargetDialog(const QString &title, const QString &desc, QWidget *parent = 0); 0122 0123 public slots: 0124 int exec() override; 0125 }; 0126 } 0127 #endif