Warning, /maui/mauikit-filebrowsing/src/controls.5/TagsDialog.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.14 0002 import QtQuick.Controls 2.14 0003 import QtQuick.Layouts 1.3 0004 0005 import org.mauikit.controls 1.3 as Maui 0006 import org.mauikit.filebrowsing 1.3 as FB 0007 0008 /** 0009 * TagsDialog 0010 * A global sidebar for the application window that can be collapsed. 0011 * 0012 * 0013 * 0014 * 0015 * 0016 * 0017 */ 0018 Maui.PopupPage 0019 { 0020 id: control 0021 0022 /** 0023 * taglist : TagsList 0024 */ 0025 property alias taglist : _tagsList 0026 0027 /** 0028 * listView : ListView 0029 */ 0030 property alias listView: _listView 0031 0032 /** 0033 * composerList : TagsList 0034 */ 0035 property alias composerList: tagListComposer.list 0036 0037 /** 0038 * tagsReady : 0039 */ 0040 signal tagsReady(var tags) 0041 0042 closeButtonVisible: false 0043 0044 hint: 1 0045 0046 maxHeight: 500 0047 maxWidth: 400 0048 0049 actions: [ 0050 0051 Action 0052 { 0053 text: i18nd("mauikitfilebrowsing", "Save") 0054 onTriggered: setTags() 0055 }, 0056 0057 Action 0058 { 0059 text: i18nd("mauikitfilebrowsing", "Cancel") 0060 onTriggered: control.close() 0061 } 0062 ] 0063 0064 headBar.visible: true 0065 headBar.forceCenterMiddleContent: false 0066 headBar.middleContent: TextField 0067 { 0068 id: tagText 0069 Layout.fillWidth: true 0070 Layout.maximumWidth: 500 0071 placeholderText: i18nd("mauikitfilebrowsing", "Filter or add a new tag") 0072 // validator: RegExpValidator { regExp: /[0-9A-F]+/ } 0073 onAccepted: 0074 { 0075 const tags = tagText.text.split(",") 0076 for(var i in tags) 0077 { 0078 const myTag = tags[i].trim() 0079 _tagsList.insert(myTag) 0080 tagListComposer.list.append(myTag) 0081 } 0082 clear() 0083 _tagsModel.filter = "" 0084 } 0085 0086 onTextChanged: 0087 { 0088 _tagsModel.filter = text 0089 } 0090 } 0091 0092 Maui.InfoDialog 0093 { 0094 id: _deleteDialog 0095 0096 property string tag 0097 title: i18nd("mauikitfilebrowsing", "Delete %1", tag) 0098 message: i18nd("mauikitfilebrowsing", "Are you sure you want to delete this tag? This action can not be undone.") 0099 template.iconSource: "tag" 0100 onAccepted: 0101 { 0102 FB.Tagging.removeTag(tag) 0103 _deleteDialog.close() 0104 } 0105 0106 onRejected: _deleteDialog.close() 0107 } 0108 0109 Maui.ContextualMenu 0110 { 0111 id: _menu 0112 0113 MenuItem 0114 { 0115 text: i18nd("mauikitfilebrowsing", "Edit") 0116 icon.name: "document-edit" 0117 } 0118 0119 MenuItem 0120 { 0121 text: i18nd("mauikitfilebrowsing", "Delete") 0122 icon.name: "delete" 0123 onTriggered: 0124 { 0125 _deleteDialog.tag = _tagsModel.get(_listView.currentIndex).tag 0126 _deleteDialog.open() 0127 } 0128 } 0129 } 0130 0131 stack: [ 0132 0133 Maui.ListBrowser 0134 { 0135 id: _listView 0136 0137 Layout.fillHeight: true 0138 Layout.fillWidth: true 0139 clip: true 0140 currentIndex: -1 0141 0142 holder.emoji: "qrc:/assets/tag.svg" 0143 holder.visible: _listView.count === 0 0144 holder.title : i18nd("mauikitfilebrowsing", "No Tags!") 0145 holder.body: i18nd("mauikitfilebrowsing", "Create new tags to organize your files.") 0146 0147 model: Maui.BaseModel 0148 { 0149 id: _tagsModel 0150 sort: "tag" 0151 sortOrder: Qt.AscendingOrder 0152 recursiveFilteringEnabled: true 0153 sortCaseSensitivity: Qt.CaseInsensitive 0154 filterCaseSensitivity: Qt.CaseInsensitive 0155 list: FB.TagsListModel 0156 { 0157 id: _tagsList 0158 strict: false 0159 } 0160 } 0161 0162 delegate: Maui.ListBrowserDelegate 0163 { 0164 width: ListView.view.width 0165 label1.text: model.tag 0166 iconSource: model.icon 0167 iconSizeHint: Maui.Style.iconSizes.small 0168 0169 template.content: Rectangle 0170 { 0171 color: model.color ? model.color : "transparent" 0172 height: Maui.Style.iconSizes.small 0173 radius: height/2 0174 width: height 0175 } 0176 0177 onClicked: 0178 { 0179 _listView.currentIndex = index 0180 if(Qt.styleHints.singleClickActivation) 0181 { 0182 tagListComposer.list.appendItem(_tagsModel.get(_listView.currentIndex)) 0183 } 0184 } 0185 0186 onDoubleClicked: 0187 { 0188 _listView.currentIndex = index 0189 if(!Qt.styleHints.singleClickActivation) 0190 { 0191 tagListComposer.list.appendItem(_tagsModel.get(_listView.currentIndex)) 0192 } 0193 } 0194 0195 onPressAndHold: 0196 { 0197 _listView.currentIndex = index 0198 _menu.open() 0199 } 0200 0201 onRightClicked: 0202 { 0203 _listView.currentIndex = index 0204 _menu.open() 0205 } 0206 } 0207 }, 0208 0209 Loader 0210 { 0211 asynchronous: true 0212 active: tagListComposer.list.urls.length > 1 0213 visible: active 0214 Layout.fillWidth: true 0215 0216 sourceComponent: Maui.ListItemTemplate 0217 { 0218 id: _info 0219 // padding: _listView.padding 0220 // implicitHeight: Maui.Style.toolBarHeight + Maui.Style.space.huge 0221 0222 property var itemInfo : FB.FM.getFileInfo( tagListComposer.list.urls[0]) 0223 label1.text: i18nd("mauikitfilebrowsing", "Tagging %1 files", tagListComposer.list.urls.length) 0224 label2.text: i18nd("mauikitfilebrowsing", "Add new tags for the selected files.") 0225 label2.wrapMode: Text.WrapAtWordBoundaryOrAnywhere 0226 iconSource : itemInfo.icon 0227 imageSource: itemInfo.thumbnail 0228 // iconSizeHint: Maui.Style.iconSizes.huge 0229 // headerSizeHint: iconSizeHint + Maui.Style.space.big 0230 0231 iconComponent: Item 0232 { 0233 Item 0234 { 0235 anchors.fill: parent 0236 layer.enabled: true 0237 0238 Rectangle 0239 { 0240 anchors.fill: parent 0241 anchors.leftMargin: Maui.Style.space.small 0242 anchors.rightMargin: Maui.Style.space.small 0243 radius: Maui.Style.radiusV 0244 color: Qt.tint(control.Maui.Theme.textColor, Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.9)) 0245 border.color: Maui.Theme.backgroundColor 0246 } 0247 0248 Rectangle 0249 { 0250 anchors.fill: parent 0251 anchors.topMargin: Maui.Style.space.tiny 0252 anchors.leftMargin: Maui.Style.space.tiny 0253 anchors.rightMargin: Maui.Style.space.tiny 0254 radius: Maui.Style.radiusV 0255 color: Qt.tint(control.Maui.Theme.textColor, Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.9)) 0256 border.color: Maui.Theme.backgroundColor 0257 } 0258 0259 Rectangle 0260 { 0261 anchors.fill: parent 0262 anchors.topMargin: Maui.Style.space.small 0263 border.color: Maui.Theme.backgroundColor 0264 0265 radius: Maui.Style.radiusV 0266 color: Qt.tint(control.Maui.Theme.textColor, Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.9)) 0267 0268 Maui.GridItemTemplate 0269 { 0270 anchors.fill: parent 0271 anchors.margins: Maui.Style.space.tiny 0272 iconSizeHint: _info.iconSizeHint 0273 0274 iconSource: _info.iconSource 0275 imageSource: _info.imageSource 0276 } 0277 } 0278 } 0279 } 0280 } 0281 } 0282 ] 0283 0284 page.footer: FB.TagList 0285 { 0286 id: tagListComposer 0287 width: parent.width 0288 visible: count > 0 0289 0290 onTagRemoved: list.remove(index) 0291 placeholderText: i18nd("mauikitfilebrowsing", "No tags yet.") 0292 } 0293 0294 onClosed: 0295 { 0296 composerList.urls = [] 0297 tagText.clear() 0298 _tagsModel.filter = "" 0299 } 0300 0301 onOpened: tagText.forceActiveFocus() 0302 0303 /** 0304 * 0305 */ 0306 function setTags() 0307 { 0308 var tags = [] 0309 0310 for(var i = 0; i < tagListComposer.count; i++) 0311 tags.push(tagListComposer.list.get(i).tag) 0312 control.tagsReady(tags) 0313 close() 0314 } 0315 }