def _init_widgets(self, layout_object): """Initialize widgets""" lbl_title = QLabel() lbl_title.setStyleSheet( 'padding: 2px; font-weight: bold; background-color: ' 'rgb(200, 200, 200);') lbl_title.setText(self.tr('QR Code')) self._cd_value_widget = CodeValueWidget(self) self._cd_value_widget.value_changed.connect( self._on_code_value_changed) value_groupbox = QgsCollapsibleGroupBoxBasic(self.tr('Data')) gp_layout = QVBoxLayout() gp_layout.setContentsMargins(0, 0, 0, 0) gp_layout.addWidget(self._cd_value_widget) value_groupbox.setLayout(gp_layout) # Item appearance appearance_groupbox = QgsCollapsibleGroupBoxBasic( self.tr('Appearance')) appearance_layout = QGridLayout() # Data color lbl_data_clr = QLabel(self.tr('Data color')) self._data_clr_btn = QgsColorButton() self._data_clr_btn.setColorDialogTitle(self.tr('Select Data Color')) self._data_clr_btn.setContext('composer') self._data_clr_btn.setAllowOpacity(False) self._data_clr_btn.colorChanged.connect(self.on_data_color_changed) appearance_layout.addWidget(lbl_data_clr, 0, 0) appearance_layout.addWidget(self._data_clr_btn, 0, 1) appearance_layout.setColumnStretch(2, 1) # Background color lbl_background_clr = QLabel(self.tr('Background color')) self._background_clr_btn = QgsColorButton() self._background_clr_btn.setColorDialogTitle( self.tr('Select Background Color')) self._background_clr_btn.setContext('composer') self._background_clr_btn.setAllowOpacity(False) self._background_clr_btn.colorChanged.connect( self.on_background_color_changed) appearance_layout.addWidget(lbl_background_clr, 1, 0) appearance_layout.addWidget(self._background_clr_btn, 1, 1) appearance_groupbox.setLayout(appearance_layout) # Properties widget self._prop_widget = QgsLayoutItemPropertiesWidget(self, layout_object) self._prop_widget.showBackgroundGroup(False) # Add widgets to layout layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(lbl_title) layout.addWidget(value_groupbox) layout.addWidget(appearance_groupbox) layout.addWidget(self._prop_widget) # Set layout self.setLayout(layout)
def init_gui(self): self._cpu_color = QgsColorButton() self._widget.mCpuLayout.addWidget(self._cpu_color) self._ram_color = QgsColorButton() self._widget.mRamLayout.addWidget(self._ram_color) self._background_color = QgsColorButton() self._widget.mBackgroundLayout.addWidget(self._background_color) self._axes_color = QgsColorButton() self._widget.mAxesLayout.addWidget(self._axes_color) setting = SnailSettings.System.RefreshSec self._widget.mRefreshSec.setMinimum(1) sec = SnailSettings.get(setting, 1, int) self._widget.mRefreshSec.setValue(sec) setting = SnailSettings.System.RamWarning activated = SnailSettings.get(setting, False, bool) self._widget.mRamWarning.setChecked(activated) setting = SnailSettings.System.RamWarningLimit limit = SnailSettings.get(setting, 90, int) self._widget.mRamWarningLimit.setValue(limit) self.read_settings()
def getParams(configure_exporter_action=None): accentColor = QgsColorButton() accentColor.setColor(QColor(0, 0, 0)) backgroundColor = QgsColorButton() backgroundColor.setColor(QColor(248, 248, 248)) params = { "Appearance": { "Add layers list": ("None", "Collapsed", "Expanded"), "Match project CRS": False, "Add address search": False, "Layer search": ("None", "placeholder"), "Measure tool": ("None", "Metric", "Imperial"), "Show popups on hover": False, "Highlight on hover": False, "Geolocate user": False, "Template": getTemplates(), "Widget Icon": accentColor, "Widget Background": backgroundColor }, "Data export": { "Precision": ("maintain", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"), "Minify GeoJSON files": True, "Mapping library location": ("Local", "CDN"), "Use debug libraries": False }, "Scale/Zoom": { "Extent": ("Canvas extent", "Fit to layers extent"), "Restrict to extent": False, "Max zoom level": ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28"), "Min zoom level": ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28"), } } if configure_exporter_action: params["Data export"]["Exporter"] = { 'option': EXPORTER_REGISTRY.getOptions(), 'action': configure_exporter_action } else: params["Data export"]["Exporter"] = EXPORTER_REGISTRY.getOptions() return params
def init(self, title, canvas, default_color, geom_type, marker): self.canvas = canvas self.geom_type = geom_type self.track_groupBox.setTitle(title) if marker: # Add marker self.marker = marker self.with_marker = True else: self.with_marker = False # Add rubber band self.band = QgsRubberBand(self.canvas, self.geom_type) if self.geom_type == QgsWkbTypes.PointGeometry: self.band.setIcon(QgsRubberBand.ICON_CIRCLE) self.band.setIconSize(12) else: self.band.setWidth(3) # Add color button widget for picking color self.color_btn = QgsColorButton() self.horizontal_layout_color.insertWidget(1, self.color_btn, 0, Qt.AlignLeft) self.color_btn.colorChanged.connect(self.color_changed) self.color_btn.setDefaultColor(default_color) self.color_btn.setColor(default_color) # Set signals self.centerButton.clicked.connect(self.center_to_location) self.clearTrackButton.clicked.connect(self.clear_track)
def setupUi(self, NorthArrowDialog): NorthArrowDialog.setObjectName("NorthArrowDialog") NorthArrowDialog.resize(281, 101) self.verticalLayout = QtWidgets.QVBoxLayout(NorthArrowDialog) self.verticalLayout.setObjectName("verticalLayout") self.groupBox = QtWidgets.QGroupBox(NorthArrowDialog) self.groupBox.setCheckable(True) self.groupBox.setChecked(False) self.groupBox.setObjectName("groupBox") self.gridLayout = QtWidgets.QGridLayout(self.groupBox) self.gridLayout.setObjectName("gridLayout") self.label = QtWidgets.QLabel(self.groupBox) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.colorButton = QgsColorButton(self.groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.colorButton.sizePolicy().hasHeightForWidth()) self.colorButton.setSizePolicy(sizePolicy) self.colorButton.setObjectName("colorButton") self.gridLayout.addWidget(self.colorButton, 0, 1, 1, 1) self.verticalLayout.addWidget(self.groupBox) self.buttonBox = QtWidgets.QDialogButtonBox(NorthArrowDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Apply|QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(NorthArrowDialog) self.buttonBox.accepted.connect(NorthArrowDialog.accept) self.buttonBox.rejected.connect(NorthArrowDialog.reject) QtCore.QMetaObject.connectSlotsByName(NorthArrowDialog)
def __init__(self, setting, widget, options): txt = options.get("dialogTitle", "") color_widget = QgsColorButton(widget, txt) signal = color_widget.colorChanged SettingWidget.__init__(self, setting, color_widget, options, signal) self.widget.setAllowAlpha(self.options.get("allowAlpha", False))
def testLinkedColorButton(self): definition = QgsPropertyDefinition('test', 'test', QgsPropertyDefinition.ColorWithAlpha) button = QgsPropertyOverrideButton() button.init(0, QgsProperty(), definition) cb = QgsColorButton() button.registerLinkedWidget(cb) project_scheme = [s for s in QgsApplication.colorSchemeRegistry().schemes() if isinstance(s, QgsProjectColorScheme)][0] project_scheme.setColors([[QColor(255, 0, 0), 'col1'], [QColor(0, 255, 0), 'col2']]) button.setToProperty(QgsProperty.fromValue('#ff0000')) self.assertTrue(cb.isEnabled()) self.assertFalse(cb.linkedProjectColorName()) button.setActive(False) self.assertTrue(cb.isEnabled()) self.assertFalse(cb.linkedProjectColorName()) button.setToProperty(QgsProperty.fromExpression('project_color(\'Cthulhu\'s delight\')')) self.assertTrue(cb.isEnabled()) self.assertFalse(cb.linkedProjectColorName()) button.setToProperty(QgsProperty.fromExpression('project_color(\'col1\')')) self.assertTrue(cb.isEnabled()) self.assertEqual(cb.linkedProjectColorName(), 'col1') button.setActive(False) self.assertTrue(cb.isEnabled()) self.assertFalse(cb.linkedProjectColorName()) button.setActive(True) self.assertTrue(cb.isEnabled()) self.assertEqual(cb.linkedProjectColorName(), 'col1')
def testLinkedColorButton(self): definition = QgsPropertyDefinition( 'test', 'test', QgsPropertyDefinition.ColorWithAlpha) button = QgsPropertyOverrideButton() button.init(0, QgsProperty(), definition) cb = QgsColorButton() button.registerEnabledWidget(cb, False) # set button to a non color property button.setToProperty(QgsProperty.fromValue('#ff0000')) self.assertFalse(cb.isEnabled()) button.setActive(False) self.assertTrue(cb.isEnabled()) # set button to a color property button.setToProperty( QgsProperty.fromExpression( 'project_color(\'Cthulhu\'s delight\')')) self.assertFalse(cb.isEnabled()) button.setActive(False) self.assertTrue(cb.isEnabled()) # test with FlagDisableCheckedWidgetOnlyWhenProjectColorSet set button.setFlags(QgsPropertyOverrideButton. FlagDisableCheckedWidgetOnlyWhenProjectColorSet) button.setToProperty(QgsProperty.fromValue('#ff0000')) self.assertTrue(cb.isEnabled()) button.setActive(False) self.assertTrue(cb.isEnabled()) button.setToProperty( QgsProperty.fromExpression( 'project_color(\'Cthulhu\'s delight\')')) self.assertFalse(cb.isEnabled()) button.setActive(False) self.assertTrue(cb.isEnabled())
def setupUi(self): self.mainLayout = QVBoxLayout() self.mainLayout.setContentsMargins(0, 0, 0, 0) self.tab = QTabWidget() self.mainLayout.addWidget(self.tab) self.param_widget = QgsPanelWidgetStack() self.widget.setDockMode(True) self.param_widget.setMainPanel(self.widget) self.tab.addTab(self.param_widget, self.tr('Properties')) self.commentLayout = QVBoxLayout() self.commentEdit = QTextEdit() self.commentEdit.setAcceptRichText(False) self.commentLayout.addWidget(self.commentEdit, 1) hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) hl.addWidget(QLabel(self.tr('Color'))) self.comment_color_button = QgsColorButton() self.comment_color_button.setAllowOpacity(True) self.comment_color_button.setWindowTitle(self.tr('Comment Color')) self.comment_color_button.setShowNull(True, self.tr('Default')) hl.addWidget(self.comment_color_button) self.commentLayout.addLayout(hl) w2 = QWidget() w2.setLayout(self.commentLayout) self.tab.addTab(w2, self.tr('Comments')) self.setLayout(self.mainLayout)
def testLinkProjectColor(self): """ Test linking to a project color """ project_scheme = [s for s in QgsApplication.colorSchemeRegistry().schemes() if isinstance(s, QgsProjectColorScheme)][0] project_scheme.setColors([[QColor(255, 0, 0), 'col1'], [QColor(0, 255, 0), 'col2']]) button = QgsColorButton() spy = QSignalSpy(button.unlinked) button.setColor(QColor(0, 0, 255)) self.assertFalse(button.linkedProjectColorName()) button.linkToProjectColor('col1') self.assertEqual(button.linkedProjectColorName(), 'col1') self.assertEqual(button.color().name(), '#ff0000') self.assertEqual(len(spy), 0) button.unlink() self.assertFalse(button.linkedProjectColorName()) self.assertEqual(button.color().name(), '#0000ff') self.assertEqual(len(spy), 1) button.linkToProjectColor('col2') self.assertEqual(button.linkedProjectColorName(), 'col2') self.assertEqual(button.color().name(), '#00ff00') self.assertEqual(len(spy), 1) project_scheme.setColors([[QColor(255, 0, 0), 'xcol1'], [QColor(0, 255, 0), 'xcol2']]) # linked color no longer exists self.assertFalse(button.linkedProjectColorName()) self.assertEqual(button.color().name(), '#0000ff') self.assertEqual(len(spy), 2)
def testNulling(self): """ Test clearing colors to null """ # start with a valid color button = QgsColorButton() button.setAllowOpacity(True) button.setColor(QColor(255, 100, 200, 255)) self.assertEqual(button.color(), QColor(255, 100, 200, 255)) spy_changed = QSignalSpy(button.colorChanged) spy_cleared = QSignalSpy(button.cleared) button.setColor(QColor(50, 100, 200, 255)) self.assertEqual(button.color(), QColor(50, 100, 200, 255)) self.assertEqual(len(spy_changed), 1) self.assertEqual(len(spy_cleared), 0) # now set to null button.setToNull() self.assertEqual(button.color(), QColor()) self.assertEqual(len(spy_changed), 2) self.assertEqual(len(spy_cleared), 1) button.setToNull() self.assertEqual(button.color(), QColor()) # should not be refired, the color wasn't changed self.assertEqual(len(spy_changed), 2) # SHOULD be refired self.assertEqual(len(spy_cleared), 2)
def setWidget(self, widget): txt = self.options.get("dialogTitle", "") self.widget = QgsColorButton(widget, txt) if self.options.get("alpha", False): self.widget.setColorDialogOptions(QColorDialog.ShowAlphaChannel) self.signal = "colorChanged" # TODO: check if signal is working self.widgetSetMethod = self.widget.setColor self.widgetGetMethod = self.widget.color
def setupUi(self, Settings): Settings.setObjectName("Settings") Settings.resize(292, 223) self.gridLayout = QtWidgets.QGridLayout(Settings) self.gridLayout.setObjectName("gridLayout") self.label_2 = QtWidgets.QLabel(Settings) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 3, 0, 1, 1) self.label = QtWidgets.QLabel(Settings) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 4, 0, 1, 1) self.saveSelectionInProject = QtWidgets.QCheckBox(Settings) self.saveSelectionInProject.setChecked(True) self.saveSelectionInProject.setObjectName("saveSelectionInProject") self.gridLayout.addWidget(self.saveSelectionInProject, 1, 0, 1, 1) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 5, 0, 1, 1) self.rubberWidth = QtWidgets.QDoubleSpinBox(Settings) self.rubberWidth.setToolTip("") self.rubberWidth.setDecimals(1) self.rubberWidth.setSingleStep(1.0) self.rubberWidth.setProperty("value", 2.0) self.rubberWidth.setObjectName("rubberWidth") self.gridLayout.addWidget(self.rubberWidth, 3, 1, 1, 1) self.scale = QtWidgets.QSpinBox(Settings) self.scale.setMinimum(1) self.scale.setMaximum(15) self.scale.setProperty("value", 5) self.scale.setObjectName("scale") self.gridLayout.addWidget(self.scale, 2, 1, 1, 1) self.label_3 = QtWidgets.QLabel(Settings) self.label_3.setObjectName("label_3") self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1) self.buttonBox = QtWidgets.QDialogButtonBox(Settings) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.gridLayout.addWidget(self.buttonBox, 6, 0, 1, 2) self.label_4 = QtWidgets.QLabel(Settings) self.label_4.setObjectName("label_4") self.gridLayout.addWidget(self.label_4, 0, 0, 1, 1) self.dockArea = QtWidgets.QComboBox(Settings) self.dockArea.setObjectName("dockArea") self.dockArea.addItem("") self.dockArea.addItem("") self.gridLayout.addWidget(self.dockArea, 0, 1, 1, 1) self.rubberColor = QgsColorButton(Settings) self.rubberColor.setObjectName("rubberColor") self.gridLayout.addWidget(self.rubberColor, 4, 1, 1, 1) self.retranslateUi(Settings) self.buttonBox.accepted.connect(Settings.accept) self.buttonBox.rejected.connect(Settings.reject) QtCore.QMetaObject.connectSlotsByName(Settings)
def __init__(self, iface): self.iface = iface self.canvas = self.iface.mapCanvas() self.plugin_dir = os.path.dirname(__file__) self.uc = UserCommunication(iface, 'Serval') self.mode = 'probe' self.bands = None self.raster = None self.px, self.py = [0, 0] self.last_point = QgsPointXY(0, 0) self.undos = defaultdict(list) self.redos = defaultdict(list) self.qgis_project = QgsProject() self.menu = u'Serval' self.actions = [] self.toolbar = self.iface.addToolBar(u'Serval') self.toolbar.setObjectName(u'Serval') self.toolbar.setToolTip(u'Serval Toolbar') # Map tools self.probeTool = QgsMapToolEmitPoint(self.canvas) self.probeTool.setObjectName('ServalProbeTool') self.probeTool.setCursor( QCursor(QPixmap(icon_path('probe_tool.svg')), hotX=2, hotY=22)) self.probeTool.canvasClicked.connect(self.point_clicked) self.drawTool = QgsMapToolEmitPoint(self.canvas) self.drawTool.setObjectName('ServalDrawTool') self.drawTool.setCursor( QCursor(QPixmap(icon_path('draw_tool.svg')), hotX=2, hotY=22)) self.drawTool.canvasClicked.connect(self.point_clicked) self.gomTool = QgsMapToolEmitPoint(self.canvas) self.gomTool.setObjectName('ServalGomTool') self.gomTool.setCursor( QCursor(QPixmap(icon_path('gom_tool.svg')), hotX=5, hotY=19)) self.gomTool.canvasClicked.connect(self.point_clicked) self.mColorButton = QgsColorButton() icon1 = QIcon(icon_path('mIconColorBox.svg')) self.mColorButton.setIcon(icon1) self.mColorButton.setMinimumSize(QSize(40, 24)) self.mColorButton.setMaximumSize(QSize(40, 24)) self.mColorButton.colorChanged.connect(self.set_rgb_from_picker) self.b1SBox = BandSpinBox() self.b2SBox = BandSpinBox() self.b3SBox = BandSpinBox() self.sboxes = [self.b1SBox, self.b2SBox, self.b3SBox] for sb in self.sboxes: sb.user_hit_enter.connect(self.change_cell_value_key) self.iface.currentLayerChanged.connect(self.set_active_raster) self.qgis_project.layersAdded.connect(self.set_active_raster) self.canvas.mapToolSet.connect(self.check_active_tool)
def action_field_add(self): #self.bar.pushMessage("Trigger", "signal received", level=QgsMessageBar.INFO) field_expression_widget = QgsFieldExpressionWidget() field_expression_widget.setLayer(self.lyrCombobox.currentLayer()) color_btn_widget = QgsColorButton() spinbox = QtGui.QSpinBox() presetrow = PresetRow(qgsfieldexpressionwidget=field_expression_widget, qgscolorbutton=color_btn_widget, qspinbox=spinbox) self._preset_rows.add_preset(presetrow) self.redraw_fields()
def __init__(self, setting, widget, allow_alpha: bool = False, dialog_title: str = None): color_widget = QgsColorButton(widget) color_widget.setColorDialogTitle(dialog_title) signal = color_widget.colorChanged SettingWidget.__init__(self, setting, color_widget, signal) self.widget.setAllowOpacity(allow_alpha)
def copy(self): field_expression_widget = QgsFieldExpressionWidget() field_expression_widget.setLayer( self._qgsfieldexpressionwidget.layer()) field_expression_widget.setField( self._qgsfieldexpressionwidget.currentText()) color_btn_widget = QgsColorButton() color_btn_widget.setColor(self._qgscolorbutton.color()) spinbox = QtGui.QSpinBox() spinbox.setValue(self._qspinbox.value()) return PresetRow(field_expression_widget, color_btn_widget, spinbox)
def __init__(self, parent=None): super().__init__(parent) self.setupUi(self) self._background_color = QgsColorButton() self.mBackgroundLayout.addWidget(self._background_color) self._labels_color = QgsColorButton() self.mAxesLabelsLayout.addWidget(self._labels_color) self._axes_color = QgsColorButton() self.mAxesLayout.addWidget(self._axes_color) self._single_color = QgsColorButton() self.mSingleColorLayout.addWidget(self._single_color) self.mButtons.button(QtWidgets.QDialogButtonBox.Apply).clicked.connect( self.apply) self.mButtons.button( QtWidgets.QDialogButtonBox.Cancel).clicked.connect(self.cancel) self.read_settings()
def __init__(self, qgsfieldexpressionwidget=None, qgscolorbutton=None, qspinbox=None): self._qgsfieldexpressionwidget = qgsfieldexpressionwidget if qgsfieldexpressionwidget is None: self._qgsfieldexpressionwidget = QgsFieldExpressionWidget() self._qgscolorbutton = qgscolorbutton if qgscolorbutton is None: self._qgscolorbutton = QgsColorButton() self._qspinbox = qspinbox if qspinbox is None: self._qspinbox = QtGui.QSpinBox() self._last_feature = None
def testClearingColors(self): """ Test setting colors to transparent """ # start with a valid color button = QgsColorButton() button.setAllowOpacity(True) button.setColor(QColor(255, 100, 200, 255)) self.assertEqual(button.color(), QColor(255, 100, 200, 255)) # now set to no color button.setToNoColor() # ensure that only the alpha channel has changed - not the other color components self.assertEqual(button.color(), QColor(255, 100, 200, 0))
def setupUi(self, Dialog): qad_windowcolor_ui.Ui_WindowColor_Dialog.setupUi(self, self) # aggiungo il bottone di qgis QgsColorButton chiamato buttonColor # che eredita la posizione di Button_ColorDummy (che viene nascosto) self.Button_ColorDummy.setHidden(True) self.buttonColor = QgsColorButton(self.Button_ColorDummy.parent()) self.buttonColor.setGeometry(self.Button_ColorDummy.geometry()) self.buttonColor.setObjectName("buttonColor") self.buttonColor.colorChanged.connect(self.colorChanged) # aggiungo il QWidget chiamato QadPreview # che eredita la posizione di widget_Preview (che viene nascosto) self.widget_Preview.setHidden(True) self.preview = QadPreview(self.plugIn, self.widget_Preview.parent(), self.tempQadVariables, self.currentContext) self.preview.setGeometry(self.widget_Preview.geometry()) self.preview.setObjectName("preview")
def createEditor(self, parent: QWidget, option: QStyleOptionViewItem, index: QModelIndex) -> QWidget: """ Creates an editor widget for the given index. Derived function. :param parent: parent QWidget :param option: QStyleOptionViewItem :param index: model index for editor creation :return: QWidget which represents the editor for the given model index """ if index.isValid(): if index.column() in (0, 1): checkbox = QCheckBox(parent) checkbox.setFocusPolicy(Qt.StrongFocus) return checkbox if index.column() == 4: color_button = QgsColorButton(parent) color_button.setFocusPolicy(Qt.StrongFocus) return color_button return super().createEditor(parent, option, index)
def __init__(self, parent=None, value_field='', def_color='#2564e1', legend_name=''): QWidget.__init__(self, parent) self._value_field = value_field # Insert controls for editing fill color and legend names self.lbl_fill_color = QLabel(self) self.lbl_fill_color.setText( QApplication.translate("ValueConfigWidget", "Fill color")) self.fill_color_btn = QgsColorButton( self, QApplication.translate("ValueConfigWidget", "Select bar fill color")) self.fill_color_btn.setMaximumHeight(30) self.fill_color_btn.setMinimumHeight(30) self.fill_color_btn.setMinimumWidth(100) if QColor.isValidColor(def_color): default_color = QColor(def_color) self.fill_color_btn.setColor(default_color) self.lbl_legend_name = QLabel(self) self.lbl_legend_name.setText( QApplication.translate("ValueConfigWidget", "Legend name")) self.txt_legend_name = QLineEdit(self) self.txt_legend_name.setMaxLength(50) self.txt_legend_name.setMinimumHeight(30) self.txt_legend_name.setText(legend_name) self.layout = QGridLayout(self) self.layout.addWidget(self.lbl_fill_color, 0, 0, 1, 1) self.layout.addWidget(self.fill_color_btn, 0, 1, 1, 1) self.layout.addWidget(self.lbl_legend_name, 1, 0, 1, 1) self.layout.addWidget(self.txt_legend_name, 1, 1, 1, 1)
def setupUi(self, ScenePropertiesWidget): ScenePropertiesWidget.setObjectName("ScenePropertiesWidget") ScenePropertiesWidget.resize(385, 657) self.verticalLayout_3 = QtWidgets.QVBoxLayout(ScenePropertiesWidget) self.verticalLayout_3.setObjectName("verticalLayout_3") self.groupBox_1 = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox_1.setObjectName("groupBox_1") self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBox_1) self.gridLayout_4.setObjectName("gridLayout_4") self.lineEdit_BaseSize = QtWidgets.QLineEdit(self.groupBox_1) self.lineEdit_BaseSize.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) self.lineEdit_BaseSize.setObjectName("lineEdit_BaseSize") self.gridLayout_4.addWidget(self.lineEdit_BaseSize, 0, 1, 1, 2) self.label_2 = QtWidgets.QLabel(self.groupBox_1) self.label_2.setObjectName("label_2") self.gridLayout_4.addWidget(self.label_2, 2, 0, 1, 1) self.label_3 = QtWidgets.QLabel(self.groupBox_1) self.label_3.setObjectName("label_3") self.gridLayout_4.addWidget(self.label_3, 0, 0, 1, 1) self.checkBox_autoZShift = QtWidgets.QCheckBox(self.groupBox_1) self.checkBox_autoZShift.setObjectName("checkBox_autoZShift") self.gridLayout_4.addWidget(self.checkBox_autoZShift, 2, 2, 1, 1) self.lineEdit_zFactor = QtWidgets.QLineEdit(self.groupBox_1) self.lineEdit_zFactor.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.lineEdit_zFactor.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) self.lineEdit_zFactor.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.lineEdit_zFactor.setObjectName("lineEdit_zFactor") self.gridLayout_4.addWidget(self.lineEdit_zFactor, 1, 1, 1, 2) self.label = QtWidgets.QLabel(self.groupBox_1) self.label.setObjectName("label") self.gridLayout_4.addWidget(self.label, 1, 0, 1, 1) self.lineEdit_zShift = QtWidgets.QLineEdit(self.groupBox_1) self.lineEdit_zShift.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) self.lineEdit_zShift.setObjectName("lineEdit_zShift") self.gridLayout_4.addWidget(self.lineEdit_zShift, 2, 1, 1, 1) self.verticalLayout_3.addWidget(self.groupBox_1) self.groupBox_4 = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox_4.setObjectName("groupBox_4") self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBox_4) self.gridLayout_3.setObjectName("gridLayout_3") self.checkBox_FixAspectRatio = QtWidgets.QCheckBox(self.groupBox_4) self.checkBox_FixAspectRatio.setObjectName("checkBox_FixAspectRatio") self.gridLayout_3.addWidget(self.checkBox_FixAspectRatio, 4, 0, 1, 1) self.radioButton_FixedExtent = QtWidgets.QRadioButton(self.groupBox_4) self.radioButton_FixedExtent.setObjectName("radioButton_FixedExtent") self.gridLayout_3.addWidget(self.radioButton_FixedExtent, 1, 0, 1, 1) self.radioButton_UseCanvasExtent = QtWidgets.QRadioButton(self.groupBox_4) self.radioButton_UseCanvasExtent.setChecked(True) self.radioButton_UseCanvasExtent.setObjectName("radioButton_UseCanvasExtent") self.gridLayout_3.addWidget(self.radioButton_UseCanvasExtent, 0, 0, 1, 1) self.gridLayout_Extent = QtWidgets.QGridLayout() self.gridLayout_Extent.setObjectName("gridLayout_Extent") self.label_10 = QtWidgets.QLabel(self.groupBox_4) self.label_10.setObjectName("label_10") self.gridLayout_Extent.addWidget(self.label_10, 7, 0, 1, 1) self.label_7 = QtWidgets.QLabel(self.groupBox_4) self.label_7.setObjectName("label_7") self.gridLayout_Extent.addWidget(self.label_7, 4, 2, 1, 1) self.label_6 = QtWidgets.QLabel(self.groupBox_4) self.label_6.setObjectName("label_6") self.gridLayout_Extent.addWidget(self.label_6, 4, 0, 1, 1) self.lineEdit_CenterY = QtWidgets.QLineEdit(self.groupBox_4) self.lineEdit_CenterY.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) self.lineEdit_CenterY.setObjectName("lineEdit_CenterY") self.gridLayout_Extent.addWidget(self.lineEdit_CenterY, 1, 3, 1, 1) self.label_8 = QtWidgets.QLabel(self.groupBox_4) self.label_8.setObjectName("label_8") self.gridLayout_Extent.addWidget(self.label_8, 1, 2, 1, 1) self.label_5 = QtWidgets.QLabel(self.groupBox_4) self.label_5.setObjectName("label_5") self.gridLayout_Extent.addWidget(self.label_5, 1, 0, 1, 1) self.pushButton_SelectExtent = QtWidgets.QPushButton(self.groupBox_4) self.pushButton_SelectExtent.setObjectName("pushButton_SelectExtent") self.gridLayout_Extent.addWidget(self.pushButton_SelectExtent, 7, 3, 1, 1) self.lineEdit_Height = QtWidgets.QLineEdit(self.groupBox_4) self.lineEdit_Height.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) self.lineEdit_Height.setObjectName("lineEdit_Height") self.gridLayout_Extent.addWidget(self.lineEdit_Height, 4, 3, 1, 1) self.lineEdit_Width = QtWidgets.QLineEdit(self.groupBox_4) self.lineEdit_Width.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) self.lineEdit_Width.setObjectName("lineEdit_Width") self.gridLayout_Extent.addWidget(self.lineEdit_Width, 4, 1, 1, 1) self.lineEdit_Rotation = QtWidgets.QLineEdit(self.groupBox_4) self.lineEdit_Rotation.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) self.lineEdit_Rotation.setObjectName("lineEdit_Rotation") self.gridLayout_Extent.addWidget(self.lineEdit_Rotation, 7, 1, 1, 1) self.lineEdit_CenterX = QtWidgets.QLineEdit(self.groupBox_4) self.lineEdit_CenterX.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly|QtCore.Qt.ImhLowercaseOnly) self.lineEdit_CenterX.setObjectName("lineEdit_CenterX") self.gridLayout_Extent.addWidget(self.lineEdit_CenterX, 1, 1, 1, 1) self.gridLayout_3.addLayout(self.gridLayout_Extent, 3, 0, 1, 1) self.verticalLayout_3.addWidget(self.groupBox_4) self.groupBox = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox.setObjectName("groupBox") self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBox) self.gridLayout_5.setObjectName("gridLayout_5") self.label_4 = QtWidgets.QLabel(self.groupBox) self.label_4.setObjectName("label_4") self.gridLayout_5.addWidget(self.label_4, 0, 0, 1, 1) self.checkBox_Outline = QtWidgets.QCheckBox(self.groupBox) self.checkBox_Outline.setObjectName("checkBox_Outline") self.gridLayout_5.addWidget(self.checkBox_Outline, 1, 0, 1, 2) self.comboBox_MaterialType = QtWidgets.QComboBox(self.groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.comboBox_MaterialType.sizePolicy().hasHeightForWidth()) self.comboBox_MaterialType.setSizePolicy(sizePolicy) self.comboBox_MaterialType.setObjectName("comboBox_MaterialType") self.gridLayout_5.addWidget(self.comboBox_MaterialType, 0, 1, 1, 1) self.verticalLayout_3.addWidget(self.groupBox) self.groupBox_2 = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox_2.setObjectName("groupBox_2") self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_2) self.gridLayout_2.setObjectName("gridLayout_2") self.radioButton_Sky = QtWidgets.QRadioButton(self.groupBox_2) self.radioButton_Sky.setChecked(True) self.radioButton_Sky.setObjectName("radioButton_Sky") self.gridLayout_2.addWidget(self.radioButton_Sky, 0, 0, 1, 2) self.radioButton_Color = QtWidgets.QRadioButton(self.groupBox_2) self.radioButton_Color.setMinimumSize(QtCore.QSize(110, 0)) self.radioButton_Color.setObjectName("radioButton_Color") self.gridLayout_2.addWidget(self.radioButton_Color, 2, 0, 1, 1) self.colorButton_Color = QgsColorButton(self.groupBox_2) self.colorButton_Color.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.colorButton_Color.sizePolicy().hasHeightForWidth()) self.colorButton_Color.setSizePolicy(sizePolicy) self.colorButton_Color.setObjectName("colorButton_Color") self.gridLayout_2.addWidget(self.colorButton_Color, 2, 1, 1, 1) self.verticalLayout_3.addWidget(self.groupBox_2) self.groupBox_3 = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox_3.setObjectName("groupBox_3") self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox_3) self.verticalLayout.setObjectName("verticalLayout") self.radioButton_ProjectCRS = QtWidgets.QRadioButton(self.groupBox_3) self.radioButton_ProjectCRS.setChecked(True) self.radioButton_ProjectCRS.setObjectName("radioButton_ProjectCRS") self.verticalLayout.addWidget(self.radioButton_ProjectCRS) self.radioButton_WGS84 = QtWidgets.QRadioButton(self.groupBox_3) self.radioButton_WGS84.setObjectName("radioButton_WGS84") self.verticalLayout.addWidget(self.radioButton_WGS84) self.verticalLayout_3.addWidget(self.groupBox_3) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem) self.retranslateUi(ScenePropertiesWidget) self.radioButton_Color.toggled['bool'].connect(self.colorButton_Color.setEnabled) QtCore.QMetaObject.connectSlotsByName(ScenePropertiesWidget) ScenePropertiesWidget.setTabOrder(self.lineEdit_BaseSize, self.lineEdit_zFactor) ScenePropertiesWidget.setTabOrder(self.lineEdit_zFactor, self.lineEdit_zShift) ScenePropertiesWidget.setTabOrder(self.lineEdit_zShift, self.checkBox_autoZShift) ScenePropertiesWidget.setTabOrder(self.checkBox_autoZShift, self.radioButton_UseCanvasExtent) ScenePropertiesWidget.setTabOrder(self.radioButton_UseCanvasExtent, self.radioButton_FixedExtent) ScenePropertiesWidget.setTabOrder(self.radioButton_FixedExtent, self.lineEdit_CenterX) ScenePropertiesWidget.setTabOrder(self.lineEdit_CenterX, self.lineEdit_CenterY) ScenePropertiesWidget.setTabOrder(self.lineEdit_CenterY, self.lineEdit_Width) ScenePropertiesWidget.setTabOrder(self.lineEdit_Width, self.lineEdit_Height) ScenePropertiesWidget.setTabOrder(self.lineEdit_Height, self.lineEdit_Rotation) ScenePropertiesWidget.setTabOrder(self.lineEdit_Rotation, self.pushButton_SelectExtent) ScenePropertiesWidget.setTabOrder(self.pushButton_SelectExtent, self.checkBox_FixAspectRatio) ScenePropertiesWidget.setTabOrder(self.checkBox_FixAspectRatio, self.comboBox_MaterialType) ScenePropertiesWidget.setTabOrder(self.comboBox_MaterialType, self.checkBox_Outline) ScenePropertiesWidget.setTabOrder(self.checkBox_Outline, self.radioButton_Sky) ScenePropertiesWidget.setTabOrder(self.radioButton_Sky, self.radioButton_Color) ScenePropertiesWidget.setTabOrder(self.radioButton_Color, self.colorButton_Color) ScenePropertiesWidget.setTabOrder(self.colorButton_Color, self.radioButton_ProjectCRS) ScenePropertiesWidget.setTabOrder(self.radioButton_ProjectCRS, self.radioButton_WGS84)
def setupUi(self, ScenePropertiesWidget): ScenePropertiesWidget.setObjectName("ScenePropertiesWidget") ScenePropertiesWidget.resize(328, 411) self.verticalLayout_3 = QtWidgets.QVBoxLayout(ScenePropertiesWidget) self.verticalLayout_3.setObjectName("verticalLayout_3") self.groupBox_1 = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox_1.setObjectName("groupBox_1") self.formLayout_3 = QtWidgets.QFormLayout(self.groupBox_1) self.formLayout_3.setObjectName("formLayout_3") self.label_3 = QtWidgets.QLabel(self.groupBox_1) self.label_3.setObjectName("label_3") self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_3) self.lineEdit_BaseSize = QtWidgets.QLineEdit(self.groupBox_1) self.lineEdit_BaseSize.setInputMethodHints(QtCore.Qt.ImhDigitsOnly) self.lineEdit_BaseSize.setObjectName("lineEdit_BaseSize") self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.lineEdit_BaseSize) self.label = QtWidgets.QLabel(self.groupBox_1) self.label.setObjectName("label") self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label) self.lineEdit_zFactor = QtWidgets.QLineEdit(self.groupBox_1) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lineEdit_zFactor.sizePolicy().hasHeightForWidth()) self.lineEdit_zFactor.setSizePolicy(sizePolicy) self.lineEdit_zFactor.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.lineEdit_zFactor.setInputMethodHints(QtCore.Qt.ImhDigitsOnly) self.lineEdit_zFactor.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.lineEdit_zFactor.setObjectName("lineEdit_zFactor") self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEdit_zFactor) self.label_2 = QtWidgets.QLabel(self.groupBox_1) self.label_2.setObjectName("label_2") self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_2) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.lineEdit_zShift = QtWidgets.QLineEdit(self.groupBox_1) self.lineEdit_zShift.setObjectName("lineEdit_zShift") self.horizontalLayout.addWidget(self.lineEdit_zShift) self.checkBox_autoZShift = QtWidgets.QCheckBox(self.groupBox_1) self.checkBox_autoZShift.setObjectName("checkBox_autoZShift") self.horizontalLayout.addWidget(self.checkBox_autoZShift) self.formLayout_3.setLayout(2, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout) self.verticalLayout_3.addWidget(self.groupBox_1) self.groupBox = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox.setObjectName("groupBox") self.formLayout = QtWidgets.QFormLayout(self.groupBox) self.formLayout.setObjectName("formLayout") self.label_4 = QtWidgets.QLabel(self.groupBox) self.label_4.setObjectName("label_4") self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_4) self.comboBox_MaterialType = QtWidgets.QComboBox(self.groupBox) self.comboBox_MaterialType.setObjectName("comboBox_MaterialType") self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.comboBox_MaterialType) self.verticalLayout_3.addWidget(self.groupBox) self.groupBox_2 = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox_2.setObjectName("groupBox_2") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox_2) self.verticalLayout_2.setObjectName("verticalLayout_2") self.radioButton_Sky = QtWidgets.QRadioButton(self.groupBox_2) self.radioButton_Sky.setChecked(True) self.radioButton_Sky.setObjectName("radioButton_Sky") self.verticalLayout_2.addWidget(self.radioButton_Sky) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.radioButton_Color = QtWidgets.QRadioButton(self.groupBox_2) self.radioButton_Color.setMinimumSize(QtCore.QSize(110, 0)) self.radioButton_Color.setObjectName("radioButton_Color") self.horizontalLayout_2.addWidget(self.radioButton_Color) self.colorButton_Color = QgsColorButton(self.groupBox_2) self.colorButton_Color.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.colorButton_Color.sizePolicy().hasHeightForWidth()) self.colorButton_Color.setSizePolicy(sizePolicy) self.colorButton_Color.setObjectName("colorButton_Color") self.horizontalLayout_2.addWidget(self.colorButton_Color) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.verticalLayout_3.addWidget(self.groupBox_2) self.groupBox_3 = QtWidgets.QGroupBox(ScenePropertiesWidget) self.groupBox_3.setObjectName("groupBox_3") self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox_3) self.verticalLayout.setObjectName("verticalLayout") self.radioButton_ProjectCRS = QtWidgets.QRadioButton(self.groupBox_3) self.radioButton_ProjectCRS.setChecked(True) self.radioButton_ProjectCRS.setObjectName("radioButton_ProjectCRS") self.verticalLayout.addWidget(self.radioButton_ProjectCRS) self.radioButton_WGS84 = QtWidgets.QRadioButton(self.groupBox_3) self.radioButton_WGS84.setObjectName("radioButton_WGS84") self.verticalLayout.addWidget(self.radioButton_WGS84) self.verticalLayout_3.addWidget(self.groupBox_3) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem) self.retranslateUi(ScenePropertiesWidget) self.radioButton_Color.toggled['bool'].connect(self.colorButton_Color.setEnabled) QtCore.QMetaObject.connectSlotsByName(ScenePropertiesWidget) ScenePropertiesWidget.setTabOrder(self.lineEdit_BaseSize, self.lineEdit_zFactor) ScenePropertiesWidget.setTabOrder(self.lineEdit_zFactor, self.lineEdit_zShift) ScenePropertiesWidget.setTabOrder(self.lineEdit_zShift, self.checkBox_autoZShift) ScenePropertiesWidget.setTabOrder(self.checkBox_autoZShift, self.comboBox_MaterialType) ScenePropertiesWidget.setTabOrder(self.comboBox_MaterialType, self.radioButton_Sky) ScenePropertiesWidget.setTabOrder(self.radioButton_Sky, self.radioButton_Color) ScenePropertiesWidget.setTabOrder(self.radioButton_Color, self.colorButton_Color) ScenePropertiesWidget.setTabOrder(self.colorButton_Color, self.radioButton_ProjectCRS) ScenePropertiesWidget.setTabOrder(self.radioButton_ProjectCRS, self.radioButton_WGS84)
def __init__(self, dFigureParams, parent=None): super(SaveFigureDlg, self).__init__(parent) self.dFigureParams = dFigureParams layout = QVBoxLayout() # output format settings grpFormatSettings = QGroupBox("Output format") lytFormatSettings = QGridLayout() # format lytFormatSettings.addWidget(QLabel("File format"), 0, 0, 1, 1) self.cmbFileFormat = QComboBox() self.cmbFileFormat.insertItems(0, ltFileFormats) sFileFormat = self.dPlotStyles["file_format"] iCurrFileFrmtNdx = ltFileFormats.index( sFileFormat) if sFileFormat in ltFileFormats else 0 self.cmbFileFormat.setCurrentIndex(iCurrFileFrmtNdx) lytFormatSettings.addWidget(self.cmbFileFormat, 0, 1, 1, 1) # dpi (for rasters) lytFormatSettings.addWidget(QLabel("Dpi (for rasters"), 1, 0, 1, 1) self.cmbDpiResolution = QComboBox() self.cmbDpiResolution.insertItems(0, liDpiResolutions) iCurrDpiResolution = self.dPlotStyles["dpi_resolution"] iCurrDpiResolNdx = ltFileFormats.index( iCurrDpiResolution) if iCurrDpiResolution in ltFileFormats else 0 self.cmbDpiResolution.setCurrentIndex(iCurrDpiResolNdx) lytFormatSettings.addWidget(self.cmbDpiResolution, 1, 1, 1, 1) # set/add to layout grpFormatSettings.setLayout(lytFormatSettings) layout.addWidget(grpFormatSettings) # output file path grpPoles = QGroupBox("Poles") lytPoles = QGridLayout() # marker color lytPoles.addWidget(QLabel("Marker color"), 0, 0, 1, 1) self.btnPointColor = QgsColorButton() point_color = self.dPlotStyles["marker_color"] self.btnPointColor.setColor(QColor(point_color)) lytPoles.addWidget(self.btnPointColor, 0, 1, 1, 1) # marker style lytPoles.addWidget(QLabel("Marker style"), 0, 2, 1, 1) self.cmbPointStyle = QComboBox() self.cmbPointStyle.insertItems(0, list(ltMarkerStyles.keys())) point_style = self.dPlotStyles["marker_style"] point_style_ndx = list( ltMarkerStyles.keys()).index(point_style) if point_style in list( ltMarkerStyles.keys()) else 0 self.cmbPointStyle.setCurrentIndex(point_style_ndx) lytPoles.addWidget(self.cmbPointStyle, 0, 3, 1, 1) # marker size lytPoles.addWidget(QLabel("Marker size"), 1, 0, 1, 1) lnPointSizes = [2, 4, 6, 8, 10, 15, 20] self.cmbPointSize = QComboBox() ltPointSizeVals = [str(val) + " pt(s)" for val in lnPointSizes] self.cmbPointSize.insertItems(0, ltPointSizeVals) point_size = self.dPlotStyles["marker_size"] point_style_ndx = ltPointSizeVals.index( point_size) if point_size in ltPointSizeVals else 2 self.cmbPointSize.setCurrentIndex(point_style_ndx) lytPoles.addWidget(self.cmbPointSize, 1, 1, 1, 1) # marker transparency lytPoles.addWidget(QLabel("Marker transp."), 1, 2, 1, 1) lnPointTransparencies = [0, 25, 50, 75] self.cmbPointTransp = QComboBox() ltPointTranspPrcntVals = [ str(val) + "%" for val in lnPointTransparencies ] self.cmbPointTransp.insertItems(0, ltPointTranspPrcntVals) point_transp = self.dPlotStyles["marker_transp"] point_transp_ndx = ltPointTranspPrcntVals.index( point_transp) if point_transp in ltPointTranspPrcntVals else 0 self.cmbPointTransp.setCurrentIndex(point_transp_ndx) lytPoles.addWidget(self.cmbPointTransp, 1, 3, 1, 1) # set/add to layout grpPoles.setLayout(lytPoles) layout.addWidget(grpPoles) # ok/cancel stuff btnOk = QPushButton("&OK") btnCancel = QPushButton("Cancel") lytButtons = QHBoxLayout() lytButtons.addStretch() lytButtons.addWidget(btnOk) lytButtons.addWidget(btnCancel) layout.addLayout(lytButtons) btnOk.clicked.connect(self.accept) btnCancel.clicked.connect(self.reject) self.setLayout(layout) self.setWindowTitle("Plot style")
def __init__(self, dPlotStyles, parent=None): super(PlotStyleDlg, self).__init__(parent) self.dPlotStyles = dPlotStyles settings = QSettings("alberese", "geocouche") layout = QVBoxLayout() # great circle settings grpGreatCircles = QGroupBox("Great circles") lytGreatCircles = QGridLayout() # line color lytGreatCircles.addWidget(QLabel("Line color"), 0, 0, 1, 1) self.btnLineColor = QgsColorButton() line_color = self.dPlotStyles["line_color"] self.btnLineColor.setColor(QColor(line_color)) lytGreatCircles.addWidget(self.btnLineColor, 0, 1, 1, 1) # line style lytGreatCircles.addWidget(QLabel("Line style"), 0, 2, 1, 1) self.cmbLineStyle = QComboBox() self.cmbLineStyle.insertItems(0, ltLineStyles) line_style = self.dPlotStyles["line_style"] line_style_ndx = ltLineStyles.index( line_style) if line_style in ltLineStyles else 0 self.cmbLineStyle.setCurrentIndex(line_style_ndx) lytGreatCircles.addWidget(self.cmbLineStyle, 0, 3, 1, 1) # line thickness lytGreatCircles.addWidget(QLabel("Line width"), 1, 0, 1, 1) self.cmbLineWidth = QComboBox() lnLineThickness = [1, 2, 3, 4, 5, 6] ltLineThicknVals = [str(val) + " pt(s)" for val in lnLineThickness] self.cmbLineWidth.insertItems(0, ltLineThicknVals) line_thickn = self.dPlotStyles["line_width"] line_thickn_ndx = ltLineThicknVals.index( line_thickn) if line_thickn in ltLineThicknVals else 0 self.cmbLineWidth.setCurrentIndex(line_thickn_ndx) lytGreatCircles.addWidget(self.cmbLineWidth, 1, 1, 1, 1) # line transparency lytGreatCircles.addWidget(QLabel("Line transp."), 1, 2, 1, 1) self.cmbLineTransp = QComboBox() lnLineTransparencies = [0, 25, 50, 75] ltLineTranspPrcntVals = [ str(val) + "%" for val in lnLineTransparencies ] self.cmbLineTransp.insertItems(0, ltLineTranspPrcntVals) line_transp = self.dPlotStyles["line_transp"] line_transp_ndx = ltLineTranspPrcntVals.index( line_transp) if line_transp in ltLineTranspPrcntVals else 0 self.cmbLineTransp.setCurrentIndex(line_transp_ndx) lytGreatCircles.addWidget(self.cmbLineTransp, 1, 3, 1, 1) # set/add to layout grpGreatCircles.setLayout(lytGreatCircles) layout.addWidget(grpGreatCircles) # pole settings grpPoles = QGroupBox("Poles") lytPoles = QGridLayout() # marker color lytPoles.addWidget(QLabel("Marker color"), 0, 0, 1, 1) self.btnPointColor = QgsColorButton() point_color = self.dPlotStyles["marker_color"] self.btnPointColor.setColor(QColor(point_color)) lytPoles.addWidget(self.btnPointColor, 0, 1, 1, 1) # marker style lytPoles.addWidget(QLabel("Marker style"), 0, 2, 1, 1) self.cmbPointStyle = QComboBox() self.cmbPointStyle.insertItems(0, list(ltMarkerStyles.keys())) point_style = self.dPlotStyles["marker_style"] point_style_ndx = list( ltMarkerStyles.keys()).index(point_style) if point_style in list( ltMarkerStyles.keys()) else 0 self.cmbPointStyle.setCurrentIndex(point_style_ndx) lytPoles.addWidget(self.cmbPointStyle, 0, 3, 1, 1) # marker size lytPoles.addWidget(QLabel("Marker size"), 1, 0, 1, 1) lnPointSizes = [2, 4, 6, 8, 10, 15, 20] self.cmbPointSize = QComboBox() ltPointSizeVals = [str(val) + " pt(s)" for val in lnPointSizes] self.cmbPointSize.insertItems(0, ltPointSizeVals) point_size = self.dPlotStyles["marker_size"] point_style_ndx = ltPointSizeVals.index( point_size) if point_size in ltPointSizeVals else 2 self.cmbPointSize.setCurrentIndex(point_style_ndx) lytPoles.addWidget(self.cmbPointSize, 1, 1, 1, 1) # marker transparency lytPoles.addWidget(QLabel("Marker transp."), 1, 2, 1, 1) lnPointTransparencies = [0, 25, 50, 75] self.cmbPointTransp = QComboBox() ltPointTranspPrcntVals = [ str(val) + "%" for val in lnPointTransparencies ] self.cmbPointTransp.insertItems(0, ltPointTranspPrcntVals) point_transp = self.dPlotStyles["marker_transp"] point_transp_ndx = ltPointTranspPrcntVals.index( point_transp) if point_transp in ltPointTranspPrcntVals else 0 self.cmbPointTransp.setCurrentIndex(point_transp_ndx) lytPoles.addWidget(self.cmbPointTransp, 1, 3, 1, 1) # set/add to layout grpPoles.setLayout(lytPoles) layout.addWidget(grpPoles) # ok/cancel stuff btnOk = QPushButton("&OK") btnCancel = QPushButton("Cancel") lytButtons = QHBoxLayout() lytButtons.addStretch() lytButtons.addWidget(btnOk) lytButtons.addWidget(btnCancel) layout.addLayout(lytButtons) btnOk.clicked.connect(self.accept) btnCancel.clicked.connect(self.reject) self.setLayout(layout) self.setWindowTitle("Plot style")
def setupUi(self, DEMPropertiesWidget): DEMPropertiesWidget.setObjectName("DEMPropertiesWidget") DEMPropertiesWidget.resize(335, 533) self.verticalLayout_2 = QtWidgets.QVBoxLayout(DEMPropertiesWidget) self.verticalLayout_2.setObjectName("verticalLayout_2") self.groupBox_Geometry = QtWidgets.QGroupBox(DEMPropertiesWidget) self.groupBox_Geometry.setObjectName("groupBox_Geometry") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.groupBox_Geometry) self.verticalLayout_6.setContentsMargins(-1, 6, -1, 6) self.verticalLayout_6.setObjectName("verticalLayout_6") self.horizontalLayout_Resampling = QtWidgets.QHBoxLayout() self.horizontalLayout_Resampling.setObjectName( "horizontalLayout_Resampling") self.label_Resampling = QtWidgets.QLabel(self.groupBox_Geometry) self.label_Resampling.setObjectName("label_Resampling") self.horizontalLayout_Resampling.addWidget(self.label_Resampling) self.horizontalSlider_DEMSize = QtWidgets.QSlider( self.groupBox_Geometry) self.horizontalSlider_DEMSize.setEnabled(True) self.horizontalSlider_DEMSize.setMinimum(1) self.horizontalSlider_DEMSize.setMaximum(6) self.horizontalSlider_DEMSize.setSingleStep(1) self.horizontalSlider_DEMSize.setPageStep(1) self.horizontalSlider_DEMSize.setProperty("value", 2) self.horizontalSlider_DEMSize.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider_DEMSize.setTickPosition( QtWidgets.QSlider.TicksBelow) self.horizontalSlider_DEMSize.setTickInterval(1) self.horizontalSlider_DEMSize.setObjectName("horizontalSlider_DEMSize") self.horizontalLayout_Resampling.addWidget( self.horizontalSlider_DEMSize) self.label_ResamplingLevel = QtWidgets.QLabel(self.groupBox_Geometry) self.label_ResamplingLevel.setMinimumSize(QtCore.QSize(10, 0)) self.label_ResamplingLevel.setObjectName("label_ResamplingLevel") self.horizontalLayout_Resampling.addWidget(self.label_ResamplingLevel) self.verticalLayout_6.addLayout(self.horizontalLayout_Resampling) self.verticalLayout_Surroundings = QtWidgets.QVBoxLayout() self.verticalLayout_Surroundings.setObjectName( "verticalLayout_Surroundings") self.checkBox_Surroundings = QtWidgets.QCheckBox( self.groupBox_Geometry) self.checkBox_Surroundings.setObjectName("checkBox_Surroundings") self.verticalLayout_Surroundings.addWidget(self.checkBox_Surroundings) self.gridLayout_Surroundings = QtWidgets.QGridLayout() self.gridLayout_Surroundings.setObjectName("gridLayout_Surroundings") self.label_3 = QtWidgets.QLabel(self.groupBox_Geometry) self.label_3.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_3.setObjectName("label_3") self.gridLayout_Surroundings.addWidget(self.label_3, 0, 2, 1, 1) self.spinBox_Roughening = QtWidgets.QSpinBox(self.groupBox_Geometry) self.spinBox_Roughening.setMinimumSize(QtCore.QSize(70, 0)) self.spinBox_Roughening.setMaximum(64) self.spinBox_Roughening.setProperty("value", 1) self.spinBox_Roughening.setObjectName("spinBox_Roughening") self.gridLayout_Surroundings.addWidget(self.spinBox_Roughening, 0, 3, 1, 1) self.spinBox_Size = QtWidgets.QSpinBox(self.groupBox_Geometry) self.spinBox_Size.setMinimumSize(QtCore.QSize(70, 0)) self.spinBox_Size.setMinimum(3) self.spinBox_Size.setMaximum(9) self.spinBox_Size.setSingleStep(2) self.spinBox_Size.setProperty("value", 3) self.spinBox_Size.setObjectName("spinBox_Size") self.gridLayout_Surroundings.addWidget(self.spinBox_Size, 0, 1, 1, 1) self.label_2 = QtWidgets.QLabel(self.groupBox_Geometry) self.label_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_2.setObjectName("label_2") self.gridLayout_Surroundings.addWidget(self.label_2, 0, 0, 1, 1) self.verticalLayout_Surroundings.addLayout( self.gridLayout_Surroundings) self.verticalLayout_6.addLayout(self.verticalLayout_Surroundings) self.verticalLayout_Clip = QtWidgets.QVBoxLayout() self.verticalLayout_Clip.setObjectName("verticalLayout_Clip") self.checkBox_Clip = QtWidgets.QCheckBox(self.groupBox_Geometry) self.checkBox_Clip.setObjectName("checkBox_Clip") self.verticalLayout_Clip.addWidget(self.checkBox_Clip) self.comboBox_ClipLayer = QtWidgets.QComboBox(self.groupBox_Geometry) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.comboBox_ClipLayer.sizePolicy().hasHeightForWidth()) self.comboBox_ClipLayer.setSizePolicy(sizePolicy) self.comboBox_ClipLayer.setMaximumSize(QtCore.QSize(220, 16777215)) self.comboBox_ClipLayer.setObjectName("comboBox_ClipLayer") self.verticalLayout_Clip.addWidget(self.comboBox_ClipLayer) self.verticalLayout_6.addLayout(self.verticalLayout_Clip) self.verticalLayout_2.addWidget(self.groupBox_Geometry) self.groupBox_Material = QtWidgets.QGroupBox(DEMPropertiesWidget) self.groupBox_Material.setObjectName("groupBox_Material") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.groupBox_Material) self.verticalLayout_4.setContentsMargins(-1, 6, -1, 6) self.verticalLayout_4.setObjectName("verticalLayout_4") self.label_5 = QtWidgets.QLabel(self.groupBox_Material) self.label_5.setObjectName("label_5") self.verticalLayout_4.addWidget(self.label_5) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setSpacing(4) self.verticalLayout.setObjectName("verticalLayout") self.radioButton_MapCanvas = QtWidgets.QRadioButton( self.groupBox_Material) self.radioButton_MapCanvas.setChecked(True) self.radioButton_MapCanvas.setObjectName("radioButton_MapCanvas") self.verticalLayout.addWidget(self.radioButton_MapCanvas) self.horizontalLayout_5 = QtWidgets.QHBoxLayout() self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.radioButton_LayerImage = QtWidgets.QRadioButton( self.groupBox_Material) self.radioButton_LayerImage.setObjectName("radioButton_LayerImage") self.horizontalLayout_5.addWidget(self.radioButton_LayerImage) self.label_LayerImage = QtWidgets.QLabel(self.groupBox_Material) self.label_LayerImage.setEnabled(False) self.label_LayerImage.setText("") self.label_LayerImage.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_LayerImage.setObjectName("label_LayerImage") self.horizontalLayout_5.addWidget(self.label_LayerImage) self.toolButton_SelectLayer = QtWidgets.QToolButton( self.groupBox_Material) self.toolButton_SelectLayer.setEnabled(False) self.toolButton_SelectLayer.setObjectName("toolButton_SelectLayer") self.horizontalLayout_5.addWidget(self.toolButton_SelectLayer) self.verticalLayout.addLayout(self.horizontalLayout_5) self.horizontalLayout_ImageFile = QtWidgets.QHBoxLayout() self.horizontalLayout_ImageFile.setObjectName( "horizontalLayout_ImageFile") self.radioButton_ImageFile = QtWidgets.QRadioButton( self.groupBox_Material) self.radioButton_ImageFile.setEnabled(True) self.radioButton_ImageFile.setObjectName("radioButton_ImageFile") self.horizontalLayout_ImageFile.addWidget(self.radioButton_ImageFile) self.lineEdit_ImageFile = QtWidgets.QLineEdit(self.groupBox_Material) self.lineEdit_ImageFile.setEnabled(False) self.lineEdit_ImageFile.setObjectName("lineEdit_ImageFile") self.horizontalLayout_ImageFile.addWidget(self.lineEdit_ImageFile) self.toolButton_ImageFile = QtWidgets.QToolButton( self.groupBox_Material) self.toolButton_ImageFile.setEnabled(False) self.toolButton_ImageFile.setObjectName("toolButton_ImageFile") self.horizontalLayout_ImageFile.addWidget(self.toolButton_ImageFile) self.verticalLayout.addLayout(self.horizontalLayout_ImageFile) self.horizontalLayout_7 = QtWidgets.QHBoxLayout() self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.radioButton_SolidColor = QtWidgets.QRadioButton( self.groupBox_Material) self.radioButton_SolidColor.setObjectName("radioButton_SolidColor") self.horizontalLayout_7.addWidget(self.radioButton_SolidColor) self.colorButton_Color = QgsColorButton(self.groupBox_Material) self.colorButton_Color.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.colorButton_Color.sizePolicy().hasHeightForWidth()) self.colorButton_Color.setSizePolicy(sizePolicy) self.colorButton_Color.setObjectName("colorButton_Color") self.horizontalLayout_7.addWidget(self.colorButton_Color) self.verticalLayout.addLayout(self.horizontalLayout_7) self.verticalLayout_4.addLayout(self.verticalLayout) self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.horizontalSlider_Opacity = QtWidgets.QSlider( self.groupBox_Material) self.horizontalSlider_Opacity.setMaximum(100) self.horizontalSlider_Opacity.setProperty("value", 100) self.horizontalSlider_Opacity.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider_Opacity.setObjectName("horizontalSlider_Opacity") self.gridLayout.addWidget(self.horizontalSlider_Opacity, 2, 2, 1, 1) self.label_17 = QtWidgets.QLabel(self.groupBox_Material) self.label_17.setObjectName("label_17") self.gridLayout.addWidget(self.label_17, 2, 0, 1, 1) self.label_TextureSize = QtWidgets.QLabel(self.groupBox_Material) self.label_TextureSize.setObjectName("label_TextureSize") self.gridLayout.addWidget(self.label_TextureSize, 0, 0, 1, 1) self.spinBox_Opacity = QtWidgets.QSpinBox(self.groupBox_Material) self.spinBox_Opacity.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.spinBox_Opacity.sizePolicy().hasHeightForWidth()) self.spinBox_Opacity.setSizePolicy(sizePolicy) self.spinBox_Opacity.setPrefix("") self.spinBox_Opacity.setMinimum(0) self.spinBox_Opacity.setMaximum(100) self.spinBox_Opacity.setSingleStep(1) self.spinBox_Opacity.setProperty("value", 100) self.spinBox_Opacity.setObjectName("spinBox_Opacity") self.gridLayout.addWidget(self.spinBox_Opacity, 2, 3, 1, 1) self.comboBox_TextureSize = QtWidgets.QComboBox(self.groupBox_Material) self.comboBox_TextureSize.setObjectName("comboBox_TextureSize") self.gridLayout.addWidget(self.comboBox_TextureSize, 0, 1, 1, 3) self.verticalLayout_4.addLayout(self.gridLayout) self.checkBox_TransparentBackground = QtWidgets.QCheckBox( self.groupBox_Material) self.checkBox_TransparentBackground.setObjectName( "checkBox_TransparentBackground") self.verticalLayout_4.addWidget(self.checkBox_TransparentBackground) self.checkBox_Shading = QtWidgets.QCheckBox(self.groupBox_Material) self.checkBox_Shading.setChecked(True) self.checkBox_Shading.setObjectName("checkBox_Shading") self.verticalLayout_4.addWidget(self.checkBox_Shading) self.verticalLayout_2.addWidget(self.groupBox_Material) self.groupBox_Others = QtWidgets.QGroupBox(DEMPropertiesWidget) self.groupBox_Others.setObjectName("groupBox_Others") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.groupBox_Others) self.verticalLayout_5.setContentsMargins(-1, 6, -1, 6) self.verticalLayout_5.setObjectName("verticalLayout_5") self.checkBox_Sides = QtWidgets.QCheckBox(self.groupBox_Others) self.checkBox_Sides.setChecked(True) self.checkBox_Sides.setObjectName("checkBox_Sides") self.verticalLayout_5.addWidget(self.checkBox_Sides) self.checkBox_Frame = QtWidgets.QCheckBox(self.groupBox_Others) self.checkBox_Frame.setObjectName("checkBox_Frame") self.verticalLayout_5.addWidget(self.checkBox_Frame) self.checkBox_Visible = QtWidgets.QCheckBox(self.groupBox_Others) self.checkBox_Visible.setChecked(True) self.checkBox_Visible.setObjectName("checkBox_Visible") self.verticalLayout_5.addWidget(self.checkBox_Visible) self.verticalLayout_2.addWidget(self.groupBox_Others) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem) self.retranslateUi(DEMPropertiesWidget) self.checkBox_Clip.toggled['bool'].connect( self.comboBox_ClipLayer.setVisible) self.radioButton_LayerImage.toggled['bool'].connect( self.label_LayerImage.setEnabled) self.radioButton_LayerImage.toggled['bool'].connect( self.toolButton_SelectLayer.setEnabled) self.radioButton_ImageFile.toggled['bool'].connect( self.lineEdit_ImageFile.setEnabled) self.radioButton_ImageFile.toggled['bool'].connect( self.toolButton_ImageFile.setEnabled) self.checkBox_Clip.toggled['bool'].connect( self.checkBox_Frame.setDisabled) self.horizontalSlider_DEMSize.valueChanged['int'].connect( self.label_ResamplingLevel.setNum) self.horizontalSlider_Opacity.valueChanged['int'].connect( self.spinBox_Opacity.setValue) self.spinBox_Opacity.valueChanged['int'].connect( self.horizontalSlider_Opacity.setValue) self.radioButton_SolidColor.toggled['bool'].connect( self.colorButton_Color.setEnabled) QtCore.QMetaObject.connectSlotsByName(DEMPropertiesWidget) DEMPropertiesWidget.setTabOrder(self.horizontalSlider_DEMSize, self.checkBox_Surroundings) DEMPropertiesWidget.setTabOrder(self.checkBox_Surroundings, self.spinBox_Size) DEMPropertiesWidget.setTabOrder(self.spinBox_Size, self.spinBox_Roughening) DEMPropertiesWidget.setTabOrder(self.spinBox_Roughening, self.checkBox_Clip) DEMPropertiesWidget.setTabOrder(self.checkBox_Clip, self.comboBox_ClipLayer) DEMPropertiesWidget.setTabOrder(self.comboBox_ClipLayer, self.radioButton_MapCanvas) DEMPropertiesWidget.setTabOrder(self.radioButton_MapCanvas, self.radioButton_LayerImage) DEMPropertiesWidget.setTabOrder(self.radioButton_LayerImage, self.toolButton_SelectLayer) DEMPropertiesWidget.setTabOrder(self.toolButton_SelectLayer, self.radioButton_ImageFile) DEMPropertiesWidget.setTabOrder(self.radioButton_ImageFile, self.lineEdit_ImageFile) DEMPropertiesWidget.setTabOrder(self.lineEdit_ImageFile, self.toolButton_ImageFile) DEMPropertiesWidget.setTabOrder(self.toolButton_ImageFile, self.radioButton_SolidColor) DEMPropertiesWidget.setTabOrder(self.radioButton_SolidColor, self.comboBox_TextureSize) DEMPropertiesWidget.setTabOrder(self.comboBox_TextureSize, self.horizontalSlider_Opacity) DEMPropertiesWidget.setTabOrder(self.horizontalSlider_Opacity, self.spinBox_Opacity) DEMPropertiesWidget.setTabOrder(self.spinBox_Opacity, self.checkBox_TransparentBackground) DEMPropertiesWidget.setTabOrder(self.checkBox_TransparentBackground, self.checkBox_Shading) DEMPropertiesWidget.setTabOrder(self.checkBox_Shading, self.checkBox_Sides) DEMPropertiesWidget.setTabOrder(self.checkBox_Sides, self.checkBox_Frame) DEMPropertiesWidget.setTabOrder(self.checkBox_Frame, self.checkBox_Visible)
def setupUi(self): type_metadata = QgsApplication.processingRegistry().parameterType( self.param.type() if self.param else self.paramType) self.setWindowTitle( self.tr('{} Parameter Definition').format(type_metadata.name())) self.mainLayout = QVBoxLayout() self.tab = QTabWidget() self.mainLayout.addWidget(self.tab) self.setMinimumWidth(300) self.verticalLayout = QVBoxLayout() self.label = QLabel(self.tr('Parameter name')) self.verticalLayout.addWidget(self.label) self.nameTextBox = QLineEdit() self.verticalLayout.addWidget(self.nameTextBox) if isinstance(self.param, QgsProcessingParameterDefinition): self.nameTextBox.setText(self.param.description()) if isinstance(self.param, QgsProcessingDestinationParameter): self.verticalLayout.addWidget(QLabel(self.tr('Default value'))) self.defaultWidget = QgsProcessingLayerOutputDestinationWidget( self.param, defaultSelection=True) self.verticalLayout.addWidget(self.defaultWidget) self.verticalLayout.addSpacing(20) self.requiredCheck = QCheckBox() self.requiredCheck.setText(self.tr('Mandatory')) self.requiredCheck.setChecked(True) if self.param is not None: self.requiredCheck.setChecked( not self.param.flags() & QgsProcessingParameterDefinition.FlagOptional) self.verticalLayout.addWidget(self.requiredCheck) self.advancedCheck = QCheckBox() self.advancedCheck.setText(self.tr('Advanced')) self.advancedCheck.setChecked(False) if self.param is not None: self.advancedCheck.setChecked( self.param.flags() & QgsProcessingParameterDefinition.FlagAdvanced) self.verticalLayout.addWidget(self.advancedCheck) # If child algorithm output is mandatory, disable checkbox if isinstance(self.param, QgsProcessingDestinationParameter): child = self.alg.childAlgorithms()[self.param.metadata() ['_modelChildId']] model_output = child.modelOutput( self.param.metadata()['_modelChildOutputName']) param_def = child.algorithm().parameterDefinition( model_output.childOutputName()) if not (param_def.flags() & QgsProcessingParameterDefinition.FlagOptional): self.requiredCheck.setEnabled(False) self.requiredCheck.setChecked(True) self.advancedCheck.setEnabled(False) self.advancedCheck.setChecked(False) self.verticalLayout.addStretch() w = QWidget() w.setLayout(self.verticalLayout) self.tab.addTab(w, self.tr('Properties')) self.commentLayout = QVBoxLayout() self.commentEdit = QTextEdit() self.commentEdit.setAcceptRichText(False) self.commentLayout.addWidget(self.commentEdit, 1) hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) hl.addWidget(QLabel(self.tr('Color'))) self.comment_color_button = QgsColorButton() self.comment_color_button.setAllowOpacity(True) self.comment_color_button.setWindowTitle(self.tr('Comment Color')) self.comment_color_button.setShowNull(True, self.tr('Default')) hl.addWidget(self.comment_color_button) self.commentLayout.addLayout(hl) w2 = QWidget() w2.setLayout(self.commentLayout) self.tab.addTab(w2, self.tr('Comments')) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.setObjectName('buttonBox') self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.mainLayout.addWidget(self.buttonBox) self.setLayout(self.mainLayout)
def __init__(self, item): QDialog.__init__(self) self.gridLayout = QGridLayout(self) self.gridLayout.setObjectName(("gridLayout")) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(("horizontalLayout")) self.mFontComboBox = QFontComboBox(self) self.mFontComboBox.setObjectName(("mFontComboBox")) self.horizontalLayout.addWidget(self.mFontComboBox) spacerItem = QSpacerItem(38, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.mFontSizeSpinBox = QSpinBox(self) self.mFontSizeSpinBox.setObjectName(("mFontSizeSpinBox")) self.horizontalLayout.addWidget(self.mFontSizeSpinBox) self.mBoldPushButton = QPushButton(self) self.mBoldPushButton.setMinimumSize(QSize(50, 0)) self.mBoldPushButton.setCheckable(True) self.mBoldPushButton.setObjectName(("mBoldPushButton")) self.horizontalLayout.addWidget(self.mBoldPushButton) self.mItalicsPushButton = QPushButton(self) self.mItalicsPushButton.setMinimumSize(QSize(50, 0)) self.mItalicsPushButton.setCheckable(True) self.mItalicsPushButton.setObjectName(("mItalicsPushButton")) self.horizontalLayout.addWidget(self.mItalicsPushButton) self.mFontColorButton = QgsColorButton(self) self.mFontColorButton.setText(("")) self.mFontColorButton.setAutoDefault(False) self.mFontColorButton.setObjectName(("mFontColorButton")) self.horizontalLayout.addWidget(self.mFontColorButton) self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) self.mButtonBox = QDialogButtonBox(self) self.mButtonBox.setOrientation(Qt.Horizontal) self.mButtonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) self.mButtonBox.setObjectName(("mButtonBox")) self.gridLayout.addWidget(self.mButtonBox, 3, 0, 1, 1) self.mTextEdit = QTextEdit(self) self.mTextEdit.setObjectName(("mTextEdit")) self.gridLayout.addWidget(self.mTextEdit, 1, 0, 1, 1) self.mStackedWidget = QStackedWidget(self) self.mStackedWidget.setObjectName(("mStackedWidget")) self.page = QWidget() self.page.setObjectName(("page")) self.mStackedWidget.addWidget(self.page) self.page_2 = QWidget() self.page_2.setObjectName(("page_2")) self.mStackedWidget.addWidget(self.page_2) self.gridLayout.addWidget(self.mStackedWidget, 2, 0, 1, 1) self.setLayout(self.gridLayout) self.mStackedWidget.setCurrentIndex(0) QObject.connect(self.mButtonBox, SIGNAL(("accepted()")), self.accept) QObject.connect(self.mButtonBox, SIGNAL(("rejected()")), self.reject) self.setTabOrder(self.mFontComboBox, self.mFontSizeSpinBox) self.setTabOrder(self.mFontSizeSpinBox, self.mBoldPushButton) self.setTabOrder(self.mBoldPushButton, self.mItalicsPushButton) self.setTabOrder(self.mItalicsPushButton, self.mFontColorButton) self.setTabOrder(self.mFontColorButton, self.mTextEdit) self.setTabOrder(self.mTextEdit, self.mButtonBox) self.setWindowTitle("Annotation text") self.mBoldPushButton.setText("B") self.mItalicsPushButton.setText("I") self.mTextDocument = None self.mItem = item self.mEmbeddedWidget = QgsAnnotationWidget(self, self.mItem ) self.mEmbeddedWidget.show() self.mStackedWidget.addWidget( self.mEmbeddedWidget ) self.mStackedWidget.setCurrentWidget( self.mEmbeddedWidget ) if ( self.mItem != None ): self.mTextDocument = self.mItem.document() self.mTextEdit.setDocument( self.mTextDocument ) self.mFontColorButton.setColorDialogTitle( "Select font color" ) self.mFontColorButton.setColorDialogOptions( QColorDialog.ShowAlphaChannel ) self.setCurrentFontPropertiesToGui() QObject.connect( self.mButtonBox, SIGNAL("accepted()"), self.applyTextToItem) # QObject.connect( self.mFontComboBox, SIGNAL( "currentFontChanged(QFont())"), self.changeCurrentFormat) self.mFontComboBox.currentFontChanged.connect(self.changeCurrentFormat) QObject.connect( self.mFontSizeSpinBox, SIGNAL( "valueChanged( int )" ), self.changeCurrentFormat ) QObject.connect( self.mBoldPushButton, SIGNAL( "toggled( bool )" ), self.changeCurrentFormat) QObject.connect( self.mItalicsPushButton, SIGNAL( "toggled( bool )" ), self.changeCurrentFormat) QObject.connect( self.mTextEdit, SIGNAL( "cursorPositionChanged()" ), self.setCurrentFontPropertiesToGui ) # QObject.connect( self.mButtonBox, SIGNAL( "accepted()" ), self.applySettingsToItem) deleteButton = QPushButton( "Delete" ) QObject.connect( deleteButton, SIGNAL( "clicked()" ), self.deleteItem ) self.mButtonBox.addButton( deleteButton, QDialogButtonBox.RejectRole )