cmakesettingspage.cpp 20.4 KB
Newer Older
1 2
/****************************************************************************
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
5 6 7 8 9 10 11
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
12 13 14
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
15
**
16 17 18 19 20 21 22
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 24
**
****************************************************************************/
25

26
#include "cmakeprojectconstants.h"
27
#include "cmakesettingspage.h"
28
#include "cmaketoolmanager.h"
29 30

#include <projectexplorer/projectexplorerconstants.h>
31
#include <projectexplorer/project.h>
32 33
#include <coreplugin/icore.h>
#include <utils/environment.h>
34 35 36 37
#include <utils/detailswidget.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <utils/treemodel.h>
38

39
#include <QCheckBox>
40
#include <QFormLayout>
41 42 43 44 45 46 47
#include <QHeaderView>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QTreeView>
#include <QWidget>
#include <QUuid>
48

49 50
using namespace Utils;

51 52 53
namespace CMakeProjectManager {
namespace Internal {

54
class CMakeToolTreeItem;
55

56 57 58
// --------------------------------------------------------------------------
// CMakeToolItemModel
// --------------------------------------------------------------------------
59

hjk's avatar
hjk committed
60
class CMakeToolItemModel : public TreeModel<TreeItem, TreeItem, CMakeToolTreeItem>
61
{
62 63 64 65 66 67 68
    Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::CMakeSettingsPage)

public:
    CMakeToolItemModel();

    CMakeToolTreeItem *cmakeToolItem(const Core::Id &id) const;
    CMakeToolTreeItem *cmakeToolItem(const QModelIndex &index) const;
69
    QModelIndex addCMakeTool(const QString &name, const FileName &executable, const bool autoRun, const bool autoCreate, const bool isAutoDetected);
70
    void addCMakeTool(const CMakeTool *item, bool changed);
71 72 73
    TreeItem *autoGroupItem() const;
    TreeItem *manualGroupItem() const;
    void reevaluateChangedFlag(CMakeToolTreeItem *item) const;
74
    void updateCMakeTool(const Core::Id &id, const QString &displayName, const FileName &executable,
75
                         bool autoRun, bool autoCreate);
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
    void removeCMakeTool(const Core::Id &id);
    void apply();

    Core::Id defaultItemId() const;
    void setDefaultItemId(const Core::Id &id);

    QString uniqueDisplayName(const QString &base) const;
private:
    Core::Id m_defaultItemId;
    QList<Core::Id> m_removedItems;
};

class CMakeToolTreeItem : public TreeItem
{
    Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::CMakeSettingsPage)

public:
    CMakeToolTreeItem(const CMakeTool *item, bool changed) :
        m_id(item->id()),
        m_name(item->displayName()),
        m_executable(item->cmakeExecutable()),
97
        m_isAutoRun(item->isAutoRun()),
98
        m_autoCreateBuildDirectory(item->autoCreateBuildDirectory()),
99 100 101 102
        m_autodetected(item->isAutoDetected()),
        m_changed(changed)
    {}

103
    CMakeToolTreeItem(const QString &name, const Utils::FileName &executable,
104
                      bool autoRun, bool autoCreate, bool autodetected) :
105 106 107
        m_id(Core::Id::fromString(QUuid::createUuid().toString())),
        m_name(name),
        m_executable(executable),
108
        m_isAutoRun(autoRun),
109
        m_autoCreateBuildDirectory(autoCreate),
110 111 112 113
        m_autodetected(autodetected),
        m_changed(true)
    {}

114
    CMakeToolTreeItem() = default;
115

116
    CMakeToolItemModel *model() const { return static_cast<CMakeToolItemModel *>(TreeItem::model()); }
117

118 119 120 121 122 123 124 125 126 127 128
    QVariant data(int column, int role) const
    {
        switch (role) {
        case Qt::DisplayRole:
            switch (column) {
            case 0: {
                QString name = m_name;
                if (model()->defaultItemId() == m_id)
                    name += tr(" (Default)");
                return name;
            }
Orgad Shaneh's avatar
Orgad Shaneh committed
129 130
            case 1:
                return m_executable.toUserOutput();
131
            }
Orgad Shaneh's avatar
Orgad Shaneh committed
132
            break;
133 134 135 136 137 138 139 140 141 142 143 144 145 146

        case Qt::FontRole: {
            QFont font;
            font.setBold(m_changed);
            font.setItalic(model()->defaultItemId() == m_id);
            return font;
        }
        }
        return QVariant();
    }

    Core::Id m_id;
    QString  m_name;
    FileName m_executable;
147
    bool m_isAutoRun = true;
148
    bool m_autoCreateBuildDirectory = false;
149 150
    bool m_autodetected = false;
    bool m_changed = true;
151 152 153 154
};

CMakeToolItemModel::CMakeToolItemModel()
{
155
    setHeader({tr("Name"), tr("Location")});
156 157
    rootItem()->appendChild(new StaticTreeItem(tr("Auto-detected")));
    rootItem()->appendChild(new StaticTreeItem(tr("Manual")));
158 159 160 161 162 163

    foreach (const CMakeTool *item, CMakeToolManager::cmakeTools())
        addCMakeTool(item, false);

    CMakeTool *defTool = CMakeToolManager::defaultCMakeTool();
    m_defaultItemId = defTool ? defTool->id() : Core::Id();
164 165 166 167 168
    connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeRemoved,
            this, &CMakeToolItemModel::removeCMakeTool);
    connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeAdded,
            this, [this](const Core::Id &id) { addCMakeTool(CMakeToolManager::findById(id), false); });

169 170
}

171
QModelIndex CMakeToolItemModel::addCMakeTool(const QString &name, const FileName &executable,
172 173
                                             const bool autoRun, const bool autoCreate,
                                             const bool isAutoDetected)
174
{
175
    CMakeToolTreeItem *item = new CMakeToolTreeItem(name, executable, autoRun, autoCreate, isAutoDetected);
176 177 178 179
    if (isAutoDetected)
        autoGroupItem()->appendChild(item);
    else
        manualGroupItem()->appendChild(item);
180

181
    return item->index();
182 183
}

184
void CMakeToolItemModel::addCMakeTool(const CMakeTool *item, bool changed)
185
{
186 187
    QTC_ASSERT(item, return);

188 189 190
    if (cmakeToolItem(item->id()))
        return;

191 192 193 194 195 196 197 198
    CMakeToolTreeItem *treeItem = new CMakeToolTreeItem(item, changed);
    if (item->isAutoDetected())
        autoGroupItem()->appendChild(treeItem);
    else
        manualGroupItem()->appendChild(treeItem);
}

TreeItem *CMakeToolItemModel::autoGroupItem() const
199
{
200
    return rootItem()->childAt(0);
201 202
}

203
TreeItem *CMakeToolItemModel::manualGroupItem() const
204
{
205
    return rootItem()->childAt(1);
206 207
}

208
void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const
209
{
210 211 212 213 214 215 216 217 218 219
    CMakeTool *orig = CMakeToolManager::findById(item->m_id);
    item->m_changed = !orig || orig->displayName() != item->m_name
            || orig->cmakeExecutable() != item->m_executable;

    //make sure the item is marked as changed when the default cmake was changed
    CMakeTool *origDefTool = CMakeToolManager::defaultCMakeTool();
    Core::Id origDefault = origDefTool ? origDefTool->id() : Core::Id();
    if (origDefault != m_defaultItemId) {
        if (item->m_id == origDefault || item->m_id == m_defaultItemId)
            item->m_changed = true;
220
    }
221 222

    item->update(); // Notify views.
223 224
}

225
void CMakeToolItemModel::updateCMakeTool(const Core::Id &id, const QString &displayName,
226 227
                                         const FileName &executable, bool autoRun,
                                         bool autoCreate)
