Skip to content

Commit

Permalink
Final 0.0.1.1.0.14 changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
luminosuslight committed Oct 6, 2016
1 parent 5ce7896 commit b011e6a
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 22 deletions.
13 changes: 13 additions & 0 deletions src/block_data/BlockBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BlockBase : public BlockInterface
Q_OBJECT

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

public:
// constructor etc:
Expand Down Expand Up @@ -112,6 +113,11 @@ class BlockBase : public BlockInterface
*/
void focusedChanged();

/**
* @brief labelChanged is emitted when the user changed the label text
*/
void labelChanged();

public slots:
QString getUid() const override { return m_uid; }
void setUid(QString id) override { m_uid = id; }
Expand All @@ -131,6 +137,8 @@ public slots:
void deletedByUser() override;
void onDeleteAnimationEnd() override;
void makeBlocksConnectedToInputsVisible() override;
virtual QString getLabel() const override { return m_label; }
virtual void setLabel(QString value) override { m_label = value; emit labelChanged(); }

protected:
/**
Expand Down Expand Up @@ -169,6 +177,11 @@ public slots:
*/
bool m_guiItemCompleted;

/**
* @brief m_label the user-chosen label text
*/
QString m_label;

};

#endif // BLOCKBASE_H
13 changes: 12 additions & 1 deletion src/block_data/BlockInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class BlockInterface : public QObject {
* @brief positionChangedExternal is emitted when the position was changed but not by the DragArea.
* This is used by the DragArea to update the values in the kineticEffect.
*/
void positionChangedExternal();
void positionChangedExternal();

public slots:
/**
Expand Down Expand Up @@ -287,6 +287,17 @@ public slots:
*/
virtual void makeBlocksConnectedToInputsVisible() = 0;

/**
* @brief getLabel returns the user-chosen label text
* @return label text to show in DragArea
*/
virtual QString getLabel() const = 0;
/**
* @brief setLabel sets the label text
* @param value the new label text
*/
virtual void setLabel(QString value) = 0;

};


Expand Down
2 changes: 2 additions & 0 deletions src/block_data/BlockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ BlockInterface* BlockManager::restoreBlock(const QJsonObject& blockState, bool a
qWarning() << "Could not create block instance of type: " << blockType;
return nullptr;
}
block->setLabel(blockState["label"].toString());
block->setState(blockState["internalState"].toObject());
QQuickItem* guiItem = createGuiItem(block);
if (!guiItem) {
Expand Down Expand Up @@ -320,6 +321,7 @@ QJsonObject BlockManager::getBlockState(BlockInterface* block) const {
blockState["posY"] = block->getGuiItem()->y() / dp;
blockState["focused"] = getFocusedBlock() == block;
blockState["nodeMergeModes"] = block->getNodeMergeModes();
blockState["label"] = block->getLabel();
blockState["internalState"] = block->getState();
return blockState;
}
Expand Down
36 changes: 33 additions & 3 deletions src/qml/BlockSettingsDrawerContent.qml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import QtQuick 2.5

import CustomElements 1.0
import "CustomControls"
import "CustomBasics"

VerticalScrollView {
contentItem: root
Column {
StretchColumn {
id: root
width: parent.width
height: implicitHeight
defaultSize: 30*dp
Text {
width: parent.width
height: 30*dp
Expand Down Expand Up @@ -43,11 +45,13 @@ VerticalScrollView {
if (focusedBlock) {
blockSettings.sourceComponent = focusedBlock.getSettingsComponent()
blockTypeLabel.text = focusedBlock.getBlockName()
labelRow.visible = true
labelInput.text = focusedBlock.label
} else {
blockSettings.sourceComponent = noFocusedBlockDummy;
blockTypeLabel.text = ""
}
//gc()
labelRow.visible = false
}
}

Connections {
Expand Down Expand Up @@ -81,6 +85,32 @@ VerticalScrollView {
}
}
}
BlockRow {
id: labelRow
implicitHeight: 0 // do not stretch
height: 30*dp
leftMargin: 15*dp
rightMargin: 15*dp

Text {
text: "Label:"
width: 90*dp
}
TextInput {
id: labelInput
text: ""
width: parent.width - 120*dp
inputMethodHints: Qt.ImhPreferLatin
onDisplayTextChanged: {
var focusedBlock = controller.blockManager().getFocusedBlock()
if (focusedBlock) {
if (focusedBlock.label !== displayText) {
focusedBlock.label = displayText
}
}
}
}
}

HorizontalDivider { // ------------------------------------------------------
}
Expand Down
16 changes: 1 addition & 15 deletions src/qml/Blocks/DimmerBlock.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,8 @@ BlockBase {
StretchColumn {
leftMargin: 15*dp
rightMargin: 15*dp
defaultSize: 30*dp
defaultSize: 30*dp

BlockRow {
Text {
text: "Name:"
width: parent.width / 2
}
TextInput {
text: block.getName()
width: parent.width / 2
inputMethodHints: Qt.ImhPreferLatin
onDisplayTextChanged: {
block.setName(displayText)
}
}
}
BlockRow {
StretchText {
text: "Channel:"
Expand Down
2 changes: 1 addition & 1 deletion src/qml/CustomBasics/BlockBase.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Rectangle {
Component {
id: noSettings
Item {
height: 60*dp
implicitHeight: 60*dp

Text {
anchors.centerIn: parent
Expand Down
4 changes: 2 additions & 2 deletions src/qml/CustomBasics/DragArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Item {
z: -1

// public
property alias text: text.text
property string text: ""
default property alias content: contentItem.data

// -------------------------- Visuals -----------------------------------
Expand All @@ -29,7 +29,6 @@ Item {
}

Text {
id: text
color: block.focused ? Qt.rgba(0.9, 0.8, 0.0, 0.5) : "#999"
font.family: "Quicksand"
font.weight: Font.Bold
Expand All @@ -38,6 +37,7 @@ Item {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
fontSizeMode: Text.Fit
text: block.label || root.text
}

Item {
Expand Down
4 changes: 4 additions & 0 deletions src/qml/CustomControls/SvgButton.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import QtQuick 2.5
import QtQuick.Window 2.0
import CustomElements 1.0
import "../CustomBasics"

Expand Down Expand Up @@ -36,6 +37,9 @@ CustomTouchArea {
source: "qrc:/images/svg/" + iconName + ".svg"
fillMode: Image.PreserveAspectFit
smooth: true

// render in double resolution to be antialiased and smooth:
sourceSize.width: width * Screen.devicePixelRatio * 2
}

Rectangle {
Expand Down

0 comments on commit b011e6a

Please sign in to comment.