summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/projectwindow.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2016-12-09 12:42:01 +0100
committerEike Ziller <eike.ziller@qt.io>2016-12-09 12:42:01 +0100
commitc175f1e62f8eb37e43a30e87ae9e693ef56dabac (patch)
treec35ee7e45ffbe3d56f76e0b2be91ee53676d0881 /src/plugins/projectexplorer/projectwindow.cpp
parent77b8198c2b1eadcd3f3a6bb9d97275d0f2d05a14 (diff)
parent5071dd80cb352ebfe67209e3f3bc70ef619a5ccf (diff)
downloadqt-creator-c175f1e62f8eb37e43a30e87ae9e693ef56dabac.tar.gz
Merge remote-tracking branch 'origin/4.2'
Conflicts: src/plugins/ios/iosdevice.cpp src/plugins/ios/iossimulator.cpp src/plugins/projectexplorer/projectwindow.cpp src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp src/shared/qbs Change-Id: Ie98e2401a2259903141a13170c78388f2da467d2
Diffstat (limited to 'src/plugins/projectexplorer/projectwindow.cpp')
-rw-r--r--src/plugins/projectexplorer/projectwindow.cpp92
1 files changed, 61 insertions, 31 deletions
diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp
index a24e8c0bff..24657cbf66 100644
--- a/src/plugins/projectexplorer/projectwindow.cpp
+++ b/src/plugins/projectexplorer/projectwindow.cpp
@@ -58,6 +58,7 @@
#include <QHeaderView>
#include <QLabel>
#include <QMenu>
+#include <QPushButton>
#include <QStyledItemDelegate>
#include <QTimer>
#include <QTreeView>
@@ -386,6 +387,17 @@ public:
this, &SelectorModel::deregisterProject);
connect(sessionManager, &SessionManager::startupProjectChanged,
this, &SelectorModel::startupProjectChanged);
+
+ m_importBuild = new QPushButton(ProjectWindow::tr("Import Existing Build..."));
+ connect(m_importBuild, &QPushButton::clicked,
+ this, &SelectorModel::handleImportBuild);
+ connect(sessionManager, &SessionManager::startupProjectChanged, this, [this](Project *project) {
+ m_importBuild->setEnabled(project && project->projectImporter());
+ });
+
+ m_manageKits = new QPushButton(ProjectWindow::tr("Manage Kits..."));
+ connect(m_manageKits, &QPushButton::clicked,
+ this, &SelectorModel::handleManageKits);
}
void updatePanel()
@@ -457,7 +469,6 @@ public:
ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0);
Project *project = projectItem ? projectItem->project() : nullptr;
- ProjectImporter *projectImporter = project ? project->projectImporter() : nullptr;
QModelIndex index = m_selectorTree->indexAt(pos);
TreeItem *item = m_projectsModel.itemForIndex(index);
@@ -468,49 +479,65 @@ public:
menu.addSeparator();
QAction *importBuild = menu.addAction(ProjectWindow::tr("Import Existing Build..."));
- importBuild->setEnabled(projectImporter);
+ importBuild->setEnabled(project && project->projectImporter());
QAction *manageKits = menu.addAction(ProjectWindow::tr("Manage Kits..."));
QAction *act = menu.exec(m_selectorTree->mapToGlobal(pos));
- if (project && projectImporter && act == importBuild) {
- QString dir = project->projectDirectory().toString();
- QString importDir = QFileDialog::getExistingDirectory(ICore::mainWindow(),
- ProjectWindow::tr("Import directory"),
- dir);
- FileName path = FileName::fromString(importDir);
-
- const QList<BuildInfo *> toImport = projectImporter->import(path, false);
- for (BuildInfo *info : toImport) {
- Target *target = project->target(info->kitId);
- if (!target) {
- target = project->createTarget(KitManager::find(info->kitId));
- if (target)
- project->addTarget(target);
- }
- if (target) {
- projectImporter->makePersistent(target->kit());
- BuildConfiguration *bc = info->factory()->create(target, info);
- QTC_ASSERT(bc, continue);
- target->addBuildConfiguration(bc);
- }
+ if (act == importBuild)
+ handleImportBuild();
+ else if (act == manageKits)
+ handleManageKits();
+ }
+
+ void handleManageKits()
+ {
+ if (ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0)) {
+ if (KitOptionsPage *page = ExtensionSystem::PluginManager::getObject<KitOptionsPage>())
+ page->showKit(KitManager::find(Id::fromSetting(projectItem->data(0, KitIdRole))));
+ }
+ ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, ICore::mainWindow());
+ }
+
+ void handleImportBuild()
+ {
+ ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0);
+ Project *project = projectItem ? projectItem->project() : 0;
+ ProjectImporter *projectImporter = project ? project->projectImporter() : 0;
+ QTC_ASSERT(projectImporter, return);
+
+ QString dir = project->projectDirectory().toString();
+ QString importDir = QFileDialog::getExistingDirectory(ICore::mainWindow(),
+ ProjectWindow::tr("Import directory"),
+ dir);
+ FileName path = FileName::fromString(importDir);
+
+ const QList<BuildInfo *> toImport = projectImporter->import(path, false);
+ for (BuildInfo *info : toImport) {
+ Target *target = project->target(info->kitId);
+ if (!target) {
+ target = project->createTarget(KitManager::find(info->kitId));
+ if (target)
+ project->addTarget(target);
}
- qDeleteAll(toImport);
- } else if (act == manageKits) {
- if (KitOptionsPage *page = ExtensionSystem::PluginManager::getObject<KitOptionsPage>()) {
- if (item)
- page->showKit(KitManager::find(Id::fromSetting(item->data(0, KitIdRole))));
+ if (target) {
+ projectImporter->makePersistent(target->kit());
+ BuildConfiguration *bc = info->factory()->create(target, info);
+ QTC_ASSERT(bc, continue);
+ target->addBuildConfiguration(bc);
}
- ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, ICore::mainWindow());
- };
+ }
+ qDeleteAll(toImport);
}
-public:
+
std::function<void (QWidget *)> m_changeListener;
ProjectsModel m_projectsModel;
ComboBoxModel m_comboBoxModel;
QComboBox *m_projectSelection;
SelectorTree *m_selectorTree;
+ QPushButton *m_importBuild;
+ QPushButton *m_manageKits;
};
//
@@ -547,6 +574,9 @@ ProjectWindow::ProjectWindow()
auto innerLayout = new QVBoxLayout;
innerLayout->setSpacing(10);
innerLayout->setContentsMargins(14, innerLayout->spacing(), 14, 0);
+ innerLayout->addWidget(selectorModel->m_manageKits);
+ innerLayout->addWidget(selectorModel->m_importBuild);
+ innerLayout->addSpacerItem(new QSpacerItem(10, 30, QSizePolicy::Maximum, QSizePolicy::Maximum));
innerLayout->addWidget(activeLabel);
innerLayout->addWidget(selectorModel->m_projectSelection);
innerLayout->addWidget(selectorModel->m_selectorTree);