Skip to content

Commit 9bdec14

Browse files
committed
feat(Qt): dock and control bar are now QML
1 parent 45a3127 commit 9bdec14

File tree

9 files changed

+234
-134
lines changed

9 files changed

+234
-134
lines changed

friture/ControlBar.qml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import QtQuick 2.15
2+
import QtQuick.Controls 2.15
3+
import QtQuick.Layouts 1.15
4+
5+
RowLayout {
6+
id: controlBar
7+
objectName: "controlBar"
8+
spacing: 0
9+
10+
SystemPalette { id: systemPalette; colorGroup: SystemPalette.Active }
11+
12+
required property var viewModel
13+
14+
ComboBox {
15+
id: widgetSelector
16+
model: [
17+
"Scope",
18+
"FFT Spectrum",
19+
"2D Spectrogram",
20+
"Octave Spectrum",
21+
"Generator",
22+
"Delay Estimator",
23+
"Long-time levels",
24+
"Pitch Tracker"
25+
]
26+
currentIndex: viewModel.currentIndex
27+
onCurrentIndexChanged: viewModel.currentIndex = currentIndex
28+
ToolTip.text: "Select the type of audio widget"
29+
30+
// replace with implicitContentWidthPolicy to either ComboBox.WidestText on Qt 6
31+
width: 130
32+
Layout.preferredWidth: width
33+
Layout.rightMargin: 5
34+
}
35+
36+
ToolButton {
37+
id: settingsButton
38+
icon.source: "qrc:/images-src/dock-settings.svg"
39+
ToolTip.text: "Customize the audio widget"
40+
icon.color: systemPalette.windowText
41+
onClicked: viewModel.onSettingsClicked()
42+
}
43+
44+
ToolButton {
45+
id: movePreviousButton
46+
icon.source: "qrc:/images-src/dock-move-previous.svg"
47+
ToolTip.text: "Move widget to previous slot"
48+
icon.color: systemPalette.windowText
49+
onClicked: viewModel.onMovePreviousClicked()
50+
}
51+
52+
ToolButton {
53+
id: moveNextButton
54+
icon.source: "qrc:/images-src/dock-move-next.svg"
55+
ToolTip.text: "Move widget to next slot"
56+
icon.color: systemPalette.windowText
57+
onClicked: viewModel.onMoveNextClicked()
58+
}
59+
60+
ToolButton {
61+
id: closeButton
62+
icon.source: "qrc:/images-src/dock-close.svg"
63+
ToolTip.text: "Close the audio widget"
64+
icon.color: systemPalette.windowText
65+
onClicked: viewModel.onCloseClicked()
66+
}
67+
68+
Item {
69+
Layout.fillWidth: true
70+
}
71+
}

friture/Dock.qml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import QtQuick 2.15
2+
import QtQuick.Controls 2.15
3+
import QtQuick.Layouts 1.2
4+
5+
Rectangle {
6+
SystemPalette { id: systemPalette; colorGroup: SystemPalette.Active }
7+
color: systemPalette.window
8+
anchors.fill: parent
9+
10+
ColumnLayout {
11+
id: root
12+
anchors.fill: parent
13+
14+
property string fixedFont
15+
16+
Item {
17+
id: control_bar_container
18+
objectName: "control_bar_container"
19+
Layout.fillWidth: true
20+
Layout.preferredHeight: 40
21+
}
22+
23+
Item {
24+
id: audio_widget_container
25+
objectName: "audio_widget_container"
26+
Layout.fillWidth: true
27+
Layout.fillHeight: true
28+
Layout.margins: 5
29+
}
30+
}
31+
}
32+

friture/Generator.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Rectangle {
1212

1313
SystemPalette { id: systemPalette; colorGroup: SystemPalette.Active }
1414
color: systemPalette.window
15-
anchors.fill: parent
1615

1716
ColumnLayout {
1817
anchors.top: parent.top

friture/controlbar.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

friture/controlbar_viewmodel.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty
2+
3+
class ControlBarViewModel(QObject):
4+
indexChanged = pyqtSignal(int)
5+
settingsClicked = pyqtSignal()
6+
movePreviousClicked = pyqtSignal()
7+
moveNextClicked = pyqtSignal()
8+
closeClicked = pyqtSignal()
9+
10+
def __init__(self, parent=None):
11+
super().__init__(parent)
12+
self._currentIndex = 0
13+
14+
def getCurrentIndex(self):
15+
return self._currentIndex
16+
17+
def setCurrentIndex(self, index):
18+
if self._currentIndex != index:
19+
self._currentIndex = index
20+
self.indexChanged.emit(index)
21+
22+
currentIndex = pyqtProperty(int, fget=getCurrentIndex, fset=setCurrentIndex, notify=indexChanged)
23+
24+
def onSettingsClicked(self):
25+
self.settingsClicked.emit()
26+
27+
def onMovePreviousClicked(self):
28+
self.movePreviousClicked.emit()
29+
30+
def onMoveNextClicked(self):
31+
self.moveNextClicked.emit()
32+
33+
def onCloseClicked(self):
34+
self.closeClicked.emit()

0 commit comments

Comments
 (0)