...
 
Commits (7)
......@@ -47,7 +47,6 @@ KisCanvasResourceProvider::KisCanvasResourceProvider(KisViewManager * view)
: m_view(view)
{
m_fGChanged = true;
m_enablefGChange = true; // default to true, so that colour history is working without popup palette
}
KisCanvasResourceProvider::~KisCanvasResourceProvider()
......@@ -369,7 +368,7 @@ void KisCanvasResourceProvider::setEraserMode(bool value)
void KisCanvasResourceProvider::slotPainting()
{
if (m_fGChanged && m_enablefGChange) {
if (m_fGChanged) {
emit sigFGColorUsed(fgColor());
m_fGChanged = false;
}
......@@ -404,11 +403,6 @@ void KisCanvasResourceProvider::slotGamutMaskDeactivate()
emit sigGamutMaskDeactivated();
}
void KisCanvasResourceProvider::slotResetEnableFGChange(bool b)
{
m_enablefGChange = b;
}
QList<QPointer<KisAbstractPerspectiveGrid> > KisCanvasResourceProvider::perspectiveGrids() const
{
return m_perspectiveGrids;
......
......@@ -200,13 +200,6 @@ public Q_SLOTS:
void slotImageSizeChanged();
void slotOnScreenResolutionChanged();
// This is a flag to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
// will be added when the user clicks on the canvas to hide the palette
// In general, we want to be able to store recent color if the pop up palette
// is not visible
void slotResetEnableFGChange(bool);
private Q_SLOTS:
void slotCanvasResourceChanged(int key, const QVariant & res);
......@@ -240,14 +233,6 @@ private:
KoCanvasResourceProvider *m_resourceManager;
bool m_fGChanged;
QList<QPointer<KisAbstractPerspectiveGrid> > m_perspectiveGrids;
// This is a flag to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
// will be added when the user clicks on the canvas to hide the palette
// In general, we want to be able to store recent color if the pop up palette
// is not visible
bool m_enablefGChange;
};
#endif
......@@ -74,13 +74,6 @@ Q_SIGNALS:
void sigSetFGColor(const KoColor& c);
void sigSetBGColor(const KoColor& c);
// This is a flag to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
// will be added when the user clicks on the canvas to hide the palette
// In general, we want to be able to store recent colours if the pop up palette
// is not visible
void sigEnableChangeColor(bool b);
void sigChangeFGColorSelector(const KoColor&);
void setSelectedColor(int);
......
......@@ -472,7 +472,6 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
connect(m_favoriteResourceManager, SIGNAL(sigSetFGColor(KoColor)), m_resourceProvider, SLOT(slotSetFGColor(KoColor)));
connect(m_favoriteResourceManager, SIGNAL(sigSetBGColor(KoColor)), m_resourceProvider, SLOT(slotSetBGColor(KoColor)));
connect(m_favoriteResourceManager, SIGNAL(sigEnableChangeColor(bool)), m_resourceProvider, SLOT(slotResetEnableFGChange(bool)));
connect(view->mainWindow(), SIGNAL(themeChanged()), this, SLOT(slotUpdateSelectionIcon()));
connect(m_resourceProvider->resourceManager(), SIGNAL(canvasResourceChanged(int,QVariant)),
......
......@@ -174,16 +174,6 @@ KisPopupPalette::KisPopupPalette(KisViewManager* viewManager, KisCoordinatesConv
connect(m_resourceManager, SIGNAL(updatePalettes()), SLOT(slotUpdate()));
connect(m_resourceManager, SIGNAL(hidePalettes()), SLOT(slotHide()));
// This is used to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
// will be added when the user clicks on the canvas to hide the palette
// In general, we want to be able to store recent color if the pop up palette
// is not visible
m_timer.setSingleShot(true);
connect(this, SIGNAL(sigTriggerTimer()), this, SLOT(slotTriggerTimer()));
connect(&m_timer, SIGNAL(timeout()), this, SLOT(slotEnableChangeFGColor()));
connect(this, SIGNAL(sigEnableChangeFGColor(bool)), m_resourceManager, SIGNAL(sigEnableChangeColor(bool)));
setCursor(Qt::ArrowCursor);
setMouseTracking(true);
setHoveredPreset(-1);
......@@ -332,16 +322,6 @@ void KisPopupPalette::setSelectedColor(int x)
m_selectedColor = x;
}
void KisPopupPalette::slotTriggerTimer()
{
m_timer.start(750);
}
void KisPopupPalette::slotEnableChangeFGColor()
{
emit sigEnableChangeFGColor(true);
}
void KisPopupPalette::slotZoomSliderChanged(int zoom) {
emit zoomLevelChanged(zoom);
}
......@@ -428,9 +408,6 @@ void KisPopupPalette::showPopupPalette(bool show)
KisSignalsBlocker b(zoomCanvasSlider);
zoomCanvasSlider->setValue(m_coordinatesConverter->zoomInPercent()); // sync the zoom slider
}
emit sigEnableChangeFGColor(!show);
} else {
emit sigTriggerTimer();
}
setVisible(show);
m_brushHud->setVisible(show && m_brushHudButton->isChecked());
......
......@@ -119,8 +119,6 @@ private:
QScopedPointer<KisSignalCompressor> m_colorChangeCompressor;
KActionCollection *m_actionCollection;
QTimer m_timer;
KisBrushHud *m_brushHud {0};
float m_popupPaletteSize {385.0};
float m_colorHistoryInnerRadius {72.0};
......@@ -158,14 +156,6 @@ Q_SIGNALS:
void sigUpdateCanvas();
void zoomLevelChanged(int);
// These are used to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
// will be added when the user clicks on the canvas to hide the palette
// In general, we want to be able to store recent color if the pop up palette
// is not visible
void sigEnableChangeFGColor(bool);
void sigTriggerTimer();
public Q_SLOTS:
void slotUpdateIcons();
......@@ -174,8 +164,6 @@ private Q_SLOTS:
void slotExternalFgColorChanged(const KoColor &color);
void slotEmitColorChanged();
void slotSetSelectedColor(int x) { setSelectedColor(x); update(); }
void slotTriggerTimer();
void slotEnableChangeFGColor();
void slotUpdate() { update(); }
void slotHide() { showPopupPalette(false); }
void slotShowTagsPopup();
......
......@@ -749,10 +749,19 @@ KisOpenGL::RendererConfig KisOpenGL::selectSurfaceConfig(KisOpenGL::OpenGLRender
const OpenGLRenderer defaultRenderer = getRendererFromProbeResult(*info);
/**
* On Windows we always prefer Angle, not what Qt suggests us
*/
#ifdef Q_OS_WIN
const OpenGLRenderer preferredAutoRenderer = RendererOpenGLES;
#else
const OpenGLRenderer preferredAutoRenderer = defaultRenderer;
#endif
OpenGLRenderers supportedRenderers = RendererNone;
FormatPositionLess compareOp;
compareOp.setPreferredRendererByQt(defaultRenderer);
compareOp.setPreferredRendererByQt(preferredAutoRenderer);
#ifdef HAVE_HDR
compareOp.setPreferredColorSpace(
......@@ -794,7 +803,7 @@ KisOpenGL::RendererConfig KisOpenGL::selectSurfaceConfig(KisOpenGL::OpenGLRender
}
}
OpenGLRenderer preferredByQt = defaultRenderer;
OpenGLRenderer preferredByQt = preferredAutoRenderer;
if (preferredByQt == RendererDesktopGL &&
supportedRenderers & RendererDesktopGL &&
......
......@@ -386,6 +386,10 @@ QTransform KisResourcesSnapshot::fillTransform() const
return m_d->fillTransform;
}
KoAbstractGradientSP KisResourcesSnapshot::currentGradient() const
{
return m_d->currentGradient;
}
QBitArray KisResourcesSnapshot::channelLockFlags() const
{
......
......@@ -83,6 +83,7 @@ public:
KoColor currentFgColor() const;
KoColor currentBgColor() const;
KisPaintOpPresetSP currentPaintOpPreset() const;
KoAbstractGradientSP currentGradient() const;
QTransform fillTransform() const;
......
......@@ -314,7 +314,7 @@ KisPaintOpPresetsPopup::KisPaintOpPresetsPopup(KisCanvasResourceProvider * resou
updateThemedIcons();
// setup things like the scene construct images, layers, etc that is a one-time thing
m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->setup();
m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->setup(resourceProvider->resourceManager());
}
......
......@@ -27,6 +27,7 @@
#include <kis_brush.h>
#include <KisGlobalResourcesInterface.h>
#include "kis_transaction.h"
#include <KoCanvasResourceProvider.h>
KisPresetLivePreviewView::KisPresetLivePreviewView(QWidget *parent)
: QGraphicsView(parent),
......@@ -41,8 +42,10 @@ KisPresetLivePreviewView::~KisPresetLivePreviewView()
delete m_brushPreviewScene;
}
void KisPresetLivePreviewView::setup()
void KisPresetLivePreviewView::setup(KoCanvasResourceProvider* resourceManager)
{
m_resourceManager = resourceManager;
// initializing to 0 helps check later if they actually have something in them
m_noPreviewText = 0;
m_sceneImageItem = 0;
......@@ -280,22 +283,12 @@ void KisPresetLivePreviewView::setupAndPaintStroke()
}
}
// Preset preview cannot display gradient color source: there is
// no resource manager for KisResourcesSnapshot, therefore gradient is nullptr.
// BUG: 385521 (Selecting "Gradient" in brush editor crashes krita)
if (proxy_preset->paintOp().id() == "paintbrush") {
QString colorSourceType = settings->getString("ColorSource/Type", "plain");
if (colorSourceType == "gradient") {
settings->setProperty("ColorSource/Type", "plain");
}
}
proxy_preset->setSettings(settings);
KisResourcesSnapshotSP resources =
new KisResourcesSnapshot(m_image,
m_layer);
m_layer, m_resourceManager);
resources->setOpacity(settings->paintOpOpacity());
resources->setBrush(proxy_preset);
......
......@@ -36,6 +36,8 @@
#include <KoColor.h>
#include "kis_signal_compressor.h"
class KoCanvasResourceProvider;
/**
* Widget for displaying a live brush preview of your
* selected brush. It listens for signalsetting changes
......@@ -58,7 +60,7 @@ public:
* This live preview might be in a UI file, so make sure to
* call this before starting to use it
*/
void setup();
void setup(KoCanvasResourceProvider* resourceManager);
/**
* @brief set the current preset from resource manager for the live preview to use.
......@@ -74,6 +76,9 @@ private Q_SLOTS:
private:
///internally sets the Resource Provider for brush preview (allowing gradients in preview)
KoCanvasResourceProvider* m_resourceManager;
/// internally sets the image area for brush preview
KisImageSP m_image;
......
......@@ -233,8 +233,7 @@ void KisColorSelector::paintEvent(QPaintEvent* e)
// If checked, use theme colors for background of selector
if (cfg.readEntry("useCustomColorForBackground", false)) {
QColor customColor = cfg.readEntry("customSelectorBackgroundColor", QColor(Qt::gray));
p.fillRect(0,0,width(), height(), customColor);
p.fillRect(0,0,width(), height(), cfg.readEntry("customSelectorBackgroundColor", QColor(Qt::gray)));
} else {
p.fillRect(0,0,width(), height(), qApp->palette().window().color());
}
......
......@@ -219,6 +219,8 @@ void KisColorSelectorSettings::savePreferences() const
cfg.writeEntry("hidePopupOnClickCheck", ui->hidePopupOnClickCheck->isChecked());
cfg.writeEntry("useCustomColorForBackground", ui->useCustomColorForBackground->isChecked());
cfg.writeEntry("customSelectorBackgroundColor", ui->customColorBackgroundSelector->color().toQColor());
//mypaint model
int shadeMyPaintComboBoxIndex = ui->ACSshadeSelectorMyPaintColorModelComboBox->currentIndex();
......@@ -385,6 +387,11 @@ void KisColorSelectorSettings::useDifferentColorSpaceChecked(bool enabled)
ui->colorSpace->setEnabled(enabled);
}
void KisColorSelectorSettings::useCustomColorForSelector(bool enabled)
{
ui->customColorBackgroundSelector->setEnabled(enabled);
}
void KisColorSelectorSettings::loadPreferences()
{
//read cfg
......@@ -457,6 +464,15 @@ void KisColorSelectorSettings::loadPreferences()
ui->shadeSelectorUpdateOnBackground->setChecked(cfg.readEntry("shadeSelectorUpdateOnBackground", true));
ui->hidePopupOnClickCheck->setChecked(cfg.readEntry("hidePopupOnClickCheck", false));
ui->useCustomColorForBackground->setChecked(cfg.readEntry("useCustomColorForBackground", false));
connect(ui->useCustomColorForBackground, SIGNAL(clicked(bool)), this, SLOT(useCustomColorForSelector(bool)));
QColor storedColor = cfg.readEntry("customSelectorBackgroundColor", QColor(Qt::gray));
KoColor c;
c.fromQColor(storedColor);
ui->customColorBackgroundSelector->setColor(c);
ui->customColorBackgroundSelector->setEnabled(cfg.readEntry("useCustomColorForBackground", false));
QString shadeMyPaintType = cfg.readEntry("shadeMyPaintType", "HSV");
......
......@@ -46,6 +46,7 @@ public Q_SLOTS:
void changedColorDocker(int);
void useDifferentColorSpaceChecked(bool);
void useCustomColorForSelector(bool);
void changedACSColorSelectorType(int);
void changedACSShadeSelectorType(int);
void changedACSColorAlignment(bool);
......
......@@ -176,9 +176,9 @@ void KisMinimalShadeSelector::paintEvent(QPaintEvent *)
KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
if (cfg.readEntry("useCustomColorForBackground", false)) {
p.fillRect(0,0,width(), height(), qApp->palette().window().color());
p.fillRect(0,0,width(), height(), cfg.readEntry("customSelectorBackgroundColor", QColor(Qt::gray)));
} else {
p.fillRect(0,0,width(), height(), QColor(128,128,128));
p.fillRect(0,0,width(), height(), qApp->palette().window().color());
}
}
......
......@@ -125,9 +125,9 @@ void KisShadeSelectorLineComboBoxPopup::paintEvent(QPaintEvent *)
KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
if (cfg.readEntry("useCustomColorForBackground", false)) {
p.fillRect(0,0,width(), height(), qApp->palette().window().color());
p.fillRect(0,0,width(), height(), cfg.readEntry("customSelectorBackgroundColor", QColor(Qt::gray)));
} else {
p.fillRect(0,0,width(), height(), QColor(128,128,128));
p.fillRect(0,0,width(), height(), qApp->palette().window().color());
}
painter.fillRect(m_selectedArea, palette().highlight());
......
......@@ -355,20 +355,29 @@
</layout>
</widget>
</item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QCheckBox" name="useCustomColorForBackground">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QCheckBox" name="useCustomColorForBackground">
<property name="text">
<string>Use custom color for selector background.</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="KisColorButton" name="customColorBackgroundSelector">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</layout>
<item>
<widget class="QGroupBox" name="useDifferentColorSpaceCheckbox">
<property name="minimumSize">
......
import os
import json
from pathlib import Path
class COAToolsFormat:
......@@ -30,7 +30,6 @@ class COAToolsFormat:
COA Tools need to import the files
"""
# For each top-level node (Group Layer)
cfg = self.cfg
export_dir = output_dir
for wn in self.nodes:
children = wn.children
......@@ -52,7 +51,7 @@ class COAToolsFormat:
fn, sheet_meta = child.saveCOASpriteSheet(export_dir)
else:
fn = child.saveCOA(export_dir)
path = Path(fn)
node = child.node
coords = node.bounds().getCoords()
relative_coords = coords
......@@ -77,9 +76,7 @@ class COAToolsFormat:
"opacity": self.remap(node.opacity(), 0, 255, 0, 1),
"pivot_offset": [0.0, 0.0],
"position": relative_coords,
"resource_path": fn.replace(
export_dir + os.path.sep + cfg["outDir"] + os.path.sep, ""
),
"resource_path": str(path.relative_to(Path(export_dir))),
"rotation": 0.0,
"scale": [1.0, 1.0],
"tiles_x": tiles_x,
......@@ -88,12 +85,8 @@ class COAToolsFormat:
"z": idx - len(children) + 1,
}
coa_data["nodes"].append(coa_entry)
json_data = json.dumps(coa_data, sort_keys=True, indent=4, separators=(",", ": "))
with open(
export_dir + os.path.sep + cfg["outDir"] + os.path.sep + wn.name + ".json", "w"
) as fh:
fh.write(json_data)
Path(export_dir, wn.name + ".json").write_text(json_data)
except ValueError as e:
self.showError(e)
......@@ -4,7 +4,7 @@ from collections import OrderedDict
CONFIG = {
"outDir": "export",
"rootPat": r"^root",
"rootPat": "root",
"sym": r"[^a-zA-Z0-9_-]",
"error": {"msg": "ERROR: {}", "timeout": 8000},
"done": {"msg": "DONE: {}", "timeout": 5000},
......
import os
import re
from pathlib import Path
from ..Config import CONFIG
def exportPath(cfg, path, dirname=""):
return os.path.join(dirname, subRoot(cfg, path))
return dirname / subRoot(cfg, path)
def subRoot(cfg, path):
patF, patR = cfg["rootPat"], CONFIG["outDir"]
return re.sub(patF, patR, path, count=1)
original = Path(path)
rootless = (
original.relateive_to(patF)
if original.parents and original.parents[0] == patF
else original
)
return patR / rootless
_sanitizer_re = re.compile(CONFIG["sym"])
def sanitize(path):
ps = path.split(os.path.sep)
ps = map(lambda p: re.sub(CONFIG["sym"], "_", p), ps)
ps = os.path.sep.join(ps)
return ps
ps = map(lambda p: _sanitizer_re.sub("_", p), Path(path).parts)
return str(Path(*ps))
[tool.black]
line-length=100
include = '\.py$'
exclude = '''
/(
\.git
| Dependencies
)/
'''
\ No newline at end of file
exclude = '/(\.git)/'
......@@ -397,6 +397,11 @@ void KisToolSelectMagnetic::deleteSelectedAnchor()
void KisToolSelectMagnetic::updateSelectedAnchor()
{
//the only anchor
if (m_anchorPoints.count() == 1) {
return;
}
// initial
if (m_selectedAnchor == 0 && m_anchorPoints.count() > 1) {
m_pointCollection[m_selectedAnchor] = computeEdgeWrapper(m_anchorPoints[0], m_anchorPoints[1]);
......