Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ find_package(Qt6 {{ .minimumQtVersion }} REQUIRED COMPONENTS Quick)
{{ if ge $mininumQtVersionFloat 6.5 }}
qt_standard_project_setup(REQUIRES {{ .minimumQtVersion }})
{{ end }}

# Content of downloaded design from Figma to Qt or similar
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/{{ .importdir }}/CMakeLists.txt")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/{{ .importdir }})
endif()

qt_add_executable({{ $target }}
main.cpp
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Downloaded Design from Figma to Qt

Save the downloaded design from Figma to Qt here, including the CMakeLists.txt.
The main project CMakeLists.txt picks this up automatically.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ files:
- in: Main.qml
- in: main.cpp

- in: '{{ .importdir }}/README.md'
out: '{{ .importdir }}/README.md'

- in: '@/common/git.ignore'
out: .gitignore
bypass: true

fields:
- importdir: importedcontent
26 changes: 20 additions & 6 deletions qt-cli/src/newitem/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ func (g *Generator) runNames() (ResultData, error) {
continue
}

inputRel := g.createInputFileRel(file)
outputRel, err := g.createOutputFileRel(file)
if err != nil {
inputRel, errIn := g.createInputFileRel(file)
outputRel, errOut := g.createOutputFileRel(file)
if errIn != nil || errOut != nil {
return ResultData{}, err
}

Expand Down Expand Up @@ -267,12 +267,26 @@ func (g *Generator) runContents(result ResultItem) error {
return nil
}

func (g *Generator) createInputFileRel(file preset.TemplateItem) string {
func (g *Generator) createInputFileRel(file preset.TemplateItem) (string, error) {
var in string

if strings.HasPrefix(file.In, "@/") {
return file.In[2:]
in = file.In[2:]
} else {
in = path.Join(g.preset.GetTemplateDir(), file.In)
}

expanded, err := utils.NewTemplateExpander().
Name(file.In).
Data(g.context.data).
Funcs(g.context.funcs).
RunString(in)

if err != nil {
return expanded, err
}

return path.Join(g.preset.GetTemplateDir(), file.In)
return expanded, nil
}

func (g *Generator) createOutputFileRel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ find_package(Qt6 6.8 REQUIRED COMPONENTS Quick)

qt_standard_project_setup(REQUIRES 6.8)

# Content of downloaded design from Figma to Qt or similar
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/importedcontent/CMakeLists.txt")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/importedcontent)
endif()

qt_add_executable(appprojects_cpp_qtquick
main.cpp
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Downloaded Design from Figma to Qt

Save the downloaded design from Figma to Qt here, including the CMakeLists.txt.
The main project CMakeLists.txt picks this up automatically.
Loading