def __init__(self):
        super().__init__()

        self.searchBar = QLineEdit()
        self.searchBar.setPlaceholderText("Search..")
        self.searchBar.textChanged.connect(self.searchFile)
        self.searchBar.setFixedHeight(36)

        self.addButton = QToolButton()
        self.addButton.setIcon(PResource.defaultIcon(Parapluie.Icon_Plus_Svg))
        self.addButton.setFixedSize(36, 36)
        self.addButton.pressed.connect(self.newFile)

        self.openButton = QToolButton()
        self.openButton.setIcon(
            PResource.defaultIcon(Parapluie.Icon_Folder_Svg))
        self.openButton.setFixedSize(36, 36)
        self.openButton.pressed.connect(self.openFile)

        topBar = QHBoxLayout()
        topBar.addWidget(self.searchBar)
        topBar.addWidget(self.openButton)
        topBar.addWidget(self.addButton)

        self.listDataWidget = QListWidget()
        self.listDataWidget.setObjectName(Parapluie.Object_Raised_Off)
        self.listDataWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.listDataWidget.setSizePolicy(QSizePolicy.Expanding,
                                          QSizePolicy.Expanding)
        self.listDataWidget.horizontalScrollBar().setEnabled(False)
        self.listDataWidget.setSpacing(3)

        layout = QVBoxLayout()
        layout.setContentsMargins(8, 8, 0, 8)
        layout.addLayout(topBar)
        layout.addSpacing(8)
        layout.addWidget(self.listDataWidget)

        self.setObjectName(Parapluie.Object_Raised_Off)
        self.setLayout(layout)

        self.dataList = []
        self.dataSource = []
        self.dataTemp = []
        self.currentFile = None
        self.newCount = -1

        self.listAdapter = JsonAdapter(self, self.listDataWidget,
                                       self.dataList, self.onItemSelected,
                                       self.onItemClosed)

        self.loadFile()
