Ejemplo n.º 1
0
    def component(self):
        self.w_json_edit.setLineWrapMode(QTextEdit.NoWrap)
        self.w_json_edit.setAcceptRichText(True)
        if 'config' in self.api_data:
            if 'param' in self.api_data['config']:
                self.json_param = self.api_data['config']['param']
                self.w_json_edit.setDocument(
                    color_json(self.api_data['config']['param']))
                self.parse_param_to_table()
        self.w_json_edit.installEventFilter(self)

        self.w_widget_tab.addTab(self.w_group, "UI")
        self.w_widget_tab.addTab(self.w_json_edit, "JSON")
        self.w_widget_tab.currentChanged.connect(self.tab_selected)

        w_run = QPushButton()
        w_run.setIcon(QIcon(get_icon_link('play_arrow.svg')))
        w_run.setText("Run")
        w_run.setToolTip("Run API call (Ctrl+R)")
        w_run.pressed.connect(self.run_api_without_save)

        w_run_save = QPushButton()
        w_run_save.setIcon(QIcon(get_icon_link('play_circle_outline.svg')))
        w_run_save.setText("Run && Save")
        w_run_save.setToolTip("Run and Save API call (Ctrl++Shift+R)")
        w_run_save.pressed.connect(self.run_api_save)

        w_sync = QPushButton()
        w_sync.setText("Sync")
        w_sync.setIcon(QIcon(get_icon_link('refresh.svg')))
        w_sync.setToolTip("Sync param (Ctrl+Shift+C)")
        w_sync.pressed.connect(self.sync_param)

        l_action = QHBoxLayout()
        l_action.addWidget(w_run, alignment=Qt.AlignLeft)
        l_action.addWidget(w_run_save, alignment=Qt.AlignLeft)
        l_action.addStretch()
        l_action.addWidget(w_sync, alignment=Qt.AlignRight)

        w_group2 = QWidget()
        w_group2.setLayout(l_action)
        w_group2.setMaximumHeight(50)

        self.addWidget(self.header())
        self.addWidget(self.w_widget_tab)
        self.addWidget(w_group2)
        self.setStretchFactor(0, 1)
        self.setStretchFactor(1, 2)
        self.setStretchFactor(2, 1)
        self.setStretchFactor(3, 1)
Ejemplo n.º 2
0
 def import_data(self, parent_item, list):
     for i in list:
         if i["isDir"]:
             item = QStandardItem(i["name"])
             item.setEditable(False)
             item.setIcon(QIcon(get_icon_link("folder_yellow.svg")))
             item.setData(i)
             parent_item.appendRow(item)
             self.import_data(item, i["child"])
         else:
             item = QStandardItem(i["name"])
             item.setEditable(False)
             item.setIcon(QIcon(get_icon_link("text_snippet.svg")))
             item.setData(i)
             parent_item.appendRow(item)
Ejemplo n.º 3
0
    def openMenu(self, position):
        indexes = self.tree.selectedIndexes()
        level = 0
        data = {}
        if len(indexes) > 0:
            index = indexes[0]
            item = self.model.itemFromIndex(index)
            data = item.data()
            if data['isDir']:
                level = 1
            else:
                level = 2

        menu = QMenu()
        menu.setStyleSheet(open('stylesheet/default.qss').read())

        # Create preference action
        rename_action = QAction(QIcon(get_icon_link('edit.svg')), '&Rename',
                                self)
        rename_action.setStatusTip('Rename')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        new_action = QAction(QIcon(get_icon_link('create_new_folder.svg')),
                             '&New Folder', self)
        new_action.setStatusTip('New Folder')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        refresh_action = QAction(QIcon(get_icon_link('refresh.svg')),
                                 '&Refresh', self)
        refresh_action.setStatusTip('Refresh')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        delete_action = QAction(QIcon(get_icon_link('delete_forever.svg')),
                                '&Delete', self)
        delete_action.setStatusTip('Delete')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        open_action = QAction(QIcon(get_icon_link('open_in_new.svg')), '&Open',
                              self)
        open_action.setStatusTip('Open file')
        # open_action.triggered.connect(self.open_file)

        # Create preference action
        expand_action = QAction(QIcon(), '&Expand', self)
        expand_action.setStatusTip('Expand')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        collapse_action = QAction(QIcon(), '&Collapse', self)
        collapse_action.setStatusTip('Collapse')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        copy_action = QAction(QIcon(get_icon_link('content_copy.svg')),
                              '&Copy', self)
        copy_action.setStatusTip('Copy')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        move_action = QAction(QIcon(get_icon_link('zoom_out_map.svg')),
                              '&Move', self)
        move_action.setStatusTip('Move')
        # exitAction.triggered.connect(self.exitCall)

        if level == 1:
            menu.addAction(rename_action)
            menu.addAction(new_action)
            menu.addSeparator()
            menu.addAction(refresh_action)
            menu.addAction(expand_action)
            menu.addAction(collapse_action)
            menu.addSeparator()
            menu.addAction(delete_action)
        elif level == 2:
            menu.addAction(open_action)
            menu.addAction(refresh_action)
            menu.addSeparator()
            menu.addAction(rename_action)
            menu.addAction(copy_action)
            menu.addAction(move_action)
            menu.addSeparator()
            menu.addAction(delete_action)
        else:
            menu.addAction(new_action)
            menu.addAction(refresh_action)

        action = menu.exec_(self.tree.viewport().mapToGlobal(position))
        if action == open_action:
            self.on_menu_select.emit("open", data)
