Commit aeb869bf authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

uses a validator when input type is URL (radio URLs, ...)

color in red when input is not acceptable

try to put a placeholder text
parent ecbe3f75
......@@ -199,7 +199,7 @@ QVariant TrackMetadataModel::data(const QModelIndex &index, int role) const
break;
case DataTypes::ResourceRole:
case DataTypes::ImageUrlRole:
result = TextEntry;
result = UrlEntry;
break;
case DataTypes::ArtistRole:
result = TextEntry;
......
......@@ -68,6 +68,7 @@ public:
enum ItemType
{
TextEntry,
UrlEntry,
IntegerEntry,
RatingEntry,
DateEntry,
......
......@@ -56,8 +56,8 @@ RowLayout {
Loader {
id: textDisplayLoader
active: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry
visible: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry
active: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.UrlEntry || model.type === TrackMetadataModel.IntegerEntry
visible: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.UrlEntry || model.type === TrackMetadataModel.IntegerEntry
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
......@@ -69,12 +69,26 @@ RowLayout {
anchors.fill: parent
validator: ((model.type === TrackMetadataModel.UrlEntry) ? urlValidator : allValidator)
placeholderText: ((model.type === TrackMetadataModel.UrlEntry) ? 'https://' : '')
color: acceptableInput ? myPalette.text : 'red'
onTextEdited: {
if (model.display !== text) {
model.display = text
delegateRow.radioEdited()
}
}
RegExpValidator {
id: allValidator
regExp: /.*/
}
RegExpValidator {
id: urlValidator
regExp: /http[s]?:\/\/.+/
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment