| 33 | using namespace KDevelop; |
| 34 | |
| 35 | ProjectSelectionPage::ProjectSelectionPage(ProjectTemplatesModel *templatesModel, AppWizardDialog *wizardDialog) |
| 36 | : AppWizardPageWidget(wizardDialog), m_templatesModel(templatesModel) |
| 37 | { |
| 38 | ui = new Ui::ProjectSelectionPage(); |
| 39 | ui->setupUi(this); |
| 40 | ui->descriptionContent->setBackgroundRole(QPalette::Base); |
| 41 | ui->descriptionContent->setForegroundRole(QPalette::Text); |
| 42 | |
| 43 | ui->locationUrl->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly ); |
| 44 | ui->locationUrl->setUrl(KDevelop::ICore::self()->projectController()->projectsBaseDirectory()); |
| 45 | |
| 46 | ui->locationValidWidget->hide(); |
| 47 | ui->locationValidWidget->setMessageType(KMessageWidget::Error); |
| 48 | ui->locationValidWidget->setCloseButtonVisible(false); |
| 49 | |
| 50 | connect( ui->locationUrl->lineEdit(), &KLineEdit::textEdited, |
| 51 | this, &ProjectSelectionPage::urlEdited); |
| 52 | connect( ui->locationUrl, &KUrlRequester::urlSelected, |
| 53 | this, &ProjectSelectionPage::urlEdited); |
| 54 | connect( ui->projectNameEdit, &QLineEdit::textEdited, |
| 55 | this, &ProjectSelectionPage::nameChanged ); |
| 56 | |
| 57 | ui->listView->setLevels(2); |
| 58 | ui->listView->setHeaderLabels(QStringList{ |
| 59 | i18nc("@title:column", "Category"), |
| 60 | i18nc("@title:column", "Project Type") |
| 61 | }); |
| 62 | ui->listView->setModel(templatesModel); |
| 63 | ui->listView->setLastLevelViewMode(MultiLevelListView::DirectChildren); |
| 64 | connect (ui->listView, &MultiLevelListView::currentIndexChanged, this, &ProjectSelectionPage::typeChanged); |
| 65 | typeChanged(ui->listView->currentIndex()); |
| 66 | |
| 67 | connect( ui->templateType, QOverload<int>::of(&QComboBox::currentIndexChanged), |
| 68 | this, &ProjectSelectionPage::templateChanged ); |
| 69 | |
| 70 | auto* getMoreButton = new KNSWidgets::Button(i18nc("@action:button", "Get More Templates"), |
| 71 | QStringLiteral("kdevappwizard.knsrc"), ui->listView); |
| 72 | connect(getMoreButton, &KNSWidgets::Button::dialogFinished, this, |
| 73 | &ProjectSelectionPage::handleNewStuffDialogFinished); |
| 74 | ui->listView->addWidget(0, getMoreButton); |
| 75 | |
| 76 | auto* loadButton = new QPushButton(ui->listView); |
| 77 | loadButton->setText(i18nc("@action:button", "Load Template from File")); |
| 78 | loadButton->setIcon(QIcon::fromTheme(QStringLiteral("application-x-archive"))); |
| 79 | connect (loadButton, &QPushButton::clicked, this, &ProjectSelectionPage::loadFileClicked); |
| 80 | ui->listView->addWidget(0, loadButton); |
| 81 | |
| 82 | m_wizardDialog = wizardDialog; |
| 83 | } |
| 84 | |
| 85 | void ProjectSelectionPage::nameChanged() |
| 86 | { |
nothing calls this directly
no test coverage detected