Differential D9877 Diff 25331 plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_docker.py
Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/palette_docker/palette_docker.py
Context not available. | |||||
27 | 27 | | |||
---|---|---|---|---|---|
28 | # Make a combobox and add palettes | 28 | # Make a combobox and add palettes | ||
29 | self.cmb_palettes = QComboBox() | 29 | self.cmb_palettes = QComboBox() | ||
30 | allPalettes = Application.resources("palette") | 30 | self.cmb_palettes.setInsertPolicy(QComboBox.InsertAlphabetically) | ||
31 | for palette_name in allPalettes: | 31 | allPalettes = Application.allPalettes(); | ||
32 | self.cmb_palettes.addItem(palette_name) | 32 | for palette in allPalettes: | ||
33 | self.cmb_palettes.model().sort(0) | 33 | self.cmb_palettes.addItem(palette.name()) | ||
34 | 34 | | |||
35 | self.currentPalette = Palette(allPalettes[list(allPalettes.keys())[0]]) | 35 | Application.notifier().paletteAdded.connect(self.slot_paletteResourceChanged) | ||
36 | Application.notifier().paletteRemoved.connect(self.slot_paletteResourceChanged) | ||||
37 | Application.notifier().paletteChanged.connect(self.slot_paletteResourceChanged) | ||||
38 | | ||||
39 | self.currentPalette = allPalettes[0] | ||||
36 | self.cmb_palettes.currentTextChanged.connect(self.slot_paletteChanged) | 40 | self.cmb_palettes.currentTextChanged.connect(self.slot_paletteChanged) | ||
37 | layout.addWidget(self.cmb_palettes) # add combobox to the layout | 41 | layout.addWidget(self.cmb_palettes) # add combobox to the layout | ||
38 | self.paletteView = PaletteView() | 42 | self.paletteView = PaletteView() | ||
Context not available. | |||||
93 | self.setWidget(widget) # add widget to the docker | 97 | self.setWidget(widget) # add widget to the docker | ||
94 | 98 | | |||
95 | def slot_paletteChanged(self, name): | 99 | def slot_paletteChanged(self, name): | ||
96 | self.currentPalette = Palette(Application.resources("palette")[name]) | 100 | newPalette = Application.allPalettes()[0] | ||
101 | for palette in Application.allPalettes(): | ||||
102 | if palette.name()==name: | ||||
103 | newPalette = palette | ||||
104 | self.currentPalette = newPalette | ||||
97 | self.paletteView.setPalette(self.currentPalette) | 105 | self.paletteView.setPalette(self.currentPalette) | ||
98 | self.slot_fill_combobox() | 106 | self.slot_fill_combobox() | ||
99 | 107 | | |||
108 | @pyqtSlot(Palette) | ||||
109 | def slot_paletteResourceChanged(self, palette): | ||||
110 | entry = self.cmb_palettes.currentEntryText(); | ||||
111 | self.cmb_palettes.clear(); | ||||
112 | for palette in Application.allPalettes(): | ||||
113 | self.cmb_palettes.addItem(palette.name()) | ||||
114 | if (palette == self.currentPalette): | ||||
115 | if self.cmb_palettes.findText(palette.name())>0: | ||||
116 | self.slot_paletteChanged(Application.allPalettes()[0]) | ||||
117 | else: | ||||
118 | self.slot_paletteChanged(palette.name()) | ||||
119 | self.cmb_palettes.setCurrentEntryText(palette.name()) | ||||
120 | else: | ||||
121 | self.cmb_palettes.setCurrentEntryText(entry) | ||||
122 | | ||||
100 | @pyqtSlot('KoColorSetEntry') | 123 | @pyqtSlot('KoColorSetEntry') | ||
101 | def slot_swatchSelected(self, entry): | 124 | def slot_swatchSelected(self, entry): | ||
102 | print("entry " + entry.name) | | |||
103 | if (self.canvas()) is not None: | 125 | if (self.canvas()) is not None: | ||
104 | if (self.canvas().view()) is not None: | 126 | if (self.canvas().view()) is not None: | ||
105 | name = entry.name | 127 | name = entry.name | ||
Context not available. | |||||
204 | # buttons.rejected.connect(dialog.reject()) | 226 | # buttons.rejected.connect(dialog.reject()) | ||
205 | 227 | | |||
206 | if dialog.exec_() == QDialog.Accepted: | 228 | if dialog.exec_() == QDialog.Accepted: | ||
207 | Resource = Application.resources("palette")[self.cmb_palettes.currentText()] | 229 | self.currentPalette.setName(paletteName.text()) | ||
208 | Resource.setName(paletteName.text()) | | |||
209 | self.currentPalette = Palette(Resource) | | |||
210 | print(paletteColumns.value()) | 230 | print(paletteColumns.value()) | ||
211 | self.currentPalette.setColumnCount(paletteColumns.value()) | 231 | self.currentPalette.setColumnCount(paletteColumns.value()) | ||
212 | self.paletteView.setPalette(self.currentPalette) | 232 | self.paletteView.setPalette(self.currentPalette) | ||
213 | self.slot_fill_combobox() | 233 | self.slot_fill_combobox() | ||
214 | self.currentPalette.setComment(paletteComment.toPlainText()) | 234 | self.currentPalette.setComment(paletteComment.toPlainText()) | ||
215 | self.currentPalette.save() | 235 | self.currentPalette.save(False) | ||
216 | 236 | | |||
217 | def slot_export_to_gimp_palette(self): | 237 | def slot_export_to_gimp_palette(self): | ||
218 | palette_exporter_gimppalette.gimpPaletteExporter(self.cmb_palettes.currentText()) | 238 | palette_exporter_gimppalette.gimpPaletteExporter(self.cmb_palettes.currentText()) | ||
Context not available. |