Changeset View
Changeset View
Standalone View
Standalone View
plugins/python/palette_docker/palette_docker.py
Context not available. | |||||
57 | self.paletteView = PaletteView() | 57 | self.paletteView = PaletteView() | ||
---|---|---|---|---|---|
58 | self.paletteView.setPalette(self.currentPalette) | 58 | self.paletteView.setPalette(self.currentPalette) | ||
59 | layout.addWidget(self.paletteView) | 59 | layout.addWidget(self.paletteView) | ||
60 | self.paletteView.entrySelectedForeGround.connect(self.slot_swatchSelected) | 60 | self.paletteView.sigSwatchSelected.connect(self.slot_swatchSelected) | ||
61 | 61 | | |||
62 | self.colorComboBox = QComboBox() | 62 | self.colorComboBox = QComboBox() | ||
63 | self.colorList = list() | 63 | self.colorList = list() | ||
Context not available. | |||||
67 | self.bnSetColor.clicked.connect(self.slot_get_color_from_combobox) | 67 | self.bnSetColor.clicked.connect(self.slot_get_color_from_combobox) | ||
68 | buttonLayout.addWidget(self.bnSetColor) | 68 | buttonLayout.addWidget(self.bnSetColor) | ||
69 | 69 | | |||
70 | self.addEntry = QAction(self) | 70 | # self.addEntry = QAction(self) | ||
71 | self.addEntry.setIconText(i18n("+")) | 71 | # self.addEntry.setIconText(i18n("+")) | ||
72 | self.addEntry.triggered.connect(self.slot_add_entry) | 72 | # self.addEntry.triggered.connect(self.slot_add_entry) | ||
73 | self.addGroup = QAction(self) | 73 | # self.addGroup = QAction(self) | ||
74 | self.addGroup.triggered.connect(self.slot_add_group) | 74 | # self.addGroup.triggered.connect(self.slot_add_group) | ||
75 | self.addGroup.setText(i18n("Add Group")) | 75 | # self.addGroup.setText(i18n("Add Group")) | ||
76 | self.addGroup.setIconText(str("\U0001F4C2")) | 76 | # self.addGroup.setIconText(str("\U0001F4C2")) | ||
77 | self.removeEntry = QAction(self) | 77 | # self.removeEntry = QAction(self) | ||
78 | self.removeEntry.setText(i18n("Remove Entry")) | 78 | # self.removeEntry.setText(i18n("Remove Entry")) | ||
79 | self.removeEntry.setIconText("-") | 79 | # self.removeEntry.setIconText("-") | ||
80 | self.removeEntry.triggered.connect(self.slot_remove_entry) | 80 | # self.removeEntry.triggered.connect(self.slot_remove_entry) | ||
81 | addEntryButton = QToolButton() | 81 | # addEntryButton = QToolButton() | ||
82 | addEntryButton.setDefaultAction(self.addEntry) | 82 | # addEntryButton.setDefaultAction(self.addEntry) | ||
83 | buttonLayout.addWidget(addEntryButton) | 83 | # buttonLayout.addWidget(addEntryButton) | ||
84 | addGroupButton = QToolButton() | 84 | # addGroupButton = QToolButton() | ||
85 | addGroupButton.setDefaultAction(self.addGroup) | 85 | # addGroupButton.setDefaultAction(self.addGroup) | ||
86 | buttonLayout.addWidget(addGroupButton) | 86 | # buttonLayout.addWidget(addGroupButton) | ||
87 | removeEntryButton = QToolButton() | 87 | # removeEntryButton = QToolButton() | ||
88 | removeEntryButton.setDefaultAction(self.removeEntry) | 88 | # removeEntryButton.setDefaultAction(self.removeEntry) | ||
89 | buttonLayout.addWidget(removeEntryButton) | 89 | # buttonLayout.addWidget(removeEntryButton) | ||
90 | 90 | | |||
91 | # QActions | 91 | # # QActions | ||
92 | self.extra = QToolButton() | 92 | # self.extra = QToolButton() | ||
93 | self.editPaletteData = QAction(self) | 93 | # self.editPaletteData = QAction(self) | ||
94 | self.editPaletteData.setText(i18n("Edit Palette Settings")) | 94 | # self.editPaletteData.setText(i18n("Edit Palette Settings")) | ||
95 | self.editPaletteData.triggered.connect(self.slot_edit_palette_data) | 95 | # self.editPaletteData.triggered.connect(self.slot_edit_palette_data) | ||
96 | self.extra.setDefaultAction(self.editPaletteData) | 96 | # self.extra.setDefaultAction(self.editPaletteData) | ||
97 | buttonLayout.addWidget(self.extra) | 97 | # buttonLayout.addWidget(self.extra) | ||
98 | self.actionMenu = QMenu() | 98 | # self.actionMenu = QMenu() | ||
99 | self.exportToGimp = QAction(self) | 99 | # self.exportToGimp = QAction(self) | ||
100 | self.exportToGimp.setText(i18n("Export as GIMP Palette File")) | 100 | # self.exportToGimp.setText(i18n("Export as GIMP Palette File")) | ||
101 | self.exportToGimp.triggered.connect(self.slot_export_to_gimp_palette) | 101 | # self.exportToGimp.triggered.connect(self.slot_export_to_gimp_palette) | ||
102 | self.exportToInkscape = QAction(self) | 102 | # self.exportToInkscape = QAction(self) | ||
103 | self.exportToInkscape.setText(i18n("Export as Inkscape SVG with Swatches")) | 103 | # self.exportToInkscape.setText(i18n("Export as Inkscape SVG with Swatches")) | ||
104 | self.exportToInkscape.triggered.connect(self.slot_export_to_inkscape_svg) | 104 | # self.exportToInkscape.triggered.connect(self.slot_export_to_inkscape_svg) | ||
105 | self.sortColors = QAction(self) | 105 | # self.sortColors = QAction(self) | ||
106 | self.sortColors.setText(i18n("Sort Colors")) | 106 | # self.sortColors.setText(i18n("Sort Colors")) | ||
107 | self.sortColors.triggered.connect(self.slot_sort_colors) | 107 | # self.sortColors.triggered.connect(self.slot_sort_colors) | ||
108 | self.actionMenu.addAction(self.editPaletteData) | 108 | # self.actionMenu.addAction(self.editPaletteData) | ||
109 | self.actionMenu.addAction(self.exportToGimp) | 109 | # self.actionMenu.addAction(self.exportToGimp) | ||
110 | self.actionMenu.addAction(self.exportToInkscape) | 110 | # self.actionMenu.addAction(self.exportToInkscape) | ||
111 | # self.actionMenu.addAction(self.sortColors) | 111 | # # self.actionMenu.addAction(self.sortColors) | ||
112 | 112 | | |||
113 | self.extra.setMenu(self.actionMenu) | 113 | # self.extra.setMenu(self.actionMenu) | ||
114 | 114 | | |||
115 | layout.addLayout(buttonLayout) | 115 | layout.addLayout(buttonLayout) | ||
116 | self.slot_fill_combobox() | 116 | self.slot_fill_combobox() | ||
Context not available. | |||||
123 | self.paletteView.setPalette(self.currentPalette) | 123 | self.paletteView.setPalette(self.currentPalette) | ||
124 | self.slot_fill_combobox() | 124 | self.slot_fill_combobox() | ||
125 | 125 | | |||
126 | @pyqtSlot('KisSwatch') | 126 | @pyqtSlot('Swatch') | ||
127 | def slot_swatchSelected(self, entry): | 127 | def slot_swatchSelected(self, entry): | ||
128 | if (self.canvas()) is not None: | 128 | if (self.canvas()) is not None: | ||
129 | if (self.canvas().view()) is not None: | 129 | if (self.canvas().view()) is not None: | ||
130 | name = entry.name() | 130 | color = entry.color() | ||
131 | if len(entry.id) > 0: | 131 | for i in range(self.currentPalette.numberOfEntries()): | ||
132 | name = entry.id() + " - " + entry.name() | 132 | if self.currentPalette.colorSetEntryByIndex(i).color() == color: | ||
133 | if len(name) > 0: | 133 | self.colorComboBox.setCurrentIndex(i) | ||
134 | if name in self.colorList: | 134 | break | ||
135 | self.colorComboBox.setCurrentIndex(self.colorList.index(name)) | 135 | self.canvas().view().setForegroundColor(color) | ||
136 | color = self.currentPalette.colorForEntry(entry) | | |||
137 | self.canvas().view().setForeGroundColor(color) | | |||
138 | ''' | 136 | ''' | ||
139 | A function for making a combobox with the available colors. We use QCompleter on the colorComboBox so that people | 137 | A function for making a combobox with the available colors. We use QCompleter on the colorComboBox so that people | ||
140 | can type in the name of a color to select it. This is useful for people with carefully made palettes where the colors | 138 | can type in the name of a color to select it. This is useful for people with carefully made palettes where the colors | ||
Context not available. | |||||
147 | palette = self.currentPalette | 145 | palette = self.currentPalette | ||
148 | self.colorComboBox.clear() | 146 | self.colorComboBox.clear() | ||
149 | self.colorList = list() | 147 | self.colorList = list() | ||
150 | # for info in palette.infoList(): | 148 | for i in range(palette.numberOfEntries()): | ||
151 | # entry = info.swatch | 149 | entry = palette.colorSetEntryByIndex(i); | ||
152 | # color = palette.colorForEntry(entry).colorForCanvas(self.canvas()) | 150 | color = entry.color() | ||
153 | # colorSquare = QPixmap(12, 12) | 151 | colorSquare = QPixmap(12, 12) | ||
154 | # if entry.spotColor() is True: | 152 | if entry.spotColor() is True: | ||
155 | # img = colorSquare.toImage() | 153 | img = colorSquare.toImage() | ||
156 | # circlePainter = QPainter() | 154 | circlePainter = QPainter() | ||
157 | # img.fill(self.colorComboBox.palette().color(QPalette.Base)) | 155 | img.fill(self.colorComboBox.palette().color(QPalette.Base)) | ||
158 | # circlePainter.begin(img) | 156 | circlePainter.begin(img) | ||
159 | # brush = QBrush(Qt.SolidPattern) | 157 | brush = QBrush(Qt.SolidPattern) | ||
160 | # brush.setColor(color) | 158 | brush.setColor(color) | ||
161 | # circlePainter.setBrush(brush) | 159 | circlePainter.setBrush(brush) | ||
162 | # circlePainter.pen().setWidth(0) | 160 | circlePainter.pen().setWidth(0) | ||
163 | # circlePainter.drawEllipse(0, 0, 11, 11) | 161 | circlePainter.drawEllipse(0, 0, 11, 11) | ||
164 | # circlePainter.end() | 162 | circlePainter.end() | ||
165 | # colorSquare = QPixmap.fromImage(img) | 163 | colorSquare = QPixmap.fromImage(img) | ||
166 | # else: | 164 | else: | ||
167 | # colorSquare.fill(color) | 165 | colorSquare.fill(color.colorForCanvas(self.canvas())) | ||
168 | # name = entry.name() | 166 | name = entry.name() | ||
169 | # if len(entry.id()) > 0: | 167 | if len(entry.id()) > 0: | ||
170 | # name = entry.id() + " - " + entry.name() | 168 | name = entry.id() + " - " + entry.name() | ||
171 | # self.colorList.append(name) | 169 | self.colorList.append(name) | ||
172 | # self.colorComboBox.addItem(QIcon(colorSquare), name) | 170 | self.colorComboBox.addItem(QIcon(colorSquare), name) | ||
173 | self.colorComboBox.setEditable(True) | 171 | self.colorComboBox.setEditable(True) | ||
174 | self.colorComboBox.setInsertPolicy(QComboBox.NoInsert) | 172 | self.colorComboBox.setInsertPolicy(QComboBox.NoInsert) | ||
175 | self.colorComboBox.completer().setCompletionMode(QCompleter.PopupCompletion) | 173 | self.colorComboBox.completer().setCompletionMode(QCompleter.PopupCompletion) | ||
Context not available. |