File indexing completed on 2024-12-22 04:40:06
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 #include "changetextscasedialog.h" 0009 0010 #include <QCheckBox> 0011 #include <QGroupBox> 0012 #include <QButtonGroup> 0013 #include <QRadioButton> 0014 #include <QGridLayout> 0015 0016 using namespace SubtitleComposer; 0017 0018 ChangeTextsCaseDialog::ChangeTextsCaseDialog(QWidget *parent) : 0019 ActionWithTargetDialog(i18n("Change Case"), parent) 0020 { 0021 QGroupBox *caseGroupBox = createGroupBox(i18nc("@title:group", "Change To")); 0022 QButtonGroup *caseButtonGroup = new QButtonGroup(this); 0023 0024 m_lowerRadioButton = new QRadioButton(caseGroupBox); 0025 m_lowerRadioButton->setText(i18n("Lower case")); 0026 m_lowerRadioButton->setChecked(true); 0027 caseButtonGroup->addButton(m_lowerRadioButton, 0); 0028 0029 m_upperRadioButton = new QRadioButton(caseGroupBox); 0030 m_upperRadioButton->setText(i18n("Upper case")); 0031 caseButtonGroup->addButton(m_upperRadioButton, 1); 0032 0033 m_titleRadioButton = new QRadioButton(caseGroupBox); 0034 m_titleRadioButton->setText(i18n("Title case")); 0035 caseButtonGroup->addButton(m_titleRadioButton, 2); 0036 0037 m_sentenceRadioButton = new QRadioButton(caseGroupBox); 0038 m_sentenceRadioButton->setText(i18n("Sentence case")); 0039 caseButtonGroup->addButton(m_sentenceRadioButton, 3); 0040 0041 m_lowerFirstCheckBox = new QCheckBox(caseGroupBox); 0042 m_lowerFirstCheckBox->setText(i18n("Convert to lower case first")); 0043 m_lowerFirstCheckBox->setEnabled(false); 0044 0045 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) 0046 connect(caseButtonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &ChangeTextsCaseDialog::onCaseButtonGroupClicked); 0047 #else 0048 connect(caseButtonGroup, &QButtonGroup::idClicked, this, &ChangeTextsCaseDialog::onCaseButtonGroupClicked); 0049 #endif 0050 0051 createLineTargetsButtonGroup(); 0052 createTextTargetsButtonGroup(); 0053 0054 QHBoxLayout *lowerFirstLayout = new QHBoxLayout(); 0055 lowerFirstLayout->addSpacing(20); 0056 lowerFirstLayout->addWidget(m_lowerFirstCheckBox); 0057 0058 QGridLayout *caseLayout = createLayout(caseGroupBox); 0059 caseLayout->addWidget(m_lowerRadioButton, 0, 0); 0060 caseLayout->addWidget(m_upperRadioButton, 1, 0); 0061 caseLayout->addWidget(m_titleRadioButton, 2, 0); 0062 caseLayout->addWidget(m_sentenceRadioButton, 3, 0); 0063 caseLayout->addLayout(lowerFirstLayout, 4, 0); 0064 } 0065 0066 ChangeTextsCaseDialog::CaseOp 0067 ChangeTextsCaseDialog::caseOperation() const 0068 { 0069 if(m_lowerRadioButton->isChecked()) 0070 return ChangeTextsCaseDialog::Lower; 0071 else if(m_upperRadioButton->isChecked()) 0072 return ChangeTextsCaseDialog::Upper; 0073 else if(m_titleRadioButton->isChecked()) 0074 return ChangeTextsCaseDialog::Title; 0075 else // if ( m_sentenceRadioButton->isChecked() ) 0076 return ChangeTextsCaseDialog::Sentence; 0077 } 0078 0079 bool 0080 ChangeTextsCaseDialog::lowerFirst() const 0081 { 0082 return m_lowerFirstCheckBox->isChecked(); 0083 } 0084 0085 void 0086 ChangeTextsCaseDialog::onCaseButtonGroupClicked(int id) 0087 { 0088 if(id < 2) 0089 m_lowerFirstCheckBox->setChecked(false); 0090 m_lowerFirstCheckBox->setEnabled(id >= 2); 0091 } 0092 0093