2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
2023-01-04 08:52:22 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2021-11-09 18:58:15 +02:00
|
|
|
|
|
|
|
|
import QtQuick.Window
|
|
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import StudioTheme as StudioTheme
|
|
|
|
|
import StudioControls as SC
|
|
|
|
|
|
|
|
|
|
import NewProjectDialog
|
2022-02-23 15:32:34 +02:00
|
|
|
import BackendApi
|
2021-11-09 18:58:15 +02:00
|
|
|
|
|
|
|
|
Item {
|
2021-11-23 21:05:02 +02:00
|
|
|
id: rootDialog
|
2021-11-09 18:58:15 +02:00
|
|
|
width: DialogValues.dialogWidth
|
|
|
|
|
height: DialogValues.dialogHeight
|
|
|
|
|
|
|
|
|
|
Rectangle { // the main dialog panel
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
color: DialogValues.darkPaneColor
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
spacing: 0
|
|
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Item { width: parent.width; height: 20 } // spacer
|
|
|
|
|
|
2021-11-09 18:58:15 +02:00
|
|
|
Item { // Header Item
|
|
|
|
|
Layout.fillWidth: true
|
2021-11-23 21:05:02 +02:00
|
|
|
implicitHeight: 164
|
2021-11-09 18:58:15 +02:00
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
ColumnLayout {
|
2021-11-09 18:58:15 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Item { width: parent.width; implicitHeight: 20 } // spacer
|
2021-11-23 21:05:02 +02:00
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Row {
|
2021-11-09 18:58:15 +02:00
|
|
|
width: parent.width
|
2021-11-23 21:05:02 +02:00
|
|
|
height: DialogValues.dialogTitleTextHeight
|
2021-11-23 21:05:02 +02:00
|
|
|
|
|
|
|
|
Item { width: DialogValues.dialogLeftPadding; height: 1 } // horizontal spacer
|
|
|
|
|
|
|
|
|
|
Image {
|
|
|
|
|
asynchronous: false
|
|
|
|
|
source: "image://newprojectdialog_library/logo"
|
|
|
|
|
width: DialogValues.logoWidth
|
|
|
|
|
height: DialogValues.logoHeight
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item { width: 10; height: 1 }
|
|
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Text {
|
2021-11-23 21:05:02 +02:00
|
|
|
text: qsTr("Let's create something wonderful with ")
|
2021-11-23 21:05:02 +02:00
|
|
|
font.pixelSize: DialogValues.dialogTitlePixelSize
|
|
|
|
|
font.family: "Titillium Web"
|
|
|
|
|
height: DialogValues.dialogTitleTextHeight
|
|
|
|
|
lineHeight: DialogValues.dialogTitleLineHeight
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
color: DialogValues.textColor
|
2021-11-23 21:05:02 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-11-23 21:05:02 +02:00
|
|
|
}
|
2021-11-09 18:58:15 +02:00
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Text {
|
2021-11-23 21:05:02 +02:00
|
|
|
text: qsTr("Qt Design Studio!")
|
2021-11-23 21:05:02 +02:00
|
|
|
font.pixelSize: DialogValues.dialogTitlePixelSize
|
|
|
|
|
font.family: "Titillium Web"
|
|
|
|
|
height: DialogValues.dialogTitleTextHeight
|
|
|
|
|
lineHeight: DialogValues.dialogTitleLineHeight
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
2021-11-23 21:05:02 +02:00
|
|
|
color: DialogValues.brandTextColor
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-11-23 21:05:02 +02:00
|
|
|
}
|
2021-11-23 21:05:02 +02:00
|
|
|
} // Row
|
2021-11-09 18:58:15 +02:00
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Item { width: 1; height: 11 } // spacer
|
|
|
|
|
|
|
|
|
|
Item {
|
2021-11-09 18:58:15 +02:00
|
|
|
width: parent.width
|
2021-11-23 21:05:02 +02:00
|
|
|
height: DialogValues.paneTitleLineHeight
|
|
|
|
|
Row {
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: DialogValues.paneTitleLineHeight
|
2021-11-23 21:05:02 +02:00
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Item { width: DialogValues.dialogLeftPadding; height: 1} // spacer
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
width: parent.width - DialogValues.dialogLeftPadding
|
|
|
|
|
text: qsTr("Create new project by selecting a suitable Preset and then adjust details.")
|
|
|
|
|
color: DialogValues.textColor
|
|
|
|
|
font.pixelSize: DialogValues.paneTitlePixelSize
|
|
|
|
|
lineHeight: DialogValues.paneTitleLineHeight
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-23 21:05:02 +02:00
|
|
|
Item { width: parent.width; Layout.fillHeight: true} // spacer
|
|
|
|
|
} // ColumnLayout
|
2021-11-09 18:58:15 +02:00
|
|
|
} // Header Item
|
|
|
|
|
|
|
|
|
|
Item { // Content Item
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
2021-11-23 21:05:02 +02:00
|
|
|
x: DialogValues.dialogLeftPadding
|
2021-11-09 18:58:15 +02:00
|
|
|
width: parent.width - 70
|
|
|
|
|
height: parent.height
|
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
|
|
Rectangle { // Left pane
|
|
|
|
|
color: DialogValues.lightPaneColor
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.minimumWidth: 379 // figured out this number visually
|
2021-11-23 21:05:02 +02:00
|
|
|
Layout.minimumHeight: 261 // figured out this number visually
|
2021-11-23 21:05:02 +02:00
|
|
|
radius: 6
|
2021-11-09 18:58:15 +02:00
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
x: DialogValues.defaultPadding // left padding
|
|
|
|
|
width: parent.width - DialogValues.defaultPadding * 2 // right padding
|
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
text: qsTr("Presets")
|
|
|
|
|
width: parent.width
|
2021-11-23 21:05:02 +02:00
|
|
|
height: 47
|
2021-11-09 18:58:15 +02:00
|
|
|
font.weight: Font.DemiBold
|
|
|
|
|
font.pixelSize: DialogValues.paneTitlePixelSize
|
|
|
|
|
lineHeight: DialogValues.paneTitleLineHeight
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
color: DialogValues.textColor
|
2021-11-23 21:05:02 +02:00
|
|
|
verticalAlignment: Qt.AlignVCenter
|
2021-11-09 18:58:15 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Rectangle { // TabBar
|
|
|
|
|
readonly property int animDur: 500
|
2021-12-01 19:30:34 +02:00
|
|
|
id: tabBar
|
2021-11-23 21:05:02 +02:00
|
|
|
x: 10 // left padding
|
2022-02-23 15:32:34 +02:00
|
|
|
width: parent.width - 20 // right padding
|
2022-03-09 14:40:52 +02:00
|
|
|
height: DialogValues.presetViewHeaderHeight
|
2021-11-23 21:05:02 +02:00
|
|
|
color: DialogValues.lightPaneColor
|
|
|
|
|
|
2022-02-23 15:32:34 +02:00
|
|
|
function selectTab(tabIndex, selectLast = false) {
|
|
|
|
|
var item = repeater.itemAt(tabIndex)
|
|
|
|
|
tabBarRow.currIndex = tabIndex
|
|
|
|
|
|
2022-03-09 14:40:52 +02:00
|
|
|
presetView.selectLast = selectLast
|
2022-02-23 15:32:34 +02:00
|
|
|
BackendApi.presetModel.setPage(tabIndex) // NOTE: it resets preset model
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: BackendApi
|
|
|
|
|
|
|
|
|
|
function onUserPresetSaved() {
|
|
|
|
|
var customTabIndex = repeater.count - 1
|
|
|
|
|
tabBar.selectTab(customTabIndex, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onLastUserPresetRemoved() {
|
|
|
|
|
tabBar.selectTab(0, false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Row {
|
|
|
|
|
id: tabBarRow
|
|
|
|
|
spacing: 20
|
|
|
|
|
property int currIndex: 0
|
2022-02-23 15:32:34 +02:00
|
|
|
readonly property string currentTabName:
|
|
|
|
|
repeater.count > 0 && repeater.itemAt(currIndex)
|
|
|
|
|
? repeater.itemAt(currIndex).text
|
|
|
|
|
: ''
|
2021-11-23 21:05:02 +02:00
|
|
|
|
|
|
|
|
Repeater {
|
2022-02-23 15:32:34 +02:00
|
|
|
id: repeater
|
|
|
|
|
model: BackendApi.categoryModel
|
2021-11-23 21:05:02 +02:00
|
|
|
Text {
|
|
|
|
|
text: name
|
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
|
font.pixelSize: DialogValues.viewHeaderPixelSize
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2022-03-10 13:42:51 +02:00
|
|
|
|
|
|
|
|
color: {
|
|
|
|
|
var color = tabBarRow.currIndex === index
|
|
|
|
|
? DialogValues.textColorInteraction
|
|
|
|
|
: DialogValues.textColor
|
|
|
|
|
|
|
|
|
|
return tabItemMouseArea.containsMouse
|
|
|
|
|
? Qt.darker(color, 1.5)
|
|
|
|
|
: color
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 19:30:34 +02:00
|
|
|
Behavior on color { ColorAnimation { duration: tabBar.animDur } }
|
2021-11-23 21:05:02 +02:00
|
|
|
|
|
|
|
|
MouseArea {
|
2022-03-10 13:42:51 +02:00
|
|
|
id: tabItemMouseArea
|
|
|
|
|
hoverEnabled: true
|
2021-11-23 21:05:02 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: {
|
2022-02-23 15:32:34 +02:00
|
|
|
tabBar.selectTab(index)
|
2021-11-23 21:05:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Text
|
|
|
|
|
} // Repeater
|
|
|
|
|
} // tabBarRow
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
2022-02-23 15:32:34 +02:00
|
|
|
function computeX() {
|
|
|
|
|
var item = tabBarRow.children[tabBarRow.currIndex] ?? tabBarRow.children[0]
|
|
|
|
|
return item.x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function computeWidth() {
|
|
|
|
|
var item = tabBarRow.children[tabBarRow.currIndex] ?? tabBarRow.children[0]
|
|
|
|
|
return item.width;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
id: strip
|
2022-02-23 15:32:34 +02:00
|
|
|
x: computeX()
|
|
|
|
|
width: computeWidth()
|
2021-11-23 21:05:02 +02:00
|
|
|
height: 5
|
|
|
|
|
radius: 2
|
|
|
|
|
color: DialogValues.textColorInteraction
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
2021-12-01 19:30:34 +02:00
|
|
|
Behavior on x { SmoothedAnimation { duration: tabBar.animDur } }
|
|
|
|
|
Behavior on width { SmoothedAnimation { duration: strip.width === 0 ? 0 : tabBar.animDur } } // do not animate initial width
|
|
|
|
|
}
|
2021-11-23 21:05:02 +02:00
|
|
|
} // Rectangle
|
|
|
|
|
|
2022-02-23 15:32:34 +02:00
|
|
|
Rectangle {
|
2022-03-09 14:40:52 +02:00
|
|
|
id: presetViewFrame
|
2021-11-09 18:58:15 +02:00
|
|
|
x: 10 // left padding
|
2022-02-23 15:32:34 +02:00
|
|
|
width: parent.width - 20 // right padding
|
2022-03-09 14:40:52 +02:00
|
|
|
height: DialogValues.presetViewHeight
|
2022-02-23 15:32:34 +02:00
|
|
|
color: DialogValues.darkPaneColor
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.margins: DialogValues.gridMargins
|
|
|
|
|
|
2022-03-22 15:11:30 +02:00
|
|
|
PresetView {
|
2022-03-09 14:40:52 +02:00
|
|
|
id: presetView
|
2022-02-23 15:32:34 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
loader: projectDetailsLoader
|
|
|
|
|
currentTabName: tabBarRow.currentTabName
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: rootDialog
|
|
|
|
|
function onHeightChanged() {
|
|
|
|
|
if (rootDialog.height < 720) { // 720 = minimum height big dialog
|
2022-03-09 14:40:52 +02:00
|
|
|
DialogValues.presetViewHeight =
|
|
|
|
|
DialogValues.presetItemHeight
|
2022-02-23 15:32:34 +02:00
|
|
|
+ 2 * DialogValues.gridMargins
|
|
|
|
|
} else {
|
2022-03-09 14:40:52 +02:00
|
|
|
DialogValues.presetViewHeight =
|
|
|
|
|
DialogValues.presetItemHeight * 2
|
2022-02-23 15:32:34 +02:00
|
|
|
+ DialogValues.gridSpacing
|
|
|
|
|
+ 2 * DialogValues.gridMargins
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-23 21:05:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-09 18:58:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item { height: 5; width: parent.width }
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: descriptionText
|
2022-02-23 15:32:34 +02:00
|
|
|
text: BackendApi.projectDescription
|
2021-11-09 18:58:15 +02:00
|
|
|
font.pixelSize: DialogValues.defaultPixelSize
|
|
|
|
|
lineHeight: DialogValues.defaultLineHeight
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
leftPadding: 14
|
2022-03-09 14:40:52 +02:00
|
|
|
width: presetViewFrame.width
|
2021-11-09 18:58:15 +02:00
|
|
|
color: DialogValues.textColor
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
maximumLineCount: 4
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // Left pane
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: projectDetailsLoader
|
|
|
|
|
// we need to specify width because the loaded item needs to use parent sizes
|
|
|
|
|
width: DialogValues.loadedPanesWidth
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
source: ""
|
|
|
|
|
}
|
|
|
|
|
} // RowLayout
|
|
|
|
|
} //Content Item
|
|
|
|
|
|
|
|
|
|
Item { // Footer
|
|
|
|
|
implicitHeight: DialogValues.footerHeight
|
|
|
|
|
implicitWidth: parent.width
|
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
spacing: DialogValues.defaultPadding
|
|
|
|
|
|
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Item { // Dialog Button Box
|
|
|
|
|
width: DialogValues.stylesPaneWidth
|
|
|
|
|
height: parent.height
|
2021-11-09 18:58:15 +02:00
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
RowLayout {
|
|
|
|
|
width: DialogValues.stylesPaneWidth
|
|
|
|
|
implicitWidth: DialogValues.stylesPaneWidth
|
|
|
|
|
implicitHeight: parent.height
|
|
|
|
|
|
|
|
|
|
SC.AbstractButton {
|
|
|
|
|
implicitWidth: DialogValues.dialogButtonWidth
|
|
|
|
|
width: DialogValues.dialogButtonWidth
|
|
|
|
|
visible: true
|
|
|
|
|
buttonIcon: qsTr("Cancel")
|
|
|
|
|
iconSize: DialogValues.defaultPixelSize
|
|
|
|
|
iconFont: StudioTheme.Constants.font
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
2022-02-23 15:32:34 +02:00
|
|
|
BackendApi.reject();
|
2021-11-23 21:05:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
|
|
|
|
|
|
SC.AbstractButton {
|
|
|
|
|
implicitWidth: DialogValues.dialogButtonWidth
|
|
|
|
|
width: DialogValues.dialogButtonWidth
|
|
|
|
|
visible: true
|
|
|
|
|
buttonIcon: qsTr("Create")
|
|
|
|
|
iconSize: DialogValues.defaultPixelSize
|
2022-02-23 15:32:34 +02:00
|
|
|
enabled: BackendApi.fieldsValid
|
2021-11-23 21:05:02 +02:00
|
|
|
iconFont: StudioTheme.Constants.font
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
2022-02-23 15:32:34 +02:00
|
|
|
BackendApi.accept();
|
2021-11-23 21:05:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // RowLayout
|
|
|
|
|
} // Dialog Button Box
|
2021-11-09 18:58:15 +02:00
|
|
|
|
2021-11-23 21:05:02 +02:00
|
|
|
Item { implicitWidth: DialogValues.dialogLeftPadding - DialogValues.defaultPadding }
|
2021-11-09 18:58:15 +02:00
|
|
|
} // RowLayout
|
|
|
|
|
} // Footer
|
|
|
|
|
} // ColumnLayout
|
|
|
|
|
} // Rectangle
|
|
|
|
|
}
|