File indexing completed on 2024-04-28 04:37:47
0001 /* 0002 SPDX-FileCopyrightText: 2007 Alexander Dymo <adymo@kdevelop.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "appwizarddialog.h" 0008 0009 #include <QPushButton> 0010 0011 #include <KLocalizedString> 0012 0013 #include <interfaces/iplugincontroller.h> 0014 #include <vcs/vcslocation.h> 0015 0016 #include "projecttemplatesmodel.h" 0017 #include "projectselectionpage.h" 0018 #include "projectvcspage.h" 0019 0020 AppWizardDialog::AppWizardDialog(KDevelop::IPluginController* pluginController, ProjectTemplatesModel* templatesModel, QWidget *parent) 0021 : KAssistantDialog(parent) 0022 { 0023 setWindowTitle(i18nc("@title:window", "Create New Project")); 0024 0025 // KAssistantDialog creates a help button by default, no option to prevent that 0026 QPushButton *helpButton = button(QDialogButtonBox::Help); 0027 if (helpButton) { 0028 buttonBox()->removeButton(helpButton); 0029 delete helpButton; 0030 } 0031 0032 m_selectionPage = new ProjectSelectionPage(templatesModel, this); 0033 m_vcsPage = new ProjectVcsPage( pluginController, this ); 0034 m_vcsPage->setSourceLocation( m_selectionPage->location() ); 0035 connect( m_selectionPage, &ProjectSelectionPage::locationChanged, 0036 m_vcsPage, &ProjectVcsPage::setSourceLocation ); 0037 m_pageItems[m_selectionPage] = addPage(m_selectionPage, i18nc("@title:tab Page for general configuration options", "General")); 0038 0039 m_pageItems[m_vcsPage] = addPage(m_vcsPage, i18nc("@title:tab Page for version control options", "Version Control") ); 0040 0041 setValid( m_pageItems[m_selectionPage], false ); 0042 0043 connect(m_selectionPage, &ProjectSelectionPage::invalid, this, [this]() { pageInValid(m_selectionPage); }); 0044 connect(m_vcsPage, &ProjectVcsPage::invalid, this, [this]() { pageInValid(m_vcsPage); }); 0045 connect(m_selectionPage, &ProjectSelectionPage::valid, this, [this]() { pageValid(m_selectionPage); }); 0046 connect(m_vcsPage, &ProjectVcsPage::valid, this, [this]() { pageValid(m_vcsPage); }); 0047 } 0048 0049 ApplicationInfo AppWizardDialog::appInfo() const 0050 { 0051 ApplicationInfo a; 0052 a.name = m_selectionPage->projectName(); 0053 a.location = m_selectionPage->location(); 0054 a.appTemplate = m_selectionPage->selectedTemplate(); 0055 a.vcsPluginName = m_vcsPage->pluginName(); 0056 0057 if( !m_vcsPage->pluginName().isEmpty() ) 0058 { 0059 a.repository = m_vcsPage->destination(); 0060 a.sourceLocation = m_vcsPage->source(); 0061 a.importCommitMessage = m_vcsPage->commitMessage(); 0062 } 0063 else 0064 { 0065 a.repository = KDevelop::VcsLocation(); 0066 a.sourceLocation.clear(); 0067 a.importCommitMessage.clear(); 0068 } 0069 return a; 0070 } 0071 0072 0073 void AppWizardDialog::pageValid( QWidget* w ) 0074 { 0075 const auto pageItemId = m_pageItems.constFind(w); 0076 if (pageItemId != m_pageItems.constEnd()) 0077 setValid(*pageItemId, true); 0078 } 0079 0080 0081 void AppWizardDialog::pageInValid( QWidget* w ) 0082 { 0083 const auto pageItemId = m_pageItems.constFind(w); 0084 if (pageItemId != m_pageItems.constEnd()) 0085 setValid(*pageItemId, false); 0086 } 0087 0088 void AppWizardDialog::next() 0089 { 0090 auto* w = qobject_cast<AppWizardPageWidget*>(currentPage()->widget()); 0091 if (!w || w->shouldContinue()) { 0092 KAssistantDialog::next(); 0093 } 0094 } 0095 0096 #include "moc_appwizarddialog.cpp"