1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
/***************************************************************************
* Copyright 2007 Alexander Dymo <adymo@kdevelop.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "appwizarddialog.h"
#include <QPushButton>
#include <KLocalizedString>
#include <interfaces/iplugincontroller.h>
#include <vcs/vcslocation.h>
#include "projecttemplatesmodel.h"
#include "projectselectionpage.h"
#include "projectvcspage.h"
AppWizardDialog::AppWizardDialog(KDevelop::IPluginController* pluginController, ProjectTemplatesModel* templatesModel, QWidget *parent)
: KAssistantDialog(parent)
{
setWindowTitle(i18nc("@title:window", "Create New Project"));
// KAssistantDialog creates a help button by default, no option to prevent that
QPushButton *helpButton = button(QDialogButtonBox::Help);
if (helpButton) {
buttonBox()->removeButton(helpButton);
delete helpButton;
}
m_selectionPage = new ProjectSelectionPage(templatesModel, this);
m_vcsPage = new ProjectVcsPage( pluginController, this );
m_vcsPage->setSourceLocation( m_selectionPage->location() );
connect( m_selectionPage, &ProjectSelectionPage::locationChanged,
m_vcsPage, &ProjectVcsPage::setSourceLocation );
m_pageItems[m_selectionPage] = addPage(m_selectionPage, i18nc("@title:tab Page for general configuration options", "General"));
m_pageItems[m_vcsPage] = addPage(m_vcsPage, i18nc("@title:tab Page for version control options", "Version Control") );
setValid( m_pageItems[m_selectionPage], false );
connect(m_selectionPage, &ProjectSelectionPage::invalid, this, [this]() { pageInValid(m_selectionPage); });
connect(m_vcsPage, &ProjectVcsPage::invalid, this, [this]() { pageInValid(m_vcsPage); });
connect(m_selectionPage, &ProjectSelectionPage::valid, this, [this]() { pageValid(m_selectionPage); });
connect(m_vcsPage, &ProjectVcsPage::valid, this, [this]() { pageValid(m_vcsPage); });
}
ApplicationInfo AppWizardDialog::appInfo() const
{
ApplicationInfo a;
a.name = m_selectionPage->projectName();
a.location = m_selectionPage->location();
a.appTemplate = m_selectionPage->selectedTemplate();
a.vcsPluginName = m_vcsPage->pluginName();
if( !m_vcsPage->pluginName().isEmpty() )
{
a.repository = m_vcsPage->destination();
a.sourceLocation = m_vcsPage->source();
a.importCommitMessage = m_vcsPage->commitMessage();
}
else
{
a.repository = KDevelop::VcsLocation();
a.sourceLocation.clear();
a.importCommitMessage.clear();
}
return a;
}
void AppWizardDialog::pageValid( QWidget* w )
{
const auto pageItemId = m_pageItems.constFind(w);
if (pageItemId != m_pageItems.constEnd())
setValid(*pageItemId, true);
}
void AppWizardDialog::pageInValid( QWidget* w )
{
const auto pageItemId = m_pageItems.constFind(w);
if (pageItemId != m_pageItems.constEnd())
setValid(*pageItemId, false);
}
void AppWizardDialog::next()
{
auto* w = qobject_cast<AppWizardPageWidget*>(currentPage()->widget());
if (!w || w->shouldContinue()) {
KAssistantDialog::next();
}
}
|