Skip to content

Commit b011e6a

Browse files
Final 0.0.1.1.0.14 changes.
1 parent 5ce7896 commit b011e6a

File tree

8 files changed

+68
-22
lines changed

8 files changed

+68
-22
lines changed

src/block_data/BlockBase.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class BlockBase : public BlockInterface
4949
Q_OBJECT
5050

5151
Q_PROPERTY(bool focused MEMBER m_focused NOTIFY focusedChanged)
52+
Q_PROPERTY(QString label READ getLabel WRITE setLabel NOTIFY labelChanged)
5253

5354
public:
5455
// constructor etc:
@@ -112,6 +113,11 @@ class BlockBase : public BlockInterface
112113
*/
113114
void focusedChanged();
114115

116+
/**
117+
* @brief labelChanged is emitted when the user changed the label text
118+
*/
119+
void labelChanged();
120+
115121
public slots:
116122
QString getUid() const override { return m_uid; }
117123
void setUid(QString id) override { m_uid = id; }
@@ -131,6 +137,8 @@ public slots:
131137
void deletedByUser() override;
132138
void onDeleteAnimationEnd() override;
133139
void makeBlocksConnectedToInputsVisible() override;
140+
virtual QString getLabel() const override { return m_label; }
141+
virtual void setLabel(QString value) override { m_label = value; emit labelChanged(); }
134142

135143
protected:
136144
/**
@@ -169,6 +177,11 @@ public slots:
169177
*/
170178
bool m_guiItemCompleted;
171179

180+
/**
181+
* @brief m_label the user-chosen label text
182+
*/
183+
QString m_label;
184+
172185
};
173186

174187
#endif // BLOCKBASE_H

src/block_data/BlockInterface.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class BlockInterface : public QObject {
207207
* @brief positionChangedExternal is emitted when the position was changed but not by the DragArea.
208208
* This is used by the DragArea to update the values in the kineticEffect.
209209
*/
210-
void positionChangedExternal();
210+
void positionChangedExternal();
211211

212212
public slots:
213213
/**
@@ -287,6 +287,17 @@ public slots:
287287
*/
288288
virtual void makeBlocksConnectedToInputsVisible() = 0;
289289

290+
/**
291+
* @brief getLabel returns the user-chosen label text
292+
* @return label text to show in DragArea
293+
*/
294+
virtual QString getLabel() const = 0;
295+
/**
296+
* @brief setLabel sets the label text
297+
* @param value the new label text
298+
*/
299+
virtual void setLabel(QString value) = 0;
300+
290301
};
291302

292303

