File indexing completed on 2025-01-05 05:14:50
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include "selectbranchestodiffdialog.h" 0008 0009 #include "gitmanager.h" 0010 #include <KLocalizedString> 0011 #include <KMessageBox> 0012 0013 SelectBranchesToDiffDialog::SelectBranchesToDiffDialog(Git::Manager *git, QWidget *parent) 0014 : AppDialog(parent) 0015 { 0016 setupUi(this); 0017 0018 const auto branches = git->branchesNames(Git::Manager::BranchType::LocalBranch); 0019 0020 comboBoxOldBranch->addItems(branches); 0021 comboBoxNewBranch->addItems(branches); 0022 connect(buttonBox, &QDialogButtonBox::accepted, this, &SelectBranchesToDiffDialog::slotAccepted); 0023 } 0024 0025 QString SelectBranchesToDiffDialog::oldBranch() const 0026 { 0027 if (radioButtonLeftIsHead->isChecked()) 0028 return QStringLiteral("HEAD"); 0029 return comboBoxOldBranch->currentText(); 0030 } 0031 0032 QString SelectBranchesToDiffDialog::newBranch() const 0033 { 0034 if (radioButtonRightIsHead->isChecked()) 0035 return QStringLiteral("HEAD"); 0036 return comboBoxNewBranch->currentText(); 0037 } 0038 0039 void SelectBranchesToDiffDialog::slotAccepted() 0040 { 0041 if (oldBranch() == newBranch()) { 0042 KMessageBox::error(this, i18n("The selected branches must be different!"), i18n("Select Branches")); 0043 return; 0044 } 0045 accept(); 0046 } 0047 0048 #include "moc_selectbranchestodiffdialog.cpp"