KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_git_auth.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include "dialog_git_auth.h"
25
27 : DIALOG_SHIM(parent, wxID_ANY, _("Connection"), wxDefaultPosition, wxSize(400, 300))
28{
30 Centre();
31}
32
34{
35}
36
38{
39 wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
40 this->SetSizer(mainSizer);
41
42 m_NameTextCtrl = new wxTextCtrl(this, wxID_ANY);
43 m_UrlTextCtrl = new wxTextCtrl(this, wxID_ANY);
44 m_AuthChoice = new wxChoice(this, wxID_ANY);
45 m_AuthChoice->Append(_("Basic"));
46 m_AuthChoice->Append(_("SSH"));
47 m_UserNameTextCtrl = new wxTextCtrl(this, wxID_ANY);
48 m_PasswordTextCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
49 m_PublicKeyPicker = new wxFilePickerCtrl(this, wxID_ANY);
50 m_PublicKeyPicker->Hide();
51
52 m_TestButton = new wxButton(this, wxID_ANY, _("Test"));
53 m_OkButton = new wxButton(this, wxID_OK, _("OK"));
54 m_CancelButton = new wxButton(this, wxID_CANCEL, _("Cancel"));
55
56 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Name")), 0, wxALL, 10);
57 mainSizer->Add(m_NameTextCtrl, 0, wxEXPAND | wxALL, 10);
58 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Url")), 0, wxALL, 10);
59 mainSizer->Add(m_UrlTextCtrl, 0, wxEXPAND | wxALL, 10);
60 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Authentication")), 0, wxALL, 10);
61 mainSizer->Add(m_AuthChoice, 0, wxEXPAND | wxALL, 10);
62 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("User Name")), 0, wxALL, 10);
63 mainSizer->Add(m_UserNameTextCtrl, 0, wxEXPAND | wxALL, 10);
64 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Password")), 0, wxALL, 10);
65 mainSizer->Add(m_PasswordTextCtrl, 0, wxEXPAND | wxALL, 10);
66 mainSizer->Add(m_PublicKeyPicker, 0, wxEXPAND | wxALL, 10);
67
68
69 wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL);
70 buttonSizer->Add(m_TestButton, 1, wxALL, 10);
71 buttonSizer->Add(m_OkButton, 1, wxALL, 10);
72 buttonSizer->Add(m_CancelButton, 1, wxALL, 10);
73 mainSizer->Add(buttonSizer, 0, wxALIGN_RIGHT);
74
75 mainSizer->Layout();
76
77 // Bind event for authentication method choice change
78 m_AuthChoice->Bind(wxEVT_CHOICE, &DIALOG_GIT_AUTH::onAuthChoiceChanged, this);
79 m_TestButton->Bind(wxEVT_BUTTON, &DIALOG_GIT_AUTH::onTestClick, this );
80}
81
82void DIALOG_GIT_AUTH::onAuthChoiceChanged(wxCommandEvent& event)
83{
84 if (m_AuthChoice->GetStringSelection() == "SSH")
85 {
86 m_PasswordTextCtrl->Hide();
87 m_PublicKeyPicker->Show();
88 }
89 else
90 {
91 m_PasswordTextCtrl->Show();
92 m_PublicKeyPicker->Hide();
93 }
94
95 Layout(); // Re-arrange the controls
96}
wxChoice * m_AuthChoice
wxTextCtrl * m_NameTextCtrl
void onTestClick(wxCommandEvent &aEvent)
wxTextCtrl * m_UserNameTextCtrl
wxFilePickerCtrl * m_PublicKeyPicker
wxButton * m_OkButton
wxTextCtrl * m_PasswordTextCtrl
wxButton * m_CancelButton
wxButton * m_TestButton
void onAuthChoiceChanged(wxCommandEvent &event)
virtual ~DIALOG_GIT_AUTH()
DIALOG_GIT_AUTH(wxWindow *parent)
wxTextCtrl * m_UrlTextCtrl
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:88
#define _(s)