Esempio n. 2
0
    def __init__(self,
                 editType: EditorType = EditorType.Manual,
                 save: bool = True,
                 sync: bool = True):
        super().__init__()
        self.editor = TextEditor()
        self.editor.keyEvent.connect(self.editorEvent)

        tool = QHBoxLayout()

        if save:
            iconSize = 36
        else:
            iconSize = 24

        if save:
            self.title = PLabelEdit()
            self.title.setMaximumWidth(300)
            self.title.setFixedHeight(iconSize)
            self.title.setMaximumHeight(iconSize)
            self.title.setStyleSheet("QLabel{color:#424242; font-size:16px}")
            self.title.setText("Untitled")
            tool.addWidget(self.title)

        tool.addStretch()

        if editType == EditorType.Manual:
            self.editorTypeBox = PComboBox()
            self.editorTypeBox.setView(MiniView.listView())
            self.editorTypeBox.addItems(["Text", "JSON", "XML", "HTML"])
            self.editorTypeBox.currentIndexChanged.connect(
                self.editorTypeChange)
            tool.addWidget(self.editorTypeBox)

        self.wrapButton = QToolButton()
        self.wrapButton.setCheckable(True)
        self.wrapButton.setText("Wrap")
        self.wrapButton.setToolTip("Wrap/Unwrap (Ctrl+W)")
        self.wrapButton.setIcon(
            PResource.defaultIcon(Parapluie.Icon_Wrap_Text_Svg))
        self.wrapButton.setFixedSize(iconSize, iconSize)
        self.wrapButton.pressed.connect(self.wrapText)
        tool.addWidget(self.wrapButton)

        formatButton = QToolButton()
        formatButton.setText("Format")
        formatButton.setToolTip("Format Code (Ctrl+F)")
        formatButton.setIcon(
            PResource.defaultIcon(Parapluie.Icon_Clean_Code_Svg))
        formatButton.setFixedSize(iconSize, iconSize)
        formatButton.pressed.connect(self.formatText)
        tool.addWidget(formatButton)

        if save:
            saveButton = QToolButton()
            saveButton.setText("Save")
            saveButton.setToolTip("Save (Ctrl+S)")
            saveButton.setIcon(PResource.defaultIcon(Parapluie.Icon_Save_Svg))
            saveButton.setFixedSize(iconSize, iconSize)
            saveButton.pressed.connect(self.saveData)
            tool.addWidget(saveButton)

        if sync:
            syncButton = QToolButton()
            syncButton.setText("Sync")
            syncButton.setToolTip("Sync (Ctrl+B)")
            syncButton.setIcon(
                PResource.defaultIcon(Parapluie.Icon_Double_Right_Chevron_Svg))
            syncButton.setFixedSize(iconSize, iconSize)
            syncButton.pressed.connect(self.syncJson)
            tool.addWidget(syncButton)

        widget = QWidget()
        widget.setLayout(tool)
        widget.layout().setContentsMargins(8, 0, 8, 0)
        widget.setObjectName(Parapluie.Object_Editor_Header)
        widget.setMaximumHeight(iconSize)

        layout = QVBoxLayout()
        layout.addWidget(widget)
        layout.addWidget(self.editor)

        self.setLayout(layout)
        self.layout().setContentsMargins(5, 5, 5, 5)
        self.setObjectName(Parapluie.Object_Editor)

        self.currentFile = None

        self.editType = EditorType.Text
        self.setEditorType(EditorType.Text)
    def __init__(self):
        super().__init__()
        # self.setMaximumWidth(600)
        self.setObjectName(Parapluie.Object_Raised_Off)

        self.backButton = QToolButton()
        self.backButton.setIcon(
            PResource.defaultIcon(Parapluie.Icon_Left_Arrow_Svg))
        self.backButton.setFixedSize(36, 36)
        self.backButton.pressed.connect(self.onBackPressed)

        self.searchBar = QLineEdit()
        self.searchBar.setPlaceholderText("Search..")
        self.searchBar.textChanged.connect(self.searchFile)
        self.searchBar.setFixedHeight(36)

        self.addButton = QToolButton()
        self.addButton.setIcon(PResource.defaultIcon(Parapluie.Icon_Plus_Svg))
        self.addButton.setFixedSize(36, 36)
        self.addButton.pressed.connect(self.newFile)

        self.openButton = QToolButton()
        self.openButton.setIcon(
            PResource.defaultIcon(Parapluie.Icon_Folder_Svg))
        self.openButton.setFixedSize(36, 36)
        self.openButton.pressed.connect(self.openFile)

        topBar = QHBoxLayout()
        topBar.addWidget(self.backButton)
        topBar.addWidget(self.searchBar)
        topBar.addWidget(self.openButton)
        topBar.addWidget(self.addButton)

        self.listDataWidget = QListWidget()
        self.listDataWidget.setContentsMargins(0, 0, 0, 0)
        # self.listDataWidget.setObjectName(Parapluie.Object_Raised)
        self.listDataWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.listDataWidget.setSizePolicy(QSizePolicy.Expanding,
                                          QSizePolicy.Expanding)
        self.listDataWidget.horizontalScrollBar().setEnabled(False)
        self.listDataWidget.setSpacing(3)

        self.gridData = PGridWidget(2)
        # self.gridData.setObjectName(Parapluie.Object_Raised)
        self.gridData.setContentsMargins(0, 0, 0, 0)
        self.gridData.setHorizontalSpacing(5)
        self.gridData.setVerticalSpacing(5)
        self.gridData.setFixColumn(True)
        self.gridData.setRowHeight(100)
        self.gridData.setAlignment(Qt.AlignTop | Qt.AlignLeft)

        self.stacked = QStackedWidget()
        self.stacked.addWidget(self.gridData)
        self.stacked.addWidget(self.listDataWidget)
        self.stacked.currentChanged.connect(self.tabChange)

        layout = QVBoxLayout()
        layout.addLayout(topBar)
        layout.addWidget(self.stacked)
        layout.setContentsMargins(8, 8, 0, 8)

        self.setLayout(layout)

        self.categoriesChange = None

        self.dataList = []  # combine
        self.categories = []  # string
        self.dataSource = XashList()
        self.dataTemp = []  # xfile
        self.listFile = []  # xfile

        self.currentFile = None
        self.newCount = -1
        self.lastSearch = {1: "", 0: ""}

        self.listAdapter = ItemAdapter(self, self.listDataWidget,
                                       self.dataList, self.dataSource,
                                       self.onItemSelected, self.onItemClosed)

        gridAdapter = GridAdapter(data=self.categories)
        gridAdapter.setOnItemClick(self.onCategoriesClicked)
        self.gridData.setAdapter(gridAdapter)

        self.stacked.setCurrentIndex(1)
        self.tabChange(1)
        self.loadFile()
