-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [cmake] Added feature for switching cmake kit
as title Log: new feature
- Loading branch information
1 parent
e357e32
commit cc4fd7b
Showing
13 changed files
with
132 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/plugins/cxx/cmake/project/properties/kitpage/kitpage.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "kitpage.h" | ||
#include "configutil.h" | ||
#include "cmake/option/kitmanager.h" | ||
|
||
#include <QFormLayout> | ||
|
||
using namespace config; | ||
DWIDGET_USE_NAMESPACE | ||
|
||
KitPage::KitPage(const dpfservice::ProjectInfo &projectInfo, QStandardItem *item, QWidget *parent) | ||
: PageWidget(parent) | ||
{ | ||
this->projectInfo = projectInfo; | ||
this->item = item; | ||
initUI(); | ||
} | ||
|
||
void KitPage::initUI() | ||
{ | ||
kitComboBox = new DComboBox(this); | ||
kitComboBox->setFixedWidth(220); | ||
|
||
QFormLayout *layout = new QFormLayout(this); | ||
layout->addRow(tr("Kit:"), kitComboBox); | ||
} | ||
|
||
void KitPage::readConfig() | ||
{ | ||
kitComboBox->clear(); | ||
|
||
kitComboBox->addItem(tr("None")); | ||
const auto &kitList = KitManager::instance()->kitList(); | ||
for (const auto &kit : kitList) { | ||
kitComboBox->addItem(kit.kitName(), kit.id()); | ||
} | ||
|
||
const auto &id = projectInfo.kitId(); | ||
const auto &kit = KitManager::instance()->findKit(id); | ||
if (!kit.isValid()) { | ||
kitComboBox->setCurrentIndex(0); | ||
} else { | ||
int index = kitComboBox->findData(id); | ||
kitComboBox->setCurrentIndex(index); | ||
} | ||
} | ||
|
||
void KitPage::saveConfig() | ||
{ | ||
ProjectConfigure *param = ConfigUtil::instance()->getConfigureParamPointer(); | ||
const QString id = kitComboBox->currentData().toString(); | ||
if (id == param->kitId) | ||
return; | ||
|
||
param->kit = kitComboBox->currentText(); | ||
param->kitId = id; | ||
QString filePath = ConfigUtil::instance()->getConfigPath(param->workspace); | ||
ConfigUtil::instance()->saveConfig(filePath, *param); | ||
|
||
ConfigUtil::instance()->updateProjectInfo(projectInfo, param); | ||
dpfservice::ProjectInfo::set(item, projectInfo); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/plugins/cxx/cmake/project/properties/kitpage/kitpage.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef KITPAGE_H | ||
#define KITPAGE_H | ||
|
||
#include "common/widget/pagewidget.h" | ||
#include "common/project/projectinfo.h" | ||
|
||
#include <DComboBox> | ||
|
||
class KitPage : public PageWidget | ||
{ | ||
public: | ||
explicit KitPage(const dpfservice::ProjectInfo &projectInfo, QStandardItem *item, QWidget *parent = nullptr); | ||
|
||
void readConfig() override; | ||
void saveConfig() override; | ||
|
||
private: | ||
void initUI(); | ||
|
||
DTK_WIDGET_NAMESPACE::DComboBox *kitComboBox { nullptr }; | ||
dpfservice::ProjectInfo projectInfo; | ||
QStandardItem *item { nullptr }; | ||
}; | ||
|
||
#endif // KITPAGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters