analyzerrunconfigwidget.cpp 4.15 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Mike McQuaid's avatar
Mike McQuaid committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
Mike McQuaid's avatar
Mike McQuaid committed
5 6
** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
**
hjk's avatar
hjk committed
7
** This file is part of Qt Creator.
Mike McQuaid's avatar
Mike McQuaid committed
8
**
hjk's avatar
hjk committed
9 10 11 12 13 14 15
** 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
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
Mike McQuaid's avatar
Mike McQuaid committed
16 17
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
18 19 20 21 22 23 24 25 26
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
Mike McQuaid's avatar
Mike McQuaid committed
27 28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
Mike McQuaid's avatar
Mike McQuaid committed
30 31 32

#include "analyzerrunconfigwidget.h"

hjk's avatar
hjk committed
33
#include <utils/detailswidget.h>
Mike McQuaid's avatar
Mike McQuaid committed
34 35
#include <utils/qtcassert.h>

36 37 38 39 40 41
#include <QDebug>
#include <QApplication>
#include <QLabel>
#include <QVBoxLayout>
#include <QComboBox>
#include <QPushButton>
Mike McQuaid's avatar
Mike McQuaid committed
42

hjk's avatar
hjk committed
43
namespace Analyzer {
44

45
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect)
46
{
hjk's avatar
hjk committed
47
    m_aspect = aspect;
48
    m_config = aspect->projectSettings();
49

hjk's avatar
hjk committed
50
    QWidget *globalSetting = new QWidget;
51
    QHBoxLayout *globalSettingLayout = new QHBoxLayout(globalSetting);
52
    globalSettingLayout->setContentsMargins(0, 0, 0, 0);
hjk's avatar
hjk committed
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67
    m_settingsCombo = new QComboBox(globalSetting);
    m_settingsCombo->addItems(QStringList()
                            << QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Global")
                            << QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Custom")
                            );
    globalSettingLayout->addWidget(m_settingsCombo);
    connect(m_settingsCombo, SIGNAL(activated(int)), this, SLOT(chooseSettings(int)));
    m_restoreButton = new QPushButton(
                QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Restore Global"),
                globalSetting);
    globalSettingLayout->addWidget(m_restoreButton);
    connect(m_restoreButton, SIGNAL(clicked()), this, SLOT(restoreGlobal()));
    globalSettingLayout->addStretch(2);

hjk's avatar
hjk committed
68 69
    QWidget *innerPane = new QWidget;
    m_configWidget = m_config->createConfigWidget(innerPane);
Mike McQuaid's avatar
Mike McQuaid committed
70

hjk's avatar
hjk committed
71 72 73 74
    QVBoxLayout *layout = new QVBoxLayout(innerPane);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(globalSetting);
    layout->addWidget(m_configWidget);
Mike McQuaid's avatar
Mike McQuaid committed
75

hjk's avatar
hjk committed
76 77
    m_details = new Utils::DetailsWidget;
    m_details->setWidget(innerPane);
Mike McQuaid's avatar
Mike McQuaid committed
78

hjk's avatar
hjk committed
79 80 81 82 83
    QVBoxLayout *outerLayout = new QVBoxLayout(this);
    outerLayout->addWidget(m_details);
    outerLayout->setContentsMargins(0, 0, 0, 0);

    chooseSettings(m_aspect->isUsingGlobalSettings() ? 0 : 1);
84 85
}

hjk's avatar
hjk committed
86
QString AnalyzerRunConfigWidget::displayName() const
87
{
hjk's avatar
hjk committed
88
    return m_aspect->displayName();
89 90
}

91 92
void AnalyzerRunConfigWidget::chooseSettings(int setting)
{
93
    QTC_ASSERT(m_aspect, return);
hjk's avatar
hjk committed
94 95 96 97 98 99 100 101 102
    bool isCustom = (setting == 1);

    m_settingsCombo->setCurrentIndex(setting);
    m_aspect->setUsingGlobalSettings(!isCustom);
    m_configWidget->setEnabled(isCustom);
    m_restoreButton->setEnabled(isCustom);
    m_details->setSummaryText(isCustom
        ? tr("Use <strong>Customized Settings<strong>")
        : tr("Use <strong>Global Settings<strong>"));
103 104 105 106
}

void AnalyzerRunConfigWidget::restoreGlobal()
{
107
    QTC_ASSERT(m_aspect, return);
108
    m_aspect->resetProjectToGlobalSettings();
Mike McQuaid's avatar
Mike McQuaid committed
109
}
hjk's avatar
hjk committed
110 111

} // namespace Analyzer