Skip to content

Commit

Permalink
qmlui: show user-made definitions in fixture browser
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Apr 4, 2021
1 parent c8146fb commit 2eecab2
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 58 deletions.
18 changes: 16 additions & 2 deletions qmlui/fixturebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ FixtureBrowser::~FixtureBrowser()

QStringList FixtureBrowser::manufacturers()
{
QStringList mfList = m_doc->fixtureDefCache()->manufacturers();
if (m_defCache.isEmpty())
m_defCache = m_doc->fixtureDefCache()->fixtureCache();

QStringList mfList = m_defCache.keys();
mfList.sort(Qt::CaseInsensitive);
m_manufacturerIndex = mfList.indexOf("Generic");
emit manufacturerIndexChanged(m_manufacturerIndex);
Expand All @@ -84,8 +87,14 @@ void FixtureBrowser::setSelectedManufacturer(QString selectedManufacturer)

QStringList FixtureBrowser::modelsList()
{
if (m_selectedManufacturer.isEmpty())
return QStringList();

if (m_defCache.isEmpty())
m_defCache = m_doc->fixtureDefCache()->fixtureCache();

qDebug() << "[FixtureBrowser] Models list for" << m_selectedManufacturer;
QStringList fxList = m_doc->fixtureDefCache()->models(m_selectedManufacturer);
QStringList fxList = m_defCache[m_selectedManufacturer].keys();
if (m_selectedManufacturer == "Generic")
{
fxList << "Generic Dimmer";
Expand All @@ -96,6 +105,11 @@ QStringList FixtureBrowser::modelsList()
return fxList;
}

bool FixtureBrowser::isUserDefinition(QString manufacturer, QString model)
{
return m_defCache[manufacturer].value(model, false);
}

QString FixtureBrowser::selectedModel() const
{
return m_selectedModel;
Expand Down
5 changes: 5 additions & 0 deletions qmlui/fixturebrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class FixtureBrowser : public QObject

QStringList modelsList();

Q_INVOKABLE bool isUserDefinition(QString manufacturer, QString model);

QString selectedModel() const;
void setSelectedModel(QString selectedModel);

Expand Down Expand Up @@ -120,6 +122,9 @@ class FixtureBrowser : public QObject
private:
Doc *m_doc;
QQuickView *m_view;

/** Cache of the organized definitions for browsing */
QMap<QString, QMap<QString, bool>> m_defCache;
/** The index of the currently selected manufacturer */
int m_manufacturerIndex;
/** The currently selected manufacturer as string */
Expand Down
93 changes: 45 additions & 48 deletions qmlui/qml/fixturesfunctions/FixtureBrowser.qml
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,12 @@ Rectangle
ListView
{
id: manufacturerList
x: 8
z: 0
visible: fixtureBrowser.selectedManufacturer.length === 0 && fixtureBrowser.searchFilter.length < 3
z: 0
width: parent.width - 12
height: parent.height - toolBar.height - 12
anchors.top: toolBar.bottom
anchors.topMargin: 6
anchors.bottom: parent.bottom
anchors.bottomMargin: 6
anchors.right: parent.right
anchors.rightMargin: 8
anchors.left: parent.left
anchors.leftMargin: 8
anchors.margins: 6
focus: true

boundsBehavior: Flickable.StopAtBounds
Expand All @@ -124,34 +119,35 @@ Rectangle
Rectangle
{
y: manufacturerList.currentItem.y
width: parent.width - 30
width: parent.width
height: UISettings.listItemHeight
color: "#0978FF"
radius: 5
color: UISettings.highlight
}
}
highlightFollowsCurrentItem: false

model: fixtureBrowser.manufacturers
delegate: FixtureBrowserDelegate
{
isManufacturer: true
textLabel: modelData
onMouseEvent:
delegate:
FixtureBrowserDelegate
{
if (type == App.Clicked)
width: modelsList.width - manufScroll.width
isManufacturer: true
textLabel: modelData
onMouseEvent:
{
mfText.label = modelData
fixtureBrowser.manufacturerIndex = index
fixtureBrowser.selectedManufacturer = modelData
modelsList.currentIndex = -1
if (type == App.Clicked)
{
mfText.label = modelData
fixtureBrowser.manufacturerIndex = index
fixtureBrowser.selectedManufacturer = modelData
modelsList.currentIndex = -1
}
}
}
}

Component.onCompleted: manufacturerList.positionViewAtIndex(manufacturerIndex, ListView.Center)

ScrollBar.vertical: CustomScrollBar { }
ScrollBar.vertical: CustomScrollBar { id: manufScroll }
}

Rectangle
Expand Down Expand Up @@ -218,7 +214,7 @@ Rectangle
id: modelsList
z: 0

width: parent.width
width: parent.width - 12
height: parent.height - manufBackLink.height - 12
anchors.top: manufBackLink.bottom
anchors.margins: 6
Expand All @@ -228,42 +224,43 @@ Rectangle
highlight:
Rectangle
{
width: modelsList.width - 30
width: modelsList.width
height: UISettings.listItemHeight - 2
color: UISettings.highlight
radius: 5
y: modelsList.currentItem ? modelsList.currentItem.y + 1 : 0
}
highlightFollowsCurrentItem: false

model: fixtureBrowser.modelsList
delegate: FixtureBrowserDelegate
{
id: dlg
manufacturer: fixtureBrowser.selectedManufacturer
textLabel: modelData

onMouseEvent:
delegate:
FixtureBrowserDelegate
{
if (type == App.Clicked)
id: dlg
width: modelsList.width - modelsScroll.width
manufacturer: fixtureBrowser.selectedManufacturer
textLabel: modelData

onMouseEvent:
{
modelsList.currentIndex = index
fixtureBrowser.selectedModel = modelData
if (modelData == "Generic RGB Panel")
if (type == App.Clicked)
{
fxPropsRect.visible = false
panelPropsRect.visible = true
}
else
{
panelPropsRect.visible = false
fxPropsRect.visible = true
modelsList.currentIndex = index
fixtureBrowser.selectedModel = modelData
if (modelData == "Generic RGB Panel")
{
fxPropsRect.visible = false
panelPropsRect.visible = true
}
else
{
panelPropsRect.visible = false
fxPropsRect.visible = true
}
editButton.enabled = true
}
editButton.enabled = true
}
}
}
ScrollBar.vertical: CustomScrollBar { }
ScrollBar.vertical: CustomScrollBar { id: modelsScroll }
}
}

Expand Down
29 changes: 21 additions & 8 deletions qmlui/qml/fixturesfunctions/FixtureBrowserDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import "."
Item
{
id: fxDraggableItem
width: parent.width - 30
width: parent.width
height: UISettings.listItemHeight

property bool isManufacturer: false
Expand Down Expand Up @@ -72,25 +72,38 @@ Item
//fontBold: true
}

// bottom divider
Rectangle
{
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 5
width: parent.width
height: 1
color: "#424246"
y: parent.height - 1
color: UISettings.fgMedium
}

Image
{
id: rightArrow
visible: isManufacturer
x: parent.width - width - 5
height: parent.height
width: height * 0.8
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/arrow-right.svg"
sourceSize: Qt.size(width, height)

}

Text
{
visible: !isManufacturer && fixtureBrowser.isUserDefinition(manufacturer, textLabel)
anchors.right: parent.right
anchors.rightMargin: 5
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/arrow-right.svg"
height: 26
width: 20
color: UISettings.fgMain
font.family: "FontAwesome"
font.pixelSize: parent.height - 5
text: FontAwesome.fa_user
}

MouseArea
Expand Down

0 comments on commit 2eecab2

Please sign in to comment.