228
{
229 230 231 232 233
    CMakeToolTreeItem *treeItem = cmakeToolItem(id);
    QTC_ASSERT(treeItem, return);

    treeItem->m_name = displayName;
    treeItem->m_executable = executable;
234
    treeItem->m_isAutoRun = autoRun;
235
    treeItem->m_autoCreateBuildDirectory = autoCreate;
236 237

    reevaluateChangedFlag(treeItem);
238 239
}

240 241
CMakeToolTreeItem *CMakeToolItemModel::cmakeToolItem(const Core::Id &id) const
{
hjk's avatar
hjk committed
242
    return findItemAtLevel<2>([id](CMakeToolTreeItem *n) { return n->m_id == id; });
243 244 245 246
}

CMakeToolTreeItem *CMakeToolItemModel::cmakeToolItem(const QModelIndex &index) const
{
hjk's avatar
hjk committed
247
    return itemForIndexAtLevel<2>(index);
248 249 250 251 252 253 254
}

void CMakeToolItemModel::removeCMakeTool(const Core::Id &id)
{
    CMakeToolTreeItem *treeItem = cmakeToolItem(id);
    QTC_ASSERT(treeItem, return);

255
    destroyItem(treeItem);
256 257 258 259 260 261 262 263
    m_removedItems.append(id);
}

void CMakeToolItemModel::apply()
{
    foreach (const Core::Id &id, m_removedItems)
        CMakeToolManager::deregisterCMakeTool(id);

264
    QList<CMakeToolTreeItem *> toRegister;
hjk's avatar
hjk committed
265
    forItemsAtLevel<2>([&toRegister](CMakeToolTreeItem *item) {
266
        item->m_changed = false;
267 268 269
        if (CMakeTool *cmake = CMakeToolManager::findById(item->m_id)) {
            cmake->setDisplayName(item->m_name);
            cmake->setCMakeExecutable(item->m_executable);
270
            cmake->setAutorun(item->m_isAutoRun);
271
            cmake->setAutoCreateBuildDirectory(item->m_autoCreateBuildDirectory);
272 273
        } else {
            toRegister.append(item);
274
        }
275
    });
276

277 278 279 280
    foreach (CMakeToolTreeItem *item, toRegister) {
        CMakeTool::Detection detection = item->m_autodetected ? CMakeTool::AutoDetection
                                                              : CMakeTool::ManualDetection;
        CMakeTool *cmake = new CMakeTool(detection, item->m_id);
281 282
        cmake->setDisplayName(item->m_name);
        cmake->setCMakeExecutable(item->m_executable);
283 284 285
        if (!CMakeToolManager::registerCMakeTool(cmake)) {
            item->m_changed = true;
            delete cmake;
286
        }
287
    }
288 289 290 291 292

    CMakeToolManager::setDefaultCMakeTool(defaultItemId());
}

Core::Id CMakeToolItemModel::defaultItemId() const
293
{
294 295 296 297 298 299
    return m_defaultItemId;
}

void CMakeToolItemModel::setDefaultItemId(const Core::Id &id)
{
    if (m_defaultItemId == id)
300
        return;
301 302 303 304 305 306 307 308 309 310 311

    Core::Id oldDefaultId = m_defaultItemId;
    m_defaultItemId = id;

    CMakeToolTreeItem *newDefault = cmakeToolItem(id);
    if (newDefault)
        reevaluateChangedFlag(newDefault);

    CMakeToolTreeItem *oldDefault = cmakeToolItem(oldDefaultId);
    if (oldDefault)
        reevaluateChangedFlag(oldDefault);
312 313
}

314 315

QString CMakeToolItemModel::uniqueDisplayName(const QString &base) const
316
{
317
    QStringList names;
hjk's avatar
hjk committed
318
    forItemsAtLevel<2>([&names](CMakeToolTreeItem *item) { names << item->m_name; });
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
    return ProjectExplorer::Project::makeUnique(base, names);
}