Ejemplo n.º 4
0
    def component(self):
        self.w_url.setText("Url: ")
        self.w_url.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        if "response" in self.api_data:
            if 'url' in self.api_data["response"]:
                self.w_url.setText(self.api_data["response"]['url'])

        self.w_status_code.setText("0 - No API call")
        if "response" in self.api_data:
            if 'status' in self.api_data["response"]:
                self.w_status_code.setText(self.print_status(self.api_data["response"]['status']))

        l_status = QHBoxLayout()
        l_status.addWidget(self.w_url)
        l_status.addWidget(self.w_status_code, alignment=Qt.AlignRight)

        if "response" in self.api_data:
            if 'header' in self.api_data["response"]:
                self.w_console.setDocument(color_json(self.api_data["response"]['header']))

        w_gr_vbox_console = QVBoxLayout()
        w_gr_vbox_console.addLayout(l_status)
        w_gr_vbox_console.addWidget(self.w_console)

        w_gr_console = QGroupBox()
        w_gr_console.setTitle("Console")
        w_gr_console.setLayout(w_gr_vbox_console)

        w_format = QPushButton()
        w_format.setText("Format")
        w_format.setIcon(QIcon(get_icon_link('format_indent_increase.svg')))
        w_format.setToolTip("Format result (Ctrl+B)")
        w_format.pressed.connect(self.format_result)

        self.w_format_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        if "config" in self.api_data:
            if 'format' in self.api_data['config']:
                self.w_format_field.setText(str(self.api_data['config']['format']))
        # self.w_format_field.pressed.connect(self.open_format_manager)
        self.w_format_field.installEventFilter(self)

        self.w_format_label.setText("String object: ")

        l_hbox = QHBoxLayout()
        l_hbox.addWidget(self.w_format_label, alignment=Qt.AlignLeft)
        l_hbox.addWidget(self.w_format_field)
        l_hbox.addWidget(w_format, alignment=Qt.AlignRight)

        w_gr_vbox_result = QVBoxLayout()
        w_gr_vbox_result.addLayout(l_hbox)

        if "response" in self.api_data:
            if 'content' in self.api_data["response"]:
                self.w_result.setDocument(color_json(self.api_data["response"]['content']))

        w_gr_vbox_result.addWidget(self.w_result)

        w_gr_result = QGroupBox()
        w_gr_result.setTitle("Result")
        w_gr_result.setLayout(w_gr_vbox_result)

        self.addWidget(w_gr_console)
        self.addWidget(w_gr_result)
        self.setStretchFactor(0, 1)
        self.setStretchFactor(1, 2)
Ejemplo n.º 5
0
    def menu(self):
        main_menu = QMenuBar()

        # Create new action
        new_action = QAction(QIcon(get_icon_link('note_add.svg')), '&New...',
                             self)
        new_action.setShortcut('Ctrl+N')
        new_action.setStatusTip('New document')
        new_action.triggered.connect(self.new_call)

        # Create new action
        open_action = QAction(QIcon(get_icon_link('description.svg')), '&Open',
                              self)
        open_action.setShortcut('Ctrl+O')
        open_action.setStatusTip('Open document')
        # openAction.triggered.connect(self.openCall)

        # Create new action
        save_action = QAction(QIcon(get_icon_link('description.svg')), '&Save',
                              self)
        save_action.setShortcut('Ctrl+S')
        save_action.setStatusTip('Save document')
        # openAction.triggered.connect(self.openCall)

        # Create exit action
        exit_action = QAction(QIcon(get_icon_link('exit_to_app.svg')), '&Exit',
                              self)
        exit_action.setShortcut('Ctrl+Q')
        exit_action.setStatusTip('Exit application')
        # exitAction.triggered.connect(self.exitCall)

        file_menu = main_menu.addMenu('&File')
        file_menu.addAction(new_action)
        file_menu.addAction(open_action)
        file_menu.addSeparator()
        file_menu.addAction(save_action)
        file_menu.addSeparator()
        file_menu.addAction(exit_action)

        # Create preference action
        api_link_action = QAction(QIcon(get_icon_link('link.svg')),
                                  '&API link manager', self)
        api_link_action.setShortcut('Ctrl+L')
        api_link_action.setStatusTip('API link manager')
        api_link_action.triggered.connect(self.api_link_manager)

        pref_menu = main_menu.addMenu('&Preferences')
        pref_menu.addAction(api_link_action)

        # Create preference action
        run_action = QAction(QIcon(get_icon_link('play_arrow.svg')), '&Run',
                             self)
        run_action.setShortcut('Ctrl+R')
        run_action.setStatusTip('Run API call')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        run_save_action = QAction(
            QIcon(get_icon_link('play_circle_outline.svg')), '&Run && Save',
            self)
        run_save_action.setShortcut('Ctrl+Shift+R')
        run_save_action.setStatusTip('Run and Save API call')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        clear_action = QAction(QIcon(get_icon_link('refresh.svg')), '&Reset',
                               self)
        clear_action.setShortcut('Ctrl+Shift+C')
        clear_action.setStatusTip('Reset param')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        format_action = QAction(
            QIcon(get_icon_link('format_indent_increase.svg')), '&Format',
            self)
        format_action.setShortcut('Ctrl+B')
        format_action.setStatusTip('Format result')
        # exitAction.triggered.connect(self.exitCall)

        run_menu = main_menu.addMenu('&Run')
        run_menu.addAction(run_action)
        run_menu.addAction(run_save_action)
        run_menu.addSeparator()
        run_menu.addAction(clear_action)
        run_menu.addAction(format_action)

        # Create preference action
        close_tab_action = QAction(QIcon(get_icon_link('close.svg')),
                                   '&Close Tab', self)
        close_tab_action.setShortcut('Ctrl+W')
        close_tab_action.setStatusTip('Close Tab')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        close_all_action = QAction(QIcon(get_icon_link('clear_all.svg')),
                                   '&Close All Tab', self)
        close_all_action.setShortcut('Ctrl+Shift+W')
        close_all_action.setStatusTip('Close All Tab')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        close_others_action = QAction(QIcon(get_icon_link('tab.svg')),
                                      '&Close Others Tab', self)
        close_others_action.setShortcut('Ctrl+Alt+W')
        close_others_action.setStatusTip('Close Others Tab')
        # exitAction.triggered.connect(self.exitCall)

        workspace_menu = main_menu.addMenu('&Workspace')
        workspace_menu.addAction(close_tab_action)
        workspace_menu.addAction(close_all_action)
        workspace_menu.addAction(close_others_action)

        # Create preference action
        shortcut_action = QAction(QIcon(get_icon_link('keyboard.svg')),
                                  '&Shortcut', self)
        shortcut_action.setShortcut('')
        shortcut_action.setStatusTip('Application shortcut')
        # exitAction.triggered.connect(self.exitCall)

        # Create preference action
        about_action = QAction(QIcon(get_icon_link('live_help.svg')), '&About',
                               self)
        about_action.setShortcut('')
        about_action.setStatusTip('Application information')
        # exitAction.triggered.connect(self.exitCall)

        help_menu = main_menu.addMenu('&Help')
        help_menu.addAction(about_action)
        help_menu.addAction(shortcut_action)

        self.setMenuBar(main_menu)