diff --git a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp index 9753df73f3..e673269c65 100644 --- a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp +++ b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp @@ -1,132 +1,130 @@ /* * This file is part of KDevelop * * Copyright 2015 Sergey Kalinichev * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include "parserwidget.h" #include "ui_parserwidget.h" #include "compilerprovider/settingsmanager.h" #include namespace { QString languageStandard(const QString& arguments) { int idx = arguments.indexOf("-std="); if(idx == -1){ return QStringLiteral("c++11"); } idx += 5; int end = arguments.indexOf(' ', idx) != -1 ? arguments.indexOf(' ', idx) : arguments.size(); return arguments.mid(idx, end - idx); } bool isCustomParserArguments(const QString& arguments, const QStringList& standards) { const auto defaultArguments = SettingsManager::globalInstance()->defaultParserArguments(); auto standard = languageStandard(arguments); auto tmpArgs(arguments); tmpArgs.replace(standard, "c++11"); if (tmpArgs == defaultArguments && standards.contains(standard)) { return false; } return true; } const int customProfileIdx = 0; } ParserWidget::ParserWidget(QWidget* parent) : QWidget(parent) , m_ui(new Ui::ParserWidget()) { m_ui->setupUi(this); connect(m_ui->parserOptions, &QLineEdit::textEdited, this, &ParserWidget::textEdited); connect(m_ui->languageStandards, static_cast(&QComboBox::activated), this, &ParserWidget::languageStandardChanged); updateEnablements(); } ParserWidget::~ParserWidget() = default; void ParserWidget::textEdited() { emit changed(); } void ParserWidget::languageStandardChanged(const QString& standard) { if (m_ui->languageStandards->currentIndex() == customProfileIdx) { m_ui->parserOptions->setText(SettingsManager::globalInstance()->defaultParserArguments()); } else { auto text = SettingsManager::globalInstance()->defaultParserArguments(); auto currentStandard = languageStandard(text); m_ui->parserOptions->setText(text.replace(currentStandard, standard)); } textEdited(); updateEnablements(); } void ParserWidget::setParserArguments(const QString& arguments) { QStringList standards; for (int i = 1; i < m_ui->languageStandards->count(); i++) { standards << m_ui->languageStandards->itemText(i); } if (isCustomParserArguments(arguments, standards)) { m_ui->languageStandards->setCurrentIndex(customProfileIdx); } else { m_ui->languageStandards->setCurrentText(languageStandard(arguments)); } m_ui->parserOptions->setText(arguments); updateEnablements(); } QString ParserWidget::parserArguments() const { return m_ui->parserOptions->text(); } void ParserWidget::updateEnablements() { if (m_ui->languageStandards->currentIndex() == customProfileIdx) { - m_ui->parserOptions->setHidden(false); - m_ui->argumentsLabel->setHidden(false); + m_ui->parserOptions->setEnabled(true); } else { - m_ui->parserOptions->setHidden(true); - m_ui->argumentsLabel->setHidden(true); + m_ui->parserOptions->setEnabled(false); } } diff --git a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui index 747b505eab..e1aa1992e7 100644 --- a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui +++ b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui @@ -1,147 +1,132 @@ ParserWidget 0 0 579 407 Form - - - + + + + + Profi&le: + + + languageStandards + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + <html><head/><body><p>Choose language profile. </p><p>Use &quot;Custom&quot; profile to modify parser command-line arguments</p></body></html> + - - - Profile - - + + Custom + - - - - 0 - 0 - - - - - 100 - 0 - - - - <html><head/><body><p>Choose language profile. </p><p>Use &quot;Custom&quot; profile to modify parser command-line arguments</p></body></html> - - - - Custom - - - - - c99 - - - - - gnu99 - - - - - c11 - - - - - gnu11 - - - - - c++03 - - - - - c++11 - - - - - c++14 - - - + + c99 + - - - Qt::Horizontal - - - - 40 - 0 - - - + + gnu99 + - - - - - - - - Command-line arguments: - - + + + c11 + + + + + gnu11 + + + + + c++03 + + + + + c++11 + - - - - - 100 - 0 - - - + + + c++14 + - + + + + + + Command-line ar&guments: + + + parserOptions + + + + + + + + 100 + 0 + + + Qt::Vertical 20 406 diff --git a/languages/plugins/custom-definesandincludes/kcm_widget/projectpathswidget.ui b/languages/plugins/custom-definesandincludes/kcm_widget/projectpathswidget.ui index 6120a22f11..ab16982322 100644 --- a/languages/plugins/custom-definesandincludes/kcm_widget/projectpathswidget.ui +++ b/languages/plugins/custom-definesandincludes/kcm_widget/projectpathswidget.ui @@ -1,274 +1,274 @@ ProjectPathsWidget 0 0 667 621 9 9 9 9 Configure which macros and include directories/files will be added to the parser during project parsing: Check this if you want the project to be reparsed to apply the changes. Reparse the project true Qt::Horizontal 40 20 0 0 0 0 <html><head/><body><p>Select compiler that will be used to retrieve standard include directories and defined macros.</p></body></html> Compiler for path <html><head/><body><p>Select compiler that will be used to retrieve standard include directories and defined macros.</p></body></html> Edit multiply includes/defines at the same time. &Batch Edit... 0 0 Add a new sub-project path entry. .. false Delete current sub-project path entry. .. true 0 8 0 Includes/Imports 0 0 0 0 0 8 Defines 0 0 0 0 0 0 8 - C/C++ parser + C/C++ Parser KComboBox QComboBox
kcombobox.h
DefinesWidget QWidget
kcm_widget/defineswidget.h
IncludesWidget QWidget
kcm_widget/includeswidget.h
ParserWidget QWidget
kcm_widget/parserwidget.h
1