Esempio n. 4
0
    def __init__(self):
        super().__init__()

        # line 1
        self.apiType = PComboBox()
        self.apiType.setFixedWidth(100)
        self.apiType.setView(listView())
        self.apiType.addItem("GET")
        self.apiType.addItem("POST")
        self.apiType.addItem("PUT")
        self.apiType.addItem("HEAD")
        self.apiType.addItem("DELETE")
        self.apiType.addItem("PATCH")
        self.apiType.addItem("OPTIONS")
        self.apiType.setObjectName(Parapluie.Object_ColorComboBox)

        self.apiURL = QLineEdit()
        self.apiURL.setPlaceholderText("API..")

        l1 = QHBoxLayout()
        l1.setSpacing(10)
        l1.addWidget(self.apiType)
        l1.addWidget(self.apiURL)

        # line 2
        addLink = QToolButton()
        addLink.setIcon(PResource.defaultIcon(Parapluie.Icon_Plus_Svg))
        addLink.setIconSize(QSize(12, 12))
        addLink.setFixedSize(32, 32)
        addLink.pressed.connect(self.openApiLinkEdit)

        self.apiLink = PComboBox()
        self.apiLink.setView(listView())
        self.apiLink.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLength)

        apiBar = QHBoxLayout()
        apiBar.setSpacing(6)
        apiBar.setContentsMargins(0, 0, 0, 0)
        apiBar.addWidget(self.apiLink, stretch=1)
        apiBar.addWidget(addLink)

        l2 = QFormLayout()
        l2.setVerticalSpacing(6)
        l2.setHorizontalSpacing(10)

        l2.addRow(formLabel("API Link:"), apiBar)

        # line 3
        self.bodyWidget = RequestBody()
        self.bodyWidget.editor.alert.connect(
            lambda a, b, c, d: self.alert.emit(a, b, c, d))

        self.paramWidget = ParamEditor(ParamType.Param)

        self.headerWidget = ParamEditor(ParamType.Param)

        self.tab = PTabWidget()
        self.tab.resizable(True)
        self.tab.setSizeBox(300, 1000, 200)
        self.tab.sizeBox.setValue(400)
        self.tab.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.tab.addTab(self.headerWidget, "Header")
        self.tab.addTab(self.paramWidget, "Param")
        self.tab.addTab(self.bodyWidget, "Body")

        lLeft = QVBoxLayout()
        lLeft.setContentsMargins(0, 0, 0, 0)
        lLeft.setAlignment(Qt.AlignTop)
        lLeft.addLayout(l1)
        lLeft.addLayout(l2)
        lLeft.addSpacing(15)
        lLeft.addWidget(self.tab)

        wLeft = PWidget()
        wLeft.setLayout(lLeft)
        wLeft.setObjectName(Parapluie.Object_Raised)

        self.description = QTextEdit()
        self.description.setMinimumHeight(300)
        self.description.setMaximumHeight(300)

        self.categories = PEditor()

        form = QFormLayout()
        form.setVerticalSpacing(6)
        form.setHorizontalSpacing(6)

        form.addRow(formLabel("Categories:", False), self.categories)
        form.addRow(formLabel("Description:", False), self.description)

        lRight = QVBoxLayout()
        lRight.setContentsMargins(0, 0, 10, 0)
        lRight.addLayout(form)
        lRight.addStretch()
        lRight.addStretch()

        wRight = PWidget()
        wRight.setLayout(lRight)
        wRight.setObjectName(Parapluie.Object_Raised)

        self.addWidget(wLeft)
        self.addWidget(wRight)
        self.setObjectName(Parapluie.Object_QSplitter)
        self.setChildrenCollapsible(False)
        self.setStretchFactor(0, 4)
        self.setStretchFactor(1, 3)

        self.dialog = RequestLink(
            self, QRect(QPoint(0, 0),
                        QApplication.primaryScreen().size()))
        self.dialog.getData()
        self.updateAPILink()
    def __init__(self, window):
        super().__init__()

        self.param = RequestParam()
        self.param.alert.connect(lambda a, b, c, d: self.alert.emit(a, b, c, d))

        self.result = RequestResult()
        self.result.alert.connect(lambda a, b, c, d: self.alert.emit(a, b, c, d))

        clearButton = QToolButton()
        clearButton.setText("Clear")
        clearButton.setToolTip("Clear (Ctrl+D)")
        clearButton.setIcon(PResource.defaultIcon(Parapluie.Icon_Clear_All_Svg))
        clearButton.setFixedSize(36, 36)
        clearButton.pressed.connect(self.clearAll)

        saveButton = QToolButton()
        saveButton.setText("Save")
        saveButton.setToolTip("Save (Ctrl+S)")
        saveButton.setIcon(PResource.defaultIcon(Parapluie.Icon_Save_Svg))
        saveButton.setFixedSize(36, 36)
        saveButton.pressed.connect(self.saveData)

        runButton = QToolButton()
        runButton.setText("Run")
        runButton.setToolTip("Run (Ctrl+R)")
        runButton.setIcon(PResource.defaultIcon(Parapluie.Icon_Play_Button_Svg))
        runButton.setFixedSize(36, 36)
        runButton.pressed.connect(self.run)

        self.category = self.param.categories

        self.title = PLabelEdit()
        self.title.setFixedHeight(36)
        self.title.setMaximumHeight(36)
        self.title.setStyleSheet("QLabel{color:#424242; font-size:16px}")
        self.title.setText("Untitled")

        tool = QHBoxLayout()
        tool.addSpacing(10)
        tool.addWidget(self.title)
        tool.addStretch()
        tool.addWidget(clearButton)
        tool.addWidget(runButton)
        tool.addWidget(saveButton)

        widget = QWidget()
        widget.setLayout(tool)
        widget.layout().setContentsMargins(8, 4, 8, 4)
        widget.setObjectName(Parapluie.Object_TopHeader)
        widget.setMaximumHeight(44)
        PFunction.applyShadow(widget)

        workLayout = QVBoxLayout()
        workLayout.addWidget(self.param)
        workLayout.addSpacing(20)
        workLayout.addWidget(self.result)
        workLayout.setContentsMargins(8, 8, 8, 8)

        workspace = PWidget()
        workspace.setLayout(workLayout)
        workspace.setObjectName(Parapluie.Object_Raised)

        scroll = QScrollArea()
        scroll.setWidget(workspace)
        scroll.setWidgetResizable(True)
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        layout = QVBoxLayout()
        layout.setSpacing(10)
        layout.setAlignment(Qt.AlignTop)
        layout.addWidget(widget)
        layout.addWidget(scroll)
        layout.setContentsMargins(0, 0, 0, 10)

        outer = PWidget()
        outer.setObjectName(Parapluie.Object_TopHeader)
        outer.setLayout(layout)

        outerLayout = QHBoxLayout()
        outerLayout.addWidget(outer)

        self.setLayout(outerLayout)
        self.layout().setContentsMargins(0, 5, 5, 10)

        self.currentFile: XFile = None
        self.win = window
        self.onSaveFunc = None