Warning, /utilities/fielding/src/ui/PageHeader.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2022 Felipe Kinoshita <kinofhek@gmail.com>
0002 // SPDX-License-Identifier: GPL-3.0-or-later
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Controls 2.15 as QQC2
0006 import QtQuick.Layouts 1.15
0007 import org.kde.kirigami 2.19 as Kirigami
0008 
0009 import org.kde.fielding
0010 import org.kde.fielding.config
0011 
0012 RowLayout {
0013     id: pageHeader
0014 
0015     Layout.fillWidth: true
0016     spacing: Kirigami.Units.smallSpacing / 2
0017 
0018     QQC2.ComboBox {
0019         Layout.maximumWidth: Kirigami.Units.largeSpacing * 10
0020         model: ["GET", "POST", "PUT", "PATCH", "DELETE"]
0021         currentIndex: Config.method
0022         onCurrentIndexChanged: {
0023             Config.method = currentIndex
0024             Config.save()
0025         }
0026     }
0027 
0028     Kirigami.ActionTextField {
0029         id: searchField
0030         Layout.fillWidth: true
0031 
0032         placeholderText: i18n("Enter URL hereā€¦")
0033 
0034         function makeRequest() {
0035             let type;
0036 
0037             switch (Config.method) {
0038                 case 0:
0039                     type = "get"
0040                     break;
0041                 case 1:
0042                     type = "post"
0043                     break;
0044                 case 2:
0045                     type = "put"
0046                     break;
0047                 case 3:
0048                     type = "patch"
0049                     break;
0050                 case 4:
0051                     type = "delete"
0052                     break;
0053             }
0054 
0055             if (text.length > 0) {
0056                 Controller.fetch(text, {
0057                     method: type,
0058                     headers: {
0059                         "Content-Type": "application/json"
0060                     }
0061                 })
0062             }
0063         }
0064 
0065         onAccepted: searchField.makeRequest()
0066     }
0067 
0068     QQC2.ToolButton {
0069         display: QQC2.AbstractButton.IconOnly
0070         action: Kirigami.Action {
0071             text: i18n("About Fielding")
0072             icon.name: "help-about"
0073             shortcut: StandardKey.HelpContents
0074             onTriggered: pageStack.layers.push("About.qml")
0075             enabled: pageStack.layers.depth <= 1
0076         }
0077 
0078         QQC2.ToolTip.visible: hovered
0079         QQC2.ToolTip.text: text
0080         QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0081     }
0082 }