2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-07-01 16:27:40 +02:00
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
#include "codegensettingspage.h"
|
|
|
|
|
|
|
|
|
|
#include "qtsupportconstants.h"
|
|
|
|
|
|
|
|
|
|
#include <cpptools/cpptoolsconstants.h>
|
2009-07-01 16:27:40 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QTextStream>
|
2009-07-01 16:27:40 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
namespace QtSupport {
|
2009-07-01 16:27:40 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
// ---------- CodeGenSettingsPageWidget
|
2009-07-01 16:27:40 +02:00
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
CodeGenSettingsPageWidget::CodeGenSettingsPageWidget(QWidget *parent) :
|
2009-07-01 16:27:40 +02:00
|
|
|
QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
2012-02-16 09:36:33 +01:00
|
|
|
connect(m_ui.includeQtModuleCheckBox, SIGNAL(toggled(bool)),
|
|
|
|
|
m_ui.addQtVersionCheckBox, SLOT(setEnabled(bool)));
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
CodeGenSettings CodeGenSettingsPageWidget::parameters() const
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
2014-07-18 15:47:20 +02:00
|
|
|
CodeGenSettings rc;
|
|
|
|
|
rc.embedding = static_cast<CodeGenSettings::UiClassEmbedding>(uiEmbedding());
|
2011-01-10 16:29:06 +01:00
|
|
|
rc.retranslationSupport =m_ui.retranslateCheckBox->isChecked();
|
|
|
|
|
rc.includeQtModule = m_ui.includeQtModuleCheckBox->isChecked();
|
2012-02-16 09:36:33 +01:00
|
|
|
rc.addQtVersionCheck = m_ui.addQtVersionCheckBox->isChecked();
|
2009-07-01 16:27:40 +02:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
void CodeGenSettingsPageWidget::setParameters(const CodeGenSettings &p)
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
2011-01-10 16:29:06 +01:00
|
|
|
m_ui.retranslateCheckBox->setChecked(p.retranslationSupport);
|
|
|
|
|
m_ui.includeQtModuleCheckBox->setChecked(p.includeQtModule);
|
2012-02-16 09:36:33 +01:00
|
|
|
m_ui.addQtVersionCheckBox->setChecked(p.addQtVersionCheck);
|
2011-01-10 16:29:06 +01:00
|
|
|
setUiEmbedding(p.embedding);
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
int CodeGenSettingsPageWidget::uiEmbedding() const
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
|
|
|
|
if (m_ui.ptrAggregationRadioButton->isChecked())
|
2014-07-18 15:47:20 +02:00
|
|
|
return CodeGenSettings::PointerAggregatedUiClass;
|
2009-07-01 16:27:40 +02:00
|
|
|
if (m_ui.aggregationButton->isChecked())
|
2014-07-18 15:47:20 +02:00
|
|
|
return CodeGenSettings::AggregatedUiClass;
|
|
|
|
|
return CodeGenSettings::InheritedUiClass;
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
void CodeGenSettingsPageWidget::setUiEmbedding(int v)
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
|
|
|
|
switch (v) {
|
2014-07-18 15:47:20 +02:00
|
|
|
case CodeGenSettings::PointerAggregatedUiClass:
|
2009-07-01 16:27:40 +02:00
|
|
|
m_ui.ptrAggregationRadioButton->setChecked(true);
|
|
|
|
|
break;
|
2014-07-18 15:47:20 +02:00
|
|
|
case CodeGenSettings::AggregatedUiClass:
|
2009-07-01 16:27:40 +02:00
|
|
|
m_ui.aggregationButton->setChecked(true);
|
|
|
|
|
break;
|
2014-07-18 15:47:20 +02:00
|
|
|
case CodeGenSettings::InheritedUiClass:
|
2009-07-01 16:27:40 +02:00
|
|
|
m_ui.multipleInheritanceButton->setChecked(true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
// ---------- CodeGenSettingsPage
|
|
|
|
|
CodeGenSettingsPage::CodeGenSettingsPage(QObject *parent) :
|
|
|
|
|
Core::IOptionsPage(parent),
|
|
|
|
|
m_widget(0)
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
m_parameters.fromSettings(Core::ICore::settings());
|
2014-07-18 15:47:20 +02:00
|
|
|
setId(Constants::CODEGEN_SETTINGS_PAGE_ID);
|
|
|
|
|
setDisplayName(QCoreApplication::translate("QtSupport", Constants::CODEGEN_SETTINGS_PAGE_NAME));
|
|
|
|
|
setCategory(CppTools::Constants::CPP_SETTINGS_CATEGORY);
|
|
|
|
|
setDisplayCategory(QCoreApplication::translate("CppTools", CppTools::Constants::CPP_SETTINGS_TR_CATEGORY));
|
|
|
|
|
setCategoryIcon(QLatin1String(CppTools::Constants::SETTINGS_CATEGORY_CPP_ICON));
|
2010-03-26 17:34:10 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
QWidget *CodeGenSettingsPage::widget()
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
if (!m_widget) {
|
2014-07-18 15:47:20 +02:00
|
|
|
m_widget = new CodeGenSettingsPageWidget;
|
2013-12-03 14:17:03 +01:00
|
|
|
m_widget->setParameters(m_parameters);
|
|
|
|
|
}
|
2009-07-01 16:27:40 +02:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
void CodeGenSettingsPage::apply()
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
|
|
|
|
if (m_widget) {
|
2014-07-18 15:47:20 +02:00
|
|
|
const CodeGenSettings newParameters = m_widget->parameters();
|
2009-07-01 16:27:40 +02:00
|
|
|
if (newParameters != m_parameters) {
|
|
|
|
|
m_parameters = newParameters;
|
2012-01-24 15:36:40 +01:00
|
|
|
m_parameters.toSettings(Core::ICore::settings());
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:47:20 +02:00
|
|
|
void CodeGenSettingsPage::finish()
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
delete m_widget;
|
2009-11-24 15:05:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-01 16:27:40 +02:00
|
|
|
} // namespace Internal
|
2014-07-18 15:47:20 +02:00
|
|
|
} // namespace QtSupport
|