Beispiel #1
0
    def __init__(self, config_file_path, help_tool):
        QWidget.__init__(self)

        layout = QVBoxLayout()

        toolbar = QToolBar("toolbar")

        save_action = toolbar.addAction(util.resourceIcon("ide/disk"), "Save")
        save_action.triggered.connect(self.save)

        save_as_action = toolbar.addAction(util.resourceIcon("ide/save_as"),
                                           "Save As")
        save_as_action.triggered.connect(self.saveAs)

        # reload_icon = toolbar.style().standardIcon(QStyle.SP_BrowserReload)
        # reload_action = toolbar.addAction(reload_icon, "Reload")
        # reload_action.triggered.connect(self.reload)

        toolbar.addSeparator()

        toolbar.addAction(help_tool.getAction())

        stretchy_separator = QWidget()
        stretchy_separator.setSizePolicy(QSizePolicy.Expanding,
                                         QSizePolicy.Expanding)
        toolbar.addWidget(stretchy_separator)

        search = SearchBox()
        search.setMaximumWidth(200)
        search.setContentsMargins(5, 2, 5, 2)

        toolbar.addWidget(search)

        layout.addWidget(toolbar)

        self.ide_panel = IdePanel()
        layout.addWidget(self.ide_panel, 1)

        self.config_file_path = config_file_path

        with open(config_file_path) as f:
            config_file_text = f.read()

        self.highlighter = KeywordHighlighter(self.ide_panel.document())

        search.filterChanged.connect(self.highlighter.setSearchString)

        self.parseDefines(config_file_text)
        self.ide_panel.document().setPlainText(config_file_text)

        cursor = self.ide_panel.textCursor()
        cursor.setPosition(0)
        self.ide_panel.setTextCursor(cursor)
        self.ide_panel.setFocus()

        self.setLayout(layout)
Beispiel #2
0
def main():
    if len(sys.argv) == 1:
        print("Missing configuration file!")
        sys.exit(1)

    QApplication.setGraphicsSystem("raster")
    app = QApplication(
        sys.argv)  #Early so that QT is initialized before other imports

    main_window = QMainWindow()

    central_widget = QWidget()
    main_window.setCentralWidget(central_widget)
    layout = QVBoxLayout()
    central_widget.setLayout(layout)

    search = SearchBox()

    ide = IdePanel()

    layout.addWidget(search)
    layout.addWidget(ide, 1)

    path = sys.argv[1]
    with open(path) as f:
        config_file = f.read()

    highlighter = KeywordHighlighter(ide.document())

    search.filterChanged.connect(highlighter.setSearchString)

    ide.document().setPlainText(config_file)

    cursor = ide.textCursor()
    cursor.setPosition(0)
    ide.setTextCursor(cursor)
    ide.setFocus()

    main_window.show()

    sys.exit(app.exec_())
Beispiel #3
0
    def __init__(self):
        QWidget.__init__(self)

        self.__filter_popup = FilterPopup(self)
        self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged)

        layout = QVBoxLayout()

        self.model = DataTypeKeysListModel()
        self.filter_model = DataTypeProxyModel(self.model)

        filter_layout = QHBoxLayout()

        self.search_box = SearchBox()
        self.search_box.filterChanged.connect(self.setSearchString)
        filter_layout.addWidget(self.search_box)

        filter_popup_button = QToolButton()
        filter_popup_button.setIcon(util.resourceIcon("ide/cog_edit.png"))
        filter_popup_button.clicked.connect(self.showFilterPopup)
        filter_layout.addWidget(filter_popup_button)
        layout.addLayout(filter_layout)

        self.data_type_keys_widget = QListView()
        self.data_type_keys_widget.setModel(self.filter_model)
        self.data_type_keys_widget.selectionModel().selectionChanged.connect(
            self.itemSelected)

        layout.addSpacing(15)
        layout.addWidget(self.data_type_keys_widget, 2)
        layout.addStretch()

        # layout.addWidget(Legend("Default types", DataTypeKeysListModel.DEFAULT_DATA_TYPE))
        layout.addWidget(
            Legend("Observations available",
                   DataTypeKeysListModel.HAS_OBSERVATIONS))

        self.setLayout(layout)
Beispiel #4
0
    def __init__(self, model, label="", help_link=""):
        HelpedWidget.__init__(self, "", help_link)

        layout = QVBoxLayout()

        widget = QWidget()
        widget.setLayout(layout)

        self.checkAllButton = QToolButton()
        self.checkAllButton.setIcon(resourceIcon("checked"))
        self.checkAllButton.setIconSize(QSize(16, 16))
        self.checkAllButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
        self.checkAllButton.setAutoRaise(True)
        self.checkAllButton.setToolTip("Select all")

        self.uncheckAllButton = QToolButton()
        self.uncheckAllButton.setIcon(resourceIcon("notchecked"))
        self.uncheckAllButton.setIconSize(QSize(16, 16))
        self.uncheckAllButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
        self.uncheckAllButton.setAutoRaise(True)
        self.uncheckAllButton.setToolTip("Unselect all")

        self.list = QListWidget()
        self.list.setContextMenuPolicy(Qt.CustomContextMenu)
        self.list.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self.search_box = SearchBox()

        check_button_layout = QHBoxLayout()

        check_button_layout.setMargin(0)
        check_button_layout.setSpacing(0)
        check_button_layout.addWidget(QLabel(label))
        check_button_layout.addStretch(1)
        check_button_layout.addWidget(self.checkAllButton)
        check_button_layout.addWidget(self.uncheckAllButton)

        layout.addLayout(check_button_layout)
        layout.addWidget(self.list)
        layout.addWidget(self.search_box)

        self.addWidget(widget)

        self.connect(self.checkAllButton, SIGNAL('clicked()'), self.checkAll)
        self.connect(self.uncheckAllButton, SIGNAL('clicked()'),
                     self.uncheckAll)
        self.connect(self.list, SIGNAL('itemChanged(QListWidgetItem*)'),
                     self.itemChanged)
        self.search_box.filterChanged.connect(self.filterList)
        # self.connect(self.search_box, SIGNAL('filterChanged(str)'), self.filterList)

        self.connect(self.list, SIGNAL('customContextMenuRequested(QPoint)'),
                     self.showContextMenu)

        assert isinstance(model, (SelectableModelMixin, ListModelMixin))
        self.model = model
        self.model.observable().attach(
            SelectableModelMixin.SELECTION_CHANGED_EVENT, self.modelChanged)
        self.model.observable().attach(ListModelMixin.LIST_CHANGED_EVENT,
                                       self.modelChanged)
        self.modelChanged()