src/block_data/BlockManager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ BlockInterface* BlockManager::restoreBlock(const QJsonObject& blockState, bool a
108108
qWarning() << "Could not create block instance of type: " << blockType;
109109
return nullptr;
110110
}
111+
block->setLabel(blockState["label"].toString());
111112
block->setState(blockState["internalState"].toObject());
112113
QQuickItem* guiItem = createGuiItem(block);
113114
if (!guiItem) {
@@ -320,6 +321,7 @@ QJsonObject BlockManager::getBlockState(BlockInterface* block) const {
320321
blockState["posY"] = block->getGuiItem()->y() / dp;
321322
blockState["focused"] = getFocusedBlock() == block;
322323
blockState["nodeMergeModes"] = block->getNodeMergeModes();
324+
blockState["label"] = block->getLabel();
323325
blockState["internalState"] = block->getState();
324326
return blockState;
325327
}

src/qml/BlockSettingsDrawerContent.qml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import QtQuick 2.5
22

3+
import CustomElements 1.0
34
import "CustomControls"
45
import "CustomBasics"
56

67
VerticalScrollView {
78
contentItem: root
8-
Column {
9+
StretchColumn {
910
id: root
1011
width: parent.width
1112
height: implicitHeight
13+
defaultSize: 30*dp
1214
Text {
1315
width: parent.width
1416
height: 30*dp
@@ -43,11 +45,13 @@ VerticalScrollView {
4345
if (focusedBlock) {
4446
blockSettings.sourceComponent = focusedBlock.getSettingsComponent()
4547
blockTypeLabel.text = focusedBlock.getBlockName()
48+
labelRow.visible = true
49+
labelInput.text = focusedBlock.label
4650
} else {
4751
blockSettings.sourceComponent = noFocusedBlockDummy;
4852
blockTypeLabel.text = ""
49-
}
50-
//gc()
53+
labelRow.visible = false
54+
}
5155
}
5256

5357
Connections {
@@ -81,6 +85,32 @@ VerticalScrollView {
8185
}
8286
}
8387
}
88+
BlockRow {
89+
id: labelRow
90+
implicitHeight: 0 // do not stretch
91+
height: 30*dp
92+
leftMargin: 15*dp
93+
rightMargin: 15*dp
94+
95+
Text {
96+
text: "Label:"
97+
width: 90*dp
98+
}
99+
TextInput {
100+
id: labelInput
101+
text: ""
102+
width: parent.width - 120*dp
103+
inputMethodHints: Qt.ImhPreferLatin
104+
onDisplayTextChanged: {
105+
var focusedBlock = controller.blockManager().getFocusedBlock()
106+
if (focusedBlock) {
107+
if (focusedBlock.label !== displayText) {
108+
focusedBlock.label = displayText
109+
}
110+
}
111+
}
112+
}
113+
}
84114

85115
HorizontalDivider { // ------------------------------------------------------
86116
}

src/qml/Blocks/DimmerBlock.qml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,8 @@ BlockBase {
7979
StretchColumn {
8080
leftMargin: 15*dp
8181
rightMargin: 15*dp
82-
defaultSize: 30*dp
82+
defaultSize: 30*dp
8383

84-
BlockRow {
85-
Text {
86-
text: "Name:"
87-
width: parent.width / 2
88-
}
89-
TextInput {
90-
text: block.getName()
91-
width: parent.width / 2
92-
inputMethodHints: Qt.ImhPreferLatin
93-
onDisplayTextChanged: {
94-
block.setName(displayText)
95-
}
96-
}
97-
}
9884
BlockRow {
9985
StretchText {
10086
text: "Channel:"

src/qml/CustomBasics/BlockBase.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Rectangle {
5353
Component {
5454
id: noSettings
5555
Item {
56-
height: 60*dp
56+
implicitHeight: 60*dp
5757

5858
Text {
5959
anchors.centerIn: parent

src/qml/CustomBasics/DragArea.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Item {
1010
z: -1
1111

1212
// public
13-
property alias text: text.text
13+
property string text: ""
1414
default property alias content: contentItem.data
1515

1616
// -------------------------- Visuals -----------------------------------
@@ -29,7 +29,6 @@ Item {
2929
}
3030

3131
Text {
32-
id: text
3332
color: block.focused ? Qt.rgba(0.9, 0.8, 0.0, 0.5) : "#999"
3433
font.family: "Quicksand"
3534
font.weight: Font.Bold
@@ -38,6 +37,7 @@ Item {
3837
verticalAlignment: Text.AlignVCenter
3938
horizontalAlignment: Text.AlignHCenter
4039
fontSizeMode: Text.Fit
40+
text: block.label || root.text
4141
}
4242

4343
Item {

src/qml/CustomControls/SvgButton.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import QtQuick 2.5
2+
import QtQuick.Window 2.0
23
import CustomElements 1.0
34
import "../CustomBasics"
45

@@ -36,6 +37,9 @@ CustomTouchArea {
3637
source: "qrc:/images/svg/" + iconName + ".svg"
3738
fillMode: Image.PreserveAspectFit
3839
smooth: true
40+
41+
// render in double resolution to be antialiased and smooth:
42+
sourceSize.width: width * Screen.devicePixelRatio * 2
3943
}
4044

4145
Rectangle {

0 commit comments

Comments
 (0)