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)
int KoColorSet::columnCount()
{
return m_columns;
if (m_columns){
return m_columns;
}
return 16;
}
QString KoColorSet::defaultFileExtension() const
......
......@@ -53,6 +53,7 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillColors()
colorSetLayout->setMargin(3);
colorSetLayout->setSpacing(0); // otherwise the use can click where there is none
colorSetContainer->setBackgroundRole(QPalette::Dark);
for(int i = 0; i<16; i++) {
colorSetLayout->setColumnMinimumWidth(i, 12);
}
......@@ -64,6 +65,7 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillColors()
patch->setFrameStyle(QFrame::Plain | QFrame::Box);
patch->setLineWidth(1);
patch->setColor(colorSet->getColor(i).color);
patch->setToolTip(colorSet->getColor(i).name);
connect(patch, SIGNAL(triggered(KoColorPatch *)), thePublic, SLOT(colorTriggered(KoColorPatch *)));
colorSetLayout->addWidget(patch, p/16, p%16);
patch->setDisplayRenderer(displayRenderer);
......
......@@ -71,7 +71,14 @@ KoEditColorSetWidget::KoEditColorSetWidget(const QList<KoColorSet *> &palettes,
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();
layout->setContentsMargins(0, 0, 0, 0);
......@@ -121,15 +128,20 @@ void KoEditColorSetWidget::setActiveColorSet(int index)
m_activeColorSet = m_colorSets.value(index);
setEnabled(m_activeColorSet != 0);
int columns = 16;
if (m_activeColorSet) {
columns = m_activeColorSet->columnCount();
if (columns==0){columns=16;}
widget.remove->setEnabled(false);
for (int i = 0; i < m_activeColorSet->nColors(); i++) {
KoColorPatch *patch = new KoColorPatch(widget.patchesFrame);
patch->setColor(m_activeColorSet->getColor(i).color);
patch->setToolTip(m_activeColorSet->getColor(i).name);
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);
m_scrollArea->setWidget(wdg);
......@@ -137,7 +149,7 @@ void KoEditColorSetWidget::setActiveColorSet(int index)
void KoEditColorSetWidget::setTextLabel(KoColorPatch *patch)
{
widget.colorName->setText(patch->color().toQColor().name());
widget.colorName->setText(patch->toolTip());
if (m_activePatch) {
m_activePatch->setFrameShape(QFrame::NoFrame);
m_activePatch->setFrameShadow(QFrame::Plain);
......@@ -159,10 +171,11 @@ void KoEditColorSetWidget::addColor()
newEntry.name = QInputDialog::getText(this, i18n("Add Color To Palette"), i18n("Color name:"));
KoColorPatch *patch = new KoColorPatch(widget.patchesFrame);
patch->setColor(newEntry.color);
patch->setToolTip(newEntry.name);
connect(patch, SIGNAL(triggered(KoColorPatch *)), this, SLOT(setTextLabel(KoColorPatch *)));
Q_ASSERT(m_gridLayout);
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);
}
}
......
......@@ -304,6 +304,7 @@ void PaletteDockerDock::entrySelected(QModelIndex index)
int i = index.row()*m_model->columnCount()+index.column();
if (i < m_currentColorSet->nColors()) {
KoColorSetEntry entry = m_currentColorSet->getColor(i);
m_wdgPaletteDock->lblColorName->setText(entry.name);
if (m_resourceProvider) {
m_resourceProvider->setFGColor(entry.color);
}
......
......@@ -14,7 +14,16 @@
<property name="spacing">
<number>1</number>
</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>
</property>
<item>
......@@ -29,7 +38,26 @@
</item>
<item>
<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">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -42,7 +70,14 @@
</property>
</spacer>
</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">
<property name="toolTip">
<string>Delete color</string>
......@@ -61,7 +96,7 @@
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="4">
<widget class="QToolButton" name="bnAdd">
<property name="toolTip">
<string>Add foreground color</string>
......@@ -80,27 +115,17 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="bnAddDialog">
<property name="toolTip">
<string>Add color</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<item row="0" column="1">
<widget class="QLabel" name="lblColorName">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="autoRaise">
<bool>false</bool>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="KisPopupButton" name="bnColorSets">
<property name="text">
<string/>
</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