Commit bc1ad37b authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Add using the colornames in the approprite colorset widgets.

The palette docker doesn't have the ability to give tooltips due being a slightly different model, so hence the extra label.

I also tried setting the kocolorsetwidget the size of the current column count, but this crashes on startup for reasons I cannot understand.
parent 22ccd662
...@@ -259,7 +259,10 @@ void KoColorSet::setColumnCount(int columns) ...@@ -259,7 +259,10 @@ void KoColorSet::setColumnCount(int columns)
int KoColorSet::columnCount() int KoColorSet::columnCount()
{ {
return m_columns; if (m_columns){
return m_columns;
}
return 16;
} }
QString KoColorSet::defaultFileExtension() const QString KoColorSet::defaultFileExtension() const
......
...@@ -53,6 +53,7 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillColors() ...@@ -53,6 +53,7 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillColors()
colorSetLayout->setMargin(3); colorSetLayout->setMargin(3);
colorSetLayout->setSpacing(0); // otherwise the use can click where there is none colorSetLayout->setSpacing(0); // otherwise the use can click where there is none
colorSetContainer->setBackgroundRole(QPalette::Dark); colorSetContainer->setBackgroundRole(QPalette::Dark);
for(int i = 0; i<16; i++) { for(int i = 0; i<16; i++) {
colorSetLayout->setColumnMinimumWidth(i, 12); colorSetLayout->setColumnMinimumWidth(i, 12);
} }
...@@ -64,6 +65,7 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillColors() ...@@ -64,6 +65,7 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillColors()
patch->setFrameStyle(QFrame::Plain | QFrame::Box); patch->setFrameStyle(QFrame::Plain | QFrame::Box);
patch->setLineWidth(1); patch->setLineWidth(1);
patch->setColor(colorSet->getColor(i).color); patch->setColor(colorSet->getColor(i).color);
patch->setToolTip(colorSet->getColor(i).name);
connect(patch, SIGNAL(triggered(KoColorPatch *)), thePublic, SLOT(colorTriggered(KoColorPatch *))); connect(patch, SIGNAL(triggered(KoColorPatch *)), thePublic, SLOT(colorTriggered(KoColorPatch *)));
colorSetLayout->addWidget(patch, p/16, p%16); colorSetLayout->addWidget(patch, p/16, p%16);
patch->setDisplayRenderer(displayRenderer); patch->setDisplayRenderer(displayRenderer);
......
...@@ -71,7 +71,14 @@ KoEditColorSetWidget::KoEditColorSetWidget(const QList<KoColorSet *> &palettes, ...@@ -71,7 +71,14 @@ KoEditColorSetWidget::KoEditColorSetWidget(const QList<KoColorSet *> &palettes,
index = widget.selector->findText(m_activeColorSet->name()); index = widget.selector->findText(m_activeColorSet->name());
} }
m_scrollArea->setMinimumWidth(16*(12+2)); int columns = 16;
if(m_activeColorSet) {
columns = m_activeColorSet->columnCount();
if (columns==0){
columns = 16;
}
}
m_scrollArea->setMinimumWidth(columns*(12+2));
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
...@@ -121,15 +128,20 @@ void KoEditColorSetWidget::setActiveColorSet(int index) ...@@ -121,15 +128,20 @@ void KoEditColorSetWidget::setActiveColorSet(int index)
m_activeColorSet = m_colorSets.value(index); m_activeColorSet = m_colorSets.value(index);
setEnabled(m_activeColorSet != 0); setEnabled(m_activeColorSet != 0);
int columns = 16;
if (m_activeColorSet) { if (m_activeColorSet) {
columns = m_activeColorSet->columnCount();
if (columns==0){columns=16;}
widget.remove->setEnabled(false); widget.remove->setEnabled(false);
for (int i = 0; i < m_activeColorSet->nColors(); i++) { for (int i = 0; i < m_activeColorSet->nColors(); i++) {
KoColorPatch *patch = new KoColorPatch(widget.patchesFrame); KoColorPatch *patch = new KoColorPatch(widget.patchesFrame);
patch->setColor(m_activeColorSet->getColor(i).color); patch->setColor(m_activeColorSet->getColor(i).color);
patch->setToolTip(m_activeColorSet->getColor(i).name);
connect(patch, SIGNAL(triggered(KoColorPatch *)), this, SLOT(setTextLabel(KoColorPatch *))); connect(patch, SIGNAL(triggered(KoColorPatch *)), this, SLOT(setTextLabel(KoColorPatch *)));
m_gridLayout->addWidget(patch, i/16, i%16); m_gridLayout->addWidget(patch, i/columns, i%columns);
} }
} }
m_scrollArea->setMinimumWidth(columns*(12+2));
wdg->setLayout(m_gridLayout); wdg->setLayout(m_gridLayout);
m_scrollArea->setWidget(wdg); m_scrollArea->setWidget(wdg);
...@@ -137,7 +149,7 @@ void KoEditColorSetWidget::setActiveColorSet(int index) ...@@ -137,7 +149,7 @@ void KoEditColorSetWidget::setActiveColorSet(int index)
void KoEditColorSetWidget::setTextLabel(KoColorPatch *patch) void KoEditColorSetWidget::setTextLabel(KoColorPatch *patch)
{ {
widget.colorName->setText(patch->color().toQColor().name()); widget.colorName->setText(patch->toolTip());
if (m_activePatch) { if (m_activePatch) {
m_activePatch->setFrameShape(QFrame::NoFrame); m_activePatch->setFrameShape(QFrame::NoFrame);
m_activePatch->setFrameShadow(QFrame::Plain); m_activePatch->setFrameShadow(QFrame::Plain);
...@@ -159,10 +171,11 @@ void KoEditColorSetWidget::addColor() ...@@ -159,10 +171,11 @@ void KoEditColorSetWidget::addColor()
newEntry.name = QInputDialog::getText(this, i18n("Add Color To Palette"), i18n("Color name:")); newEntry.name = QInputDialog::getText(this, i18n("Add Color To Palette"), i18n("Color name:"));
KoColorPatch *patch = new KoColorPatch(widget.patchesFrame); KoColorPatch *patch = new KoColorPatch(widget.patchesFrame);
patch->setColor(newEntry.color); patch->setColor(newEntry.color);
patch->setToolTip(newEntry.name);
connect(patch, SIGNAL(triggered(KoColorPatch *)), this, SLOT(setTextLabel(KoColorPatch *))); connect(patch, SIGNAL(triggered(KoColorPatch *)), this, SLOT(setTextLabel(KoColorPatch *)));
Q_ASSERT(m_gridLayout); Q_ASSERT(m_gridLayout);
Q_ASSERT(m_activeColorSet); Q_ASSERT(m_activeColorSet);
m_gridLayout->addWidget(patch, m_activeColorSet->nColors()/16, m_activeColorSet->nColors()%16); m_gridLayout->addWidget(patch, m_activeColorSet->nColors()/m_activeColorSet->columnCount(), m_activeColorSet->nColors()%m_activeColorSet->columnCount());
m_activeColorSet->add(newEntry); m_activeColorSet->add(newEntry);
} }
} }
......
...@@ -304,6 +304,7 @@ void PaletteDockerDock::entrySelected(QModelIndex index) ...@@ -304,6 +304,7 @@ void PaletteDockerDock::entrySelected(QModelIndex index)
int i = index.row()*m_model->columnCount()+index.column(); int i = index.row()*m_model->columnCount()+index.column();
if (i < m_currentColorSet->nColors()) { if (i < m_currentColorSet->nColors()) {
KoColorSetEntry entry = m_currentColorSet->getColor(i); KoColorSetEntry entry = m_currentColorSet->getColor(i);
m_wdgPaletteDock->lblColorName->setText(entry.name);
if (m_resourceProvider) { if (m_resourceProvider) {
m_resourceProvider->setFGColor(entry.color); m_resourceProvider->setFGColor(entry.color);
} }
......
...@@ -14,7 +14,16 @@ ...@@ -14,7 +14,16 @@
<property name="spacing"> <property name="spacing">
<number>1</number> <number>1</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
...@@ -29,7 +38,26 @@ ...@@ -29,7 +38,26 @@
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1"> <item row="0" column="5">
<widget class="QToolButton" name="bnAddDialog">
<property name="toolTip">
<string>Add color</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -42,7 +70,14 @@ ...@@ -42,7 +70,14 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="5"> <item row="0" column="0">
<widget class="KisPopupButton" name="bnColorSets">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QToolButton" name="bnRemove"> <widget class="QToolButton" name="bnRemove">
<property name="toolTip"> <property name="toolTip">
<string>Delete color</string> <string>Delete color</string>
...@@ -61,7 +96,7 @@ ...@@ -61,7 +96,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="4">
<widget class="QToolButton" name="bnAdd"> <widget class="QToolButton" name="bnAdd">
<property name="toolTip"> <property name="toolTip">
<string>Add foreground color</string> <string>Add foreground color</string>
...@@ -80,27 +115,17 @@ ...@@ -80,27 +115,17 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="0" column="1">
<widget class="QToolButton" name="bnAddDialog"> <widget class="QLabel" name="lblColorName">
<property name="toolTip"> <property name="minimumSize">
<string>Add color</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size> <size>
<width>22</width> <width>60</width>
<height>22</height> <height>0</height>
</size> </size>
</property> </property>
<property name="autoRaise"> <property name="frameShape">
<bool>false</bool> <enum>QFrame::StyledPanel</enum>
</property> </property>
</widget>
</item>
<item row="0" column="0">
<widget class="KisPopupButton" name="bnColorSets">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment