mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 19:37:09 +02:00
added a completion list to InputField, use it for all genres input field
This commit is contained in:
@@ -53,10 +53,12 @@ Item {
|
|||||||
height: parent.height * 0.2
|
height: parent.height * 0.2
|
||||||
spacing: defaultFontHeight * 0.5
|
spacing: defaultFontHeight * 0.5
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
z: 2
|
||||||
|
|
||||||
InputField {
|
InputField {
|
||||||
id: genreInputField
|
id: genreInputField
|
||||||
width: parent.width - createFromInputButton.width - parent.spacing
|
width: parent.width - createFromInputButton.width - parent.spacing
|
||||||
|
completionModel: allGenres
|
||||||
|
|
||||||
onAccepted: createStation(text);
|
onAccepted: createStation(text);
|
||||||
}
|
}
|
||||||
@@ -81,7 +83,7 @@ Item {
|
|||||||
TagCloud {
|
TagCloud {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: parent.width / 6
|
anchors.margins: parent.width / 6
|
||||||
model: styleModel
|
model: allGenres
|
||||||
|
|
||||||
onTagClicked: {
|
onTagClicked: {
|
||||||
root.createStation(tag);
|
root.createStation(tag);
|
||||||
|
@@ -13,6 +13,7 @@ Rectangle {
|
|||||||
property bool showSearchIcon: false
|
property bool showSearchIcon: false
|
||||||
property string text: ""
|
property string text: ""
|
||||||
property string placeholderText: ""
|
property string placeholderText: ""
|
||||||
|
property variant completionModel
|
||||||
|
|
||||||
property int spacing: defaultFontHeight * 0.2
|
property int spacing: defaultFontHeight * 0.2
|
||||||
signal accepted( string text )
|
signal accepted( string text )
|
||||||
@@ -54,7 +55,15 @@ Rectangle {
|
|||||||
font.pointSize: defaultFontSize
|
font.pointSize: defaultFontSize
|
||||||
|
|
||||||
onAccepted: root.accepted( text );
|
onAccepted: root.accepted( text );
|
||||||
onTextChanged: root.text = text;
|
onTextChanged: {
|
||||||
|
root.text = text;
|
||||||
|
realCompletionListModel.clear();
|
||||||
|
for (var i in completionModel) {
|
||||||
|
if (completionModel[i].indexOf(text) == 0) {
|
||||||
|
realCompletionListModel.append({modelData: completionModel[i]})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -91,4 +100,63 @@ Rectangle {
|
|||||||
anchors.margins: root.radius * 0.1
|
anchors.margins: root.radius * 0.1
|
||||||
clip: true
|
clip: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors {
|
||||||
|
top: parent.bottom
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
height: Math.min(completionListView.count, 10) * completionListView.delegateHeight
|
||||||
|
color: "white"
|
||||||
|
ListView {
|
||||||
|
id: completionListView
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.rightMargin: scrollBar.width + scrollBar.margin
|
||||||
|
clip: true
|
||||||
|
model: ListModel {
|
||||||
|
id: realCompletionListModel
|
||||||
|
}
|
||||||
|
|
||||||
|
property int delegateHeight: defaultFontHeight * 1.25
|
||||||
|
delegate: Rectangle {
|
||||||
|
height: completionListView.delegateHeight
|
||||||
|
color: delegateMouseArea.containsMouse ? "lightblue" : "transparent"
|
||||||
|
width: parent.width
|
||||||
|
Text {
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
margins: defaultFontHeight / 4
|
||||||
|
}
|
||||||
|
text: modelData
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: delegateMouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onClicked: {
|
||||||
|
textInput.text = modelData
|
||||||
|
realCompletionListModel.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ScrollBar {
|
||||||
|
id: scrollBar
|
||||||
|
listView: completionListView
|
||||||
|
color: "black"
|
||||||
|
margin: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -99999999
|
||||||
|
z: -1
|
||||||
|
enabled: completionListView.count > 0
|
||||||
|
onClicked: {
|
||||||
|
realCompletionListModel.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,8 @@ Item {
|
|||||||
|
|
||||||
property int margin: defaultFontHeight * 0.25
|
property int margin: defaultFontHeight * 0.25
|
||||||
|
|
||||||
|
property color color: "white"
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
name: "hidden"; when: !listView.moving
|
name: "hidden"; when: !listView.moving
|
||||||
@@ -48,7 +50,7 @@ Item {
|
|||||||
id: background
|
id: background
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
|
radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
|
||||||
color: "white"
|
color: scrollBar.color
|
||||||
opacity: 0.2
|
opacity: 0.2
|
||||||
clip: true
|
clip: true
|
||||||
// Size the bar to the required size, depending upon the orientation.
|
// Size the bar to the required size, depending upon the orientation.
|
||||||
@@ -61,7 +63,7 @@ Item {
|
|||||||
width: orientation == Qt.Vertical ? (parent.width-2) : (pageSize * (scrollBar.width-2))
|
width: orientation == Qt.Vertical ? (parent.width-2) : (pageSize * (scrollBar.width-2))
|
||||||
height: orientation == Qt.Vertical ? (pageSize * (scrollBar.height-2)) : (parent.height-2)
|
height: orientation == Qt.Vertical ? (pageSize * (scrollBar.height-2)) : (parent.height-2)
|
||||||
radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
|
radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
|
||||||
color: "white"
|
color: scrollBar.color
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "widgets/DeclarativeCoverArtProvider.h"
|
#include "widgets/DeclarativeCoverArtProvider.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/TomahawkCache.h"
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
@@ -61,6 +62,8 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa
|
|||||||
} else {
|
} else {
|
||||||
// TODO: only load if needed, i.e. the user clicks on start station by artist
|
// TODO: only load if needed, i.e. the user clicks on start station by artist
|
||||||
loadArtistCharts();
|
loadArtistCharts();
|
||||||
|
|
||||||
|
rootContext()->setContextProperty("allGenres", TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "genres"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user