File indexing completed on 2025-01-05 05:14:49

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 "remoteinfodialog.h"
0008 #include "commands/commandaddremote.h"
0009 #include <QPushButton>
0010 
0011 RemoteInfoDialog::RemoteInfoDialog(QWidget *parent)
0012     : QDialog(parent)
0013 {
0014     setupUi(this);
0015 
0016     checkBoxTags->setCheckState(Qt::PartiallyChecked);
0017     auto button = buttonBox->button(QDialogButtonBox::Ok);
0018     connect(lineEditName, &QLineEdit::textChanged, this, [button](const QString &str) {
0019         button->setEnabled(!str.trimmed().isEmpty());
0020     });
0021     // Disable as lineEditName is empty
0022     button->setEnabled(false);
0023 }
0024 
0025 QString RemoteInfoDialog::remoteName() const
0026 {
0027     return lineEditName->text();
0028 }
0029 
0030 QString RemoteInfoDialog::remoteUrl() const
0031 {
0032     return lineEditUrl->text();
0033 }
0034 
0035 Git::CommandAddRemote *RemoteInfoDialog::command()
0036 {
0037     auto cmd = new Git::CommandAddRemote(this);
0038     cmd->setTags(checkBoxTags->checkState());
0039     cmd->setRemoteName(lineEditName->text());
0040     cmd->setUrl(lineEditUrl->text());
0041     cmd->setMirror(checkBoxMirror->isChecked());
0042     cmd->setFetch(checkBoxFetch->isChecked());
0043     return cmd;
0044 }
0045 
0046 #include "moc_remoteinfodialog.cpp"