ui: language standard
Added language standard select functionality to gui and language standard to project settings.
This commit is contained in:
@@ -199,6 +199,9 @@ Parser::Arguments Project::getParserArguments() const
|
||||
utility::append(args.frameworkSearchPaths, projSettings->getFrameworkSearchPaths());
|
||||
utility::append(args.frameworkSearchPaths, appSettings->getFrameworkSearchPaths());
|
||||
|
||||
args.language = projSettings->getLanguage();
|
||||
args.languageStandard = projSettings->getStandard();
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ public:
|
||||
std::vector<FilePath> frameworkSearchPaths;
|
||||
std::vector<std::string> compilerFlags;
|
||||
bool logErrors;
|
||||
std::string language;
|
||||
std::string languageStandard;
|
||||
};
|
||||
|
||||
Parser(ParserClient* client);
|
||||
|
||||
@@ -46,6 +46,26 @@ void ProjectSettings::save(const FilePath& filePath)
|
||||
Settings::save(filePath);
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getLanguage() const
|
||||
{
|
||||
return getValue<std::string>("language_settings/language", "C++");
|
||||
}
|
||||
|
||||
bool ProjectSettings::setLanguage(const std::string& language)
|
||||
{
|
||||
return setValue<std::string>("language_settings/language", language);
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getStandard() const
|
||||
{
|
||||
return getValue<std::string>("language_settings/standard", "11");
|
||||
}
|
||||
|
||||
bool ProjectSettings::setStandard(const std::string& standard)
|
||||
{
|
||||
return setValue<std::string>("language_settings/standard", standard);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getSourcePaths() const
|
||||
{
|
||||
return getRelativePathValues("source/source_paths/source_path");
|
||||
|
||||
@@ -18,6 +18,13 @@ public:
|
||||
|
||||
virtual void save(const FilePath& filePath);
|
||||
|
||||
// language settings
|
||||
std::string getLanguage() const;
|
||||
bool setLanguage(const std::string& language);
|
||||
|
||||
std::string getStandard() const;
|
||||
bool setStandard(const std::string& standard);
|
||||
|
||||
// source
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
bool setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "vld.h"
|
||||
|
||||
//#define DEPLOY
|
||||
// #define DEPLOY
|
||||
|
||||
#ifdef DEPLOY
|
||||
static std::string appSettingsPath = std::string(std::getenv("APPDATA")) + "/../local/Coati Software/Coati/ApplicationSettings.xml";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "qt/window/QtProjectSetupScreen.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QLineEdit>
|
||||
@@ -53,7 +52,6 @@ void QtTextLine::handleButtonPress()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QtProjectSetupScreen::QtProjectSetupScreen(QWidget *parent)
|
||||
: QtSettingsWindow(parent)
|
||||
, m_frameworkPaths(nullptr)
|
||||
@@ -108,6 +106,15 @@ void QtProjectSetupScreen::loadProjectSettings()
|
||||
m_projectName->setText(QString::fromStdString(projSettings->getFilePath().withoutExtension().fileName()));
|
||||
m_projectFileLocation->setText(QString::fromStdString(projSettings->getFilePath().parentDirectory().str()));
|
||||
|
||||
if (projSettings->getLanguage().length() > 0)
|
||||
{
|
||||
m_language->setCurrentText(QString::fromStdString(projSettings->getLanguage()));
|
||||
}
|
||||
if (projSettings->getStandard().length() > 0)
|
||||
{
|
||||
m_cppStandard->setCurrentText(QString::fromStdString(projSettings->getStandard()));
|
||||
}
|
||||
|
||||
m_sourcePaths->setList(projSettings->getSourcePaths());
|
||||
m_includePaths->setList(projSettings->getHeaderSearchPaths());
|
||||
|
||||
@@ -134,9 +141,16 @@ void QtProjectSetupScreen::populateForm(QFormLayout* layout)
|
||||
layout->addRow(locationLabel, m_projectFileLocation);
|
||||
|
||||
QLabel* languageLabel = new QLabel("Language");
|
||||
QComboBox* language = new QComboBox();
|
||||
language->insertItem(0, "C++");
|
||||
layout->addRow(languageLabel, language);
|
||||
m_language = new QComboBox();
|
||||
m_language->insertItem(0, "C++");
|
||||
m_language->insertItem(1, "C");
|
||||
connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
|
||||
layout->addRow(languageLabel, m_language);
|
||||
|
||||
m_standardLabel = new QLabel("Standard");
|
||||
m_cppStandard = new QComboBox();
|
||||
m_cppStandard->insertItem(0, "11");
|
||||
layout->addRow(m_standardLabel, m_cppStandard);
|
||||
|
||||
QPushButton* helpButton;
|
||||
|
||||
@@ -197,6 +211,11 @@ void QtProjectSetupScreen::handleUpdateButtonPress()
|
||||
|
||||
projSettings->clear();
|
||||
|
||||
projSettings->setLanguage(m_language->currentText().toStdString());
|
||||
if (m_cppStandard->isVisible())
|
||||
{
|
||||
projSettings->setStandard(m_cppStandard->currentText().toStdString());
|
||||
}
|
||||
projSettings->setSourcePaths(m_sourcePaths->getList());
|
||||
projSettings->setHeaderSearchPaths(m_includePaths->getList());
|
||||
|
||||
@@ -209,6 +228,13 @@ void QtProjectSetupScreen::handleUpdateButtonPress()
|
||||
m_projectFileLocation->getText().toStdString() + "/" + m_projectName->text().toStdString() + ".coatiproject";
|
||||
projSettings->save(projectFile);
|
||||
|
||||
projSettings->setLanguage(m_language->currentText().toStdString());
|
||||
|
||||
if (m_cppStandard->isVisible())
|
||||
{
|
||||
projSettings->setStandard(m_cppStandard->currentText().toStdString());
|
||||
}
|
||||
|
||||
MessageLoadProject(projectFile).dispatch();
|
||||
clear();
|
||||
|
||||
@@ -245,3 +271,17 @@ void QtProjectSetupScreen::handlePreferencesButtonPress()
|
||||
{
|
||||
emit showPreferences();
|
||||
}
|
||||
|
||||
void QtProjectSetupScreen::handleSelectionChanged(int index)
|
||||
{
|
||||
if (index != 0)
|
||||
{
|
||||
m_standardLabel->hide();
|
||||
m_cppStandard->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_standardLabel->show();
|
||||
m_cppStandard->show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef QT_PROJECT_SETUP_SCREEN_H
|
||||
#define QT_PROJECT_SETUP_SCREEN_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -56,6 +57,7 @@ protected:
|
||||
private slots:
|
||||
void handleCancelButtonPress();
|
||||
void handleUpdateButtonPress();
|
||||
void handleSelectionChanged(int index);
|
||||
|
||||
void handleSourcePathHelpPress();
|
||||
void handleIncludePathHelpPress();
|
||||
@@ -72,6 +74,11 @@ private:
|
||||
QtDirectoryListBox* m_frameworkPaths;
|
||||
|
||||
QPushButton* m_preferencesButton;
|
||||
|
||||
QComboBox* m_language;
|
||||
QComboBox* m_cppStandard;
|
||||
|
||||
QLabel* m_standardLabel;
|
||||
};
|
||||
|
||||
#endif //QT_PROJECT_SETUP_SCREEN_H
|
||||
|
||||
@@ -110,9 +110,15 @@ std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arg
|
||||
|
||||
// The option '-x c++' treats subsequent input files as C++.
|
||||
args.push_back("-x");
|
||||
args.push_back("c++");
|
||||
std::string language = getLanguageArgument(arguments.language);
|
||||
args.push_back(language);
|
||||
// args.push_back("c++");
|
||||
|
||||
args.push_back("-std=c++11");
|
||||
// TODO: handle other standards...
|
||||
if (language == "c++")
|
||||
{
|
||||
args.push_back("-std=c++11");
|
||||
}
|
||||
|
||||
args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end());
|
||||
|
||||
@@ -196,3 +202,17 @@ ParserClient* CxxParser::getParserClient()
|
||||
{
|
||||
return m_client;
|
||||
}
|
||||
|
||||
std::string CxxParser::getLanguageArgument(const std::string& language) const
|
||||
{
|
||||
std::string result = language;
|
||||
|
||||
boost::algorithm::to_lower(result);
|
||||
|
||||
if (result != "c++" && result != "c")
|
||||
{
|
||||
result = "c++";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ private:
|
||||
FileRegister* getFileRegister();
|
||||
ParserClient* getParserClient();
|
||||
|
||||
std::string getLanguageArgument(const std::string& language) const;
|
||||
|
||||
friend class TaskParseCxx;
|
||||
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
|
||||
Reference in New Issue
Block a user