analyzerrunconfigwidget.cpp 4.19 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
namespace Internal {

hjk's avatar
hjk committed
46
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(AnalyzerRunConfigurationAspect *aspect)
47
{
hjk's avatar
hjk committed
48 49
    m_aspect = aspect;
    m_config = aspect->customSubConfig();
50

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

55 56 57 58 59 60 61 62 63 64 65 66 67 68
    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
69 70
    QWidget *innerPane = new QWidget;
    m_configWidget = m_config->createConfigWidget(innerPane);
Mike McQuaid's avatar
Mike McQuaid committed
71

hjk's avatar
hjk committed
72 73 74 75
    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
76

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

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

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

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

92 93
void AnalyzerRunConfigWidget::chooseSettings(int setting)
{
94
    QTC_ASSERT(m_aspect, return);
hjk's avatar
hjk committed
95 96 97 98 99 100 101 102 103
    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>"));
104 105 106 107
}

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

112
} // namespace Internal
hjk's avatar
hjk committed
113
} // namespace Analyzer