1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include "projectexplorer_export.h" 29 30 #include "kitinformation.h" 31 #include "kitmanager.h" 32 #include "projectimporter.h" 33 #include "task.h" 34 35 #include <utils/wizardpage.h> 36 37 #include <QPointer> 38 #include <QString> 39 #include <QMap> 40 QT_FORWARD_DECLARE_CLASS(QSpacerItem)41QT_FORWARD_DECLARE_CLASS(QSpacerItem) 42 43 namespace Utils { class FilePath; } 44 45 namespace ProjectExplorer { 46 class Kit; 47 class Project; 48 49 namespace Internal { 50 class ImportWidget; 51 class TargetSetupPageUi; 52 class TargetSetupWidget; 53 } // namespace Internal 54 55 /// \internal 56 class PROJECTEXPLORER_EXPORT TargetSetupPage : public Utils::WizardPage 57 { 58 Q_OBJECT 59 60 public: 61 explicit TargetSetupPage(QWidget *parent = nullptr); 62 ~TargetSetupPage() override; 63 64 /// Initializes the TargetSetupPage 65 /// \note The import information is gathered in initializePage(), make sure that the right projectPath is set before 66 void initializePage() override; 67 68 // Call these before initializePage! 69 void setTasksGenerator(const TasksGenerator &tasksGenerator); 70 void setProjectPath(const Utils::FilePath &dir); 71 void setProjectImporter(ProjectImporter *importer); 72 bool importLineEditHasFocus() const; 73 74 /// Sets whether the targetsetupage uses a scrollarea 75 /// to host the widgets from the factories 76 /// call this before \sa initializePage() 77 void setUseScrollArea(bool b); 78 79 bool isComplete() const override; 80 bool setupProject(Project *project); 81 QList<Utils::Id> selectedKits() const; 82 83 void openOptions(); 84 void changeAllKitsSelections(); 85 86 void kitFilterChanged(const QString &filterText); 87 88 private: 89 void doInitializePage(); 90 91 void showEvent(QShowEvent *event) final; 92 93 void handleKitAddition(Kit *k); 94 void handleKitRemoval(Kit *k); 95 void handleKitUpdate(Kit *k); 96 void updateVisibility(); 97 98 void reLayout(); 99 static bool compareKits(const Kit *k1, const Kit *k2); 100 std::vector<Internal::TargetSetupWidget *> sortedWidgetList() const; 101 102 void kitSelectionChanged(); 103 104 bool isUpdating() const; 105 void selectAtLeastOneEnabledKit(); removeWidget(Kit * k)106 void removeWidget(Kit *k) { removeWidget(widget(k)); } 107 void removeWidget(Internal::TargetSetupWidget *w); 108 Internal::TargetSetupWidget *addWidget(Kit *k); 109 void addAdditionalWidgets(); 110 void removeAdditionalWidgets(QLayout *layout); removeAdditionalWidgets()111 void removeAdditionalWidgets() { removeAdditionalWidgets(m_baseLayout); } 112 void updateWidget(Internal::TargetSetupWidget *widget); 113 bool isUsable(const Kit *kit) const; 114 115 void setupImports(); 116 void import(const Utils::FilePath &path, bool silent = false); 117 118 void setupWidgets(const QString &filterText = QString()); 119 void reset(); 120 121 Internal::TargetSetupWidget *widget(const Kit *k, 122 Internal::TargetSetupWidget *fallback = nullptr) const 123 { 124 return k ? widget(k->id(), fallback) : fallback; 125 } 126 Internal::TargetSetupWidget *widget(const Utils::Id kitId, 127 Internal::TargetSetupWidget *fallback = nullptr) const; 128 129 TasksGenerator m_tasksGenerator; 130 QPointer<ProjectImporter> m_importer; 131 QLayout *m_baseLayout = nullptr; 132 Utils::FilePath m_projectPath; 133 QString m_defaultShadowBuildLocation; 134 std::vector<Internal::TargetSetupWidget *> m_widgets; 135 136 Internal::TargetSetupPageUi *m_ui; 137 138 Internal::ImportWidget *m_importWidget; 139 QSpacerItem *m_spacer; 140 QList<QWidget *> m_potentialWidgets; 141 142 bool m_widgetsWereSetUp = false; 143 }; 144 145 } // namespace ProjectExplorer 146