// -----------------------------------------------------------------------
// CMakeToolItemConfigWidget
// -----------------------------------------------------------------------

class CMakeToolItemConfigWidget : public QWidget
{
    Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::CMakeSettingsPage)

public:
    explicit CMakeToolItemConfigWidget(CMakeToolItemModel *model);
    void load(const CMakeToolTreeItem *item);
    void store() const;

private:
    CMakeToolItemModel *m_model;
    QLineEdit *m_displayNameLineEdit;
338
    QCheckBox *m_autoRunCheckBox;
339
    QCheckBox *m_autoCreateBuildDirectoryCheckBox;
340 341 342 343 344 345 346 347 348 349 350 351 352 353
    PathChooser *m_binaryChooser;
    Core::Id m_id;
    bool m_loadingItem;
};

CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
    : m_model(model), m_loadingItem(false)
{
    m_displayNameLineEdit = new QLineEdit(this);

    m_binaryChooser = new PathChooser(this);
    m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand);
    m_binaryChooser->setMinimumWidth(400);
    m_binaryChooser->setHistoryCompleter(QLatin1String("Cmake.Command.History"));
354
    m_binaryChooser->setCommandVersionArguments({"--version"});
355

356
    m_autoRunCheckBox = new QCheckBox;
357
    m_autoRunCheckBox->setText(tr("Autorun CMake"));
358
    m_autoRunCheckBox->setToolTip(tr("Automatically run CMake after changes to CMake project files."));
359

360 361 362 363
    m_autoCreateBuildDirectoryCheckBox = new QCheckBox;
    m_autoCreateBuildDirectoryCheckBox->setText(tr("Auto-create build directories"));
    m_autoCreateBuildDirectoryCheckBox->setToolTip(tr("Automatically create build directories for CMake projects."));

364 365 366 367
    QFormLayout *formLayout = new QFormLayout(this);
    formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
    formLayout->addRow(new QLabel(tr("Name:")), m_displayNameLineEdit);
    formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser);
368
    formLayout->addRow(m_autoRunCheckBox);
369
    formLayout->addRow(m_autoCreateBuildDirectoryCheckBox);
370

371
    connect(m_binaryChooser, &PathChooser::rawPathChanged,
372 373 374
            this, &CMakeToolItemConfigWidget::store);
    connect(m_displayNameLineEdit, &QLineEdit::textChanged,
            this, &CMakeToolItemConfigWidget::store);
375 376
    connect(m_autoRunCheckBox, &QCheckBox::toggled,
            this, &CMakeToolItemConfigWidget::store);
377 378
    connect(m_autoCreateBuildDirectoryCheckBox, &QCheckBox::toggled,
            this, &CMakeToolItemConfigWidget::store);
379 380
}

381
void CMakeToolItemConfigWidget::store() const
382
{
383
    if (!m_loadingItem && m_id.isValid())
384
        m_model->updateCMakeTool(m_id, m_displayNameLineEdit->text(), m_binaryChooser->fileName(),
385 386
                                 m_autoRunCheckBox->checkState() == Qt::Checked,
                                 m_autoCreateBuildDirectoryCheckBox->checkState() == Qt::Checked);
387
}
388

389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
{
    m_loadingItem = true; // avoid intermediate signal handling
    m_id = Core::Id();
    if (!item) {
        m_loadingItem = false;
        return;
    }

    // Set values:
    m_displayNameLineEdit->setEnabled(!item->m_autodetected);
    m_displayNameLineEdit->setText(item->m_name);

    m_binaryChooser->setReadOnly(item->m_autodetected);
    m_binaryChooser->setFileName(item->m_executable);

405
    m_autoRunCheckBox->setChecked(item->m_isAutoRun);
406
    m_autoCreateBuildDirectoryCheckBox->setChecked(item->m_autoCreateBuildDirectory);
407

408 409
    m_id = item->m_id;
    m_loadingItem = false;
410 411
}

