Commit 52afd0cb authored by Anna Medonosova's avatar Anna Medonosova
Browse files

Advanced Color Selector: option to hide color selector

Summary:
I have resurrected the original patch by Ranveer Aggarwal, which enables the user to hide the
color selector part of the docker.

There was one issue with the original: the docker settings button is inside the color selector, therefore when you hide
the selector, the only way to configure the docker is via the main menu, "Settings" -> "Configure Krita". To solve that I have added
a fallback settings button to the docker widget, which appears when the color selector part is hidden.

BUG: 337328

Reviewers: #krita, rempt

Reviewed By: #krita, rempt

Subscribers: rempt

Tags: #krita

Differential Revision: https://phabricator.kde.org/D17893
parent 6b6758bb
......@@ -50,6 +50,7 @@ KisColorSelectorContainer::KisColorSelectorContainer(QWidget *parent) :
m_minimalShadeSelector(new KisMinimalShadeSelector(this)),
m_shadeSelector(m_myPaintShadeSelector),
m_gamutMaskToolbar(new KisGamutMaskToolbar(this)),
m_showColorSelector(true),
m_canvas(0)
{
m_widgetLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
......@@ -169,6 +170,20 @@ void KisColorSelectorContainer::updateSettings()
{
KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
m_onDockerResizeSetting = (int)cfg.readEntry("onDockerResize", 0);
m_showColorSelector = (bool) cfg.readEntry("showColorSelector", true);
if (m_showColorSelector) {
m_colorSelector->show();
if (m_colorSelector->configuration().mainType == KisColorSelectorConfiguration::Wheel) {
m_gamutMaskToolbar->show();
} else {
m_gamutMaskToolbar->hide();
}
} else {
m_colorSelector->hide();
m_gamutMaskToolbar->hide();
}
QString type = cfg.readEntry("shadeSelectorType", "Minimal");
......@@ -189,14 +204,6 @@ void KisColorSelectorContainer::updateSettings()
if(m_shadeSelector!=0)
m_shadeSelector->show();
if (m_colorSelector->configuration().mainType == KisColorSelectorConfiguration::Wheel) {
m_gamutMaskToolbar->show();
} else {
m_gamutMaskToolbar->hide();
}
}
void KisColorSelectorContainer::reactOnLayerChange()
......
......@@ -62,6 +62,7 @@ private:
KisGamutMaskToolbar* m_gamutMaskToolbar;
int m_onDockerResizeSetting;
bool m_showColorSelector;
QBoxLayout* m_widgetLayout;
......
......@@ -20,10 +20,12 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QToolButton>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <ksharedconfig.h>
#include <kis_icon_utils.h>
#include <QAction>
#include <kactioncollection.h>
......@@ -48,8 +50,13 @@ KisColorSelectorNgDockerWidget::KisColorSelectorNgDockerWidget(QWidget *parent)
QWidget(parent),
m_colorHistoryAction(0),
m_commonColorsAction(0),
m_widgetLayout(0),
m_mainLayout(0),
m_horizontalPatchesContainer(0),
m_sidebarLayout(0),
m_verticalColorPatchesLayout(0),
m_horizontalColorPatchesLayout(0),
m_fallbackSettingsButton(new QToolButton(this)),
m_canvas(0)
{
setAutoFillBackground(true);
......@@ -63,16 +70,47 @@ KisColorSelectorNgDockerWidget::KisColorSelectorNgDockerWidget(QWidget *parent)
//shade selector
// fallback settings button when the color selector is disabled
m_fallbackSettingsButton->setIcon(KisIconUtils::loadIcon("configure"));
m_fallbackSettingsButton->setIconSize(QSize(22,22));
m_fallbackSettingsButton->setAutoRaise(true);
m_fallbackSettingsButton->hide();
//layout
m_widgetLayout = new QHBoxLayout();
m_widgetLayout->setSpacing(0);
m_widgetLayout->setMargin(0);
m_mainLayout = new QVBoxLayout();
m_mainLayout->setSpacing(0);
m_mainLayout->setMargin(0);
m_horizontalPatchesContainer = new QHBoxLayout();
m_horizontalPatchesContainer->setSpacing(0);
m_horizontalPatchesContainer->setMargin(0);
m_sidebarLayout = new QVBoxLayout();
m_sidebarLayout->setSpacing(0);
m_sidebarLayout->setMargin(0);
m_verticalColorPatchesLayout = new QHBoxLayout();
m_verticalColorPatchesLayout->setSpacing(0);
m_verticalColorPatchesLayout->setMargin(0);
m_verticalColorPatchesLayout->addWidget(m_colorSelectorContainer);
m_horizontalColorPatchesLayout = new QVBoxLayout(this);
m_horizontalColorPatchesLayout = new QVBoxLayout();
m_horizontalColorPatchesLayout->setSpacing(0);
m_horizontalColorPatchesLayout->setMargin(0);
m_horizontalColorPatchesLayout->addLayout(m_verticalColorPatchesLayout);
m_horizontalPatchesContainer->addLayout(m_horizontalColorPatchesLayout);
m_mainLayout->addWidget(m_colorSelectorContainer);
m_mainLayout->addLayout(m_horizontalPatchesContainer);
m_sidebarLayout->addLayout(m_verticalColorPatchesLayout);
m_widgetLayout->addLayout(m_mainLayout);
m_widgetLayout->addLayout(m_sidebarLayout);
setLayout(m_widgetLayout);
updateLayout();
......@@ -99,6 +137,7 @@ KisColorSelectorNgDockerWidget::KisColorSelectorNgDockerWidget(QWidget *parent)
m_commonColorsAction = KisActionRegistry::instance()->makeQAction("show_common_colors", this);
connect(m_commonColorsAction, SIGNAL(triggered()), m_commonColorsWidget, SLOT(showPopup()), Qt::UniqueConnection);
connect(m_fallbackSettingsButton, SIGNAL(clicked()), this, SLOT(openSettings()));
}
void KisColorSelectorNgDockerWidget::unsetCanvas()
......@@ -154,6 +193,7 @@ void KisColorSelectorNgDockerWidget::updateLayout()
{
KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
bool showColorSelector = (bool) cfg.readEntry("showColorSelector", true);
//color patches
bool m_lastColorsShow = cfg.readEntry("lastUsedColorsShow", true);
......@@ -170,12 +210,14 @@ void KisColorSelectorNgDockerWidget::updateLayout()
else
m_commonColorsDirection=KisColorPatches::Horizontal;
m_verticalColorPatchesLayout->removeWidget(m_colorHistoryWidget);
m_verticalColorPatchesLayout->removeWidget(m_commonColorsWidget);
m_horizontalColorPatchesLayout->removeWidget(m_colorHistoryWidget);
m_horizontalColorPatchesLayout->removeWidget(m_commonColorsWidget);
m_sidebarLayout->removeWidget(m_fallbackSettingsButton);
m_mainLayout->removeWidget(m_fallbackSettingsButton);
if(m_lastColorsShow==false)
m_colorHistoryWidget->hide();
else
......@@ -188,6 +230,9 @@ void KisColorSelectorNgDockerWidget::updateLayout()
m_commonColorsWidget->show();
}
bool fallbackSettingsButtonVertical = true;
if(m_lastColorsShow && m_lastColorsDirection==KisColorPatches::Vertical) {
m_verticalColorPatchesLayout->addWidget(m_colorHistoryWidget);
}
......@@ -198,10 +243,29 @@ void KisColorSelectorNgDockerWidget::updateLayout()
if(m_lastColorsShow && m_lastColorsDirection==KisColorPatches::Horizontal) {
m_horizontalColorPatchesLayout->addWidget(m_colorHistoryWidget);
fallbackSettingsButtonVertical = false;
}
if(m_commonColorsShow && m_commonColorsDirection==KisColorPatches::Horizontal) {
m_horizontalColorPatchesLayout->addWidget(m_commonColorsWidget);
fallbackSettingsButtonVertical = false;
}
// prefer the vertical column, if patch components have different layout
if (m_commonColorsDirection != m_lastColorsDirection) {
fallbackSettingsButtonVertical = true;
}
if (!showColorSelector) {
if (fallbackSettingsButtonVertical) {
m_sidebarLayout->addWidget(m_fallbackSettingsButton);
} else {
m_horizontalPatchesContainer->addWidget(m_fallbackSettingsButton);
}
m_fallbackSettingsButton->show();
} else {
m_fallbackSettingsButton->hide();
}
updateGeometry();
......
......@@ -21,6 +21,8 @@
#include <QWidget>
#include <QPointer>
#include <QToolButton>
#include <kis_canvas2.h>
class QAction;
......@@ -57,8 +59,14 @@ private:
QAction * m_colorHistoryAction;
QAction * m_commonColorsAction;
QHBoxLayout* m_widgetLayout;
QVBoxLayout* m_mainLayout;
QHBoxLayout* m_horizontalPatchesContainer;
QVBoxLayout* m_sidebarLayout;
QHBoxLayout* m_verticalColorPatchesLayout; // vertical color patches should be added here
QVBoxLayout* m_horizontalColorPatchesLayout;//horizontal ----------"----------------------
QToolButton* m_fallbackSettingsButton;
QPointer<KisCanvas2> m_canvas;
......
......@@ -170,6 +170,7 @@ void KisColorSelectorSettings::savePreferences() const
cfg.writeEntry("onDockerResize", ui->dockerResizeOptionsComboBox->currentIndex());
cfg.writeEntry("zoomSelectorOptions", ui->zoomSelectorOptionComboBox->currentIndex() );
cfg.writeEntry("zoomSize", ui->popupSize->value());
cfg.writeEntry("showColorSelector", ui->chkShowColorSelector->isChecked());
bool useCustomColorSpace = ui->useDifferentColorSpaceCheckbox->isChecked();
const KoColorSpace* colorSpace = useCustomColorSpace ? ui->colorSpace->currentColorSpace() : 0;
......@@ -358,8 +359,6 @@ void KisColorSelectorSettings::changedACSLastUsedColorAlignment(bool toggled)
ui->lastUsedColorsNumRows->setEnabled(toggled);
}
void KisColorSelectorSettings::changedACSShadeSelectorType(int index)
{
......@@ -399,7 +398,7 @@ void KisColorSelectorSettings::loadPreferences()
ui->dockerResizeOptionsComboBox->setCurrentIndex( (int)cfg.readEntry("onDockerResize", 0) );
ui->zoomSelectorOptionComboBox->setCurrentIndex( (int) cfg.readEntry("zoomSelectorOptions", 0) );
ui->popupSize->setValue(cfg.readEntry("zoomSize", 280));
ui->chkShowColorSelector->setChecked((bool) cfg.readEntry("showColorSelector", true));
{
KisConfig kisconfig(true);
......@@ -525,6 +524,7 @@ void KisColorSelectorSettings::loadDefaultPreferences()
ui->dockerResizeOptionsComboBox->setCurrentIndex(0);
ui->zoomSelectorOptionComboBox->setCurrentIndex(0);
ui->popupSize->setValue(280);
ui->chkShowColorSelector->setChecked(true);
ui->useDifferentColorSpaceCheckbox->setChecked(false);
......
Supports Markdown
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