2009-07-01 16:27:40 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2009-07-01 16:27:40 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cppsettingspage.h"
|
|
|
|
|
#include "designerconstants.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QTextStream>
|
2009-07-01 16:27:40 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
namespace Designer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
// ---------- CppSettingsPageWidget
|
|
|
|
|
|
|
|
|
|
CppSettingsPageWidget::CppSettingsPageWidget(QWidget *parent) :
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormClassWizardGenerationParameters CppSettingsPageWidget::parameters() const
|
|
|
|
|
{
|
|
|
|
|
FormClassWizardGenerationParameters rc;
|
2011-01-10 16:29:06 +01:00
|
|
|
rc.embedding = static_cast<UiClassEmbedding>(uiEmbedding());
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppSettingsPageWidget::setParameters(const FormClassWizardGenerationParameters &p)
|
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CppSettingsPageWidget::uiEmbedding() const
|
|
|
|
|
{
|
|
|
|
|
if (m_ui.ptrAggregationRadioButton->isChecked())
|
2011-01-10 16:29:06 +01:00
|
|
|
return PointerAggregatedUiClass;
|
2009-07-01 16:27:40 +02:00
|
|
|
if (m_ui.aggregationButton->isChecked())
|
2011-01-10 16:29:06 +01:00
|
|
|
return AggregatedUiClass;
|
|
|
|
|
return InheritedUiClass;
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppSettingsPageWidget::setUiEmbedding(int v)
|
|
|
|
|
{
|
|
|
|
|
switch (v) {
|
2011-01-10 16:29:06 +01:00
|
|
|
case PointerAggregatedUiClass:
|
2009-07-01 16:27:40 +02:00
|
|
|
m_ui.ptrAggregationRadioButton->setChecked(true);
|
|
|
|
|
break;
|
2011-01-10 16:29:06 +01:00
|
|
|
case AggregatedUiClass:
|
2009-07-01 16:27:40 +02:00
|
|
|
m_ui.aggregationButton->setChecked(true);
|
|
|
|
|
break;
|
2011-01-10 16:29:06 +01:00
|
|
|
case InheritedUiClass:
|
2009-07-01 16:27:40 +02:00
|
|
|
m_ui.multipleInheritanceButton->setChecked(true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
QString CppSettingsPageWidget::searchKeywords() const
|
|
|
|
|
{
|
|
|
|
|
QString rc;
|
|
|
|
|
QTextStream(&rc) << m_ui.ptrAggregationRadioButton->text()
|
|
|
|
|
<< ' ' << m_ui.aggregationButton->text()
|
|
|
|
|
<< ' ' << m_ui.multipleInheritanceButton->text()
|
|
|
|
|
<< ' ' << m_ui.retranslateCheckBox->text()
|
|
|
|
|
<< ' ' << m_ui.includeQtModuleCheckBox->text();
|
|
|
|
|
rc.remove(QLatin1Char('&'));
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-01 16:27:40 +02:00
|
|
|
// ---------- CppSettingsPage
|
|
|
|
|
CppSettingsPage::CppSettingsPage(QObject *parent) : Core::IOptionsPage(parent)
|
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
m_parameters.fromSettings(Core::ICore::settings());
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CppSettingsPage::id() const
|
|
|
|
|
{
|
2009-11-27 16:12:12 +01:00
|
|
|
return QLatin1String(Designer::Constants::SETTINGS_CPP_SETTINGS_ID);
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString CppSettingsPage::displayName() const
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
2009-11-27 16:12:12 +01:00
|
|
|
return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CPP_SETTINGS_NAME);
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CppSettingsPage::category() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(Designer::Constants::SETTINGS_CATEGORY);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString CppSettingsPage::displayCategory() const
|
2009-07-01 16:27:40 +02:00
|
|
|
{
|
2009-11-27 16:12:12 +01:00
|
|
|
return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_TR_CATEGORY);
|
2009-07-01 16:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-26 17:34:10 +01:00
|
|
|
QIcon CppSettingsPage::categoryIcon() const
|
|
|
|
|
{
|
|
|
|
|
return QIcon(QLatin1String(Designer::Constants::SETTINGS_CATEGORY_ICON));
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-01 16:27:40 +02:00
|
|
|
QWidget *CppSettingsPage::createPage(QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
m_widget = new CppSettingsPageWidget(parent);
|
|
|
|
|
m_widget->setParameters(m_parameters);
|
2009-11-24 15:05:02 +01:00
|
|
|
if (m_searchKeywords.isEmpty())
|
|
|
|
|
m_searchKeywords = m_widget->searchKeywords();
|
2009-07-01 16:27:40 +02:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppSettingsPage::apply()
|
|
|
|
|
{
|
|
|
|
|
if (m_widget) {
|
|
|
|
|
const FormClassWizardGenerationParameters newParameters = m_widget->parameters();
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppSettingsPage::finish()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
bool CppSettingsPage::matches(const QString &s) const
|
|
|
|
|
{
|
|
|
|
|
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-01 16:27:40 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Designer
|