412 413 414 415 416
// --------------------------------------------------------------------------
// CMakeToolConfigWidget
// --------------------------------------------------------------------------

class CMakeToolConfigWidget : public QWidget
417
{
Sergey Belyashov's avatar
Sergey Belyashov committed
418
    Q_OBJECT
419
public:
420
    CMakeToolConfigWidget()
421 422 423 424 425 426 427 428 429 430 431
    {
        m_addButton = new QPushButton(tr("Add"), this);

        m_cloneButton = new QPushButton(tr("Clone"), this);
        m_cloneButton->setEnabled(false);

        m_delButton = new QPushButton(tr("Remove"), this);
        m_delButton->setEnabled(false);

        m_makeDefButton = new QPushButton(tr("Make Default"), this);
        m_makeDefButton->setEnabled(false);
Leena Miettinen's avatar
Leena Miettinen committed
432
        m_makeDefButton->setToolTip(tr("Set as the default CMake Tool to use when creating a new kit or when no value is set."));
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496

        m_container = new DetailsWidget(this);
        m_container->setState(DetailsWidget::NoSummary);
        m_container->setVisible(false);

        m_cmakeToolsView = new QTreeView(this);
        m_cmakeToolsView->setModel(&m_model);
        m_cmakeToolsView->setUniformRowHeights(true);
        m_cmakeToolsView->setSelectionMode(QAbstractItemView::SingleSelection);
        m_cmakeToolsView->setSelectionBehavior(QAbstractItemView::SelectRows);
        m_cmakeToolsView->expandAll();

        QHeaderView *header = m_cmakeToolsView->header();
        header->setStretchLastSection(false);
        header->setSectionResizeMode(0, QHeaderView::ResizeToContents);
        header->setSectionResizeMode(1, QHeaderView::Stretch);

        QVBoxLayout *buttonLayout = new QVBoxLayout();
        buttonLayout->setContentsMargins(0, 0, 0, 0);
        buttonLayout->addWidget(m_addButton);
        buttonLayout->addWidget(m_cloneButton);
        buttonLayout->addWidget(m_delButton);
        buttonLayout->addWidget(m_makeDefButton);
        buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));

        QVBoxLayout *verticalLayout = new QVBoxLayout();
        verticalLayout->addWidget(m_cmakeToolsView);
        verticalLayout->addWidget(m_container);

        QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
        horizontalLayout->addLayout(verticalLayout);
        horizontalLayout->addLayout(buttonLayout);

        connect(m_cmakeToolsView->selectionModel(), &QItemSelectionModel::currentChanged,
                this, &CMakeToolConfigWidget::currentCMakeToolChanged, Qt::QueuedConnection);

        connect(m_addButton, &QAbstractButton::clicked,
                this, &CMakeToolConfigWidget::addCMakeTool);
        connect(m_cloneButton, &QAbstractButton::clicked,
                this, &CMakeToolConfigWidget::cloneCMakeTool);
        connect(m_delButton, &QAbstractButton::clicked,
                this, &CMakeToolConfigWidget::removeCMakeTool);
        connect(m_makeDefButton, &QAbstractButton::clicked,
                this, &CMakeToolConfigWidget::setDefaultCMakeTool);

        m_itemConfigWidget = new CMakeToolItemConfigWidget(&m_model);
        m_container->setWidget(m_itemConfigWidget);
    }

    void apply();
    void cloneCMakeTool();
    void addCMakeTool();
    void removeCMakeTool();
    void setDefaultCMakeTool();
    void currentCMakeToolChanged(const QModelIndex &newCurrent);

    CMakeToolItemModel m_model;
    QTreeView *m_cmakeToolsView;
    QPushButton *m_addButton;
    QPushButton *m_cloneButton;
    QPushButton *m_delButton;
    QPushButton *m_makeDefButton;
    DetailsWidget *m_container;
    CMakeToolItemConfigWidget *m_itemConfigWidget;
497
    CMakeToolTreeItem *m_currentItem = nullptr;
498 499 500 501 502 503 504 505 506 507
};

void CMakeToolConfigWidget::apply()
{
    m_model.apply();
}

void CMakeToolConfigWidget::cloneCMakeTool()
{
    if (!m_currentItem)
508
        return;
509 510 511

    QModelIndex newItem = m_model.addCMakeTool(tr("Clone of %1").arg(m_currentItem->m_name),
                                               m_currentItem->m_executable,
512 513
                                               m_currentItem->m_isAutoRun,
                                               m_currentItem->m_autoCreateBuildDirectory, false);
514 515

    m_cmakeToolsView->setCurrentIndex(newItem);
516 517
}

518
void CMakeToolConfigWidget::addCMakeTool()
519
{
520
    QModelIndex newItem = m_model.addCMakeTool(m_model.uniqueDisplayName(tr("New CMake")),
521
                                               FileName(), true, false, false);
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554

    m_cmakeToolsView->setCurrentIndex(newItem);
}

void CMakeToolConfigWidget::removeCMakeTool()
{
    bool delDef = m_model.defaultItemId() == m_currentItem->m_id;
    m_model.removeCMakeTool(m_currentItem->m_id);
    m_currentItem = 0;

    if (delDef) {
        CMakeToolTreeItem *it = static_cast<CMakeToolTreeItem *>(m_model.autoGroupItem()->firstChild());
        if (!it)
            it = static_cast<CMakeToolTreeItem *>(m_model.manualGroupItem()->firstChild());
        if (it)
            m_model.setDefaultItemId(it->m_id);
    }

    TreeItem *newCurrent = m_model.manualGroupItem()->lastChild();
    if (!newCurrent)
        newCurrent = m_model.autoGroupItem()->lastChild();

    if (newCurrent)
        m_cmakeToolsView->setCurrentIndex(newCurrent->index());
}

void CMakeToolConfigWidget::setDefaultCMakeTool()
{
    if (!m_currentItem)
        return;

    m_model.setDefaultItemId(m_currentItem->m_id);
    m_makeDefButton->setEnabled(false);
555 556
}

557 558 559 560 561 562 563 564 565 566 567 568 569 570
void CMakeToolConfigWidget::currentCMakeToolChanged(const QModelIndex &newCurrent)
{
    m_currentItem = m_model.cmakeToolItem(newCurrent);
    m_itemConfigWidget->load(m_currentItem);
    m_container->setVisible(m_currentItem);
    m_cloneButton->setEnabled(m_currentItem);
    m_delButton->setEnabled(m_currentItem && !m_currentItem->m_autodetected);
    m_makeDefButton->setEnabled(m_currentItem && (!m_model.defaultItemId().isValid() || m_currentItem->m_id != m_model.defaultItemId()));
}

/////
// CMakeSettingsPage
////

Tobias Hunger's avatar
Tobias Hunger committed
571
CMakeSettingsPage::CMakeSettingsPage()
572
{
573
    setId(Constants::CMAKE_SETTINGSPAGE_ID);
574 575 576 577
    setDisplayName(tr("CMake"));
    setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
    setDisplayCategory(QCoreApplication::translate("ProjectExplorer",
       ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY));
578
    setCategoryIcon(Utils::Icon(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
579 580
}

581
QWidget *CMakeSettingsPage::widget()
582
{
583 584 585 586
    if (!m_widget)
        m_widget = new CMakeToolConfigWidget;
    return m_widget;
}
587

588 589 590 591
void CMakeSettingsPage::apply()
{
    QTC_ASSERT(m_widget, return);
    m_widget->m_itemConfigWidget->store();
592
    m_widget->apply();
593
}
594

595 596 597 598
void CMakeSettingsPage::finish()
{
    delete m_widget;
    m_widget = 0;
599 600 601 602
}

} // namespace Internal
} // namespace CMakeProjectManager
Sergey Belyashov's avatar
Sergey Belyashov committed
603 604

#include "cmakesettingspage.moc"