forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/master' into 10.0
Change-Id: I9f6090e2a9f62fd3a9823f5a7342ea423dfbb2ac
This commit is contained in:
@@ -32,6 +32,9 @@ class %{CN}
|
||||
@if '%{AddQObjectMacro}'
|
||||
Q_OBJECT
|
||||
@endif
|
||||
@if '%{AddQmlElementMacro}'
|
||||
QML_ELEMENT
|
||||
@endif
|
||||
public:
|
||||
@if '%{Base}' === 'QObject' || %{JS: Cpp.hasQObjectParent('%{Base}')}
|
||||
explicit %{CN}(QObject *parent = nullptr);
|
||||
|
||||
@@ -146,6 +146,17 @@
|
||||
"checked": "%{JS: [ 'QObject', 'QWidget', 'QMainWindow', 'QDeclarativeItem', 'QQuickItem'].indexOf(value('Base')) >= 0 }"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "AddQmlElementMacro",
|
||||
"trDisplayName": "Add QML_ELEMENT",
|
||||
"type": "CheckBox",
|
||||
"data":
|
||||
{
|
||||
"checkedValue": "AddQmlElementMacro",
|
||||
"uncheckedValue": "",
|
||||
"checked": "%{JS: ['QQuickItem'].indexOf(value('Base')) >= 0 }"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Sp2",
|
||||
"type": "Spacer"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
QT -= gui
|
||||
QT = core
|
||||
|
||||
CONFIG += c++17 console
|
||||
CONFIG -= app_bundle
|
||||
CONFIG += c++17 cmdline
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
|
||||
4
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
4
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -915,6 +915,10 @@ OperatorNameId::Kind Bind::cppOperator(OperatorAST *ast)
|
||||
kind = OperatorNameId::ArrayAccessOp;
|
||||
break;
|
||||
|
||||
case T_LESS_EQUAL_GREATER:
|
||||
kind = OperatorNameId::SpaceShipOp;
|
||||
break;
|
||||
|
||||
default:
|
||||
kind = OperatorNameId::InvalidOp;
|
||||
} // switch
|
||||
|
||||
7
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
7
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
@@ -612,7 +612,12 @@ void Lexer::scan_helper(Token *tok)
|
||||
tok->f.kind = T_LESS_LESS;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_LESS_EQUAL;
|
||||
if (_languageFeatures.cxx20Enabled && _yychar == '>') {
|
||||
yyinp();
|
||||
tok->f.kind = T_LESS_EQUAL_GREATER;
|
||||
} else {
|
||||
tok->f.kind = T_LESS_EQUAL;
|
||||
}
|
||||
} else if (_yychar == ':') {
|
||||
if (*(_currentChar+1) != ':' || *(_currentChar+2) == ':' || *(_currentChar+2) == '>') {
|
||||
yyinp();
|
||||
|
||||
5
src/libs/3rdparty/cplusplus/Names.h
vendored
5
src/libs/3rdparty/cplusplus/Names.h
vendored
@@ -180,7 +180,7 @@ public:
|
||||
! = < > += -= *= /= %=
|
||||
^= &= |= << >> >>= <<= == !=
|
||||
<= >= && || ++ -- , ->* ->
|
||||
() []
|
||||
() [] <=>
|
||||
*/
|
||||
enum Kind {
|
||||
InvalidOp,
|
||||
@@ -225,7 +225,8 @@ public:
|
||||
ArrowStarOp,
|
||||
ArrowOp,
|
||||
FunctionCallOp,
|
||||
ArrayAccessOp
|
||||
ArrayAccessOp,
|
||||
SpaceShipOp
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
39
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
39
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -98,10 +98,11 @@ enum {
|
||||
And = 8,
|
||||
Equality = 9,
|
||||
Relational = 10,
|
||||
Shift = 11,
|
||||
Additive = 12,
|
||||
Multiplicative = 13,
|
||||
PointerToMember = 14
|
||||
ThreeWayComp = 11,
|
||||
Shift = 12,
|
||||
Additive = 13,
|
||||
Multiplicative = 14,
|
||||
PointerToMember = 15
|
||||
};
|
||||
} // namespace Precedece
|
||||
|
||||
@@ -116,29 +117,30 @@ inline int precedence(int tokenKind, bool templateArguments)
|
||||
return Prec::Assignment;
|
||||
|
||||
switch (tokenKind) {
|
||||
case T_COMMA: return Prec::Comma;
|
||||
case T_QUESTION: return Prec::Conditional;
|
||||
case T_PIPE_PIPE: return Prec::LogicalOr;
|
||||
case T_AMPER_AMPER: return Prec::LogicalAnd;
|
||||
case T_PIPE: return Prec::InclusiveOr;
|
||||
case T_CARET: return Prec::ExclusiveOr;
|
||||
case T_AMPER: return Prec::And;
|
||||
case T_COMMA: return Prec::Comma;
|
||||
case T_QUESTION: return Prec::Conditional;
|
||||
case T_PIPE_PIPE: return Prec::LogicalOr;
|
||||
case T_AMPER_AMPER: return Prec::LogicalAnd;
|
||||
case T_PIPE: return Prec::InclusiveOr;
|
||||
case T_CARET: return Prec::ExclusiveOr;
|
||||
case T_AMPER: return Prec::And;
|
||||
case T_EQUAL_EQUAL:
|
||||
case T_EXCLAIM_EQUAL: return Prec::Equality;
|
||||
case T_EXCLAIM_EQUAL: return Prec::Equality;
|
||||
case T_GREATER:
|
||||
case T_LESS:
|
||||
case T_LESS_EQUAL:
|
||||
case T_GREATER_EQUAL: return Prec::Relational;
|
||||
case T_GREATER_EQUAL: return Prec::Relational;
|
||||
case T_LESS_EQUAL_GREATER: return Prec::ThreeWayComp;
|
||||
case T_LESS_LESS:
|
||||
case T_GREATER_GREATER: return Prec::ExclusiveOr;
|
||||
case T_GREATER_GREATER: return Prec::ExclusiveOr;
|
||||
case T_PLUS:
|
||||
case T_MINUS: return Prec::Additive;
|
||||
case T_MINUS: return Prec::Additive;
|
||||
case T_STAR:
|
||||
case T_SLASH:
|
||||
case T_PERCENT: return Prec::Multiplicative;
|
||||
case T_PERCENT: return Prec::Multiplicative;
|
||||
case T_ARROW_STAR:
|
||||
case T_DOT_STAR: return Prec::PointerToMember;
|
||||
default: return Prec::Unknown;
|
||||
case T_DOT_STAR: return Prec::PointerToMember;
|
||||
default: return Prec::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1300,6 +1302,7 @@ bool Parser::parseOperator(OperatorAST *&node) // ### FIXME
|
||||
case T_GREATER_EQUAL:
|
||||
case T_GREATER_GREATER_EQUAL:
|
||||
case T_LESS_EQUAL:
|
||||
case T_LESS_EQUAL_GREATER:
|
||||
case T_LESS_LESS_EQUAL:
|
||||
case T_MINUS_EQUAL:
|
||||
case T_PERCENT_EQUAL:
|
||||
|
||||
1
src/libs/3rdparty/cplusplus/Token.cpp
vendored
1
src/libs/3rdparty/cplusplus/Token.cpp
vendored
@@ -91,6 +91,7 @@ const char *token_names[] = {
|
||||
("<="),
|
||||
("<<"),
|
||||
("<<="),
|
||||
("<=>"),
|
||||
("-"),
|
||||
("-="),
|
||||
("--"),
|
||||
|
||||
2
src/libs/3rdparty/cplusplus/Token.h
vendored
2
src/libs/3rdparty/cplusplus/Token.h
vendored
@@ -99,6 +99,7 @@ enum Kind {
|
||||
T_LESS_EQUAL,
|
||||
T_LESS_LESS,
|
||||
T_LESS_LESS_EQUAL,
|
||||
T_LESS_EQUAL_GREATER,
|
||||
T_MINUS,
|
||||
T_MINUS_EQUAL,
|
||||
T_MINUS_MINUS,
|
||||
@@ -446,6 +447,7 @@ struct LanguageFeatures
|
||||
unsigned int cxxEnabled : 1;
|
||||
unsigned int cxx11Enabled : 1;
|
||||
unsigned int cxx14Enabled : 1;
|
||||
unsigned int cxx20Enabled : 1;
|
||||
unsigned int objCEnabled : 1;
|
||||
unsigned int c99Enabled : 1;
|
||||
};
|
||||
|
||||
@@ -222,6 +222,9 @@ void NamePrettyPrinter::visit(const OperatorNameId *name)
|
||||
case OperatorNameId::ArrayAccessOp:
|
||||
_name += QLatin1String("[]");
|
||||
break;
|
||||
case OperatorNameId::SpaceShipOp:
|
||||
_name += QLatin1String("<=>");
|
||||
break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,24 @@ struct Value
|
||||
inline bool is_zero () const
|
||||
{ return l == 0; }
|
||||
|
||||
template<typename T> static bool cmpImpl(T v1, T v2)
|
||||
{
|
||||
if (v1 < v2)
|
||||
return -1;
|
||||
if (v1 > v2)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
Value cmp(const Value &other) const
|
||||
{
|
||||
Value v = *this;
|
||||
if (v.is_ulong() || other.is_ulong())
|
||||
v.set_long(cmpImpl(v.ul, other.ul));
|
||||
else
|
||||
v.set_long(cmpImpl(v.l, other.l));
|
||||
return v;
|
||||
}
|
||||
|
||||
#define PP_DEFINE_BIN_OP(name, op) \
|
||||
inline Value operator op(const Value &other) const \
|
||||
{ \
|
||||
@@ -488,24 +506,25 @@ private:
|
||||
inline int precedence(int tokenKind) const
|
||||
{
|
||||
switch (tokenKind) {
|
||||
case T_PIPE_PIPE: return 0;
|
||||
case T_AMPER_AMPER: return 1;
|
||||
case T_PIPE: return 2;
|
||||
case T_CARET: return 3;
|
||||
case T_AMPER: return 4;
|
||||
case T_PIPE_PIPE: return 0;
|
||||
case T_AMPER_AMPER: return 1;
|
||||
case T_PIPE: return 2;
|
||||
case T_CARET: return 3;
|
||||
case T_AMPER: return 4;
|
||||
case T_EQUAL_EQUAL:
|
||||
case T_EXCLAIM_EQUAL: return 5;
|
||||
case T_EXCLAIM_EQUAL: return 5;
|
||||
case T_GREATER:
|
||||
case T_LESS:
|
||||
case T_LESS_EQUAL:
|
||||
case T_GREATER_EQUAL: return 6;
|
||||
case T_GREATER_EQUAL: return 6;
|
||||
case T_LESS_EQUAL_GREATER: return 7;
|
||||
case T_LESS_LESS:
|
||||
case T_GREATER_GREATER: return 7;
|
||||
case T_GREATER_GREATER: return 8;
|
||||
case T_PLUS:
|
||||
case T_MINUS: return 8;
|
||||
case T_MINUS: return 9;
|
||||
case T_STAR:
|
||||
case T_SLASH:
|
||||
case T_PERCENT: return 9;
|
||||
case T_PERCENT: return 10;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
@@ -525,6 +544,7 @@ private:
|
||||
case T_GREATER:
|
||||
case T_LESS:
|
||||
case T_LESS_EQUAL:
|
||||
case T_LESS_EQUAL_GREATER:
|
||||
case T_GREATER_EQUAL:
|
||||
case T_LESS_LESS:
|
||||
case T_GREATER_GREATER:
|
||||
@@ -543,24 +563,25 @@ private:
|
||||
static inline Value evaluate_expression(int tokenKind, const Value &lhs, const Value &rhs)
|
||||
{
|
||||
switch (tokenKind) {
|
||||
case T_PIPE_PIPE: return lhs || rhs;
|
||||
case T_AMPER_AMPER: return lhs && rhs;
|
||||
case T_PIPE: return lhs | rhs;
|
||||
case T_CARET: return lhs ^ rhs;
|
||||
case T_AMPER: return lhs & rhs;
|
||||
case T_EQUAL_EQUAL: return lhs == rhs;
|
||||
case T_EXCLAIM_EQUAL: return lhs != rhs;
|
||||
case T_GREATER: return lhs > rhs;
|
||||
case T_LESS: return lhs < rhs;
|
||||
case T_LESS_EQUAL: return lhs <= rhs;
|
||||
case T_GREATER_EQUAL: return lhs >= rhs;
|
||||
case T_LESS_LESS: return lhs << rhs;
|
||||
case T_GREATER_GREATER: return lhs >> rhs;
|
||||
case T_PLUS: return lhs + rhs;
|
||||
case T_MINUS: return lhs - rhs;
|
||||
case T_STAR: return lhs * rhs;
|
||||
case T_SLASH: return rhs.is_zero() ? Value() : lhs / rhs;
|
||||
case T_PERCENT: return rhs.is_zero() ? Value() : lhs % rhs;
|
||||
case T_PIPE_PIPE: return lhs || rhs;
|
||||
case T_AMPER_AMPER: return lhs && rhs;
|
||||
case T_PIPE: return lhs | rhs;
|
||||
case T_CARET: return lhs ^ rhs;
|
||||
case T_AMPER: return lhs & rhs;
|
||||
case T_EQUAL_EQUAL: return lhs == rhs;
|
||||
case T_EXCLAIM_EQUAL: return lhs != rhs;
|
||||
case T_GREATER: return lhs > rhs;
|
||||
case T_LESS: return lhs < rhs;
|
||||
case T_LESS_EQUAL: return lhs <= rhs;
|
||||
case T_LESS_EQUAL_GREATER: return lhs.cmp(rhs);
|
||||
case T_GREATER_EQUAL: return lhs >= rhs;
|
||||
case T_LESS_LESS: return lhs << rhs;
|
||||
case T_GREATER_GREATER: return lhs >> rhs;
|
||||
case T_PLUS: return lhs + rhs;
|
||||
case T_MINUS: return lhs - rhs;
|
||||
case T_STAR: return lhs * rhs;
|
||||
case T_SLASH: return rhs.is_zero() ? Value() : lhs / rhs;
|
||||
case T_PERCENT: return rhs.is_zero() ? Value() : lhs % rhs;
|
||||
|
||||
default:
|
||||
return Value();
|
||||
|
||||
@@ -99,3 +99,4 @@ add_subdirectory(studiowelcome)
|
||||
add_subdirectory(qnx)
|
||||
add_subdirectory(webassembly)
|
||||
add_subdirectory(mcusupport)
|
||||
add_subdirectory(saferenderer)
|
||||
|
||||
@@ -131,7 +131,8 @@ ClangdFindReferences::ClangdFindReferences(ClangdClient *client, TextDocument *d
|
||||
replacement ? SearchResultWindow::SearchAndReplace : SearchResultWindow::SearchOnly,
|
||||
SearchResultWindow::PreserveCaseDisabled,
|
||||
"CppEditor");
|
||||
d->search->makeNonInteractive(callback);
|
||||
if (callback)
|
||||
d->search->makeNonInteractive(callback);
|
||||
if (categorize)
|
||||
d->search->setFilter(new CppSearchResultFilter);
|
||||
if (d->replacementData) {
|
||||
|
||||
@@ -62,6 +62,8 @@ const char CMAKE_FEATURE_ID[] = "CMakeProjectManager.Wizard.FeatureCMake";
|
||||
// Tool
|
||||
const char TOOL_ID[] = "CMakeProjectManager.CMakeKitInformation";
|
||||
|
||||
// Data
|
||||
const char BUILD_FOLDER_ROLE[] = "CMakeProjectManager.data.buildFolder";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
@@ -108,6 +108,9 @@ QVariant CMakeTargetNode::data(Id role) const
|
||||
return {};
|
||||
};
|
||||
|
||||
if (role == Constants::BUILD_FOLDER_ROLE)
|
||||
return m_buildDirectory.toVariant();
|
||||
|
||||
if (role == Android::Constants::AndroidAbi)
|
||||
return value(Android::Constants::ANDROID_ABI);
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ ToolChain *toolchainFromFlags(const Kit *kit, const QStringList &flags, const Ut
|
||||
return ToolChainKitAspect::toolChain(kit, language);
|
||||
|
||||
// Try exact compiler match.
|
||||
const Utils::FilePath compiler = Utils::FilePath::fromString(compilerPath(flags.front()));
|
||||
const Utils::FilePath compiler = Utils::FilePath::fromUserInput(compilerPath(flags.front()));
|
||||
ToolChain *toolchain = ToolChainManager::toolChain([&compiler, &language](const ToolChain *tc) {
|
||||
return tc->isValid() && tc->language() == language && tc->compilerCommand() == compiler;
|
||||
});
|
||||
|
||||
@@ -157,11 +157,8 @@ static QStringList jsonObjectFlags(const QJsonObject &object, QSet<QString> &fla
|
||||
|
||||
static FilePath jsonObjectFilePath(const QJsonObject &object)
|
||||
{
|
||||
const QString workingDir = QDir::cleanPath(object["directory"].toString());
|
||||
FilePath fileName = FilePath::fromString(QDir::cleanPath(object["file"].toString()));
|
||||
if (fileName.toFileInfo().isRelative())
|
||||
fileName = FilePath::fromString(QDir::cleanPath(workingDir + "/" + fileName.toString()));
|
||||
return fileName;
|
||||
const FilePath workingDir = FilePath::fromUserInput(object["directory"].toString());
|
||||
return workingDir.resolvePath(object["file"].toString());
|
||||
}
|
||||
|
||||
std::vector<DbEntry> CompilationDbParser::readJsonObjects() const
|
||||
|
||||
@@ -219,6 +219,7 @@ QString Utils::toString(CPlusPlus::Kind kind)
|
||||
TOKEN(T_LBRACKET);
|
||||
TOKEN(T_LESS);
|
||||
TOKEN(T_LESS_EQUAL);
|
||||
TOKEN(T_LESS_EQUAL_GREATER);
|
||||
TOKEN(T_LESS_LESS);
|
||||
TOKEN(T_LESS_LESS_EQUAL);
|
||||
TOKEN(T_LPAREN);
|
||||
|
||||
@@ -26,10 +26,14 @@
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/find/searchresultwindow.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <texteditor/basefilefind.h>
|
||||
#include <texteditor/behaviorsettings.h>
|
||||
@@ -614,9 +618,19 @@ void CppEditorWidget::renameUsages(const QString &replacement, QTextCursor curso
|
||||
{
|
||||
if (cursor.isNull())
|
||||
cursor = textCursor();
|
||||
CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, textDocument()};
|
||||
QPointer<CppEditorWidget> cppEditorWidget = this;
|
||||
d->m_modelManager->globalRename(cursorInEditor, replacement);
|
||||
|
||||
// First check if the symbol to be renamed comes from a generated file.
|
||||
LinkHandler continuation = [=, self = QPointer(this)](const Link &link) {
|
||||
if (!self)
|
||||
return;
|
||||
showRenameWarningIfFileIsGenerated(link.targetFilePath);
|
||||
CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, textDocument()};
|
||||
QPointer<CppEditorWidget> cppEditorWidget = this;
|
||||
d->m_modelManager->globalRename(cursorInEditor, replacement);
|
||||
};
|
||||
CppModelManager::followSymbol(
|
||||
CursorInEditor{cursor, textDocument()->filePath(), this, textDocument()},
|
||||
continuation, true, false);
|
||||
}
|
||||
|
||||
void CppEditorWidget::renameUsages(const Utils::FilePath &filePath, const QString &replacement,
|
||||
@@ -737,6 +751,45 @@ void CppEditorWidget::handleOutlineChanged(const QWidget *newOutline)
|
||||
}
|
||||
}
|
||||
|
||||
void CppEditorWidget::showRenameWarningIfFileIsGenerated(const Utils::FilePath &filePath)
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
for (const Project * const project : SessionManager::projects()) {
|
||||
const Node * const node = project->nodeForFilePath(filePath);
|
||||
if (!node)
|
||||
continue;
|
||||
if (!node->isGenerated())
|
||||
return;
|
||||
ExtraCompiler *ec = nullptr;
|
||||
QString warning = CppEditor::Tr::tr(
|
||||
"You are trying to rename a symbol declared in the generated file \"%1\".\n"
|
||||
"This is normally not a good idea, as the file will likely get "
|
||||
"overwritten during the build process.")
|
||||
.arg(filePath.toUserOutput());
|
||||
if (const Target * const target = project->activeTarget()) {
|
||||
if (const BuildSystem * const bs = target->buildSystem())
|
||||
ec = bs->extraCompilerForTarget(filePath);
|
||||
}
|
||||
if (ec) {
|
||||
warning.append('\n').append(CppEditor::Tr::tr(
|
||||
"Do you want to edit \"%1\" instead?")
|
||||
.arg(ec->source().toUserOutput()));
|
||||
}
|
||||
static const Id infoId("cppeditor.renameWarning");
|
||||
InfoBarEntry info(infoId, warning);
|
||||
if (ec) {
|
||||
info.addCustomButton(CppEditor::Tr::tr("Open %1").arg(ec->source().fileName()),
|
||||
[source = ec->source()] {
|
||||
EditorManager::openEditor(source);
|
||||
ICore::infoBar()->removeInfo(infoId);
|
||||
});
|
||||
}
|
||||
ICore::infoBar()->addInfo(info);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
using Utils::Text::selectAt;
|
||||
|
||||
@@ -136,6 +136,7 @@ private:
|
||||
const ProjectPart *projectPart() const;
|
||||
|
||||
void handleOutlineChanged(const QWidget* newOutline);
|
||||
void showRenameWarningIfFileIsGenerated(const Utils::FilePath &filePath);
|
||||
|
||||
private:
|
||||
QScopedPointer<Internal::CppEditorWidgetPrivate> d;
|
||||
|
||||
@@ -163,6 +163,7 @@ CPlusPlus::LanguageFeatures ProjectPart::deriveLanguageFeatures() const
|
||||
CPlusPlus::LanguageFeatures features;
|
||||
features.cxx11Enabled = languageVersion >= Utils::LanguageVersion::CXX11;
|
||||
features.cxx14Enabled = languageVersion >= Utils::LanguageVersion::CXX14;
|
||||
features.cxx20Enabled = languageVersion >= Utils::LanguageVersion::CXX20;
|
||||
features.cxxEnabled = hasCxx;
|
||||
features.c99Enabled = languageVersion >= Utils::LanguageVersion::C99;
|
||||
features.objCEnabled = languageExtensions.testFlag(Utils::LanguageExtension::ObjectiveC);
|
||||
|
||||
@@ -22,6 +22,7 @@ add_qtc_plugin(McuSupport
|
||||
mcutargetdescription.h
|
||||
mcuhelpers.cpp mcuhelpers.h
|
||||
settingshandler.cpp settingshandler.h
|
||||
mcuqmlprojectnode.cpp mcuqmlprojectnode.h
|
||||
)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
96
src/plugins/mcusupport/mcuqmlprojectnode.cpp
Normal file
96
src/plugins/mcusupport/mcuqmlprojectnode.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "mcuqmlprojectnode.h"
|
||||
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
namespace McuSupport::Internal {
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
McuQmlProjectNode::McuQmlProjectNode(const FilePath &projectFolder, const FilePath &inputsJsonFile)
|
||||
: FolderNode(projectFolder)
|
||||
{
|
||||
setDisplayName("QmlProject");
|
||||
setIcon(DirectoryIcon(":/projectexplorer/images/fileoverlay_qml.png"));
|
||||
setIsGenerated(false);
|
||||
setPriority(Node::DefaultProjectPriority);
|
||||
setFilePath(projectFolder);
|
||||
setListInProject(true);
|
||||
|
||||
const expected_str<QByteArray> expectedJsonContent = inputsJsonFile.fileContents();
|
||||
if (!expectedJsonContent)
|
||||
return;
|
||||
|
||||
const QJsonDocument inputDoc = QJsonDocument::fromJson(*expectedJsonContent);
|
||||
const QVariantMap mainProjectObject = inputDoc.object().toVariantMap();
|
||||
const FilePath mainProjectFilePath = FilePath::fromUserInput(
|
||||
mainProjectObject.value("qmlProjectFile", "").toString());
|
||||
|
||||
auto mainFileNode = std::make_unique<FileNode>(mainProjectFilePath,
|
||||
FileNode::fileTypeForFileName(
|
||||
mainProjectFilePath));
|
||||
mainFileNode->setPriority(100);
|
||||
addNestedNode(std::move(mainFileNode));
|
||||
|
||||
this->populateModuleNode(this, mainProjectObject);
|
||||
|
||||
auto modulesNode = std::make_unique<McuQmlProjectFolderNode>(filePath());
|
||||
modulesNode->setDisplayName("QmlProject Modules");
|
||||
modulesNode->setIcon(DirectoryIcon(":/projectexplorer/images/fileoverlay_modules.png"));
|
||||
modulesNode->setPriority(10);
|
||||
for (QVariant moduleVariant : mainProjectObject.value("modulesDependencies", {}).toList()) {
|
||||
const QVariantMap moduleObject = moduleVariant.toMap();
|
||||
auto moduleNode = std::make_unique<McuQmlProjectFolderNode>(filePath());
|
||||
moduleNode->setIcon(DirectoryIcon(":/projectexplorer/images/fileoverlay_qml.png"));
|
||||
moduleNode->setDisplayName(
|
||||
FilePath::fromUserInput(moduleObject.value("qmlProjectFile", "module").toString())
|
||||
.baseName());
|
||||
populateModuleNode(moduleNode.get(), moduleObject);
|
||||
modulesNode->addNode(std::move(moduleNode));
|
||||
}
|
||||
addNode(std::move(modulesNode));
|
||||
}
|
||||
|
||||
bool McuQmlProjectNode::populateModuleNode(FolderNode *moduleNode, const QVariantMap &moduleObject)
|
||||
{
|
||||
if (!moduleNode)
|
||||
return false;
|
||||
|
||||
const static int NODES_COUNT = 6;
|
||||
const static QString nodes[NODES_COUNT] = {"QmlFiles",
|
||||
"ImageFiles",
|
||||
"InterfaceFiles",
|
||||
"FontFiles",
|
||||
"TranslationFiles",
|
||||
"ModuleFiles"};
|
||||
const static QString icons[NODES_COUNT] = {":/projectexplorer/images/fileoverlay_qml.png",
|
||||
":/projectexplorer/images/fileoverlay_qrc.png",
|
||||
":/projectexplorer/images/fileoverlay_h.png",
|
||||
":/projectexplorer/images/fileoverlay_qrc.png",
|
||||
":/projectexplorer/images/fileoverlay_qrc.png",
|
||||
":/projectexplorer/images/fileoverlay_qml.png"};
|
||||
const static int priorities[NODES_COUNT] = {70, 60, 50, 40, 30, 20};
|
||||
|
||||
for (int i = 0; i < NODES_COUNT; i++) {
|
||||
const QString &node = nodes[i];
|
||||
const QString &icon = icons[i];
|
||||
const int &p = priorities[i];
|
||||
auto foldernode = std::make_unique<McuQmlProjectFolderNode>(filePath());
|
||||
foldernode->setShowWhenEmpty(false);
|
||||
foldernode->setDisplayName(node);
|
||||
foldernode->setIcon(DirectoryIcon(icon));
|
||||
foldernode->setPriority(p);
|
||||
const auto nodeFiles = moduleObject.value(node, {}).toStringList();
|
||||
for (auto p : nodeFiles) {
|
||||
const FilePath nodePath = FilePath::fromUserInput(p);
|
||||
foldernode->addNestedNode(
|
||||
std::make_unique<FileNode>(nodePath, FileNode::fileTypeForFileName(nodePath)));
|
||||
}
|
||||
moduleNode->addNode(std::move(foldernode));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace McuSupport::Internal
|
||||
47
src/plugins/mcusupport/mcuqmlprojectnode.h
Normal file
47
src/plugins/mcusupport/mcuqmlprojectnode.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mcuqmlprojectnode.h"
|
||||
#include "mcusupport_global.h"
|
||||
#include "mcusupportplugin.h"
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/osspecificaspects.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
#include <QHostInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace McuSupport::Internal {
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
class McuQmlProjectFolderNode : public FolderNode
|
||||
{
|
||||
public:
|
||||
explicit McuQmlProjectFolderNode(const FilePath &path)
|
||||
: FolderNode(path)
|
||||
{}
|
||||
bool showInSimpleTree() const override { return true; }
|
||||
};
|
||||
|
||||
class McuQmlProjectNode : public FolderNode
|
||||
{
|
||||
public:
|
||||
explicit McuQmlProjectNode(const FilePath &projectFolder, const FilePath &inputsJsonFile);
|
||||
bool showInSimpleTree() const override { return true; }
|
||||
bool populateModuleNode(FolderNode *moduleNode, const QVariantMap &moduleObject);
|
||||
};
|
||||
}; // namespace McuSupport::Internal
|
||||
@@ -37,6 +37,8 @@ QtcPlugin {
|
||||
"mcusupportoptions.h",
|
||||
"mcukitmanager.cpp",
|
||||
"mcukitmanager.h",
|
||||
"mcuqmlprojectnode.cpp",
|
||||
"mcuqmlprojectnode.h",
|
||||
"mcusupportoptionspage.cpp",
|
||||
"mcusupportoptionspage.h",
|
||||
"mcusupportplugin.cpp",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "mcukitinformation.h"
|
||||
#include "mcukitmanager.h"
|
||||
#include "mcuqmlprojectnode.h"
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportdevice.h"
|
||||
#include "mcusupportoptions.h"
|
||||
@@ -24,8 +25,15 @@
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/infobar.h>
|
||||
|
||||
#include <QTimer>
|
||||
@@ -49,6 +57,42 @@ void printMessage(const QString &message, bool important)
|
||||
Core::MessageManager::writeSilently(displayMessage);
|
||||
}
|
||||
|
||||
void updateMCUProjectTree(ProjectExplorer::Project *p)
|
||||
{
|
||||
if (!p || !p->rootProjectNode())
|
||||
return;
|
||||
ProjectExplorer::Target *target = p->activeTarget();
|
||||
if (!target || !target->kit()
|
||||
|| !target->kit()->hasValue(Constants::KIT_MCUTARGET_KITVERSION_KEY))
|
||||
return;
|
||||
|
||||
p->rootProjectNode()->forEachProjectNode([](const ProjectNode *node) {
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
const FilePath projectBuildFolder = FilePath::fromVariant(
|
||||
node->data(CMakeProjectManager::Constants::BUILD_FOLDER_ROLE));
|
||||
const QString targetName = node->displayName();
|
||||
if (targetName.isEmpty())
|
||||
return;
|
||||
|
||||
const FilePath inputsJsonFile = projectBuildFolder / "CMakeFiles" / (targetName + ".dir")
|
||||
/ "config/input.json";
|
||||
|
||||
printMessage("found Input json file " + inputsJsonFile.absoluteFilePath().toString(), true);
|
||||
|
||||
if (!inputsJsonFile.exists())
|
||||
return;
|
||||
|
||||
auto qmlProjectNode = std::make_unique<McuQmlProjectNode>(FilePath(node->filePath()),
|
||||
inputsJsonFile);
|
||||
|
||||
auto qmlProjectNodePtr = qmlProjectNode.get();
|
||||
const_cast<ProjectNode *>(node)->addNode(std::move(qmlProjectNode));
|
||||
ProjectExplorer::ProjectTree::emitSubtreeChanged(qmlProjectNodePtr);
|
||||
});
|
||||
};
|
||||
|
||||
class McuSupportPluginPrivate
|
||||
{
|
||||
public:
|
||||
@@ -74,6 +118,10 @@ void McuSupportPlugin::initialize()
|
||||
setObjectName("McuSupportPlugin");
|
||||
dd = new McuSupportPluginPrivate;
|
||||
|
||||
connect(SessionManager::instance(),
|
||||
&SessionManager::projectFinishedParsing,
|
||||
updateMCUProjectTree);
|
||||
|
||||
dd->m_options.registerQchFiles();
|
||||
dd->m_options.registerExamples();
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/mcusupport/wizards/");
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "suggest/nimsuggestcache.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
@@ -66,6 +65,9 @@ public:
|
||||
NimToolsSettingsPage toolsSettingsPage{&settings};
|
||||
NimCodeStylePreferencesFactory codeStylePreferencesPage;
|
||||
NimToolChainFactory toolChainFactory;
|
||||
|
||||
NimProjectFactory nimProjectFactory;
|
||||
NimbleProjectFactory nimbleProjectFactory;
|
||||
};
|
||||
|
||||
NimPlugin::~NimPlugin()
|
||||
@@ -82,9 +84,6 @@ void NimPlugin::initialize()
|
||||
TextEditor::SnippetProvider::registerGroup(Constants::C_NIMSNIPPETSGROUP_ID,
|
||||
Tr::tr("Nim", "SnippetProvider"),
|
||||
&NimEditorFactory::decorateEditor);
|
||||
|
||||
ProjectManager::registerProjectType<NimProject>(Constants::C_NIM_PROJECT_MIMETYPE);
|
||||
ProjectManager::registerProjectType<NimbleProject>(Constants::C_NIMBLE_MIMETYPE);
|
||||
}
|
||||
|
||||
void NimPlugin::extensionsInitialized()
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
#include "nimblebuildsystem.h"
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -47,4 +50,11 @@ void NimbleProject::setExcludedFiles(const QStringList &excludedFiles)
|
||||
m_excludedFiles = excludedFiles;
|
||||
}
|
||||
|
||||
// Factory
|
||||
|
||||
NimbleProjectFactory::NimbleProjectFactory()
|
||||
{
|
||||
ProjectManager::registerProjectType<NimbleProject>(Constants::C_NIMBLE_MIMETYPE);
|
||||
}
|
||||
|
||||
} // Nim
|
||||
|
||||
@@ -28,4 +28,10 @@ protected:
|
||||
QStringList m_excludedFiles;
|
||||
};
|
||||
|
||||
class NimbleProjectFactory
|
||||
{
|
||||
public:
|
||||
NimbleProjectFactory();
|
||||
};
|
||||
|
||||
} // Nim
|
||||
|
||||
@@ -9,18 +9,40 @@
|
||||
#include "nimtoolchain.h"
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Nim {
|
||||
|
||||
NimProject::NimProject(const FilePath &fileName) : Project(Constants::C_NIM_MIMETYPE, fileName)
|
||||
class NimProject : public Project
|
||||
{
|
||||
public:
|
||||
explicit NimProject(const FilePath &filePath);
|
||||
|
||||
Tasks projectIssues(const Kit *k) const final;
|
||||
|
||||
// Keep for compatibility with Qt Creator 4.10
|
||||
QVariantMap toMap() const final;
|
||||
|
||||
QStringList excludedFiles() const;
|
||||
void setExcludedFiles(const QStringList &excludedFiles);
|
||||
|
||||
protected:
|
||||
// Keep for compatibility with Qt Creator 4.10
|
||||
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) final;
|
||||
|
||||
QStringList m_excludedFiles;
|
||||
};
|
||||
|
||||
NimProject::NimProject(const FilePath &filePath) : Project(Constants::C_NIM_MIMETYPE, filePath)
|
||||
{
|
||||
setId(Constants::C_NIMPROJECT_ID);
|
||||
setDisplayName(fileName.completeBaseName());
|
||||
setDisplayName(filePath.completeBaseName());
|
||||
// ensure debugging is enabled (Nim plugin translates nim code to C code)
|
||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
|
||||
@@ -65,4 +87,11 @@ void NimProject::setExcludedFiles(const QStringList &excludedFiles)
|
||||
m_excludedFiles = excludedFiles;
|
||||
}
|
||||
|
||||
// Factory
|
||||
|
||||
NimProjectFactory::NimProjectFactory()
|
||||
{
|
||||
ProjectManager::registerProjectType<NimProject>(Constants::C_NIM_PROJECT_MIMETYPE);
|
||||
}
|
||||
|
||||
} // Nim
|
||||
|
||||
@@ -3,36 +3,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Nim {
|
||||
|
||||
class NimBuildSystem;
|
||||
|
||||
class NimProject : public ProjectExplorer::Project
|
||||
class NimProjectFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NimProject(const Utils::FilePath &fileName);
|
||||
|
||||
ProjectExplorer::Tasks projectIssues(const ProjectExplorer::Kit *k) const final;
|
||||
|
||||
// Keep for compatibility with Qt Creator 4.10
|
||||
QVariantMap toMap() const final;
|
||||
|
||||
QStringList excludedFiles() const;
|
||||
void setExcludedFiles(const QStringList &excludedFiles);
|
||||
|
||||
protected:
|
||||
// Keep for compatibility with Qt Creator 4.10
|
||||
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) final;
|
||||
|
||||
QStringList m_excludedFiles;
|
||||
NimProjectFactory();
|
||||
};
|
||||
|
||||
} // namespace Nim
|
||||
} // Nim
|
||||
|
||||
@@ -71,6 +71,7 @@ Project {
|
||||
"qtsupport/qtsupport.qbs",
|
||||
"remotelinux/remotelinux.qbs",
|
||||
"resourceeditor/resourceeditor.qbs",
|
||||
"saferenderer/saferenderer.qbs",
|
||||
"scxmleditor/scxmleditor.qbs",
|
||||
"serialterminal/serialterminal.qbs",
|
||||
"silversearcher/silversearcher.qbs",
|
||||
|
||||
@@ -248,6 +248,13 @@ ExtraCompiler *BuildSystem::extraCompilerForSource(const Utils::FilePath &source
|
||||
return findExtraCompiler([source](const ExtraCompiler *ec) { return ec->source() == source; });
|
||||
}
|
||||
|
||||
ExtraCompiler *BuildSystem::extraCompilerForTarget(const Utils::FilePath &target) const
|
||||
{
|
||||
return findExtraCompiler([target](const ExtraCompiler *ec) {
|
||||
return ec->targets().contains(target);
|
||||
});
|
||||
}
|
||||
|
||||
MakeInstallCommand BuildSystem::makeInstallCommand(const FilePath &installRoot) const
|
||||
{
|
||||
QTC_ASSERT(target()->project()->hasMakeInstallEquivalent(), return {});
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
|
||||
// Owned by the build system. Use only in main thread. Can go away at any time.
|
||||
ExtraCompiler *extraCompilerForSource(const Utils::FilePath &source) const;
|
||||
ExtraCompiler *extraCompilerForTarget(const Utils::FilePath &target) const;
|
||||
|
||||
virtual MakeInstallCommand makeInstallCommand(const Utils::FilePath &installRoot) const;
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ SessionNameInputDialog::SessionNameInputDialog(QWidget *parent)
|
||||
auto buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
|
||||
m_okButton = buttons->button(QDialogButtonBox::Ok);
|
||||
m_switchToButton = new QPushButton;
|
||||
m_switchToButton->setDefault(true);
|
||||
buttons->addButton(m_switchToButton, QDialogButtonBox::AcceptRole);
|
||||
connect(m_switchToButton, &QPushButton::clicked, this, [this] {
|
||||
m_usedSwitchTo = true;
|
||||
@@ -83,6 +84,13 @@ SessionNameInputDialog::SessionNameInputDialog(QWidget *parent)
|
||||
buttons,
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_newSessionLineEdit, &QLineEdit::textChanged, [this](const QString &text) {
|
||||
m_okButton->setEnabled(!text.isEmpty());
|
||||
m_switchToButton->setEnabled(!text.isEmpty());
|
||||
});
|
||||
m_okButton->setEnabled(false);
|
||||
m_switchToButton->setEnabled(false);
|
||||
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
@@ -173,18 +173,17 @@ public:
|
||||
runControl->target()->buildSystem());
|
||||
QTC_ASSERT(qmlBuildSystem, return);
|
||||
|
||||
const QString mainScript = aspect->mainScript;
|
||||
const QString currentFile = aspect->currentFile;
|
||||
const FilePath mainScript = aspect->mainScript;
|
||||
const FilePath currentFile = aspect->currentFile;
|
||||
|
||||
const QString mainScriptFromProject = qmlBuildSystem->targetFile(
|
||||
FilePath::fromString(mainScript)).path();
|
||||
const QString mainScriptFromProject = qmlBuildSystem->targetFile(mainScript).path();
|
||||
|
||||
QStringList qmlProjectRunConfigurationArguments = cmd.splitArguments();
|
||||
|
||||
if (!currentFile.isEmpty() && qmlProjectRunConfigurationArguments.last().contains(mainScriptFromProject)) {
|
||||
qmlProjectRunConfigurationArguments.removeLast();
|
||||
cmd = CommandLine(cmd.executable(), qmlProjectRunConfigurationArguments);
|
||||
cmd.addArg(currentFile);
|
||||
cmd.addArg(currentFile.path());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace QmlProjectManager {
|
||||
const char M_CURRENT_FILE[] = "CurrentFile";
|
||||
const char CURRENT_FILE[] = QT_TRANSLATE_NOOP("::QmlProjectManager", "<Current File>");
|
||||
|
||||
static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
||||
static bool caseInsensitiveLessThan(const FilePath &s1, const FilePath &s2)
|
||||
{
|
||||
return s1.toLower() < s2.toLower();
|
||||
return s1.toString().toCaseFolded() < s2.toString().toCaseFolded();
|
||||
}
|
||||
|
||||
QmlMainFileAspect::QmlMainFileAspect(Target *target)
|
||||
@@ -89,12 +89,12 @@ void QmlMainFileAspect::fromMap(const QVariantMap &map)
|
||||
|
||||
void QmlMainFileAspect::updateFileComboBox()
|
||||
{
|
||||
QDir projectDir(m_target->project()->projectDirectory().toString());
|
||||
const FilePath projectDir = m_target->project()->projectDirectory();
|
||||
|
||||
if (mainScriptSource() == FileInProjectFile) {
|
||||
const QString mainScriptInFilePath = projectDir.relativeFilePath(mainScript());
|
||||
const FilePath mainScriptInFilePath = projectDir.relativeChildPath(mainScript());
|
||||
m_fileListModel.clear();
|
||||
m_fileListModel.appendRow(new QStandardItem(mainScriptInFilePath));
|
||||
m_fileListModel.appendRow(new QStandardItem(mainScriptInFilePath.toString()));
|
||||
if (m_fileListCombo)
|
||||
m_fileListCombo->setEnabled(false);
|
||||
return;
|
||||
@@ -106,27 +106,25 @@ void QmlMainFileAspect::updateFileComboBox()
|
||||
m_fileListModel.appendRow(new QStandardItem(CURRENT_FILE));
|
||||
QModelIndex currentIndex;
|
||||
|
||||
QStringList sortedFiles = Utils::transform(m_target->project()->files(Project::SourceFiles),
|
||||
&Utils::FilePath::toString);
|
||||
FilePaths sortedFiles = m_target->project()->files(Project::SourceFiles);
|
||||
|
||||
// make paths relative to project directory
|
||||
QStringList relativeFiles;
|
||||
for (const QString &fn : std::as_const(sortedFiles))
|
||||
relativeFiles += projectDir.relativeFilePath(fn);
|
||||
FilePaths relativeFiles;
|
||||
for (const FilePath &fn : std::as_const(sortedFiles))
|
||||
relativeFiles += projectDir.relativeChildPath(fn);
|
||||
sortedFiles = relativeFiles;
|
||||
|
||||
std::stable_sort(sortedFiles.begin(), sortedFiles.end(), caseInsensitiveLessThan);
|
||||
|
||||
QString mainScriptPath;
|
||||
FilePath mainScriptPath;
|
||||
if (mainScriptSource() != FileInEditor)
|
||||
mainScriptPath = projectDir.relativeFilePath(mainScript());
|
||||
mainScriptPath = projectDir.relativeChildPath(mainScript());
|
||||
|
||||
for (const QString &fn : std::as_const(sortedFiles)) {
|
||||
QFileInfo fileInfo(fn);
|
||||
if (fileInfo.suffix() != "qml")
|
||||
for (const FilePath &fn : std::as_const(sortedFiles)) {
|
||||
if (fn.suffixView() != u"qml")
|
||||
continue;
|
||||
|
||||
auto item = new QStandardItem(fn);
|
||||
auto item = new QStandardItem(fn.toString());
|
||||
m_fileListModel.appendRow(item);
|
||||
|
||||
if (mainScriptPath == fn)
|
||||
@@ -170,7 +168,7 @@ void QmlMainFileAspect::setScriptSource(MainScriptSource source, const QString &
|
||||
m_mainScriptFilename.clear();
|
||||
} else { // FileInSettings
|
||||
m_scriptFile = settingsPath;
|
||||
m_mainScriptFilename = m_target->project()->projectDirectory().toString() + '/' + m_scriptFile;
|
||||
m_mainScriptFilename = m_target->project()->projectDirectory() / m_scriptFile;
|
||||
}
|
||||
|
||||
emit changed();
|
||||
@@ -180,14 +178,11 @@ void QmlMainFileAspect::setScriptSource(MainScriptSource source, const QString &
|
||||
/**
|
||||
Returns absolute path to main script file.
|
||||
*/
|
||||
QString QmlMainFileAspect::mainScript() const
|
||||
FilePath QmlMainFileAspect::mainScript() const
|
||||
{
|
||||
if (!qmlBuildSystem()->mainFile().isEmpty()) {
|
||||
const QString pathInProject = qmlBuildSystem()->mainFile();
|
||||
if (QFileInfo(pathInProject).isAbsolute())
|
||||
return pathInProject;
|
||||
else
|
||||
return QDir(qmlBuildSystem()->canonicalProjectDir().toString()).absoluteFilePath(pathInProject);
|
||||
const FilePath pathInProject = qmlBuildSystem()->mainFile();
|
||||
return qmlBuildSystem()->canonicalProjectDir().resolvePath(pathInProject);
|
||||
}
|
||||
|
||||
if (!m_mainScriptFilename.isEmpty())
|
||||
@@ -196,7 +191,7 @@ QString QmlMainFileAspect::mainScript() const
|
||||
return m_currentFileFilename;
|
||||
}
|
||||
|
||||
QString QmlMainFileAspect::currentFile() const
|
||||
FilePath QmlMainFileAspect::currentFile() const
|
||||
{
|
||||
return m_currentFileFilename;
|
||||
}
|
||||
@@ -207,7 +202,7 @@ void QmlMainFileAspect::changeCurrentFile(Core::IEditor *editor)
|
||||
editor = EditorManager::currentEditor();
|
||||
|
||||
if (editor)
|
||||
m_currentFileFilename = editor->document()->filePath().toString();
|
||||
m_currentFileFilename = editor->document()->filePath();
|
||||
|
||||
emit changed();
|
||||
}
|
||||
@@ -219,7 +214,7 @@ bool QmlMainFileAspect::isQmlFilePresent()
|
||||
IDocument *document = EditorManager::currentDocument();
|
||||
const MimeType mainScriptMimeType = mimeTypeForFile(mainScript());
|
||||
if (document) {
|
||||
m_currentFileFilename = document->filePath().toString();
|
||||
m_currentFileFilename = document->filePath();
|
||||
if (mainScriptMimeType.matchesName(ProjectExplorer::Constants::QML_MIMETYPE)
|
||||
|| mainScriptMimeType.matchesName(ProjectExplorer::Constants::QMLUI_MIMETYPE)) {
|
||||
qmlFileFound = true;
|
||||
@@ -229,13 +224,13 @@ bool QmlMainFileAspect::isQmlFilePresent()
|
||||
|| mainScriptMimeType.matchesName(QmlJSTools::Constants::QMLPROJECT_MIMETYPE)) {
|
||||
// find a qml file with lowercase filename. This is slow, but only done
|
||||
// in initialization/other border cases.
|
||||
const auto files = m_target->project()->files(Project::SourceFiles);
|
||||
const FilePaths files = m_target->project()->files(Project::SourceFiles);
|
||||
for (const FilePath &filename : files) {
|
||||
if (!filename.isEmpty() && filename.baseName().at(0).isLower()) {
|
||||
const MimeType type = mimeTypeForFile(filename);
|
||||
if (type.matchesName(ProjectExplorer::Constants::QML_MIMETYPE)
|
||||
|| type.matchesName(ProjectExplorer::Constants::QMLUI_MIMETYPE)) {
|
||||
m_currentFileFilename = filename.toString();
|
||||
m_currentFileFilename = filename;
|
||||
qmlFileFound = true;
|
||||
break;
|
||||
}
|
||||
@@ -252,4 +247,5 @@ QmlBuildSystem *QmlMainFileAspect::qmlBuildSystem() const
|
||||
{
|
||||
return static_cast<QmlBuildSystem *>(m_target->buildSystem());
|
||||
}
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
} // QmlProjectManager
|
||||
|
||||
@@ -38,8 +38,8 @@ public:
|
||||
|
||||
struct Data : BaseAspect::Data
|
||||
{
|
||||
QString mainScript;
|
||||
QString currentFile;
|
||||
Utils::FilePath mainScript;
|
||||
Utils::FilePath currentFile;
|
||||
};
|
||||
|
||||
void addToLayout(Utils::Layouting::LayoutBuilder &builder) final;
|
||||
@@ -52,8 +52,8 @@ public:
|
||||
|
||||
void setScriptSource(MainScriptSource source, const QString &settingsPath = QString());
|
||||
|
||||
QString mainScript() const;
|
||||
QString currentFile() const;
|
||||
Utils::FilePath mainScript() const;
|
||||
Utils::FilePath currentFile() const;
|
||||
void changeCurrentFile(Core::IEditor *editor = nullptr);
|
||||
bool isQmlFilePresent();
|
||||
QmlBuildSystem *qmlBuildSystem() const;
|
||||
@@ -64,9 +64,9 @@ public:
|
||||
QStandardItemModel m_fileListModel;
|
||||
QString m_scriptFile;
|
||||
// absolute path to current file (if being used)
|
||||
QString m_currentFileFilename;
|
||||
Utils::FilePath m_currentFileFilename;
|
||||
// absolute path to selected main script (if being used)
|
||||
QString m_mainScriptFilename;
|
||||
Utils::FilePath m_mainScriptFilename;
|
||||
};
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
} // QmlProjectManager
|
||||
|
||||
@@ -250,7 +250,9 @@ void QmlBuildSystem::parseProject(RefreshOptions options)
|
||||
}
|
||||
}
|
||||
|
||||
bool QmlBuildSystem::setFileSettingInProjectFile(const QString &setting, const Utils::FilePath &mainFilePath, const QString &oldFile)
|
||||
bool QmlBuildSystem::setFileSettingInProjectFile(const QString &setting,
|
||||
const FilePath &mainFilePath,
|
||||
const FilePath &oldFile)
|
||||
{
|
||||
// make sure to change it also in the qmlproject file
|
||||
const Utils::FilePath qmlProjectFilePath = project()->projectFilePath();
|
||||
@@ -283,7 +285,7 @@ bool QmlBuildSystem::setFileSettingInProjectFile(const QString &setting, const U
|
||||
auto index = fileContent.lastIndexOf("}");
|
||||
fileContent.insert(index, addedText);
|
||||
} else {
|
||||
QString originalFileName = oldFile;
|
||||
QString originalFileName = oldFile.path();
|
||||
originalFileName.replace(".", "\\.");
|
||||
const QRegularExpression expression(QString("%1\\s*\"(%2)\"").arg(settingQmlCode).arg(originalFileName));
|
||||
|
||||
@@ -328,43 +330,42 @@ void QmlBuildSystem::refresh(RefreshOptions options)
|
||||
emit projectChanged();
|
||||
}
|
||||
|
||||
QString QmlBuildSystem::mainFile() const
|
||||
FilePath QmlBuildSystem::mainFile() const
|
||||
{
|
||||
if (m_projectItem)
|
||||
return m_projectItem->mainFile();
|
||||
return QString();
|
||||
return FilePath::fromString(m_projectItem->mainFile());
|
||||
return {};
|
||||
}
|
||||
|
||||
QString QmlBuildSystem::mainUiFile() const
|
||||
FilePath QmlBuildSystem::mainUiFile() const
|
||||
{
|
||||
if (m_projectItem)
|
||||
return m_projectItem->mainUiFile();
|
||||
return QString();
|
||||
return FilePath::fromString(m_projectItem->mainUiFile());
|
||||
return {};
|
||||
}
|
||||
|
||||
Utils::FilePath QmlBuildSystem::mainFilePath() const
|
||||
FilePath QmlBuildSystem::mainFilePath() const
|
||||
{
|
||||
return projectDirectory().pathAppended(mainFile());
|
||||
return projectDirectory().resolvePath(mainFile());
|
||||
}
|
||||
|
||||
Utils::FilePath QmlBuildSystem::mainUiFilePath() const
|
||||
FilePath QmlBuildSystem::mainUiFilePath() const
|
||||
{
|
||||
return projectDirectory().pathAppended(mainUiFile());
|
||||
return projectDirectory().resolvePath(mainUiFile());
|
||||
}
|
||||
|
||||
bool QmlBuildSystem::setMainFileInProjectFile(const Utils::FilePath &newMainFilePath)
|
||||
bool QmlBuildSystem::setMainFileInProjectFile(const FilePath &newMainFilePath)
|
||||
{
|
||||
|
||||
return setFileSettingInProjectFile("mainFile", newMainFilePath, mainFile());
|
||||
}
|
||||
|
||||
bool QmlBuildSystem::setMainUiFileInProjectFile(const Utils::FilePath &newMainUiFilePath)
|
||||
bool QmlBuildSystem::setMainUiFileInProjectFile(const FilePath &newMainUiFilePath)
|
||||
{
|
||||
return setMainUiFileInMainFile(newMainUiFilePath)
|
||||
&& setFileSettingInProjectFile("mainUiFile", newMainUiFilePath, mainUiFile());
|
||||
}
|
||||
|
||||
bool QmlBuildSystem::setMainUiFileInMainFile(const Utils::FilePath &newMainUiFilePath)
|
||||
bool QmlBuildSystem::setMainUiFileInMainFile(const FilePath &newMainUiFilePath)
|
||||
{
|
||||
Core::FileChangeBlocker fileChangeBlocker(mainFilePath());
|
||||
const QList<Core::IEditor *> editors = Core::DocumentModel::editorsForFilePath(mainFilePath());
|
||||
@@ -793,9 +794,9 @@ bool QmlBuildSystem::deleteFiles(Node *context, const FilePaths &filePaths)
|
||||
bool QmlBuildSystem::renameFile(Node * context, const FilePath &oldFilePath, const FilePath &newFilePath)
|
||||
{
|
||||
if (dynamic_cast<QmlProjectNode *>(context)) {
|
||||
if (oldFilePath.endsWith(mainFile()))
|
||||
if (oldFilePath.endsWith(mainFile().path()))
|
||||
return setMainFileInProjectFile(newFilePath);
|
||||
if (oldFilePath.endsWith(mainUiFile()))
|
||||
if (oldFilePath.endsWith(mainUiFile().path()))
|
||||
return setMainUiFileInProjectFile(newFilePath);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -53,8 +53,8 @@ public:
|
||||
void refresh(RefreshOptions options);
|
||||
|
||||
Utils::FilePath canonicalProjectDir() const;
|
||||
QString mainFile() const;
|
||||
QString mainUiFile() const;
|
||||
Utils::FilePath mainFile() const;
|
||||
Utils::FilePath mainUiFile() const;
|
||||
Utils::FilePath mainFilePath() const;
|
||||
Utils::FilePath mainUiFilePath() const;
|
||||
|
||||
@@ -106,7 +106,7 @@ signals:
|
||||
private:
|
||||
bool setFileSettingInProjectFile(const QString &setting,
|
||||
const Utils::FilePath &mainFilePath,
|
||||
const QString &oldFile);
|
||||
const Utils::FilePath &oldFile);
|
||||
|
||||
std::unique_ptr<QmlProjectItem> m_projectItem;
|
||||
Utils::FilePath m_canonicalProjectDir;
|
||||
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
QString disabledReason() const final;
|
||||
bool isEnabled() const final;
|
||||
|
||||
QString mainScript() const;
|
||||
FilePath mainScript() const;
|
||||
FilePath qmlRuntimeFilePath() const;
|
||||
void createQtVersionAspect();
|
||||
|
||||
@@ -108,7 +108,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
cmd.addArg("widget");
|
||||
}
|
||||
|
||||
const FilePath main = bs->targetFile(FilePath::fromString(mainScript()));
|
||||
const FilePath main = bs->targetFile(mainScript());
|
||||
if (!main.isEmpty())
|
||||
cmd.addArg(main.nativePath());
|
||||
|
||||
@@ -292,7 +292,7 @@ bool QmlProjectRunConfiguration::isEnabled() const
|
||||
&& activeBuildSystem()->hasParsingData();
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfiguration::mainScript() const
|
||||
FilePath QmlProjectRunConfiguration::mainScript() const
|
||||
{
|
||||
return m_qmlMainFileAspect->mainScript();
|
||||
}
|
||||
|
||||
8
src/plugins/saferenderer/CMakeLists.txt
Normal file
8
src/plugins/saferenderer/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
add_qtc_plugin(SafeRenderer
|
||||
DEPENDS
|
||||
QtCreator::Core QtCreator::ProjectExplorer
|
||||
SOURCES
|
||||
saferenderer.qrc
|
||||
saferenderer.cpp
|
||||
saferenderer.h
|
||||
)
|
||||
20
src/plugins/saferenderer/SafeRenderer.json.in
Normal file
20
src/plugins/saferenderer/SafeRenderer.json.in
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
\"Name\" : \"SafeRenderer\",
|
||||
\"Version\" : \"$$QTCREATOR_VERSION\",
|
||||
\"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\",
|
||||
\"DisabledByDefault\" : true,
|
||||
\"Vendor\" : \"The Qt Company Ltd\",
|
||||
\"Copyright\" : \"(C) $$QTCREATOR_COPYRIGHT_YEAR The Qt Company Ltd\",
|
||||
\"License\" : [ \"Commercial Usage\",
|
||||
\"\",
|
||||
\"Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and The Qt Company.\",
|
||||
\"\",
|
||||
\"GNU General Public License Usage\",
|
||||
\"\",
|
||||
\"Alternatively, this plugin 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 plugin. 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.\"
|
||||
],
|
||||
\"Category\" : \"Device Support\",
|
||||
\"Description\" : \"Helper plugin for Qt Safe Renderer projects.\",
|
||||
\"Url\" : \"https://www.qt.io\",
|
||||
$$dependencyList
|
||||
}
|
||||
29
src/plugins/saferenderer/saferenderer.cpp
Normal file
29
src/plugins/saferenderer/saferenderer.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "saferenderer.h"
|
||||
|
||||
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
||||
|
||||
namespace SafeRenderer::Internal {
|
||||
|
||||
SafeRendererPlugin::SafeRendererPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
SafeRendererPlugin::~SafeRendererPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
bool SafeRendererPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
|
||||
// Add Qt Creator project wizard path
|
||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/saferenderer/wizards/");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace SafeRenderer::Internal
|
||||
22
src/plugins/saferenderer/saferenderer.h
Normal file
22
src/plugins/saferenderer/saferenderer.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
namespace SafeRenderer::Internal {
|
||||
|
||||
class SafeRendererPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "SafeRenderer.json")
|
||||
|
||||
public:
|
||||
SafeRendererPlugin();
|
||||
~SafeRendererPlugin() override;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) override;
|
||||
};
|
||||
|
||||
} // namespace SafeRenderer::Internal
|
||||
14
src/plugins/saferenderer/saferenderer.qbs
Normal file
14
src/plugins/saferenderer/saferenderer.qbs
Normal file
@@ -0,0 +1,14 @@
|
||||
import qbs
|
||||
|
||||
QtcPlugin {
|
||||
name: "SafeRenderer"
|
||||
|
||||
Depends { name: "Core" }
|
||||
Depends { name: "ProjectExplorer" }
|
||||
|
||||
files: [
|
||||
"saferenderer.cpp",
|
||||
"saferenderer.h",
|
||||
"saferenderer.qrc",
|
||||
]
|
||||
}
|
||||
12
src/plugins/saferenderer/saferenderer.qrc
Normal file
12
src/plugins/saferenderer/saferenderer.qrc
Normal file
@@ -0,0 +1,12 @@
|
||||
<RCC>
|
||||
<qresource prefix="/saferenderer">
|
||||
<file>wizards/icon.png</file>
|
||||
<file>wizards/icon@2x.png</file>
|
||||
<file>wizards/qsrapp/file.pro</file>
|
||||
<file>wizards/qsrapp/main.cpp.tpl</file>
|
||||
<file>wizards/qsrapp/main.qml.tpl</file>
|
||||
<file>wizards/qsrapp/qml.qrc.tpl</file>
|
||||
<file>wizards/qsrapp/safeasset.qrc.tpl</file>
|
||||
<file>wizards/qsrapp/wizard.json</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
BIN
src/plugins/saferenderer/wizards/icon.png
Normal file
BIN
src/plugins/saferenderer/wizards/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
src/plugins/saferenderer/wizards/icon@2x.png
Normal file
BIN
src/plugins/saferenderer/wizards/icon@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
52
src/plugins/saferenderer/wizards/qsrapp/file.pro
Normal file
52
src/plugins/saferenderer/wizards/qsrapp/file.pro
Normal file
@@ -0,0 +1,52 @@
|
||||
QT = qtsaferenderer qsrplatformadaptation
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which as been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \\
|
||||
%{CppFileName}
|
||||
|
||||
|
||||
# List of language codes that your application supports. For example, SAFE_LANGUAGES = en fi.
|
||||
#SAFE_LANGUAGES = en
|
||||
|
||||
# List of translation file names excluding the language code. For example, SAFE_TRANSLATION = $$PWD/safeui.
|
||||
#SAFE_TRANSLATION = $$PWD/safeui
|
||||
|
||||
# List of translation file names including the language code. There must be one file
|
||||
# for each language listed in SAFE_LANGUAGES. For example, TRANSLATIONS += safeui_en.ts safeui_fi.ts.
|
||||
#TRANSLATIONS += safeui_en.ts
|
||||
|
||||
# You can use an lupdate_only{...} conditional statement to specify the QML files that contain texts.
|
||||
#lupdate_only {
|
||||
# SOURCES += main.qml
|
||||
#}
|
||||
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
||||
QML_IMPORT_PATH = $$PWD/imports
|
||||
|
||||
# Additional import path used to resolve QML modules just for Qt Quick Designer
|
||||
QML_DESIGNER_IMPORT_PATH =
|
||||
|
||||
|
||||
CONFIG += qtsaferenderer exceptions
|
||||
SAFE_QML = $$PWD/main.qml
|
||||
SAFE_LAYOUT_PATH = $$PWD/layoutData
|
||||
SAFE_RESOURCES += safeasset.qrc
|
||||
|
||||
!cross_compile: DEFINES += HOST_BUILD
|
||||
!cross_compile: QT += widgets quick svg
|
||||
|
||||
DISTFILES += main.qml
|
||||
66
src/plugins/saferenderer/wizards/qsrapp/main.cpp.tpl
Normal file
66
src/plugins/saferenderer/wizards/qsrapp/main.cpp.tpl
Normal file
@@ -0,0 +1,66 @@
|
||||
%{Cpp:LicenseTemplate}\
|
||||
%{JS: QtSupport.qtIncludes([ 'QtCore/QCoreApplication' ],
|
||||
[ 'QtCore/QCoreApplication' ]) }\
|
||||
|
||||
#include <QtSafeRenderer/qsafelayout.h>
|
||||
#include <QtSafeRenderer/qsafelayoutresourcereader.h>
|
||||
#include <QtSafeRenderer/statemanager.h>
|
||||
|
||||
#if defined(HOST_BUILD)
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#endif
|
||||
|
||||
#if defined(USE_OUTPUTVERIFIER)
|
||||
#include <outputverifier.h>
|
||||
#include "testverifier.h"
|
||||
#endif
|
||||
|
||||
#include "safewindow.h"
|
||||
#include "eventhandler.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Q_UNUSED(argc);
|
||||
Q_UNUSED(argv);
|
||||
|
||||
static SafeRenderer::QSafeLayoutResourceReader layout("/layoutData/main/main.srl");
|
||||
|
||||
#if defined(USE_OUTPUTVERIFIER)
|
||||
static OutputVerifier outputVerifier;
|
||||
#if defined(HOST_BUILD)
|
||||
//In host environment the TestVerifier must be explicitly created.
|
||||
//In OpeWFD adaptation the MISRVerifier instance is created in the SafeWindow adaptation.
|
||||
static TestVerifier testVerifier(outputVerifier);
|
||||
#endif
|
||||
SafeWindow telltaleWindow(layout.size(), QSafePoint(0U, 0U), outputVerifier);
|
||||
#else
|
||||
SafeWindow telltaleWindow(layout.size(), QSafePoint(0U, 0U));
|
||||
#endif
|
||||
static SafeRenderer::StateManager stateManager(telltaleWindow, layout);
|
||||
telltaleWindow.requestUpdate(); //Request is required because eventHandler is not running yet.
|
||||
|
||||
#if defined(USE_OUTPUTVERIFIER)
|
||||
EventHandler msgHandler(stateManager, telltaleWindow, outputVerifier);
|
||||
#else
|
||||
EventHandler msgHandler(stateManager, telltaleWindow);
|
||||
#endif
|
||||
|
||||
#if defined(HOST_BUILD)
|
||||
//Mixing the Qt and Qt Safe Renderer renderers is done here only for demonstration purposes on host, not for production purposes of any kind.
|
||||
QQmlApplicationEngine engine;
|
||||
const QUrl url(QStringLiteral("qrc:/main.qml"));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, qApp,
|
||||
[url](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl)
|
||||
qDebug() << "Failed to start the main.qml";
|
||||
}, Qt::QueuedConnection);
|
||||
engine.addImportPath(":/imports");
|
||||
engine.load(url);
|
||||
#endif
|
||||
|
||||
msgHandler.handleEvents();
|
||||
|
||||
return 0;
|
||||
}
|
||||
26
src/plugins/saferenderer/wizards/qsrapp/main.qml.tpl
Normal file
26
src/plugins/saferenderer/wizards/qsrapp/main.qml.tpl
Normal file
@@ -0,0 +1,26 @@
|
||||
import Qt.SafeRenderer 2.0
|
||||
import QtQuick.Window 2.15
|
||||
|
||||
Window {
|
||||
id: window
|
||||
width: 640
|
||||
height: 480
|
||||
visible: true
|
||||
title: qsTr("Hello QSR")
|
||||
|
||||
SafeText {
|
||||
id: safeText
|
||||
objectName: "safetextitem"
|
||||
x: 206
|
||||
y: 208
|
||||
width: 340
|
||||
height: 34
|
||||
color: "#8ae234"
|
||||
fillColor: "black"
|
||||
text: "Hello Qt Safe Renderer!"
|
||||
font.family: "Lato"
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
font.pixelSize: 32
|
||||
runtimeEditable: true
|
||||
}
|
||||
}
|
||||
5
src/plugins/saferenderer/wizards/qsrapp/qml.qrc.tpl
Normal file
5
src/plugins/saferenderer/wizards/qsrapp/qml.qrc.tpl
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,2 @@
|
||||
<!DOCTYPE RCC>
|
||||
<RCC/>
|
||||
103
src/plugins/saferenderer/wizards/qsrapp/wizard.json
Normal file
103
src/plugins/saferenderer/wizards/qsrapp/wizard.json
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "Qt4ProjectManager.Qt4Project" ],
|
||||
"id": "E.QSRApp",
|
||||
"category": "D.QtSafeRendererApplication",
|
||||
"trDescription": "Creates a Qt Safe Renderer project with simple UI and project setup.",
|
||||
"trDisplayName": "Qt Safe Renderer Application",
|
||||
"trDisplayCategory": "Application (Qt Safe Renderer)",
|
||||
"icon": "../icon.png",
|
||||
"iconKind": "Themed",
|
||||
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
|
||||
"enabled": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0 || value('Plugins').indexOf('CMakeProjectManager') >= 0}",
|
||||
|
||||
"options":
|
||||
[
|
||||
{ "key": "ProjectFile", "value": "%{JS: value('BuildSystem') == 'qmake' ? value('ProFile') : value('CMakeFile')}" },
|
||||
{ "key": "ProFile", "value": "%{JS: Util.fileName(value('ProjectDirectory') + '/' + value('ProjectName'), 'pro')}" },
|
||||
{ "key": "HasTranslation", "value": "%{JS: value('TsFileName') !== ''}" },
|
||||
{ "key": "CppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" }
|
||||
],
|
||||
|
||||
"pages":
|
||||
[
|
||||
{
|
||||
"trDisplayName": "Project Location",
|
||||
"trShortTitle": "Location",
|
||||
"typeId": "Project",
|
||||
"data": { "trDescription": "This wizard creates a simple Qt Safe Renderer application." }
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Define Build System",
|
||||
"trShortTitle": "Build System",
|
||||
"typeId": "Fields",
|
||||
"enabled": "%{JS: !value('IsSubproject')}",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"name": "BuildSystem",
|
||||
"trDisplayName": "Build system:",
|
||||
"type": "ComboBox",
|
||||
"persistenceKey": "BuildSystemType",
|
||||
"data":
|
||||
{
|
||||
"index": 0,
|
||||
"items":
|
||||
[
|
||||
{
|
||||
"trKey": "qmake",
|
||||
"value": "qmake",
|
||||
"condition": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Kit Selection",
|
||||
"trShortTitle": "Kits",
|
||||
"typeId": "Kits",
|
||||
"enabled": "%{JS: !value('IsSubproject')}",
|
||||
"data": { "projectFilePath": "%{ProjectFile}" }
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Project Management",
|
||||
"trShortTitle": "Summary",
|
||||
"typeId": "Summary"
|
||||
}
|
||||
],
|
||||
"generators":
|
||||
[
|
||||
{
|
||||
"typeId": "File",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"source": "file.pro",
|
||||
"target": "%{ProFile}",
|
||||
"openAsProject": true,
|
||||
"condition": "%{JS: value('BuildSystem') === 'qmake'}"
|
||||
},
|
||||
{
|
||||
"source": "main.cpp.tpl",
|
||||
"target": "%{CppFileName}",
|
||||
"openInEditor": false
|
||||
},
|
||||
{
|
||||
"source": "safeasset.qrc.tpl",
|
||||
"target": "safeasset.qrc"
|
||||
},
|
||||
{
|
||||
"source": "qml.qrc.tpl",
|
||||
"target": "qml.qrc"
|
||||
},
|
||||
{
|
||||
"source": "main.qml.tpl",
|
||||
"target": "main.qml",
|
||||
"openInEditor": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -442,6 +442,7 @@ void tst_SimpleLexer::ppOpOrPunc()
|
||||
const QByteArray source = QTest::currentDataTag();
|
||||
LanguageFeatures languageFeatures;
|
||||
languageFeatures.cxxEnabled = true;
|
||||
languageFeatures.cxx20Enabled = true;
|
||||
run(source, toTokens({unsigned(expectedTokenKind)}), false, CompareKind, true, languageFeatures);
|
||||
}
|
||||
|
||||
@@ -492,6 +493,7 @@ void tst_SimpleLexer::ppOpOrPunc_data()
|
||||
QTest::newRow("==") << T_EQUAL_EQUAL;
|
||||
QTest::newRow("!=") << T_EXCLAIM_EQUAL;
|
||||
QTest::newRow("<=") << T_LESS_EQUAL;
|
||||
QTest::newRow("<=>") << T_LESS_EQUAL_GREATER;
|
||||
QTest::newRow(">=") << T_GREATER_EQUAL;
|
||||
QTest::newRow("&&") << T_AMPER_AMPER;
|
||||
QTest::newRow("||") << T_PIPE_PIPE;
|
||||
|
||||
Reference in New Issue
Block a user