Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_dlg_preferences.cc
Go to the documentation of this file.
1/*
2 * preferencesdlg.cc - part of KImageShop
3 *
4 * SPDX-FileCopyrightText: 1999 Michael Koch <koch@kde.org>
5 * SPDX-FileCopyrightText: 2003-2011 Boudewijn Rempt <boud@valdyas.org>
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#include "kis_dlg_preferences.h"
11
12#include <config-hdr.h>
13#include <opengl/kis_opengl.h>
14
15#include <QBitmap>
16#include <QCheckBox>
17#include <QComboBox>
18#include <QClipboard>
19#include <QCursor>
20#include <QScreen>
21#include <QFileDialog>
22#include <QFormLayout>
23#include <QGridLayout>
24#include <QGroupBox>
25#include <QLabel>
26#include <QLayout>
27#include <QLineEdit>
28#include <QMdiArea>
29#include <QMessageBox>
30#include <QPushButton>
31#include <QRadioButton>
32#include <QSettings>
33#include <QSlider>
34#include <QStandardPaths>
35#include <QThread>
36#include <QStyleFactory>
37#include <QScreen>
38#include <QFontComboBox>
39#include <QFont>
40#include <QSurfaceFormat>
41#include <QColorSpace>
42#include <QTextBrowser>
43
44#include <KisApplication.h>
45#include <KisDocument.h>
46#include <kis_icon.h>
47#include <KisPart.h>
50#include <KoColorProfile.h>
51#include <KoColorSpaceEngine.h>
52#include <KoConfigAuthorPage.h>
53#include <KoConfig.h>
54#include <KoPointerEvent.h>
55
56#include <KoFileDialog.h>
58#include "KoID.h"
59#include <KoVBox.h>
60
61#include <KTitleWidget>
62#include <KoResourcePaths.h>
63#include <kformat.h>
64#include <klocalizedstring.h>
65#include <kstandardguiitem.h>
66#include <kundo2stack.h>
67
68#include <KisResourceCacheDb.h>
69#include <KisResourceLocator.h>
70
74#include "kis_action_registry.h"
75#include <kis_image.h>
76#include <KisSqueezedComboBox.h>
78#include "kis_clipboard.h"
80#include "KoColorSpace.h"
83#include "kis_config.h"
84#include "kis_image_config.h"
86#include "KisMainWindow.h"
87#include "KisMimeDatabase.h"
93#ifdef Q_OS_LINUX
94#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
96
97#endif
98#include <KoColorimetryUtils.h>
99#endif
100
102
103// for the performance update
104#include <kis_cubic_curve.h>
105#include <kis_signals_blocker.h>
106
109
111#include <config-qt-patches-present.h>
112
113#ifdef Q_OS_WIN
114#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
115// this include is Qt5-only, the switch to WinTab is embedded in Qt
116# include "config_qt5_has_wintab_switch.h"
117#else
118# include <QtGui/private/qguiapplication_p.h>
119# include <QtGui/qpa/qplatformintegration.h>
120#endif
121#include "config-high-dpi-scale-factor-rounding-policy.h"
123#endif
124
125#ifdef Q_OS_ANDROID
126#include <KisAndroidUtils.h>
127#endif
128
134Q_GUI_EXPORT int qt_defaultDpi();
135
136QString shortNameOfDisplay(int index)
137{
138 if (QGuiApplication::screens().length() <= index) {
139 return QString();
140 }
141 QScreen* screen = QGuiApplication::screens()[index];
142 QString resolution = QString::number(screen->geometry().width()).append("x").append(QString::number(screen->geometry().height()));
143 QString name = screen->name();
144 // name and resolution for a specific screen can change, so they are not used in the identifier; but they can help people understand which screen is which
145
146 KisConfig cfg(true);
147 QString shortName = resolution + " " + name + " " + cfg.getScreenStringIdentfier(index);
148 return shortName;
149}
150
151
152struct WritableLocationValidator : public QValidator {
154 : QValidator(parent)
155 {
156 }
157
158 State validate(QString &line, int &/*pos*/) const override
159 {
160 QFileInfo fi(line);
161 if (!fi.isWritable()) {
162 return Intermediate;
163 }
164 return Acceptable;
165 }
166};
167
168struct BackupSuffixValidator : public QValidator {
169 BackupSuffixValidator(QObject *parent)
170 : QValidator(parent)
172 << "0" << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9"
173 << "/" << "\\" << ":" << ";" << " ")
174 {}
175
177
179
180 State validate(QString &line, int &/*pos*/) const override
181 {
182 Q_FOREACH(const QString invalidChar, invalidCharacters) {
183 if (line.contains(invalidChar)) {
184 return Invalid;
185 }
186 }
187 return Acceptable;
188 }
189};
190
191/*
192 * We need this because the final item in the ComboBox is a used as an action to launch file selection dialog.
193 * So disabling it makes sure that user doesn't accidentally scroll and select it and get confused why the
194 * file picker launched.
195 */
196class UnscrollableComboBox : public QObject
197{
198public:
199 UnscrollableComboBox(QObject *parent)
200 : QObject(parent)
201 {
202 }
203
204 bool eventFilter(QObject *, QEvent *event) override
205 {
206 if (event->type() == QEvent::Wheel) {
207 event->accept();
208 return true;
209 }
210 return false;
211 }
212};
213
214QIcon addDisabledStatesToIcon(const QIcon &_icon, const QSize &size) {
215
216 QIcon icon = _icon;
217 QImage imageOrig = _icon.pixmap(size).toImage();
218
219 auto makeFainter = [imageOrig] (int alphaVal) {
220 QImage image = imageOrig;
221 QImage alpha = QImage(image.size(), QImage::Format_Alpha8);
222 alpha.fill(alphaVal);
223 image.setAlphaChannel(alpha);
224 QPixmap pixmap = QPixmap();
225 pixmap.convertFromImage(image);
226 return pixmap;
227 };
228
229 QPixmap thirdOpaque = makeFainter(int(256*0.3));
230 QPixmap halfOpaque = makeFainter(int(256*0.65));
231
232 icon.addPixmap(thirdOpaque, QIcon::Mode::Disabled, QIcon::State::Off);
233 icon.addPixmap(thirdOpaque, QIcon::Mode::Disabled, QIcon::State::On);
234 icon.addPixmap(halfOpaque, QIcon::Mode::Normal, QIcon::State::Off);
235
236 return icon;
237}
238
239GeneralTab::GeneralTab(QWidget *_parent, const char *_name)
240 : WdgGeneralSettings(_parent, _name)
241{
242 KisConfig cfg(true);
243
244 // HACK ALERT!
245 // QScrollArea contents are opaque at multiple levels
246 // The contents themselves AND the viewport widget
247 {
248 scrollAreaWidgetContents->setAutoFillBackground(false);
249 scrollAreaWidgetContents->parentWidget()->setAutoFillBackground(false);
250 }
251
252 //
253 // Cursor Tab
254 //
255
256 QStringList cursorItems = QStringList()
257 << i18n("No Cursor")
258 << i18n("Tool Icon")
259 << i18n("Arrow")
260 << i18n("Small Circle")
261 << i18n("Crosshair")
262 << i18n("Triangle Righthanded")
263 << i18n("Triangle Lefthanded")
264 << i18n("Black Pixel")
265 << i18n("White Pixel");
266
267 QStringList outlineItems = QStringList()
268 << i18nc("Display options label to not DISPLAY brush outline", "No Outline")
269 << i18n("Circle Outline")
270 << i18n("Preview Outline")
271 << i18n("Tilt Outline");
272
273 // brush
274
275 m_cmbCursorShape->addItems(cursorItems);
276
277 m_cmbCursorShape->setCurrentIndex(cfg.newCursorStyle());
278
279 m_cmbOutlineShape->addItems(outlineItems);
280
281 m_cmbOutlineShape->setCurrentIndex(cfg.newOutlineStyle());
282
283 m_showOutlinePainting->setChecked(cfg.showOutlineWhilePainting());
284 m_changeBrushOutline->setChecked(!cfg.forceAlwaysFullSizedOutline());
285
286 KoColor cursorColor(KoColorSpaceRegistry::instance()->rgb8());
287 cursorColor.fromQColor(cfg.getCursorMainColor());
288 cursorColorButton->setColor(cursorColor);
289
290 // eraser
291
292 m_chkSeparateEraserCursor->setChecked(cfg.separateEraserCursor());
293
294 m_cmbEraserCursorShape->addItems(cursorItems);
295 m_cmbEraserCursorShape->addItem(i18n("Eraser"));
296
297 m_cmbEraserCursorShape->setCurrentIndex(cfg.eraserCursorStyle());
298
299 m_cmbEraserOutlineShape->addItems(outlineItems);
300
301 m_cmbEraserOutlineShape->setCurrentIndex(cfg.eraserOutlineStyle());
302
303 m_showEraserOutlinePainting->setChecked(cfg.showEraserOutlineWhilePainting());
304 m_changeEraserBrushOutline->setChecked(!cfg.forceAlwaysFullSizedEraserOutline());
305
306 KoColor eraserCursorColor(KoColorSpaceRegistry::instance()->rgb8());
307 eraserCursorColor.fromQColor(cfg.getEraserCursorMainColor());
308 eraserCursorColorButton->setColor(eraserCursorColor);
309
310 // Color sampler
311
312 setColorSamplerPreviewStyleItems(m_cmbColorSamplerPreviewStyle);
313 setColorSamplerPreviewStyleIndexByValue(m_cmbColorSamplerPreviewStyle, cfg.colorSamplerPreviewStyle());
314 connect(m_cmbColorSamplerPreviewStyle,
315 QOverload<int>::of(&QComboBox::currentIndexChanged),
316 this,
318 colorSamplePreviewStyleChanged(m_cmbColorSamplerPreviewStyle->currentIndex());
319
320 m_nmbColorSamplerPreviewSize->setRange(1, 400);
321 m_nmbColorSamplerPreviewSize->setValue(cfg.colorSamplerPreviewCircleDiameter());
322 m_lblColorSamplerPreviewSizePreview->setDiameter(cfg.colorSamplerPreviewCircleDiameter());
323 connect(m_nmbColorSamplerPreviewSize,SIGNAL(valueChanged(int)), SLOT(colorSamplePreviewSizeChanged(int)));
324
325 m_ssbColorSamplerPreviewThickness->setRange(1, 50);
326 m_ssbColorSamplerPreviewThickness->setValue(cfg.colorSamplerPreviewCircleThickness());
327 m_lblColorSamplerPreviewSizePreview->setThickness(cfg.colorSamplerPreviewCircleThickness()/100.0);
328 connect(m_ssbColorSamplerPreviewThickness,SIGNAL(valueChanged(qreal)), SLOT(colorSamplePreviewThicknessChanged(qreal)));
329
330 m_chkColorSamplerPreviewOutlineEnabled->setChecked(cfg.colorSamplerPreviewCircleOutlineEnabled());
331 m_lblColorSamplerPreviewSizePreview->setOutlineEnabled(cfg.colorSamplerPreviewCircleOutlineEnabled());
332 connect(m_chkColorSamplerPreviewOutlineEnabled,SIGNAL(stateChanged(int)), SLOT(colorSamplePreviewOutlineEnabledChanged(int)));
333
334 m_chkColorSamplerPreviewExtraCircles->setChecked(cfg.colorSamplerPreviewCircleExtraCirclesEnabled());
335
336 m_grpColorSamplerZoomPreview->setChecked(cfg.colorSamplerZoomPreviewEnabled());
337
338 m_ssbColorSamplerZoomPreviewScale->setRange(1, 50);
339 m_ssbColorSamplerZoomPreviewScale->setSingleStep(1);
340 m_ssbColorSamplerZoomPreviewScale->setValue(cfg.colorSamplerZoomPreviewScale());
341
342 m_cmbColorSamplerPreviewCirclePosition->addItem(i18n("Center"));
343 m_cmbColorSamplerPreviewCirclePosition->addItem(i18n("Top"));
344 m_cmbColorSamplerPreviewCirclePosition->addItem(i18n("Top Left"));
345 m_cmbColorSamplerPreviewCirclePosition->addItem(i18n("Top Right"));
346 m_cmbColorSamplerPreviewCirclePosition->setCurrentIndex(int(cfg.colorSamplerPreviewCirclePosition()));
347
348
349 KisSpinBoxI18nHelper::setText(m_ssbColorSamplerPreviewThickness, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
350
351
352
353
354
355
356
357
358 //
359 // Window Tab
360 //
361 chkUseCustomFont->setChecked(cfg.readEntry<bool>("use_custom_system_font", false));
362 cmbCustomFont->findChild <QComboBox*>("stylesComboBox")->setVisible(false);
363
364 QString fontName = cfg.readEntry<QString>("custom_system_font", "");
365 if (fontName.isEmpty()) {
366 cmbCustomFont->setCurrentFont(qApp->font());
367
368 }
369 else {
370 int pointSize = qApp->font().pointSize();
371 cmbCustomFont->setCurrentFont(QFont(fontName, pointSize));
372 }
373 int fontSize = cfg.readEntry<int>("custom_font_size", -1);
374 if (fontSize < 0) {
375 intFontSize->setValue(qApp->font().pointSize());
376 }
377 else {
378 intFontSize->setValue(fontSize);
379 }
380
381 m_cmbMDIType->setCurrentIndex(cfg.readEntry<int>("mdi_viewmode", (int)QMdiArea::TabbedView));
382 enableSubWindowOptions(m_cmbMDIType->currentIndex());
383 connect(m_cmbMDIType, SIGNAL(currentIndexChanged(int)), SLOT(enableSubWindowOptions(int)));
384
385 m_backgroundimage->setText(cfg.getMDIBackgroundImage());
386 connect(m_bnFileName, SIGNAL(clicked()), SLOT(getBackgroundImage()));
387 connect(clearBgImageButton, SIGNAL(clicked()), SLOT(clearBackgroundImage()));
388
389 QString xml = cfg.getMDIBackgroundColor();
390 KoColor mdiColor = KoColor::fromXML(xml);
391 m_mdiColor->setColor(mdiColor);
392
393 m_chkRubberBand->setChecked(cfg.readEntry<int>("mdi_rubberband", cfg.useOpenGL()));
394
395 m_chkCanvasMessages->setChecked(cfg.showCanvasMessages());
396
397 const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
398 QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
399 m_chkHiDPI->setChecked(kritarc.value("EnableHiDPI", true).toBool());
400#if defined(Q_OS_WIN) && defined(HAVE_HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY)
401 m_chkHiDPIFractionalScaling->setChecked(kritarc.value("EnableHiDPIFractionalScaling", false).toBool());
402#else
403 m_wdgHiDPIFractionalScaling->setEnabled(false);
404#endif
405 chkUsageLogging->setChecked(kritarc.value("LogUsage", true).toBool());
406
407
408 //
409 // Tools tab
410 //
411 m_radioToolOptionsInDocker->setChecked(cfg.toolOptionsInDocker());
412 cmbFlowMode->setCurrentIndex((int)!cfg.readEntry<bool>("useCreamyAlphaDarken", true));
413 cmbCmykBlendingMode->setCurrentIndex((int)!cfg.readEntry<bool>("useSubtractiveBlendingForCmykColorSpaces", true));
414 m_chkSwitchSelectionCtrlAlt->setChecked(cfg.switchSelectionCtrlAlt());
415 cmbTouchPainting->addItem(
416 KoPointerEvent::tabletInputReceived() ? i18nc("touch painting", "Auto (Disabled)")
417 : i18nc("touch painting", "Auto (Enabled)"));
418 cmbTouchPainting->addItem(i18nc("touch painting", "Enabled"));
419 cmbTouchPainting->addItem(i18nc("touch painting", "Disabled"));
420 cmbTouchPainting->setCurrentIndex(int(cfg.touchPainting()));
421 chkTouchPressureSensitivity->setChecked(cfg.readEntry("useTouchPressureSensitivity", true));
422 connect(cmbTouchPainting, SIGNAL(currentIndexChanged(int)),
424 updateTouchPressureSensitivityEnabled(cmbTouchPainting->currentIndex());
425
426 chkEnableTransformToolAfterPaste->setChecked(cfg.activateTransformToolAfterPaste());
427 chkZoomHorizontally->setChecked(cfg.zoomHorizontal());
428
429 chkEnableLongPress->setChecked(cfg.longPressEnabled());
430
431 m_groupBoxKineticScrollingSettings->setChecked(cfg.kineticScrollingEnabled());
432
433 m_cmbKineticScrollingGesture->addItem(i18n("On Touch Drag"));
434 m_cmbKineticScrollingGesture->addItem(i18n("On Click Drag"));
435 m_cmbKineticScrollingGesture->addItem(i18n("On Middle-Click Drag"));
436 //m_cmbKineticScrollingGesture->addItem(i18n("On Right Click Drag"));
437
438 spnZoomSteps->setValue(cfg.zoomSteps());
439
440
441 m_cmbKineticScrollingGesture->setCurrentIndex(cfg.kineticScrollingGesture());
442 m_kineticScrollingSensitivitySlider->setRange(0, 100);
443 m_kineticScrollingSensitivitySlider->setValue(cfg.kineticScrollingSensitivity());
444 m_chkKineticScrollingHideScrollbars->setChecked(cfg.kineticScrollingHiddenScrollbars());
445
446 intZoomMarginSize->setValue(cfg.zoomMarginSize());
447
448 bool sapEnabled = cfg.selectionActionBar();
449
450 chkEnableSelectionActionBar->setChecked(sapEnabled);
451
452 //
453 // File handling
454 //
455 int autosaveInterval = cfg.autoSaveInterval();
456 //convert to minutes
457 m_autosaveSpinBox->setValue(autosaveInterval / 60);
458 m_autosaveCheckBox->setChecked(autosaveInterval > 0);
459 chkHideAutosaveFiles->setChecked(cfg.readEntry<bool>("autosavefileshidden", true));
460
461 m_chkCompressKra->setChecked(cfg.compressKra());
462 chkZip64->setChecked(cfg.useZip64());
463 m_chkTrimKra->setChecked(cfg.trimKra());
464 m_chkTrimFramesImport->setChecked(cfg.trimFramesImport());
465
466 m_backupFileCheckBox->setChecked(cfg.backupFile());
467 cmbBackupFileLocation->setCurrentIndex(cfg.readEntry<int>("backupfilelocation", 0));
468 txtBackupFileSuffix->setText(cfg.readEntry<QString>("backupfilesuffix", "~"));
469 QValidator *validator = new BackupSuffixValidator(txtBackupFileSuffix);
470 txtBackupFileSuffix->setValidator(validator);
471 intNumBackupFiles->setValue(cfg.readEntry<int>("numberofbackupfiles", 1));
472
473 cmbDefaultExportFileType->clear();
475
476 QMap<QString, QString> mimeTypeMap;
477
478 foreach (const QString &mimeType, mimeFilter) {
479 QString description = KisMimeDatabase::descriptionForMimeType(mimeType);
480 mimeTypeMap.insert(description, mimeType);
481 }
482
483 // Sort after we get the description because mimeType values have image, application, etc... in front
484 QStringList sortedDescriptions = mimeTypeMap.keys();
485 sortedDescriptions.sort(Qt::CaseInsensitive);
486
487 cmbDefaultExportFileType->addItem(i18n("All Supported Files"), "all/mime");
488 foreach (const QString &description, sortedDescriptions) {
489 const QString &mimeType = mimeTypeMap.value(description);
490 cmbDefaultExportFileType->addItem(description, mimeType);
491 }
492
493 const QString mimeTypeToFind = cfg.exportMimeType(false).toUtf8();
494 const int index = cmbDefaultExportFileType->findData(mimeTypeToFind);
495
496 if (index >= 0) {
497 cmbDefaultExportFileType->setCurrentIndex(index);
498 } else {
499 // Index can't be found, default set to image/png
500 const QString defaultMimeType = "image/png";
501 const int defaultIndex = cmbDefaultExportFileType->findData(defaultMimeType);
502 if (defaultIndex >= 0) {
503 cmbDefaultExportFileType->setCurrentIndex(defaultIndex);
504 } else {
505 // Case where the default mime type is also not found in the combo box
506 qDebug() << "Default mime type not found in the combo box.";
507 }
508 }
509
510 QString selectedMimeType = cmbDefaultExportFileType->currentData().toString();
511
512 //
513 // Animation tab
514 //
515 m_chkAutoPin->setChecked(cfg.autoPinLayersToTimeline());
516 m_chkAdaptivePlaybackRange->setChecked(cfg.adaptivePlaybackRange());
517 m_chkAutoZoom->setChecked(cfg.autoZoomTimelineToPlaybackRange());
518
519 //
520 // Miscellaneous tab
521 //
522 cmbStartupSession->addItem(i18n("Open default window"));
523 cmbStartupSession->addItem(i18n("Load previous session"));
524 cmbStartupSession->addItem(i18n("Show session manager"));
525 cmbStartupSession->setCurrentIndex(cfg.sessionOnStartup());
526
527 chkSaveSessionOnQuit->setChecked(cfg.saveSessionOnQuit(false));
528
529 m_chkConvertOnImport->setChecked(cfg.convertToImageColorspaceOnImport());
530
533 connect(m_btnChangeSplash, &QPushButton::clicked, this, &GeneralTab::slotChangeSplashScreen);
534
535 m_undoStackSize->setValue(cfg.undoStackLimit());
536 chkCumulativeUndo->setChecked(cfg.useCumulativeUndoRedo());
537 connect(chkCumulativeUndo, SIGNAL(toggled(bool)), btnAdvancedCumulativeUndo, SLOT(setEnabled(bool)));
538 btnAdvancedCumulativeUndo->setEnabled(chkCumulativeUndo->isChecked());
539 connect(btnAdvancedCumulativeUndo, SIGNAL(clicked()), SLOT(showAdvancedCumulativeUndoSettings()));
541
542 chkShowRootLayer->setChecked(cfg.showRootLayer());
543
544 chkRenameMergedLayers->setChecked(KisImageConfig(true).renameMergedLayers());
545 chkRenamePastedLayers->setChecked(cfg.renamePastedLayers());
546 chkRenameDuplicatedLayers->setChecked(KisImageConfig(true).renameDuplicatedLayers());
547
548 KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
549 bool dontUseNative = true;
550#ifdef Q_OS_ANDROID
551 dontUseNative = false;
552#endif
553#ifdef Q_OS_UNIX
554 if (qgetenv("XDG_CURRENT_DESKTOP") == "KDE") {
555 dontUseNative = false;
556 }
557#endif
558#ifdef Q_OS_MACOS
559 dontUseNative = false;
560#endif
561#ifdef Q_OS_WIN
562 dontUseNative = false;
563#endif
564 m_chkNativeFileDialog->setChecked(!group.readEntry("DontUseNativeFileDialog", dontUseNative));
565
566 if (!qEnvironmentVariable("APPIMAGE").isEmpty()) {
567 // AppImages don't have access to platform plugins. BUG: 447805
568 // Setting the checkbox to false is
569 m_chkNativeFileDialog->setChecked(false);
570 m_chkNativeFileDialog->setEnabled(false);
571 }
572
573 intMaxBrushSize->setValue(KisImageConfig(true).maxBrushSize());
574 chkIgnoreHighFunctionKeys->setChecked(cfg.ignoreHighFunctionKeys());
575#ifndef Q_OS_WIN
576 // we properly support ignoring high F-keys on Windows only. To support on other platforms
577 // we should synchronize KisExtendedModifiersMatcher to ignore the keys as well.
578 chkIgnoreHighFunctionKeys->setVisible(false);
579#endif
580
581 cmbIconsInMenu->addItem(i18n("Default"));
582 cmbIconsInMenu->addItem(i18n("Yes"));
583 cmbIconsInMenu->addItem(i18n("No"));
584 cmbIconsInMenu->setCurrentIndex(cfg.iconsInMenu());
585
586 //
587 // Resources
588 //
589 m_urlResourceFolder->setMode(KoFileDialog::OpenDirectory);
590 m_urlResourceFolder->setConfigurationName("resource_directory");
591 const QString resourceLocation = KoResourcePaths::getAppDataLocation();
592 if (QFileInfo(resourceLocation).isWritable()) {
593 m_urlResourceFolder->setFileName(resourceLocation);
594 }
595 else {
596 m_urlResourceFolder->setFileName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
597 }
598 QValidator *writableValidator = new WritableLocationValidator(m_urlResourceFolder);
599 m_urlResourceFolder->setValidator(writableValidator);
600 connect(m_urlResourceFolder, SIGNAL(textChanged(QString)), SLOT(checkResourcePath()));
602
603 grpRestartMessage->setPixmap(
604 grpRestartMessage->style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(QSize(32, 32)));
605 grpRestartMessage->setText(i18n("You will need to Restart Krita for the changes to take an effect."));
606
607 grpAndroidWarningMessage->setVisible(false);
608 grpAndroidWarningMessage->setPixmap(
609 grpAndroidWarningMessage->style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(QSize(32, 32)));
610 grpAndroidWarningMessage->setText(
611 i18n("Saving at a Location picked from the File Picker may slow down the startup!"));
612
613#ifdef Q_OS_ANDROID
614 m_urlResourceFolder->setVisible(false);
615
616 m_resourceFolderSelector->setVisible(true);
617 m_resourceFolderSelector->installEventFilter(new UnscrollableComboBox(this));
618
619 const QList<QPair<QString, QString>> writableLocations = []() {
620 QList<QPair<QString, QString>> writableLocationsAndText;
621 // filters out the duplicates
622 const QList<QString> locations = []() {
623 QStringList filteredLocations;
624 const QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
625 Q_FOREACH(const QString &location, locations) {
626 if (!filteredLocations.contains(location)) {
627 filteredLocations.append(location);
628 }
629 }
630 return filteredLocations;
631 }();
632
633 bool isFirst = true;
634
635 Q_FOREACH (QString location, locations) {
636 QString text;
637 QFileInfo fileLocation(location);
638 // The first one that we get from is the "Default"
639 if (isFirst) {
640 text = i18n("Default");
641 isFirst = false;
642 } else if (location.startsWith("/data")) {
643 text = i18n("Internal Storage");
644 } else {
645 text = i18n("SD-Card");
646 }
647 if (fileLocation.isWritable()) {
648 writableLocationsAndText.append({text, location});
649 }
650 }
651 return writableLocationsAndText;
652 }();
653
654 for (auto it = writableLocations.constBegin(); it != writableLocations.constEnd(); ++it) {
655 m_resourceFolderSelector->addItem(it->first + " - " + it->second);
656 // we need it to extract out the path
657 m_resourceFolderSelector->setItemData(m_resourceFolderSelector->count() - 1, it->second, Qt::UserRole);
658 }
659
660 // if the user has selected a custom location, we add it to the list as well.
661 if (resourceLocation.startsWith("content://")) {
662 m_resourceFolderSelector->addItem(resourceLocation);
663 int index = m_resourceFolderSelector->count() - 1;
664 m_resourceFolderSelector->setItemData(index, resourceLocation, Qt::UserRole);
665 m_resourceFolderSelector->setCurrentIndex(index);
666 grpAndroidWarningMessage->setVisible(true);
667 } else {
668 // find the index of the current resource location in the writableLocation, so we can set our view to that
669 auto iterator = std::find_if(writableLocations.constBegin(),
670 writableLocations.constEnd(),
671 [&resourceLocation](QPair<QString, QString> location) {
672 return location.second == resourceLocation;
673 });
674
675 if (iterator != writableLocations.constEnd()) {
676 int index = writableLocations.indexOf(*iterator);
677 KIS_SAFE_ASSERT_RECOVER_NOOP(index < m_resourceFolderSelector->count());
678 m_resourceFolderSelector->setCurrentIndex(index);
679 }
680 }
681
682 // this should be the last item we add.
683 m_resourceFolderSelector->addItem(i18n("Choose Manually"));
684
685 connect(m_resourceFolderSelector, qOverload<int>(&QComboBox::activated), this, [this](int index) {
686 const int previousIndex = m_resourceFolderSelector->currentIndex();
687
688 // if it is the last item in the last item, then open file picker and set the name returned as the filename
689 if (m_resourceFolderSelector->count() - 1 == index) {
690 KoFileDialog dialog(this, KoFileDialog::OpenDirectory, "Select Directory");
691 const QString selectedDirectory = dialog.filename();
692
693 if (!selectedDirectory.isEmpty()) {
694 // if the index above "Choose Manually" is a content Uri, then we just modify it, and then set that as
695 // the index.
696 if (m_resourceFolderSelector->itemData(index - 1, Qt::DisplayRole)
697 .value<QString>()
698 .startsWith("content://")) {
699 m_resourceFolderSelector->setItemText(index - 1, selectedDirectory);
700 m_resourceFolderSelector->setItemData(index - 1, selectedDirectory, Qt::UserRole);
701 m_resourceFolderSelector->setCurrentIndex(index - 1);
702 } else {
703 // There isn't any content Uri in the ComboBox list, so just insert one, and set that as the index.
704 m_resourceFolderSelector->insertItem(index, selectedDirectory);
705 m_resourceFolderSelector->setItemData(index, selectedDirectory, Qt::UserRole);
706 m_resourceFolderSelector->setCurrentIndex(index);
707 }
708 // since we have selected the custom location, make the warning visible.
709 grpAndroidWarningMessage->setVisible(true);
710 } else {
711 m_resourceFolderSelector->setCurrentIndex(previousIndex);
712 }
713 }
714
715 // hide-unhide based on the selection of user.
716 grpAndroidWarningMessage->setVisible(
717 m_resourceFolderSelector->currentData(Qt::UserRole).value<QString>().startsWith("content://"));
718 });
719
720#else
721 m_resourceFolderSelector->setVisible(false);
722#endif
723
724 grpWindowsAppData->setVisible(false);
725#ifdef Q_OS_WIN
726 QString folderInStandardAppData;
727 QString folderInPrivateAppData;
728 KoResourcePaths::getAllUserResourceFoldersLocationsForWindowsStore(folderInStandardAppData, folderInPrivateAppData);
729
730 if (!folderInPrivateAppData.isEmpty()) {
731 const auto pathToDisplay = [](const QString &path) {
732 // Due to how Unicode word wrapping works, the string does not
733 // wrap after backslashes in Qt 5.12. We don't want the path to
734 // become too long, so we add a U+200B ZERO WIDTH SPACE to allow
735 // wrapping. The downside is that we cannot let the user select
736 // and copy the path because it now contains invisible unicode
737 // code points.
738 // See: https://bugreports.qt.io/browse/QTBUG-80892
739 return QDir::toNativeSeparators(path).replace(QChar('\\'), QStringLiteral(u"\\\u200B"));
740 };
741
742 const QDir privateResourceDir(folderInPrivateAppData);
743 const QDir appDataDir(folderInStandardAppData);
744 grpWindowsAppData->setPixmap(
745 grpWindowsAppData->style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(QSize(32, 32)));
746 // Similar text is also used in KisViewManager.cpp
747 grpWindowsAppData->setText(i18nc("@info resource folder",
748 "<p>You are using the Microsoft Store package version of Krita. "
749 "Even though Krita can be configured to place resources under the "
750 "user AppData location, Windows may actually store the files "
751 "inside a private app location.</p>\n"
752 "<p>You should check both locations to determine where "
753 "the files are located.</p>\n"
754 "<p><b>User AppData</b> (<a href=\"copyuser\">Copy</a>):<br/>\n"
755 "%1</p>\n"
756 "<p><b>Private app location</b> (<a href=\"copyprivate\">Copy</a>):<br/>\n"
757 "%2</p>",
758 pathToDisplay(appDataDir.absolutePath()),
759 pathToDisplay(privateResourceDir.absolutePath())));
760 grpWindowsAppData->setVisible(true);
761
762 connect(grpWindowsAppData,
764 qApp,
765 [userPath = appDataDir.absolutePath(),
766 privatePath = privateResourceDir.absolutePath()](const QString &link) {
767 if (link == QStringLiteral("copyuser")) {
768 qApp->clipboard()->setText(QDir::toNativeSeparators(userPath));
769 } else if (link == QStringLiteral("copyprivate")) {
770 qApp->clipboard()->setText(QDir::toNativeSeparators(privatePath));
771 } else {
772 qWarning() << "Unexpected link activated in lblWindowsAppDataNote:" << link;
773 }
774 });
775 }
776#endif
777
778
779 const int forcedFontDPI = cfg.readEntry("forcedDpiForQtFontBugWorkaround", -1);
780 chkForcedFontDPI->setChecked(forcedFontDPI > 0);
781 intForcedFontDPI->setValue(forcedFontDPI > 0 ? forcedFontDPI : qt_defaultDpi());
782 intForcedFontDPI->setEnabled(forcedFontDPI > 0);
783 connect(chkForcedFontDPI, SIGNAL(toggled(bool)), intForcedFontDPI, SLOT(setEnabled(bool)));
784
785 m_pasteFormatGroup.addButton(btnDownload, KisClipboard::PASTE_FORMAT_DOWNLOAD);
786 m_pasteFormatGroup.addButton(btnLocal, KisClipboard::PASTE_FORMAT_LOCAL);
787 m_pasteFormatGroup.addButton(btnBitmap, KisClipboard::PASTE_FORMAT_CLIP);
788 m_pasteFormatGroup.addButton(btnAsk, KisClipboard::PASTE_FORMAT_ASK);
789
790 QAbstractButton *button = m_pasteFormatGroup.button(cfg.pasteFormat(false));
791
792 Q_ASSERT(button);
793
794 if (button) {
795 button->setChecked(true);
796 }
797}
798
800{
801 KisConfig cfg(true);
802
803 m_cmbCursorShape->setCurrentIndex(cfg.newCursorStyle(true));
804 m_cmbOutlineShape->setCurrentIndex(cfg.newOutlineStyle(true));
805 m_chkSeparateEraserCursor->setChecked(cfg.readEntry<bool>("separateEraserCursor", false));
806 m_cmbEraserCursorShape->setCurrentIndex(cfg.eraserCursorStyle(true));
807 m_cmbEraserOutlineShape->setCurrentIndex(cfg.eraserOutlineStyle(true));
808 setColorSamplerPreviewStyleIndexByValue(m_cmbColorSamplerPreviewStyle, cfg.colorSamplerPreviewStyle(true));
809 m_ssbColorSamplerPreviewThickness->setValue(cfg.colorSamplerPreviewCircleThickness(true));
810 m_nmbColorSamplerPreviewSize->setValue(cfg.colorSamplerPreviewCircleDiameter(true));
811 m_chkColorSamplerPreviewOutlineEnabled->setChecked(cfg.colorSamplerPreviewCircleOutlineEnabled(true));
812 m_grpColorSamplerZoomPreview->setChecked(cfg.colorSamplerZoomPreviewEnabled(true));
813 m_ssbColorSamplerZoomPreviewScale->setValue(cfg.colorSamplerZoomPreviewScale(true));
814 m_cmbColorSamplerPreviewCirclePosition->setCurrentIndex(int(cfg.colorSamplerPreviewCirclePosition(true)));
815
816
817 chkShowRootLayer->setChecked(cfg.showRootLayer(true));
818 m_autosaveCheckBox->setChecked(cfg.autoSaveInterval(true) > 0);
819 //convert to minutes
820 m_autosaveSpinBox->setValue(cfg.autoSaveInterval(true) / 60);
821 chkHideAutosaveFiles->setChecked(true);
822
825
826 m_undoStackSize->setValue(cfg.undoStackLimit(true));
827 chkCumulativeUndo->setChecked(cfg.useCumulativeUndoRedo(true));
829
830 m_backupFileCheckBox->setChecked(cfg.backupFile(true));
831 cmbBackupFileLocation->setCurrentIndex(0);
832 txtBackupFileSuffix->setText("~");
833 intNumBackupFiles->setValue(1);
834
835 m_showOutlinePainting->setChecked(cfg.showOutlineWhilePainting(true));
836 m_changeBrushOutline->setChecked(!cfg.forceAlwaysFullSizedOutline(true));
837 m_showEraserOutlinePainting->setChecked(cfg.showEraserOutlineWhilePainting(true));
838 m_changeEraserBrushOutline->setChecked(!cfg.forceAlwaysFullSizedEraserOutline(true));
839
840#if defined Q_OS_ANDROID || defined Q_OS_MACOS || defined Q_OS_WIN
841 m_chkNativeFileDialog->setChecked(true);
842#else
843 m_chkNativeFileDialog->setChecked(false);
844#endif
845
846 intMaxBrushSize->setValue(1000);
847
848 chkIgnoreHighFunctionKeys->setChecked(cfg.ignoreHighFunctionKeys(true));
849
850
851 chkUseCustomFont->setChecked(false);
852 cmbCustomFont->setCurrentFont(qApp->font());
853 intFontSize->setValue(qApp->font().pointSize());
854
855
856 m_cmbMDIType->setCurrentIndex((int)QMdiArea::TabbedView);
857 m_chkRubberBand->setChecked(cfg.useOpenGL(true));
858 KoColor mdiColor;
859 mdiColor.fromXML(cfg.getMDIBackgroundColor(true));
860 m_mdiColor->setColor(mdiColor);
861 m_backgroundimage->setText(cfg.getMDIBackgroundImage(true));
862 m_chkCanvasMessages->setChecked(cfg.showCanvasMessages(true));
863 m_chkCompressKra->setChecked(cfg.compressKra(true));
864 m_chkTrimKra->setChecked(cfg.trimKra(true));
865 m_chkTrimFramesImport->setChecked(cfg.trimFramesImport(true));
866 chkZip64->setChecked(cfg.useZip64(true));
867 m_chkHiDPI->setChecked(true);
868#if defined(Q_OS_WIN) && defined(HAVE_HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY)
869 m_chkHiDPIFractionalScaling->setChecked(true);
870#endif
871 chkUsageLogging->setChecked(true);
872 m_radioToolOptionsInDocker->setChecked(cfg.toolOptionsInDocker(true));
873 cmbFlowMode->setCurrentIndex(0);
874 chkEnableLongPress->setChecked(cfg.longPressEnabled(true));
875 m_groupBoxKineticScrollingSettings->setChecked(cfg.kineticScrollingEnabled(true));
876 m_cmbKineticScrollingGesture->setCurrentIndex(cfg.kineticScrollingGesture(true));
877 spnZoomSteps->setValue(cfg.zoomSteps(true));
878 m_kineticScrollingSensitivitySlider->setValue(cfg.kineticScrollingSensitivity(true));
879 m_chkKineticScrollingHideScrollbars->setChecked(cfg.kineticScrollingHiddenScrollbars(true));
880 intZoomMarginSize->setValue(cfg.zoomMarginSize(true));
881 m_chkSwitchSelectionCtrlAlt->setChecked(cfg.switchSelectionCtrlAlt(true));
882 cmbTouchPainting->setCurrentIndex(int(cfg.touchPainting(true)));
883 chkTouchPressureSensitivity->setChecked(true);
884 chkEnableTransformToolAfterPaste->setChecked(cfg.activateTransformToolAfterPaste(true));
885 chkZoomHorizontally->setChecked(cfg.zoomHorizontal(true));
886 m_chkConvertOnImport->setChecked(cfg.convertToImageColorspaceOnImport(true));
887
888 KoColor cursorColor(KoColorSpaceRegistry::instance()->rgb8());
889 cursorColor.fromQColor(cfg.getCursorMainColor(true));
890 cursorColorButton->setColor(cursorColor);
891
892 KoColor eraserCursorColor(KoColorSpaceRegistry::instance()->rgb8());
893 eraserCursorColor.fromQColor(cfg.getEraserCursorMainColor(true));
894 eraserCursorColorButton->setColor(eraserCursorColor);
895
896
897 m_chkAutoPin->setChecked(cfg.autoPinLayersToTimeline(true));
898 m_chkAdaptivePlaybackRange->setChecked(cfg.adaptivePlaybackRange(false));
899
900 m_urlResourceFolder->setFileName(KoResourcePaths::getAppDataLocation());
901
902 chkForcedFontDPI->setChecked(false);
903 intForcedFontDPI->setValue(qt_defaultDpi());
904 intForcedFontDPI->setEnabled(false);
905
906 chkRenameMergedLayers->setChecked(KisImageConfig(true).renameMergedLayers(true));
907 chkRenamePastedLayers->setChecked(cfg.renamePastedLayers(true));
908 chkRenameDuplicatedLayers->setChecked(KisImageConfig(true).renameDuplicatedLayers(true));
909
910 QAbstractButton *button = m_pasteFormatGroup.button(cfg.pasteFormat(true));
911 Q_ASSERT(button);
912
913 if (button) {
914 button->setChecked(true);
915 }
916}
917
919{
920 KisDlgConfigureCumulativeUndo dlg(m_cumulativeUndoData, m_undoStackSize->value(), this);
921 if (dlg.exec() == KoDialog::Accepted) {
923 }
924}
925
927{
928 bool circleSettingsVisible = index == int(KisConfig::ColorSamplerPreviewStyle::Circle);
929 m_frmColorSamplerCircleSettings->setVisible(circleSettingsVisible);
930}
931
933{
934 m_lblColorSamplerPreviewSizePreview->setDiameter(value);
935}
936
938{
939 m_lblColorSamplerPreviewSizePreview->setThickness(value/100.0);
940}
941
943{
944 m_lblColorSamplerPreviewSizePreview->setOutlineEnabled(value);
945}
946
951
953{
955 if (dlg.exec() == QDialog::Accepted) {
958 }
959}
960
961void GeneralTab::setButtonGroupEnabled(const QButtonGroup &buttonGroup, bool value)
962{
963 Q_FOREACH(QAbstractButton* button, buttonGroup.buttons()) {
964 if (button) {
965 button->setEnabled(value);
966 }
967 }
968}
969
971{
972 return (CursorStyle)m_cmbCursorShape->currentIndex();
973}
974
976{
977 return (OutlineStyle)m_cmbOutlineShape->currentIndex();
978}
979
981{
982 return (CursorStyle)m_cmbEraserCursorShape->currentIndex();
983}
984
986{
987 return (OutlineStyle)m_cmbEraserOutlineShape->currentIndex();
988}
989
994
996{
997 return m_nmbColorSamplerPreviewSize->value();
998}
999
1001{
1002 return m_ssbColorSamplerPreviewThickness->value();
1003}
1004
1006{
1007 return m_chkColorSamplerPreviewOutlineEnabled->isChecked();
1008}
1009
1011{
1012 return m_chkColorSamplerPreviewExtraCircles->isChecked();
1013}
1014
1016{
1017 return m_ssbColorSamplerZoomPreviewScale->value();
1018}
1019
1021{
1022 return m_grpColorSamplerZoomPreview->isChecked();
1023}
1024
1026{
1027 int index = m_cmbColorSamplerPreviewCirclePosition->currentIndex();
1029}
1030
1032{
1033 return (KisConfig::SessionOnStartup)cmbStartupSession->currentIndex();
1034}
1035
1037{
1038 return (KisConfig::IconsInMenu)cmbIconsInMenu->currentIndex();
1039}
1040
1042{
1043 return chkSaveSessionOnQuit->isChecked();
1044}
1045
1047{
1048 return chkShowRootLayer->isChecked();
1049}
1050
1052{
1053 //convert to seconds
1054 return m_autosaveCheckBox->isChecked() ? m_autosaveSpinBox->value() * 60 : 0;
1055}
1056
1058{
1059 return m_splashScreenImage;
1060}
1061
1063{
1064 return m_undoStackSize->value();
1065}
1066
1068{
1069 return m_showOutlinePainting->isChecked();
1070}
1071
1073{
1074 return m_showEraserOutlinePainting->isChecked();
1075}
1076
1078{
1079 return m_cmbMDIType->currentIndex();
1080}
1081
1083{
1084 return m_chkCanvasMessages->isChecked();
1085}
1086
1088{
1089 return m_chkCompressKra->isChecked();
1090}
1091
1093{
1094 return m_chkTrimKra->isChecked();
1095}
1096
1098{
1099 return m_chkTrimFramesImport->isChecked();
1100}
1101
1103{
1104 return cmbDefaultExportFileType->currentData().toString();
1105}
1106
1108{
1109 return chkZip64->isChecked();
1110}
1111
1113{
1114 return m_radioToolOptionsInDocker->isChecked();
1115}
1116
1118{
1119 return spnZoomSteps->value();
1120}
1121
1123{
1124 return chkEnableLongPress->isChecked();
1125}
1126
1128{
1129 return m_groupBoxKineticScrollingSettings->isChecked();
1130}
1131
1133{
1134 return m_cmbKineticScrollingGesture->currentIndex();
1135}
1136
1138{
1139 return m_kineticScrollingSensitivitySlider->value();
1140}
1141
1143{
1144 return m_chkKineticScrollingHideScrollbars->isChecked();
1145}
1146
1148{
1149 return intZoomMarginSize->value();
1150}
1151
1153{
1154 return m_chkSwitchSelectionCtrlAlt->isChecked();
1155}
1156
1158{
1159 return m_chkConvertOnImport->isChecked();
1160}
1161
1163{
1164 return m_chkAutoPin->isChecked();
1165}
1166
1168{
1169 return m_chkAdaptivePlaybackRange->isChecked();
1170}
1171
1173{
1174 return m_chkAutoZoom->isChecked();
1175}
1176
1178{
1179 return chkForcedFontDPI->isChecked() ? intForcedFontDPI->value() : -1;
1180}
1181
1183{
1184 // Order is synchronized with KisConfig::ColorSamplerPreviewStyle.
1185 cmb->addItems({
1186 i18nc("Preview option for no color sampler", "None"),
1187 i18nc("Preview option for a circular/ring-shaped color sampler", "Circle"),
1188 i18nc("Preview option for a rectangular color sampler left of the cursor", "Rectangle Left"),
1189 i18nc("Preview option for a rectangular color sampler right of the cursor", "Rectangle Right"),
1190 i18nc("Preview option for a rectangular color sampler above the cursor", "Rectangle Above"),
1191 });
1192}
1193
1195{
1196 cmb->setCurrentIndex(int(style));
1197}
1198
1203
1205{
1206 return chkRenameMergedLayers->isChecked();
1207}
1208
1210{
1211 return chkRenamePastedLayers->isChecked();
1212}
1213
1215{
1216 return chkRenameDuplicatedLayers->isChecked();
1217}
1218
1220{
1221 KoFileDialog dialog(this, KoFileDialog::OpenFile, "BackgroundImages");
1222 dialog.setCaption(i18n("Select a Background Image"));
1223 dialog.setDefaultDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
1224 dialog.setImageFilters();
1225
1226 QString fn = dialog.filename();
1227 // dialog box was canceled or somehow no file was selected
1228 if (fn.isEmpty()) {
1229 return;
1230 }
1231
1232 QImage image(fn);
1233 if (image.isNull()) {
1234 QMessageBox::warning(this, i18nc("@title:window", "Krita"), i18n("%1 is not a valid image file!", fn));
1235 }
1236 else {
1237 m_backgroundimage->setText(fn);
1238 }
1239}
1240
1242{
1243 // clearing the background image text will implicitly make the background color be used
1244 m_backgroundimage->setText("");
1245}
1246
1248{
1249 const QFileInfo fi(m_urlResourceFolder->fileName());
1250 if (!fi.isWritable()) {
1251 grpNonWritableLocation->setPixmap(
1252 grpNonWritableLocation->style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(QSize(32, 32)));
1253 grpNonWritableLocation->setText(
1254 i18nc("@info resource folder", "<b>Warning:</b> this location is not writable."));
1255 grpNonWritableLocation->setVisible(true);
1256 } else {
1257 grpNonWritableLocation->setVisible(false);
1258 }
1259}
1260
1262{
1263 group_subWinMode->setEnabled(mdi_mode == QMdiArea::SubWindowView);
1264}
1265
1267{
1268 chkTouchPressureSensitivity->setEnabled(touchPainting != int(KisConfig::TOUCH_PAINTING_DISABLED));
1269}
1270
1271
1272#include "kactioncollection.h"
1273#include "KisActionsSnapshot.h"
1274
1275ShortcutSettingsTab::ShortcutSettingsTab(QWidget *parent, const char *name)
1276 : QWidget(parent)
1277{
1278 setObjectName(name);
1279
1280 QGridLayout * l = new QGridLayout(this);
1281 l->setContentsMargins(0, 0, 0, 0);
1282 m_page = new WdgShortcutSettings(this);
1283 l->addWidget(m_page, 0, 0);
1284
1285
1286 m_snapshot.reset(new KisActionsSnapshot);
1287
1288 KisKActionCollection *collection =
1290
1291 Q_FOREACH (QAction *action, collection->actions()) {
1292 m_snapshot->addAction(action->objectName(), action);
1293 }
1294
1295 QMap<QString, KisKActionCollection*> sortedCollections =
1296 m_snapshot->actionCollections();
1297
1298 for (auto it = sortedCollections.constBegin(); it != sortedCollections.constEnd(); ++it) {
1299 m_page->addCollection(it.value(), it.key());
1300 }
1301}
1302
1306
1311
1317
1322
1323ColorSettingsTab::ColorSettingsTab(QWidget *parent, const char *name)
1324 : QWidget(parent)
1325 , m_proofModel(new KisProofingConfigModel())
1326{
1327 setObjectName(name);
1328
1329 // XXX: Make sure only profiles that fit the specified color model
1330 // are shown in the profile combos
1331
1332 QGridLayout * l = new QGridLayout(this);
1333 l->setContentsMargins(0, 0, 0, 0);
1334 m_page = new WdgColorSettings(this);
1335 l->addWidget(m_page, 0, 0);
1336
1337 KisConfig cfg(true);
1338
1340
1341 m_page->useDefColorSpace->setChecked(cfg.useDefaultColorSpace());
1342 connect(m_page->useDefColorSpace, SIGNAL(toggled(bool)), this, SLOT(toggleUseDefaultColorSpace(bool)));
1344 for (QList<KoID>::iterator id = colorSpaces.begin(); id != colorSpaces.end(); /* nop */) {
1346 id = colorSpaces.erase(id);
1347 } else {
1348 ++id;
1349 }
1350 }
1351 m_page->cmbWorkingColorSpace->setIDList(colorSpaces);
1352 m_page->cmbWorkingColorSpace->setCurrent(cfg.workingColorSpace());
1353 m_page->cmbWorkingColorSpace->setEnabled(cfg.useDefaultColorSpace());
1354
1355 if (!m_colorManagedByOS) {
1356 m_page->bnAddColorProfile->setIcon(koIcon("document-import-16"));
1357 connect(m_page->bnAddColorProfile, SIGNAL(clicked()), SLOT(installProfile()));
1358 }
1359 m_page->bnAddColorProfile->setVisible(!m_colorManagedByOS);
1360
1361 {
1362 QStringList profiles;
1363 QMap<QString, const KoColorProfile *> profileList;
1364 Q_FOREACH(const KoColorProfile *profile, KoColorSpaceRegistry::instance()->profilesFor(RGBAColorModelID.id())) {
1365 profileList[profile->name()] = profile;
1366 profiles.append(profile->name());
1367 }
1368
1369 std::sort(profiles.begin(), profiles.end());
1370 Q_FOREACH (const QString profile, profiles) {
1371 m_page->cmbColorProfileForEXR->addSqueezedItem(profile);
1372 }
1373
1375 const QString defaultProfile = KoColorSpaceRegistry::instance()->defaultProfileForColorSpace(colorSpaceId);
1376 const QString userProfile = cfg.readEntry("ExrDefaultColorProfile", defaultProfile);
1377
1378 m_page->cmbColorProfileForEXR->setCurrent(profiles.contains(userProfile) ? userProfile : defaultProfile);
1379 }
1380
1381
1382 if (!m_colorManagedByOS) {
1383 QFormLayout *monitorProfileGrid = new QFormLayout(m_page->monitorprofileholder);
1384 monitorProfileGrid->setContentsMargins(0, 0, 0, 0);
1385 for(int i = 0; i < QGuiApplication::screens().count(); ++i) {
1386 QLabel *lbl = new QLabel(i18nc("The number of the screen (ordinal) and shortened 'name' of the screen (model + resolution)", "Screen %1 (%2):", i + 1, shortNameOfDisplay(i)));
1387 lbl->setWordWrap(true);
1390 cmb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
1391 monitorProfileGrid->addRow(lbl, cmb);
1393 }
1394
1395 refillMonitorProfiles(KoID("RGBA"));
1396
1397 for(int i = 0; i < QApplication::screens().count(); ++i) {
1398 if (m_monitorProfileWidgets[i]->contains(cfg.monitorProfile(i))) {
1399 m_monitorProfileWidgets[i]->setCurrent(cfg.monitorProfile(i));
1400 }
1401 }
1402 } else {
1403 QVBoxLayout *vboxLayout = new QVBoxLayout(m_page->monitorprofileholder);
1404 vboxLayout->setContentsMargins(0, 0, 0, 0);
1405 vboxLayout->addItem(new QSpacerItem(20,20));
1406
1407 QGroupBox *groupBox = new QGroupBox(i18n("Display's color space is managed by the operating system"));
1408 vboxLayout->addWidget(groupBox);
1409
1410 QFormLayout *monitorProfileGrid = new QFormLayout(groupBox);
1411 monitorProfileGrid->setContentsMargins(0, 0, 0, 0);
1412
1414 new QCheckBox(i18n("Enable canvas color management"), this);
1415
1417 i18n("<p>Enabling canvas color management automatically creates "
1418 "a separate native surface for the canvas. It might cause "
1419 "performance issues on some systems.</p>"
1420 ""
1421 "<p>If color management is disabled, Krita will render "
1422 "the canvas into the surface of the main window, which "
1423 "is considered sRGB. It will cause two limitations:"
1424 ""
1425 "<ol>"
1426 " <li>the color gamut will be limited to sRGB</li>"
1427 " <li>color proofing mode will be limited to \"use global display settings\", "
1428 " i.e. paper white proofing will become impossible</li>"
1429 "</ol>"
1430 "</p>"));
1431
1432 monitorProfileGrid->addRow(m_chkEnableCanvasColorSpaceManagement);
1433
1434 // surface color space
1436 m_canvasSurfaceColorSpace->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
1437 QLabel *canvasSurfaceColorSpaceLbl = new QLabel(i18n("Canvas surface color space:"), this);
1438 monitorProfileGrid->addRow(canvasSurfaceColorSpaceLbl, m_canvasSurfaceColorSpace);
1439
1440 m_canvasSurfaceColorSpace->addSqueezedItem(i18n("Preferred by operating system"), QVariant::fromValue(CanvasSurfaceMode::Preferred));
1441 m_canvasSurfaceColorSpace->addSqueezedItem(i18n("Rec 709 Gamma 2.2"), QVariant::fromValue(CanvasSurfaceMode::Rec709g22));
1442 m_canvasSurfaceColorSpace->addSqueezedItem(i18n("Rec 709 Linear"), QVariant::fromValue(CanvasSurfaceMode::Rec709g10));
1443 m_canvasSurfaceColorSpace->addSqueezedItem(i18n("Rec 2020 PQ"), QVariant::fromValue(CanvasSurfaceMode::Rec2020pq));
1444 m_canvasSurfaceColorSpace->addSqueezedItem(i18n("Unmanaged (testing only)"), QVariant::fromValue(CanvasSurfaceMode::Unmanaged));
1445
1446 m_canvasSurfaceColorSpace->setToolTip(
1447 i18n("<p>Color space of the pixels that are transferred to the "
1448 "window compositor. Use \"preferred\" space unless you know "
1449 "what you are doing</p>"));
1450
1451 // surface bit depth
1453 m_canvasSurfaceBitDepth->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
1454 QLabel *canvasSurfaceBitDepthLbl = new QLabel(i18n("Canvas surface bit depth (needs restart):"), this);
1455 monitorProfileGrid->addRow(canvasSurfaceBitDepthLbl, m_canvasSurfaceBitDepth);
1456
1457 m_canvasSurfaceBitDepth->addSqueezedItem(i18n("Auto"), QVariant::fromValue(CanvasSurfaceBitDepthMode::DepthAuto));
1458 m_canvasSurfaceBitDepth->addSqueezedItem(i18n("8-bit"), QVariant::fromValue(CanvasSurfaceBitDepthMode::Depth8Bit));
1459 m_canvasSurfaceBitDepth->addSqueezedItem(i18n("10-bit"), QVariant::fromValue(CanvasSurfaceBitDepthMode::Depth10Bit));
1460
1461 m_canvasSurfaceBitDepth->setToolTip(
1462 i18n("<p>The bit depth of the color that is passed to the window "
1463 "compositor. You should switch into 10-bit mode if you want to use "
1464 "HDR capabilities of your display</p>"));
1465
1466 const QString currentBitBepthString = QSurfaceFormat::defaultFormat().redBufferSize() == 10 ? i18n("10-bit") : i18n("8-bit");
1467 QLabel *currentCanvasSurfaceBitDepthLbl = new QLabel(i18n("Current canvas surface bit depth:"), this);
1468 QLabel *currentCanvasSurfaceBitDepth = new QLabel(currentBitBepthString, this);
1469 monitorProfileGrid->addRow(currentCanvasSurfaceBitDepthLbl, currentCanvasSurfaceBitDepth);
1470
1471 vboxLayout->addItem(new QSpacerItem(20,20));
1472
1474 QTextBrowser *preferredLbl = new QTextBrowser(this);
1475 preferredLbl->setText(i18n("Color space preferred by the operating system:\n%1", KisPlatformPluginInterfaceFactory::instance()->osPreferredColorSpaceReport(mainWindow)));
1476 preferredLbl->setReadOnly(true);
1477
1478 QHBoxLayout *colorDescriptionChoice = new QHBoxLayout();
1479 vboxLayout->addLayout(colorDescriptionChoice);
1480
1481 QLabel *descriptionChoiceLabel = new QLabel(i18n("Diagram:"));
1482 colorDescriptionChoice->addWidget(descriptionChoiceLabel);
1483
1484 QRadioButton *containerSpace = new QRadioButton(i18nc("@info:radiobutton", "Preferred Space"), this);
1485 colorDescriptionChoice->addWidget(containerSpace);
1486 containerSpace->setToolTip(i18nc("@info:tooltip", "This is the space preferred by the operating system."));
1487 m_preferredSpaceGraphicMode.addButton(containerSpace, PreferredSpace);
1488
1489 QRadioButton *masteringSpace = new QRadioButton(i18nc("@info:radiobutton", "Current Display"), this);
1490 colorDescriptionChoice->addWidget(masteringSpace);
1491 m_preferredSpaceGraphicMode.addButton(masteringSpace, MasteringSpace);
1492 masteringSpace->setToolTip(i18nc("@info:tooltip", "This is the space representing the currently active display."));
1493
1494 QHBoxLayout *colorDescriptionLayout = new QHBoxLayout();
1495 vboxLayout->addLayout(colorDescriptionLayout);
1497 colorDescriptionLayout->addWidget(m_preferredSpaceGraphic);
1498 colorDescriptionLayout->addWidget(preferredLbl);
1499
1500 containerSpace->setChecked(true);
1501 colorDescriptionChoice->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
1502
1503 m_preferredSpaceGraphic->setFixedSize(QSize(200, 200));
1505 connect(&m_preferredSpaceGraphicMode, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(updatePreferredSpaceGraphic()));
1509
1511
1512 {
1513 auto mode = cfg.canvasSurfaceColorSpaceManagementMode();
1514 int index = m_canvasSurfaceColorSpace->findData(QVariant::fromValue(mode));
1515 KIS_SAFE_ASSERT_RECOVER(index >= 0) {
1516 index = 0;
1517 }
1518 m_canvasSurfaceColorSpace->setCurrentIndex(index);
1519 }
1520
1521 {
1522 auto mode = cfg.canvasSurfaceBitDepthMode();
1523 int index = m_canvasSurfaceBitDepth->findData(QVariant::fromValue(mode));
1524 KIS_SAFE_ASSERT_RECOVER(index >= 0) {
1525 index = 0;
1526 }
1527 m_canvasSurfaceBitDepth->setCurrentIndex(index);
1528 }
1529
1530 connect(m_chkEnableCanvasColorSpaceManagement, &QCheckBox::toggled, m_canvasSurfaceColorSpace, &QWidget::setEnabled);
1532
1533 connect(m_chkEnableCanvasColorSpaceManagement, &QCheckBox::toggled, canvasSurfaceColorSpaceLbl, &QWidget::setEnabled);
1534 canvasSurfaceColorSpaceLbl->setEnabled(m_chkEnableCanvasColorSpaceManagement->isChecked());
1535
1536 connect(m_chkEnableCanvasColorSpaceManagement, &QCheckBox::toggled, m_canvasSurfaceBitDepth, &QWidget::setEnabled);
1538
1539 connect(m_chkEnableCanvasColorSpaceManagement, &QCheckBox::toggled, canvasSurfaceBitDepthLbl, &QWidget::setEnabled);
1540 canvasSurfaceBitDepthLbl->setEnabled(m_chkEnableCanvasColorSpaceManagement->isChecked());
1541 }
1542
1543 m_page->chkBlackpoint->setChecked(cfg.useBlackPointCompensation());
1544 m_page->chkAllowLCMSOptimization->setChecked(cfg.allowLCMSOptimization());
1545 m_page->chkForcePaletteColor->setChecked(cfg.forcePaletteColors());
1546 m_page->cmbMonitorIntent->setCurrentIndex(cfg.monitorRenderIntent());
1547 KisImageConfig cfgImage(true);
1548
1552 KisProofingConfigurationSP proofingConfig = cfgImage.defaultProofingconfiguration();
1553
1554 m_page->wdgProofingOptions->setProofingConfig(proofingConfig);
1555
1556 m_proofModel->data.set(*proofingConfig.data());
1557
1558 connect(m_page->chkBlackpoint, SIGNAL(toggled(bool)), this, SLOT(updateProofingDisplayInfo()));
1559 connect(m_page->cmbMonitorIntent, SIGNAL(currentIndexChanged(int)), this, SLOT(updateProofingDisplayInfo()));
1561
1564 m_pasteBehaviourGroup.addButton(m_page->radioPasteAsk, KisClipboard::PASTE_ASK);
1565
1566 QAbstractButton *button = m_pasteBehaviourGroup.button(cfg.pasteBehaviour());
1567 Q_ASSERT(button);
1568
1569 if (button) {
1570 button->setChecked(true);
1571 }
1572
1573 if (!m_colorManagedByOS) {
1574 refillMonitorProfiles(KoID("RGBA"));
1575
1576 for(int i = 0; i < QApplication::screens().count(); ++i) {
1577 if (m_monitorProfileWidgets[i]->contains(cfg.monitorProfile(i))) {
1578 m_monitorProfileWidgets[i]->setCurrent(cfg.monitorProfile(i));
1579 }
1580 }
1581 }
1582}
1583
1585{
1587
1588 KoFileDialog dialog(this, KoFileDialog::OpenFiles, "OpenDocumentICC");
1589 dialog.setCaption(i18n("Install Color Profiles"));
1590 dialog.setDefaultDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
1591 dialog.setMimeTypeFilters(QStringList() << "application/vnd.iccprofile", "application/vnd.iccprofile");
1592 QStringList profileNames = dialog.filenames();
1593
1595 Q_ASSERT(iccEngine);
1596
1597 QString saveLocation = KoResourcePaths::saveLocation("icc_profiles");
1598
1599 Q_FOREACH (const QString &profileName, profileNames) {
1600 if (!QFile::copy(profileName, saveLocation + QFileInfo(profileName).fileName())) {
1601 qWarning() << "Could not install profile!" << saveLocation + QFileInfo(profileName).fileName();
1602 continue;
1603 }
1604 iccEngine->addProfile(saveLocation + QFileInfo(profileName).fileName());
1605 }
1606
1607 KisConfig cfg(true);
1608 refillMonitorProfiles(KoID("RGBA"));
1609
1610 for(int i = 0; i < QApplication::screens().count(); ++i) {
1611 if (m_monitorProfileWidgets[i]->contains(cfg.monitorProfile(i))) {
1612 m_monitorProfileWidgets[i]->setCurrent(cfg.monitorProfile(i));
1613 }
1614 }
1615
1616}
1617
1619{
1620 m_page->cmbWorkingColorSpace->setEnabled(useDefColorSpace);
1621}
1622
1624{
1625 m_page->cmbWorkingColorSpace->setCurrent("RGBA");
1626
1628 const QString defaultProfile = KoColorSpaceRegistry::instance()->defaultProfileForColorSpace(colorSpaceId);
1629 m_page->cmbColorProfileForEXR->setCurrent(defaultProfile);
1630
1631 KisConfig cfg(true);
1632
1633 if (!m_colorManagedByOS) {
1634 refillMonitorProfiles(KoID("RGBA"));
1635 } else {
1637
1638 {
1639 auto mode = cfg.canvasSurfaceColorSpaceManagementMode(true);
1640 int index = m_canvasSurfaceColorSpace->findData(QVariant::fromValue(mode));
1641 KIS_SAFE_ASSERT_RECOVER(index >= 0) {
1642 index = 0;
1643 }
1644 m_canvasSurfaceColorSpace->setCurrentIndex(index);
1645 }
1646
1647 {
1648 auto mode = cfg.canvasSurfaceBitDepthMode(true);
1649 int index = m_canvasSurfaceBitDepth->findData(QVariant::fromValue(mode));
1650 KIS_SAFE_ASSERT_RECOVER(index >= 0) {
1651 index = 0;
1652 }
1653 m_canvasSurfaceBitDepth->setCurrentIndex(index);
1654 }
1655 }
1656
1657 KisImageConfig cfgImage(true);
1658 KisProofingConfigurationSP proofingConfig = cfgImage.defaultProofingconfiguration(true);
1659 m_page->wdgProofingOptions->setProofingConfig(proofingConfig);
1660
1661 m_page->chkBlackpoint->setChecked(cfg.useBlackPointCompensation(true));
1662 m_page->chkAllowLCMSOptimization->setChecked(cfg.allowLCMSOptimization(true));
1663 m_page->chkForcePaletteColor->setChecked(cfg.forcePaletteColors(true));
1664 m_page->cmbMonitorIntent->setCurrentIndex(cfg.monitorRenderIntent(true));
1665 QAbstractButton *button = m_pasteBehaviourGroup.button(cfg.pasteBehaviour(true));
1666 Q_ASSERT(button);
1667 if (button) {
1668 button->setChecked(true);
1669 }
1670}
1671
1672
1674{
1676
1677 for (int i = 0; i < QApplication::screens().count(); ++i) {
1678 m_monitorProfileWidgets[i]->clear();
1679 }
1680
1681 QMap<QString, const KoColorProfile *> profileList;
1682 Q_FOREACH(const KoColorProfile *profile, KoColorSpaceRegistry::instance()->profilesFor(colorSpaceId.id())) {
1683 profileList[profile->name()] = profile;
1684 }
1685
1686 Q_FOREACH (const KoColorProfile *profile, profileList.values()) {
1687 //qDebug() << "Profile" << profile->name() << profile->isSuitableForDisplay() << csf->defaultProfile();
1688 if (profile->isSuitableForDisplay()) {
1689 for (int i = 0; i < QApplication::screens().count(); ++i) {
1690 m_monitorProfileWidgets[i]->addSqueezedItem(profile->name());
1691 }
1692 }
1693 }
1694
1695 for (int i = 0; i < QApplication::screens().count(); ++i) {
1696 m_monitorProfileLabels[i]->setText(i18nc("The number of the screen (ordinal) and shortened 'name' of the screen (model + resolution)", "Screen %1 (%2):", i + 1, shortNameOfDisplay(i)));
1698 }
1699}
1700
1703 options.first = KoColorConversionTransformation::Intent(m_page->cmbMonitorIntent->currentIndex());
1705 options.second.setFlag(KoColorConversionTransformation::BlackpointCompensation, m_page->chkBlackpoint->isChecked());
1706 m_page->wdgProofingOptions->setDisplayConfigOptions(options);
1707}
1708
1710{
1711 if (!m_preferredSpaceGraphic) return;
1712 if (!KisPlatformPluginInterfaceFactory::instance()->surfaceColorManagedByOS()) return;
1715 KoColorimetryUtils::xyY whitePoint;
1716
1717#ifdef Q_OS_LINUX
1718#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
1719 KisRootSurfaceInfoProxy proxy(mainWindow);
1720 std::optional<KisSurfaceColorimetry::SurfaceDescription> currentDescription = proxy.currentSurfaceDescription();
1721 if (m_preferredSpaceGraphicMode.checkedId() == PreferredSpace) {
1722 if (currentDescription) {
1723 if (std::holds_alternative<KisSurfaceColorimetry::Colorimetry>(currentDescription->colorSpace.primaries)) {
1724 auto col = std::get<KisSurfaceColorimetry::Colorimetry>(currentDescription->colorSpace.primaries);
1725 colorants << col.red().toxyY() << col.green().toxyY() << col.blue().toxyY();
1726 whitePoint = col.white().toxyY();
1727 m_preferredSpaceGraphic->setRGBData(whitePoint, colorants);
1728 } else {
1729 bool enable = true;
1730 auto named = std::get<KisSurfaceColorimetry::NamedPrimaries>(currentDescription->colorSpace.primaries);
1742 } else {
1743 enable = false;
1744 }
1745
1746 if (enable) {
1747 colorants << col.red().toxyY() << col.green().toxyY() << col.blue().toxyY();
1748 whitePoint = col.white().toxyY();
1749 m_preferredSpaceGraphic->setRGBData(whitePoint, colorants);
1750 } else {
1751 m_preferredSpaceGraphic->setProfileDataAvailable(false);
1752 }
1753
1754 }
1755 } else {
1756 m_preferredSpaceGraphic->setProfileDataAvailable(false);
1757 }
1758 } else if(m_preferredSpaceGraphicMode.checkedId() == MasteringSpace) {
1759 if (currentDescription && currentDescription->masteringInfo) {
1760 auto col = currentDescription->masteringInfo->primaries;
1761 colorants << col.red().toxyY() << col.green().toxyY() << col.blue().toxyY();
1762 whitePoint = col.white().toxyY();
1763
1764 m_preferredSpaceGraphic->setRGBData(whitePoint, colorants);
1765 } else {
1766 m_preferredSpaceGraphic->setProfileDataAvailable(false);
1767 }
1768 }
1769#endif
1770#endif
1771 m_preferredSpaceGraphic->update();
1772}
1773
1774//---------------------------------------------------------------------------------------------------
1775
1777{
1778 KisConfig cfg(true);
1779 const KisCubicCurve curve(cfg.pressureTabletCurve(true));
1780 m_page->pressureCurve->setCurve(curve);
1781
1782 m_page->chkUseRightMiddleClickWorkaround->setChecked(
1783 KisConfig(true).useRightMiddleTabletButtonWorkaround(true));
1784
1785#if defined Q_OS_WIN && (defined QT5_HAS_WINTAB_SWITCH || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1786 m_page->radioWintab->setChecked(!cfg.useWin8PointerInput(true));
1787 m_page->radioWin8PointerInput->setChecked(cfg.useWin8PointerInput(true));
1788#else
1789 m_page->grpTabletApi->setVisible(false);
1790#endif
1791
1792#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_PAGE_UP_DOWN
1793 m_page->chkUsePageUpDownMouseButtonEmulationWorkaround->setChecked(
1794 cfg.usePageUpDownMouseButtonEmulationWorkaround(true));
1795#endif
1796
1797#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
1798 m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->setChecked(
1799 cfg.useHighFunctionKeyMouseButtonEmulationWorkaround(true));
1800#endif
1801
1802#if KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
1803 m_page->chkUseIgnoreHistoricTabletEventsWorkaround->setChecked(cfg.useIgnoreHistoricTabletEventsWorkaround(true));
1804#endif
1805
1806#ifdef Q_OS_ANDROID
1808 m_page->chkHideTouchAndStylusCursorsWorkaround->setChecked(cfg.hideTouchAndStylusCursorsWorkaround(true));
1809 }
1810#endif
1811
1812 m_page->chkUseTimestampsForBrushSpeed->setChecked(false);
1813 m_page->intMaxAllowedBrushSpeed->setValue(30);
1814 m_page->intBrushSpeedSmoothing->setValue(3);
1815 m_page->tiltDirectionOffsetAngle->setAngle(0);
1816}
1817
1818TabletSettingsTab::TabletSettingsTab(QWidget* parent, const char* name): QWidget(parent)
1819{
1820 setObjectName(name);
1821
1822 QGridLayout * l = new QGridLayout(this);
1823 l->setContentsMargins(0, 0, 0, 0);
1824 m_page = new WdgTabletSettings(this);
1825 l->addWidget(m_page, 0, 0);
1826
1827 KisConfig cfg(true);
1828 const KisCubicCurve curve(cfg.pressureTabletCurve());
1829 m_page->pressureCurve->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
1830 m_page->pressureCurve->setCurve(curve);
1831
1832 m_page->chkUseRightMiddleClickWorkaround->setChecked(
1834
1835#if defined Q_OS_WIN && (defined QT5_HAS_WINTAB_SWITCH || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1836# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
1837 QString actualTabletProtocol = "<unknown>";
1838 using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
1839 if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) {
1840 actualTabletProtocol = nativeWindowsApp->isWinTabEnabled() ? "WinTab" : "Windows Ink";
1841 }
1842 m_page->grpTabletApi->setTitle(i18n("Tablet Input API (currently active API: \"%1\")", actualTabletProtocol));
1843# endif
1844 m_page->radioWintab->setChecked(!cfg.useWin8PointerInput());
1845 m_page->radioWin8PointerInput->setChecked(cfg.useWin8PointerInput());
1846
1847 connect(m_page->btnResolutionSettings, SIGNAL(clicked()), SLOT(slotResolutionSettings()));
1848 connect(m_page->radioWintab, SIGNAL(toggled(bool)), m_page->btnResolutionSettings, SLOT(setEnabled(bool)));
1849 m_page->btnResolutionSettings->setEnabled(m_page->radioWintab->isChecked());
1850#else
1851 m_page->grpTabletApi->setVisible(false);
1852#endif
1853 connect(m_page->btnTabletTest, SIGNAL(clicked()), SLOT(slotTabletTest()));
1854
1855#ifdef Q_OS_WIN
1856 m_page->chkUseTimestampsForBrushSpeed->setText(i18n("Use tablet driver timestamps for brush speed (may cause severe artifacts when using WinTab tablet API)"));
1857#else
1858 m_page->chkUseTimestampsForBrushSpeed->setText(i18n("Use tablet driver timestamps for brush speed"));
1859#endif
1860 m_page->chkUseTimestampsForBrushSpeed->setChecked(cfg.readEntry("useTimestampsForBrushSpeed", false));
1861
1862#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_PAGE_UP_DOWN
1863 m_page->chkUsePageUpDownMouseButtonEmulationWorkaround->setChecked(
1864 cfg.usePageUpDownMouseButtonEmulationWorkaround());
1865#else
1866 m_page->chkUsePageUpDownMouseButtonEmulationWorkaround->hide();
1867#endif
1868
1869#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
1870 m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->setChecked(
1871 cfg.useHighFunctionKeyMouseButtonEmulationWorkaround());
1872#else
1873 m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->hide();
1874#endif
1875
1876#if KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
1877 m_page->chkUseIgnoreHistoricTabletEventsWorkaround->setChecked(cfg.useIgnoreHistoricTabletEventsWorkaround());
1878#else
1879 m_page->chkUseIgnoreHistoricTabletEventsWorkaround->hide();
1880#endif
1881
1882#ifdef Q_OS_ANDROID
1884 m_page->chkHideTouchAndStylusCursorsWorkaround->setChecked(cfg.hideTouchAndStylusCursorsWorkaround());
1885 } else {
1886 m_page->chkHideTouchAndStylusCursorsWorkaround->hide();
1887 }
1888#else
1889 m_page->chkHideTouchAndStylusCursorsWorkaround->hide();
1890#endif
1891
1892 m_page->intMaxAllowedBrushSpeed->setRange(1, 100);
1893 m_page->intMaxAllowedBrushSpeed->setValue(cfg.readEntry("maxAllowedSpeedValue", 30));
1894 KisSpinBoxI18nHelper::install(m_page->intMaxAllowedBrushSpeed, [](int value) {
1895 // i18n: This is meant to be used in a spinbox so keep the {n} in the text
1896 // and it will be substituted by the number. The text before will be
1897 // used as the prefix and the text after as the suffix
1898 return i18np("Maximum brush speed: {n} px/ms", "Maximum brush speed: {n} px/ms", value);
1899 });
1900
1901 m_page->intBrushSpeedSmoothing->setRange(3, 100);
1902 m_page->intBrushSpeedSmoothing->setValue(cfg.readEntry("speedValueSmoothing", 3));
1903 KisSpinBoxI18nHelper::install(m_page->intBrushSpeedSmoothing, [](int value) {
1904 // i18n: This is meant to be used in a spinbox so keep the {n} in the text
1905 // and it will be substituted by the number. The text before will be
1906 // used as the prefix and the text after as the suffix
1907 return i18np("Brush speed smoothing: {n} sample", "Brush speed smoothing: {n} samples", value);
1908 });
1909
1910 m_page->tiltDirectionOffsetAngle->setDecimals(0);
1911 m_page->tiltDirectionOffsetAngle->setRange(-180, 180);
1912 // the angle is saved in clockwise direction to be consistent with Drawing Angle, so negate
1913 m_page->tiltDirectionOffsetAngle->setAngle(-cfg.readEntry("tiltDirectionOffset", 0.0));
1914 m_page->tiltDirectionOffsetAngle->setPrefix(i18n("Pen tilt direction offset: "));
1915 m_page->tiltDirectionOffsetAngle->setFlipOptionsMode(KisAngleSelector::FlipOptionsMode_MenuButton);
1916}
1917
1919{
1920 TabletTestDialog tabletTestDialog(this);
1921 tabletTestDialog.exec();
1922}
1923
1924#ifdef Q_OS_WIN
1926#endif
1927
1929{
1930#ifdef Q_OS_WIN
1932 dlg.exec();
1933#endif
1934}
1935
1936
1937//---------------------------------------------------------------------------------------------------
1939
1941{
1942 return KisImageConfig(true).totalRAM();
1943}
1944
1946{
1947 return intMemoryLimit->value() - intPoolLimit->value();
1948}
1949
1950PerformanceTab::PerformanceTab(QWidget *parent, const char *name)
1951 : WdgPerformanceSettings(parent, name)
1952 , m_frameRateModel(new KisFrameRateLimitModel())
1953{
1954 KisImageConfig cfg(true);
1955 const double totalRAM = cfg.totalRAM();
1956 lblTotalMemory->setText(KFormat().formatByteSize(totalRAM * 1024 * 1024, 0, KFormat::IECBinaryDialect, KFormat::UnitMegaByte));
1957
1958 KisSpinBoxI18nHelper::setText(sliderMemoryLimit, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1959 sliderMemoryLimit->setRange(1, 100, 2);
1960 sliderMemoryLimit->setSingleStep(0.01);
1961
1962 KisSpinBoxI18nHelper::setText(sliderPoolLimit, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1963 sliderPoolLimit->setRange(0, 20, 2);
1964 sliderPoolLimit->setSingleStep(0.01);
1965
1966 KisSpinBoxI18nHelper::setText(sliderUndoLimit, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1967 sliderUndoLimit->setRange(0, 50, 2);
1968 sliderUndoLimit->setSingleStep(0.01);
1969
1970 intMemoryLimit->setMinimumWidth(80);
1971 intPoolLimit->setMinimumWidth(80);
1972 intUndoLimit->setMinimumWidth(80);
1973
1974 {
1975 formLayout->takeRow(2);
1976 label_5->setVisible(false);
1977 intPoolLimit->setVisible(false);
1978 sliderPoolLimit->setVisible(false);
1979 }
1980
1981 SliderAndSpinBoxSync *sync1 =
1982 new SliderAndSpinBoxSync(sliderMemoryLimit,
1983 intMemoryLimit,
1984 getTotalRAM);
1985
1986 sync1->slotParentValueChanged();
1987 m_syncs << sync1;
1988
1989 SliderAndSpinBoxSync *sync2 =
1990 new SliderAndSpinBoxSync(sliderPoolLimit,
1991 intPoolLimit,
1992 std::bind(&KisIntParseSpinBox::value,
1993 intMemoryLimit));
1994
1995
1996 connect(intMemoryLimit, SIGNAL(valueChanged(int)), sync2, SLOT(slotParentValueChanged()));
1997 sync2->slotParentValueChanged();
1998 m_syncs << sync2;
1999
2000 SliderAndSpinBoxSync *sync3 =
2001 new SliderAndSpinBoxSync(sliderUndoLimit,
2002 intUndoLimit,
2004 this));
2005
2006
2007 connect(intPoolLimit, SIGNAL(valueChanged(int)), sync3, SLOT(slotParentValueChanged()));
2008 connect(intMemoryLimit, SIGNAL(valueChanged(int)), sync3, SLOT(slotParentValueChanged()));
2009 sync3->slotParentValueChanged();
2010 m_syncs << sync3;
2011
2012 sliderSwapSize->setSuffix(i18n(" GiB"));
2013 sliderSwapSize->setRange(1, 64);
2014 intSwapSize->setRange(1, 64);
2015
2016
2017 KisAcyclicSignalConnector *swapSizeConnector = new KisAcyclicSignalConnector(this);
2018
2019 swapSizeConnector->connectForwardInt(sliderSwapSize, SIGNAL(valueChanged(int)),
2020 intSwapSize, SLOT(setValue(int)));
2021
2022 swapSizeConnector->connectBackwardInt(intSwapSize, SIGNAL(valueChanged(int)),
2023 sliderSwapSize, SLOT(setValue(int)));
2024
2025 swapFileLocation->setMode(KoFileDialog::OpenDirectory);
2026 swapFileLocation->setConfigurationName("swapfile_location");
2027 swapFileLocation->setFileName(cfg.swapDir());
2028
2029 sliderThreadsLimit->setRange(1, QThread::idealThreadCount());
2030 sliderFrameClonesLimit->setRange(1, QThread::idealThreadCount());
2031
2032 sliderFrameTimeout->setRange(5, 600);
2033 sliderFrameTimeout->setSuffix(i18nc("suffix for \"seconds\"", " sec"));
2034 sliderFrameTimeout->setValue(cfg.frameRenderingTimeout() / 1000);
2035
2036 sliderFpsLimit->setSuffix(i18n(" fps"));
2037
2038 KisWidgetConnectionUtils::connectControlState(sliderFpsLimit, m_frameRateModel.data(), "frameRateState", "frameRate");
2039 KisWidgetConnectionUtils::connectControl(chkDetectFps, m_frameRateModel.data(), "detectFrameRate");
2040
2041 connect(sliderThreadsLimit, SIGNAL(valueChanged(int)), SLOT(slotThreadsLimitChanged(int)));
2042 connect(sliderFrameClonesLimit, SIGNAL(valueChanged(int)), SLOT(slotFrameClonesLimitChanged(int)));
2043
2044 intCachedFramesSizeLimit->setRange(256, 10000);
2045 intCachedFramesSizeLimit->setSuffix(i18n(" px"));
2046 intCachedFramesSizeLimit->setSingleStep(1);
2047 intCachedFramesSizeLimit->setPageStep(1000);
2048
2049 intRegionOfInterestMargin->setRange(1, 100);
2050 KisSpinBoxI18nHelper::setText(intRegionOfInterestMargin,
2051 i18nc("{n} is the number value, % is the percent sign", "{n}%"));
2052 intRegionOfInterestMargin->setSingleStep(1);
2053 intRegionOfInterestMargin->setPageStep(10);
2054
2055 connect(chkCachedFramesSizeLimit, SIGNAL(toggled(bool)), intCachedFramesSizeLimit, SLOT(setEnabled(bool)));
2056 connect(chkUseRegionOfInterest, SIGNAL(toggled(bool)), intRegionOfInterestMargin, SLOT(setEnabled(bool)));
2057
2058 connect(chkTransformToolUseInStackPreview, SIGNAL(toggled(bool)), chkTransformToolForceLodMode, SLOT(setEnabled(bool)));
2059
2060#ifndef Q_OS_WIN
2061 // AVX workaround is needed on Windows+GCC only
2062 chkDisableAVXOptimizations->setVisible(false);
2063#endif
2064
2065 load(false);
2066}
2067
2069{
2070 qDeleteAll(m_syncs);
2071}
2072
2073void PerformanceTab::load(bool requestDefault)
2074{
2075 KisImageConfig cfg(true);
2076
2077 sliderMemoryLimit->setValue(cfg.memoryHardLimitPercent(requestDefault));
2078 sliderPoolLimit->setValue(cfg.memoryPoolLimitPercent(requestDefault));
2079 sliderUndoLimit->setValue(cfg.memorySoftLimitPercent(requestDefault));
2080
2081 chkPerformanceLogging->setChecked(cfg.enablePerfLog(requestDefault));
2082 chkProgressReporting->setChecked(cfg.enableProgressReporting(requestDefault));
2083
2084 sliderSwapSize->setValue(cfg.maxSwapSize(requestDefault) / 1024);
2085 swapFileLocation->setFileName(cfg.swapDir(requestDefault));
2086
2087 m_lastUsedThreadsLimit = cfg.maxNumberOfThreads(requestDefault);
2088 m_lastUsedClonesLimit = cfg.frameRenderingClones(requestDefault);
2089
2090 sliderThreadsLimit->setValue(m_lastUsedThreadsLimit);
2091 sliderFrameClonesLimit->setValue(m_lastUsedClonesLimit);
2092
2093#if KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
2094 m_frameRateModel->data.set(std::make_tuple(cfg.detectFpsLimit(requestDefault), cfg.fpsLimit(requestDefault)));
2095#else
2096 m_frameRateModel->data.set(std::make_tuple(false, cfg.fpsLimit(requestDefault)));
2097 chkDetectFps->setVisible(false);
2098#endif
2099 {
2100 KisConfig cfg2(true);
2101 chkOpenGLFramerateLogging->setChecked(cfg2.enableOpenGLFramerateLogging(requestDefault));
2102 chkBrushSpeedLogging->setChecked(cfg2.enableBrushSpeedLogging(requestDefault));
2103 chkDisableVectorOptimizations->setChecked(cfg2.disableVectorOptimizations(requestDefault));
2104#ifdef Q_OS_WIN
2105 chkDisableAVXOptimizations->setChecked(cfg2.disableAVXOptimizations(requestDefault));
2106#endif
2107 chkBackgroundCacheGeneration->setChecked(cfg2.calculateAnimationCacheInBackground(requestDefault));
2108 }
2109
2110 if (cfg.useOnDiskAnimationCacheSwapping(requestDefault)) {
2111 optOnDisk->setChecked(true);
2112 } else {
2113 optInMemory->setChecked(true);
2114 }
2115
2116 chkCachedFramesSizeLimit->setChecked(cfg.useAnimationCacheFrameSizeLimit(requestDefault));
2117 intCachedFramesSizeLimit->setValue(cfg.animationCacheFrameSizeLimit(requestDefault));
2118 intCachedFramesSizeLimit->setEnabled(chkCachedFramesSizeLimit->isChecked());
2119
2120 chkUseRegionOfInterest->setChecked(cfg.useAnimationCacheRegionOfInterest(requestDefault));
2121 intRegionOfInterestMargin->setValue(cfg.animationCacheRegionOfInterestMargin(requestDefault) * 100.0);
2122 intRegionOfInterestMargin->setEnabled(chkUseRegionOfInterest->isChecked());
2123
2124 {
2125 KConfigGroup group = KSharedConfig::openConfig()->group("KisToolTransform");
2126 chkTransformToolUseInStackPreview->setChecked(!group.readEntry("useOverlayPreviewStyle", false));
2127 chkTransformToolForceLodMode->setChecked(group.readEntry("forceLodMode", true));
2128 chkTransformToolForceLodMode->setEnabled(chkTransformToolUseInStackPreview->isChecked());
2129 }
2130
2131 {
2132 KConfigGroup group = KSharedConfig::openConfig()->group("KritaTransform/KisToolMove");
2133 chkMoveToolForceLodMode->setChecked(group.readEntry("forceLodMode", false));
2134 }
2135
2136 {
2137 KConfigGroup group( KSharedConfig::openConfig(), "filterdialog");
2138 chkFiltersForceLodMode->setChecked(group.readEntry("forceLodMode", true));
2139 }
2140}
2141
2143{
2144 KisImageConfig cfg(false);
2145
2146 cfg.setMemoryHardLimitPercent(sliderMemoryLimit->value());
2147 cfg.setMemorySoftLimitPercent(sliderUndoLimit->value());
2148 cfg.setMemoryPoolLimitPercent(sliderPoolLimit->value());
2149
2150 cfg.setEnablePerfLog(chkPerformanceLogging->isChecked());
2151 cfg.setEnableProgressReporting(chkProgressReporting->isChecked());
2152
2153 cfg.setMaxSwapSize(sliderSwapSize->value() * 1024);
2154
2155 cfg.setSwapDir(swapFileLocation->fileName());
2156
2157 cfg.setMaxNumberOfThreads(sliderThreadsLimit->value());
2158 cfg.setFrameRenderingClones(sliderFrameClonesLimit->value());
2159 cfg.setFrameRenderingTimeout(sliderFrameTimeout->value() * 1000);
2160 cfg.setFpsLimit(std::get<int>(*m_frameRateModel->data));
2161#if KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
2162 cfg.setDetectFpsLimit(std::get<bool>(*m_frameRateModel->data));
2163#endif
2164
2165 {
2166 KisConfig cfg2(true);
2167 cfg2.setEnableOpenGLFramerateLogging(chkOpenGLFramerateLogging->isChecked());
2168 cfg2.setEnableBrushSpeedLogging(chkBrushSpeedLogging->isChecked());
2169 cfg2.setDisableVectorOptimizations(chkDisableVectorOptimizations->isChecked());
2170#ifdef Q_OS_WIN
2171 cfg2.setDisableAVXOptimizations(chkDisableAVXOptimizations->isChecked());
2172#endif
2173 cfg2.setCalculateAnimationCacheInBackground(chkBackgroundCacheGeneration->isChecked());
2174 }
2175
2176 cfg.setUseOnDiskAnimationCacheSwapping(optOnDisk->isChecked());
2177
2178 cfg.setUseAnimationCacheFrameSizeLimit(chkCachedFramesSizeLimit->isChecked());
2179 cfg.setAnimationCacheFrameSizeLimit(intCachedFramesSizeLimit->value());
2180
2181 cfg.setUseAnimationCacheRegionOfInterest(chkUseRegionOfInterest->isChecked());
2182 cfg.setAnimationCacheRegionOfInterestMargin(intRegionOfInterestMargin->value() / 100.0);
2183
2184 {
2185 KConfigGroup group = KSharedConfig::openConfig()->group("KisToolTransform");
2186 group.writeEntry("useOverlayPreviewStyle", !chkTransformToolUseInStackPreview->isChecked());
2187 group.writeEntry("forceLodMode", chkTransformToolForceLodMode->isChecked());
2188 }
2189
2190 {
2191 KConfigGroup group = KSharedConfig::openConfig()->group("KritaTransform/KisToolMove");
2192 group.writeEntry("forceLodMode", chkMoveToolForceLodMode->isChecked());
2193 }
2194
2195 {
2196 KConfigGroup group( KSharedConfig::openConfig(), "filterdialog");
2197 group.writeEntry("forceLodMode", chkFiltersForceLodMode->isChecked());
2198 }
2199
2200}
2201
2203{
2204 KisSignalsBlocker b(sliderFrameClonesLimit);
2205 sliderFrameClonesLimit->setValue(qMin(m_lastUsedClonesLimit, value));
2207}
2208
2210{
2211 KisSignalsBlocker b(sliderThreadsLimit);
2212 sliderThreadsLimit->setValue(qMax(m_lastUsedThreadsLimit, value));
2214}
2215
2216//---------------------------------------------------------------------------------------------------
2217
2218#include "KoColor.h"
2221#include <QOpenGLContext>
2222#include <QScreen>
2223
2224namespace {
2225
2226QString colorSpaceString(const KisSurfaceColorSpaceWrapper &cs, int depth)
2227{
2228 const QString csString =
2229#ifdef HAVE_HDR
2231 cs == KisSurfaceColorSpaceWrapper::scRGBColorSpace ? "Rec. 709 Linear" :
2232#endif
2235 "Unknown Color Space";
2236
2237 return QString("%1 (%2 bit)").arg(csString).arg(depth);
2238}
2239
2240int formatToIndex(KisConfig::RootSurfaceFormat fmt)
2241{
2242 return fmt == KisConfig::BT2020_PQ ? 1 :
2243 fmt == KisConfig::BT709_G10 ? 2 :
2244 0;
2245}
2246
2247KisConfig::RootSurfaceFormat indexToFormat(int value)
2248{
2249 return value == 1 ? KisConfig::BT2020_PQ :
2252}
2253
2254int assistantDrawModeToIndex(KisConfig::AssistantsDrawMode mode)
2255{
2258 0;
2259}
2260
2261KisConfig::AssistantsDrawMode indexToAssistantDrawMode(int value)
2262{
2266}
2267
2268} // anonymous namespace
2269
2270DisplaySettingsTab::DisplaySettingsTab(QWidget *parent, const char *name)
2271 : WdgDisplaySettings(parent, name)
2272{
2273 KisConfig cfg(true);
2274
2275 const QString rendererOpenGLText = i18nc("canvas renderer", "OpenGL");
2276 const QString rendererSoftwareText = i18nc("canvas renderer", "Software Renderer (very slow)");
2277#ifdef Q_OS_WIN
2278 const QString rendererOpenGLESText =
2279 qEnvironmentVariable("QT_ANGLE_PLATFORM") != "opengl"
2280 ? i18nc("canvas renderer", "Direct3D 11 via ANGLE")
2281 : i18nc("canvas renderer", "OpenGL via ANGLE");
2282#else
2283 const QString rendererOpenGLESText = i18nc("canvas renderer", "OpenGL ES");
2284#endif
2285
2287 lblCurrentRenderer->setText(renderer == KisOpenGL::RendererOpenGLES ? rendererOpenGLESText :
2288 renderer == KisOpenGL::RendererDesktopGL ? rendererOpenGLText :
2289 renderer == KisOpenGL::RendererSoftware ? rendererSoftwareText :
2290 i18nc("canvas renderer", "Unknown"));
2291
2292 cmbPreferredRenderer->clear();
2293
2294 const KisOpenGL::OpenGLRenderers supportedRenderers = KisOpenGL::getSupportedOpenGLRenderers();
2295 const bool onlyOneRendererSupported =
2296 supportedRenderers == KisOpenGL::RendererDesktopGL ||
2297 supportedRenderers == KisOpenGL::RendererOpenGLES ||
2298 supportedRenderers == KisOpenGL::RendererSoftware;
2299
2300
2301 if (!onlyOneRendererSupported) {
2302 QString qtPreferredRendererText;
2304 qtPreferredRendererText = rendererOpenGLESText;
2306 qtPreferredRendererText = rendererSoftwareText;
2307 } else {
2308 qtPreferredRendererText = rendererOpenGLText;
2309 }
2310 cmbPreferredRenderer->addItem(i18nc("canvas renderer", "Auto (%1)", qtPreferredRendererText), KisOpenGL::RendererAuto);
2311 cmbPreferredRenderer->setCurrentIndex(0);
2312 } else {
2313 cmbPreferredRenderer->setEnabled(false);
2314 }
2315
2316 if (supportedRenderers & KisOpenGL::RendererDesktopGL) {
2317 cmbPreferredRenderer->addItem(rendererOpenGLText, KisOpenGL::RendererDesktopGL);
2319 cmbPreferredRenderer->setCurrentIndex(cmbPreferredRenderer->count() - 1);
2320 }
2321 }
2322
2323 if (supportedRenderers & KisOpenGL::RendererOpenGLES) {
2324 cmbPreferredRenderer->addItem(rendererOpenGLESText, KisOpenGL::RendererOpenGLES);
2326 cmbPreferredRenderer->setCurrentIndex(cmbPreferredRenderer->count() - 1);
2327 }
2328 }
2329
2330 if (supportedRenderers & KisOpenGL::RendererSoftware) {
2331 cmbPreferredRenderer->addItem(rendererSoftwareText, KisOpenGL::RendererSoftware);
2333 cmbPreferredRenderer->setCurrentIndex(cmbPreferredRenderer->count() - 1);
2334 }
2335 }
2336
2337 if (!(supportedRenderers &
2341
2342 grpOpenGL->setEnabled(false);
2343 grpOpenGL->setChecked(false);
2344 chkUseTextureBuffer->setEnabled(false);
2345 cmbAssistantsDrawMode->setEnabled(false);
2346 cmbFilterMode->setEnabled(false);
2347 } else {
2348 grpOpenGL->setEnabled(true);
2349 grpOpenGL->setChecked(cfg.useOpenGL());
2350 chkUseTextureBuffer->setEnabled(cfg.useOpenGL());
2351 chkUseTextureBuffer->setChecked(cfg.useOpenGLTextureBuffer());
2352 cmbAssistantsDrawMode->setEnabled(cfg.useOpenGL());
2353 cmbAssistantsDrawMode->setCurrentIndex(assistantDrawModeToIndex(cfg.assistantsDrawMode()));
2354 cmbFilterMode->setEnabled(cfg.useOpenGL());
2355 cmbFilterMode->setCurrentIndex(cfg.openGLFilteringMode());
2356 // Don't show the high quality filtering mode if it's not available
2357 if (!KisOpenGL::supportsLoD()) {
2358 cmbFilterMode->removeItem(3);
2359 }
2360 }
2361
2362 {
2363 std::optional<KisOpenGL::XcbGLProviderProtocol> currentXcbGlProvider = KisOpenGL::xcbGlProviderProtocol();
2364
2365 lblPreferredXcbGlApi->setVisible(currentXcbGlProvider.has_value());
2366 cmbPreferredXcbGlApi->setVisible(currentXcbGlProvider.has_value());
2367
2368 if (currentXcbGlProvider.has_value()) {
2369 const QString glxCurrent = i18nc("@item:inlistbox", "GLX (current)");
2370 const QString glxNotCurrent = i18nc("@item:inlistbox", "GLX");
2371 const QString eglCurrent = i18nc("@item:inlistbox", "EGL (current)");
2372 const QString eglNotCurrent = i18nc("@item:inlistbox", "EGL");
2373
2374 cmbPreferredXcbGlApi->addItem(*currentXcbGlProvider == KisOpenGL::XCB_GLX ? glxCurrent : glxNotCurrent, KisOpenGL::XCB_GLX);
2375 cmbPreferredXcbGlApi->addItem(*currentXcbGlProvider == KisOpenGL::XCB_EGL ? eglCurrent : eglNotCurrent, KisOpenGL::XCB_EGL);
2376
2377 cmbPreferredXcbGlApi->setToolTip(i18nc("@info:tooltip",
2378 "<p>If you are using Krita on X11 or XWayland and experience slowness, "
2379 "try switching between EGL and GLX</p>"));
2380
2381 KisOpenGL::XcbGLProviderProtocol preferredValue =
2383
2384 int index = cmbPreferredXcbGlApi->findData(preferredValue);
2385
2386 KIS_SAFE_ASSERT_RECOVER(index >= 0) {
2387 index = 0;
2388 }
2389 cmbPreferredXcbGlApi->setCurrentIndex(index);
2390 }
2391 }
2392
2393 lblCurrentDisplayFormat->setText("");
2394 lblCurrentRootSurfaceFormat->setText("");
2395 grpHDRWarning->setVisible(false);
2396 cmbPreferedRootSurfaceFormat->addItem(colorSpaceString(KisSurfaceColorSpaceWrapper::sRGBColorSpace, 8));
2397#ifdef HAVE_HDR
2398 cmbPreferedRootSurfaceFormat->addItem(colorSpaceString(KisSurfaceColorSpaceWrapper::bt2020PQColorSpace, 10));
2399 cmbPreferedRootSurfaceFormat->addItem(colorSpaceString(KisSurfaceColorSpaceWrapper::scRGBColorSpace, 16));
2400#endif
2401 cmbPreferedRootSurfaceFormat->setCurrentIndex(formatToIndex(KisConfig::BT709_G22));
2402 slotPreferredSurfaceFormatChanged(cmbPreferedRootSurfaceFormat->currentIndex());
2403
2404 QOpenGLContext *context = QOpenGLContext::currentContext();
2405
2406 if (!context) {
2407 context = QOpenGLContext::globalShareContext();
2408 }
2409
2410 if (context) {
2411 QScreen *screen = KisPart::instance()->currentMainwindow()->screen();
2412 KisScreenInformationAdapter adapter(context);
2413 if (screen && adapter.isValid()) {
2415 if (info.isValid()) {
2416 QStringList toolTip;
2417
2418 toolTip << i18n("Display Id: %1", info.screen->name());
2419 toolTip << i18n("Display Name: %1 %2", info.screen->manufacturer(), info.screen->model());
2420 toolTip << i18n("Min Luminance: %1", info.minLuminance);
2421 toolTip << i18n("Max Luminance: %1", info.maxLuminance);
2422 toolTip << i18n("Max Full Frame Luminance: %1", info.maxFullFrameLuminance);
2423 toolTip << i18n("Red Primary: %1, %2", info.redPrimary[0], info.redPrimary[1]);
2424 toolTip << i18n("Green Primary: %1, %2", info.greenPrimary[0], info.greenPrimary[1]);
2425 toolTip << i18n("Blue Primary: %1, %2", info.bluePrimary[0], info.bluePrimary[1]);
2426 toolTip << i18n("White Point: %1, %2", info.whitePoint[0], info.whitePoint[1]);
2427
2428 lblCurrentDisplayFormat->setToolTip(toolTip.join('\n'));
2429 lblCurrentDisplayFormat->setText(colorSpaceString(info.colorSpace, info.bitsPerColor));
2430 } else {
2431 lblCurrentDisplayFormat->setToolTip("");
2432 lblCurrentDisplayFormat->setText(i18n("Unknown"));
2433 }
2434 } else {
2435 lblCurrentDisplayFormat->setToolTip("");
2436 lblCurrentDisplayFormat->setText(i18n("Unknown"));
2437 qWarning() << "Failed to fetch display info:" << adapter.errorString();
2438 }
2439
2440 const QSurfaceFormat currentFormat = KisOpenGLModeProber::instance()->surfaceformatInUse();
2441 const auto colorSpace = KisSurfaceColorSpaceWrapper::fromQtColorSpace(currentFormat.colorSpace());
2442 lblCurrentRootSurfaceFormat->setText(colorSpaceString(colorSpace, currentFormat.redBufferSize()));
2443 cmbPreferedRootSurfaceFormat->setCurrentIndex(formatToIndex(cfg.rootSurfaceFormat()));
2444 connect(cmbPreferedRootSurfaceFormat, SIGNAL(currentIndexChanged(int)), SLOT(slotPreferredSurfaceFormatChanged(int)));
2445 slotPreferredSurfaceFormatChanged(cmbPreferedRootSurfaceFormat->currentIndex());
2446 }
2447
2448#ifndef HAVE_HDR
2449 HDR->setEnabled(false);
2450
2456 if (KisPlatformPluginInterfaceFactory::instance()->surfaceColorManagedByOS()) {
2457 const int hdrTabIndex = tabWidget->indexOf(HDR);
2458 KIS_SAFE_ASSERT_RECOVER_NOOP(hdrTabIndex >= 0);
2459 if (hdrTabIndex >= 0) {
2460 tabWidget->setTabVisible(hdrTabIndex, false);
2461 }
2462 }
2463#endif
2464
2465 const QStringList openglWarnings = KisOpenGL::getOpenGLWarnings();
2466 if (openglWarnings.isEmpty()) {
2467 grpOpenGLWarnings->setVisible(false);
2468 } else {
2469 QString text = QString("<p><b>%1</b>").arg(i18np("Warning:", "Warnings:", openglWarnings.size()));
2470 text.append("<ul>");
2471 Q_FOREACH (const QString &warning, openglWarnings) {
2472 text.append("<li>");
2473 text.append(warning.toHtmlEscaped());
2474 text.append("</li>");
2475 }
2476 text.append("</ul></p>");
2477 grpOpenGLWarnings->setText(text);
2478 grpOpenGLWarnings->setPixmap(
2479 grpOpenGLWarnings->style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(QSize(32, 32)));
2480 grpOpenGLWarnings->setVisible(true);
2481 }
2482
2483 KisImageConfig imageCfg(false);
2484
2485 KoColor c;
2487 c.setOpacity(1.0);
2488 btnSelectionOverlayColor->setColor(c);
2489 sldSelectionOverlayOpacity->setRange(0.0, 1.0, 2);
2490 sldSelectionOverlayOpacity->setSingleStep(0.05);
2491 sldSelectionOverlayOpacity->setValue(imageCfg.selectionOverlayMaskColor().alphaF());
2492
2493 sldSelectionOutlineOpacity->setRange(0.0, 1.0, 2);
2494 sldSelectionOutlineOpacity->setSingleStep(0.05);
2495 sldSelectionOutlineOpacity->setValue(imageCfg.selectionOutlineOpacity());
2496
2497 intCheckSize->setValue(cfg.checkSize());
2498 chkMoving->setChecked(cfg.scrollCheckers());
2500 ck1.fromQColor(cfg.checkersColor1());
2501 colorChecks1->setColor(ck1);
2503 ck2.fromQColor(cfg.checkersColor2());
2504 colorChecks2->setColor(ck2);
2506 cb.fromQColor(cfg.canvasBorderColor());
2507 canvasBorder->setColor(cb);
2508 hideScrollbars->setChecked(cfg.hideScrollbars());
2509 chkCurveAntialiasing->setChecked(cfg.antialiasCurves());
2510 chkSelectionOutlineAntialiasing->setChecked(cfg.antialiasSelectionOutline());
2511 chkChannelsAsColor->setChecked(cfg.showSingleChannelAsColor());
2512 chkHidePopups->setChecked(cfg.hidePopups());
2513
2514 connect(grpOpenGL, SIGNAL(toggled(bool)), SLOT(slotUseOpenGLToggled(bool)));
2515
2516 KoColor gridColor(KoColorSpaceRegistry::instance()->rgb8());
2517 gridColor.fromQColor(cfg.getPixelGridColor());
2518 pixelGridColorButton->setColor(gridColor);
2519 pixelGridDrawingThresholdBox->setValue(cfg.getPixelGridDrawingThreshold() * 100);
2520 KisSpinBoxI18nHelper::setText(pixelGridDrawingThresholdBox, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
2521}
2522
2524{
2525 KisConfig cfg(true);
2526 cmbPreferredRenderer->setCurrentIndex(0);
2529 grpOpenGL->setEnabled(false);
2530 grpOpenGL->setChecked(false);
2531 chkUseTextureBuffer->setEnabled(false);
2532 cmbAssistantsDrawMode->setEnabled(false);
2533 cmbFilterMode->setEnabled(false);
2534 }
2535 else {
2536 grpOpenGL->setEnabled(true);
2537 grpOpenGL->setChecked(cfg.useOpenGL(true));
2538 chkUseTextureBuffer->setChecked(cfg.useOpenGLTextureBuffer(true));
2539 chkUseTextureBuffer->setEnabled(true);
2540 cmbAssistantsDrawMode->setEnabled(true);
2541 cmbAssistantsDrawMode->setCurrentIndex(assistantDrawModeToIndex(cfg.assistantsDrawMode(true)));
2542 cmbFilterMode->setEnabled(true);
2543 cmbFilterMode->setCurrentIndex(cfg.openGLFilteringMode(true));
2544 }
2545
2546 chkMoving->setChecked(cfg.scrollCheckers(true));
2547
2548 KisImageConfig imageCfg(false);
2549
2550 KoColor c;
2551 c.fromQColor(imageCfg.selectionOverlayMaskColor(true));
2552 c.setOpacity(1.0);
2553 btnSelectionOverlayColor->setColor(c);
2554 sldSelectionOverlayOpacity->setValue(imageCfg.selectionOverlayMaskColor(true).alphaF());
2555
2556 sldSelectionOutlineOpacity->setValue(imageCfg.selectionOutlineOpacity(true));
2557
2558 intCheckSize->setValue(cfg.checkSize(true));
2560 ck1.fromQColor(cfg.checkersColor1(true));
2561 colorChecks1->setColor(ck1);
2563 ck2.fromQColor(cfg.checkersColor2(true));
2564 colorChecks2->setColor(ck2);
2566 cvb.fromQColor(cfg.canvasBorderColor(true));
2567 canvasBorder->setColor(cvb);
2568 hideScrollbars->setChecked(cfg.hideScrollbars(true));
2569 chkCurveAntialiasing->setChecked(cfg.antialiasCurves(true));
2570 chkSelectionOutlineAntialiasing->setChecked(cfg.antialiasSelectionOutline(true));
2571 chkChannelsAsColor->setChecked(cfg.showSingleChannelAsColor(true));
2572 chkHidePopups->setChecked(cfg.hidePopups(true));
2573
2574 KoColor gridColor(KoColorSpaceRegistry::instance()->rgb8());
2575 gridColor.fromQColor(cfg.getPixelGridColor(true));
2576 pixelGridColorButton->setColor(gridColor);
2577 pixelGridDrawingThresholdBox->setValue(cfg.getPixelGridDrawingThreshold(true) * 100);
2578 KisSpinBoxI18nHelper::setText(pixelGridDrawingThresholdBox, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
2579
2580 cmbPreferedRootSurfaceFormat->setCurrentIndex(formatToIndex(KisConfig::BT709_G22));
2581 slotPreferredSurfaceFormatChanged(cmbPreferedRootSurfaceFormat->currentIndex());
2582}
2583
2585{
2586 chkUseTextureBuffer->setEnabled(isChecked);
2587 cmbFilterMode->setEnabled(isChecked);
2588 cmbAssistantsDrawMode->setEnabled(isChecked);
2589}
2590
2592{
2593 Q_UNUSED(index);
2594
2595 QOpenGLContext *context = QOpenGLContext::currentContext();
2596 if (context) {
2597 QScreen *screen = KisPart::instance()->currentMainwindow()->screen();
2598 KisScreenInformationAdapter adapter(context);
2599 if (adapter.isValid()) {
2601 if (info.isValid()) {
2602 if (cmbPreferedRootSurfaceFormat->currentIndex() != formatToIndex(KisConfig::BT709_G22) &&
2604 grpHDRWarning->setVisible(true);
2605 grpHDRWarning->setPixmap(
2606 grpHDRWarning->style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(QSize(32, 32)));
2607 grpHDRWarning->setText(i18n("<b>Warning:</b> current display doesn't support HDR rendering"));
2608 } else {
2609 grpHDRWarning->setVisible(false);
2610 }
2611 }
2612 }
2613 }
2614}
2615
2616//---------------------------------------------------------------------------------------------------
2618{
2619 KisConfig cfg(true);
2620
2621 chkDockers->setChecked(cfg.hideDockersFullscreen());
2622 chkMenu->setChecked(cfg.hideMenuFullscreen());
2623 chkScrollbars->setChecked(cfg.hideScrollbarsFullscreen());
2624 chkStatusbar->setChecked(cfg.hideStatusbarFullscreen());
2625 chkTitlebar->setChecked(cfg.hideTitlebarFullscreen());
2626 chkToolbar->setChecked(cfg.hideToolbarFullscreen());
2627
2628}
2629
2631{
2632 KisConfig cfg(true);
2633 chkDockers->setChecked(cfg.hideDockersFullscreen(true));
2634 chkMenu->setChecked(cfg.hideMenuFullscreen(true));
2635 chkScrollbars->setChecked(cfg.hideScrollbarsFullscreen(true));
2636 chkStatusbar->setChecked(cfg.hideStatusbarFullscreen(true));
2637 chkTitlebar->setChecked(cfg.hideTitlebarFullscreen(true));
2638 chkToolbar->setChecked(cfg.hideToolbarFullscreen(true));
2639}
2640
2641
2642//---------------------------------------------------------------------------------------------------
2643
2645static const QStringList allowedColorHistorySortingValues({"none", "hsv"});
2646}
2647
2648PopupPaletteTab::PopupPaletteTab(QWidget *parent, const char *name)
2649 : WdgPopupPaletteSettingsBase(parent, name)
2650{
2651 using namespace PopupPaletteTabPrivate;
2652
2653 load();
2654
2655 connect(chkShowColorHistory, SIGNAL(toggled(bool)), cmbColorHistorySorting, SLOT(setEnabled(bool)));
2656 connect(chkShowColorHistory, SIGNAL(toggled(bool)), lblColorHistorySorting, SLOT(setEnabled(bool)));
2657 connect(cmbSelectorType, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSelectorTypeChanged(int)));
2658 KIS_SAFE_ASSERT_RECOVER_NOOP(cmbColorHistorySorting->count() == allowedColorHistorySortingValues.size());
2659}
2660
2662{
2663 using namespace PopupPaletteTabPrivate;
2664
2665 KisConfig config(true);
2666 sbNumPresets->setValue(config.favoritePresets());
2667 sbPaletteSize->setValue(config.readEntry("popuppalette/size", 385));
2668 sbSelectorSize->setValue(config.readEntry("popuppalette/selectorSize", 140));
2669 cmbSelectorType->setCurrentIndex(config.readEntry<bool>("popuppalette/usevisualcolorselector", false) ? 1 : 0);
2670 chkShowColorHistory->setChecked(config.readEntry("popuppalette/showColorHistory", true));
2671 chkShowRotationTrack->setChecked(config.readEntry("popuppalette/showRotationTrack", true));
2672 chkUseDynamicSlotCount->setChecked(config.readEntry("popuppalette/useDynamicSlotCount", true));
2673 grpFixTriangleRotation->setChecked(config.readEntry("popuppalette/fixTriangleRotation", false));
2674 sbTriangleRotationAngle->setValue(config.readEntry("popuppalette/triangleRotationAngle", 0));
2675
2676 QString currentSorting = config.readEntry("popuppalette/colorHistorySorting", QString("hsv"));
2677 if (!allowedColorHistorySortingValues.contains(currentSorting)) {
2678 currentSorting = "hsv";
2679 }
2680 cmbColorHistorySorting->setCurrentIndex(allowedColorHistorySortingValues.indexOf(currentSorting));
2681 cmbColorHistorySorting->setEnabled(chkShowColorHistory->isChecked());
2682 lblColorHistorySorting->setEnabled(chkShowColorHistory->isChecked());
2683 grpFixTriangleRotation->setEnabled(!cmbSelectorType->currentIndex());
2684}
2685
2687{
2688 using namespace PopupPaletteTabPrivate;
2689
2690 KisConfig config(true);
2691 config.setFavoritePresets(sbNumPresets->value());
2692 config.writeEntry("popuppalette/size", sbPaletteSize->value());
2693 config.writeEntry("popuppalette/selectorSize", sbSelectorSize->value());
2694 config.writeEntry<bool>("popuppalette/usevisualcolorselector", cmbSelectorType->currentIndex() > 0);
2695 config.writeEntry<bool>("popuppalette/showColorHistory", chkShowColorHistory->isChecked());
2696 config.writeEntry<bool>("popuppalette/showRotationTrack", chkShowRotationTrack->isChecked());
2697 config.writeEntry<bool>("popuppalette/useDynamicSlotCount", chkUseDynamicSlotCount->isChecked());
2698 config.writeEntry("popuppalette/colorHistorySorting",
2699 allowedColorHistorySortingValues[cmbColorHistorySorting->currentIndex()]);
2700 config.writeEntry<bool>("popuppalette/fixTriangleRotation", grpFixTriangleRotation->isChecked());
2701 config.writeEntry("popuppalette/triangleRotationAngle", sbTriangleRotationAngle->value());
2702}
2703
2705{
2706 KisConfig config(true);
2707 sbNumPresets->setValue(config.favoritePresets(true));
2708 sbPaletteSize->setValue(385);
2709 sbSelectorSize->setValue(140);
2710 cmbSelectorType->setCurrentIndex(0);
2711 chkShowColorHistory->setChecked(true);
2712 chkShowRotationTrack->setChecked(true);
2713 chkUseDynamicSlotCount->setChecked(true);
2714 cmbColorHistorySorting->setEnabled(chkShowColorHistory->isChecked());
2715 lblColorHistorySorting->setEnabled(chkShowColorHistory->isChecked());
2716 grpFixTriangleRotation->setChecked(false);
2717 sbTriangleRotationAngle->setValue(0);
2718}
2719
2721 grpFixTriangleRotation->setEnabled(!index);
2722}
2723
2724//---------------------------------------------------------------------------------------------------
2725
2726KisDlgPreferences::KisDlgPreferences(QWidget* parent, const char* name)
2727 : KPageDialog(parent)
2728{
2729 Q_UNUSED(name);
2730 setWindowTitle(i18n("Configure Krita"));
2731 setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults);
2732
2733 setFaceType(KPageDialog::List);
2734
2735 // General
2736 KoVBox *vbox = new KoVBox();
2737 KPageWidgetItem *page = new KPageWidgetItem(vbox, i18n("General"));
2738 page->setObjectName("general");
2739 page->setHeader(i18n("General"));
2740 page->setIcon(KisIconUtils::loadIcon("config-general"));
2741 m_pages << page;
2742 addPage(page);
2743 m_general = new GeneralTab(vbox);
2744
2745 // Shortcuts
2746 vbox = new KoVBox();
2747 page = new KPageWidgetItem(vbox, i18n("Keyboard Shortcuts"));
2748 page->setObjectName("shortcuts");
2749 page->setHeader(i18n("Shortcuts"));
2750 page->setIcon(KisIconUtils::loadIcon("config-keyboard"));
2751 m_pages << page;
2752 addPage(page);
2754 connect(this, SIGNAL(accepted()), m_shortcutSettings, SLOT(saveChanges()));
2755 connect(this, SIGNAL(rejected()), m_shortcutSettings, SLOT(cancelChanges()));
2756
2757 // Canvas input settings
2759 page = addPage(m_inputConfiguration, i18n("Canvas Input Settings"));
2760 page->setHeader(i18n("Canvas Input"));
2761 page->setObjectName("canvasinput");
2762 page->setIcon(KisIconUtils::loadIcon("config-canvas-input"));
2763 m_pages << page;
2764
2765 // Display
2766 vbox = new KoVBox();
2767 page = new KPageWidgetItem(vbox, i18n("Display"));
2768 page->setObjectName("display");
2769 page->setHeader(i18n("Display"));
2770 page->setIcon(KisIconUtils::loadIcon("config-display"));
2771 m_pages << page;
2772 addPage(page);
2774
2775 // Color
2776 vbox = new KoVBox();
2777 page = new KPageWidgetItem(vbox, i18n("Color Management"));
2778 page->setObjectName("colormanagement");
2779 page->setHeader(i18nc("Label of color as in Color Management", "Color"));
2780 page->setIcon(KisIconUtils::loadIcon("config-color-manage"));
2781 m_pages << page;
2782 addPage(page);
2784
2785 // Performance
2786 vbox = new KoVBox();
2787 page = new KPageWidgetItem(vbox, i18n("Performance"));
2788 page->setObjectName("performance");
2789 page->setHeader(i18n("Performance"));
2790 page->setIcon(KisIconUtils::loadIcon("config-performance"));
2791 m_pages << page;
2792 addPage(page);
2794
2795 // Tablet
2796 vbox = new KoVBox();
2797 page = new KPageWidgetItem(vbox, i18n("Tablet settings"));
2798 page->setObjectName("tablet");
2799 page->setHeader(i18n("Tablet"));
2800 page->setIcon(KisIconUtils::loadIcon("config-tablet"));
2801 m_pages << page;
2802 addPage(page);
2804
2805 // full-screen mode
2806 vbox = new KoVBox();
2807 page = new KPageWidgetItem(vbox, i18n("Canvas-only settings"));
2808 page->setObjectName("canvasonly");
2809 page->setHeader(i18n("Canvas-only"));
2810 page->setIcon(KisIconUtils::loadIcon("config-canvas-only"));
2811 m_pages << page;
2812 addPage(page);
2814
2815 // Pop-up Palette
2816 vbox = new KoVBox();
2817 page = new KPageWidgetItem(vbox, i18n("Pop-up Palette"));
2818 page->setObjectName("popuppalette");
2819 page->setHeader(i18n("Pop-up Palette"));
2820 page->setIcon(KisIconUtils::loadIcon("config-popup-palette"));
2821 m_pages << page;
2822 addPage(page);
2824
2825 // Author profiles
2827 page = addPage(m_authorPage, i18nc("@title:tab Author page", "Author" ));
2828 page->setObjectName("author");
2829 page->setHeader(i18n("Author"));
2830 page->setIcon(KisIconUtils::loadIcon("user-identity"));
2831 m_pages << page;
2832
2833 KGuiItem::assign(button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
2834 KGuiItem::assign(button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
2835 QPushButton *restoreDefaultsButton = button(QDialogButtonBox::RestoreDefaults);
2836 restoreDefaultsButton->setText(i18nc("@action:button", "Restore Defaults"));
2837
2838 connect(this, SIGNAL(accepted()), m_inputConfiguration, SLOT(saveChanges()));
2839 connect(this, SIGNAL(rejected()), m_inputConfiguration, SLOT(revertChanges()));
2840
2842 QStringList keys = preferenceSetRegistry->keys();
2843 keys.sort();
2844 Q_FOREACH(const QString &key, keys) {
2845 KisAbstractPreferenceSetFactory *preferenceSetFactory = preferenceSetRegistry->value(key);
2846 KisPreferenceSet* preferenceSet = preferenceSetFactory->createPreferenceSet();
2847 vbox = new KoVBox();
2848 page = new KPageWidgetItem(vbox, preferenceSet->name());
2849 page->setHeader(preferenceSet->header());
2850 page->setIcon(preferenceSet->icon());
2851 addPage(page);
2852 preferenceSet->setParent(vbox);
2853 preferenceSet->loadPreferences();
2854
2855 connect(restoreDefaultsButton, SIGNAL(clicked(bool)), preferenceSet, SLOT(loadDefaultPreferences()), Qt::UniqueConnection);
2856 connect(this, SIGNAL(accepted()), preferenceSet, SLOT(savePreferences()), Qt::UniqueConnection);
2857 }
2858
2859 connect(restoreDefaultsButton, SIGNAL(clicked(bool)), this, SLOT(slotDefault()));
2860
2861 KisConfig cfg(true);
2862 QString currentPageName = cfg.readEntry<QString>("KisDlgPreferences/CurrentPage");
2863 Q_FOREACH(KPageWidgetItem *page, m_pages) {
2864 if (page->objectName() == currentPageName) {
2865 setCurrentPage(page);
2866 break;
2867 }
2868 }
2869
2870 // TODO QT6: check what this code actually does?
2871#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
2872 {
2873 // HACK ALERT! Remove title widget background, thus making
2874 // it consistent across all systems
2875 const auto *titleWidget = findChild<KTitleWidget*>();
2876 if (titleWidget) {
2877 QLayoutItem *titleFrame = titleWidget->layout()->itemAt(0); // vboxLayout -> titleFrame
2878 if (titleFrame) {
2879 titleFrame->widget()->setBackgroundRole(QPalette::Window);
2880 }
2881 }
2882 }
2883#endif
2884}
2885
2887{
2888 KisConfig cfg(true);
2889 cfg.writeEntry<QString>("KisDlgPreferences/CurrentPage", currentPage()->objectName());
2890}
2891
2892void KisDlgPreferences::showEvent(QShowEvent *event){
2893 KPageDialog::showEvent(event);
2894 button(QDialogButtonBox::Cancel)->setAutoDefault(false);
2895 button(QDialogButtonBox::Ok)->setAutoDefault(false);
2896 button(QDialogButtonBox::RestoreDefaults)->setAutoDefault(false);
2897 button(QDialogButtonBox::Cancel)->setDefault(false);
2898 button(QDialogButtonBox::Ok)->setDefault(false);
2899 button(QDialogButtonBox::RestoreDefaults)->setDefault(false);
2900}
2901
2903{
2904 if (buttonBox()->buttonRole(button) == QDialogButtonBox::RejectRole) {
2905 m_cancelClicked = true;
2906 }
2907}
2908
2910{
2911 if (currentPage()->objectName() == "general") {
2913 }
2914 else if (currentPage()->objectName() == "shortcuts") {
2916 }
2917 else if (currentPage()->objectName() == "display") {
2919 }
2920 else if (currentPage()->objectName() == "colormanagement") {
2922 }
2923 else if (currentPage()->objectName() == "performance") {
2925 }
2926 else if (currentPage()->objectName() == "tablet") {
2928 }
2929 else if (currentPage()->objectName() == "canvasonly") {
2931 }
2932 else if (currentPage()->objectName() == "canvasinput") {
2934 }
2935 else if (currentPage()->objectName() == "popuppalette") {
2937 }
2938}
2939
2940KPageWidgetItem *KisDlgPreferences::getPage(Page page_enum)
2941{
2942 QString name = "";
2943 switch (page_enum) {
2944 case General:
2945 name = "general";
2946 break;
2947 case Shortucts:
2948 name = "shortcuts";
2949 break;
2950 case Color:
2951 name = "colormanagement";
2952 break;
2953 case Performance:
2954 name = "performance";
2955 break;
2956 case Display:
2957 name = "display";
2958 break;
2959 case Tablet:
2960 name = "tablet";
2961 break;
2962 case Fullscreen:
2963 name = "canvasonly";
2964 break;
2965 case Input:
2966 name = "canvasinput";
2967 break;
2968 case PopupPalette:
2969 name = "popuppalette";
2970 break;
2971 }
2972
2973 Q_FOREACH (KPageWidgetItem *page, m_pages) {
2974 if (page->objectName() == name) {
2975 return page;
2976 }
2977 }
2978 return nullptr;
2979}
2980
2982{
2983 switch (page.page) {
2984 case General: {
2985 QWidget *tab = nullptr;
2986 switch (page.tab) {
2987 case File:
2988 tab = m_general->File;
2989 break;
2990 case Pasting:
2991 tab = m_general->Pasting;
2992 break;
2993 case Window:
2994 tab = m_general->Window;
2995 break;
2996 case Cursor:
2997 tab = m_general->Cursor;
2998 break;
2999 case Tools:
3000 tab = m_general->Tools;
3001 break;
3002 case Animation:
3003 tab = m_general->Animation;
3004 break;
3005 case Resources:
3006 tab = m_general->Resources;
3007 break;
3009 tab = m_general->Miscellaneous;
3010 break;
3011 }
3012 m_general->tabWidget->setCurrentWidget(tab);
3013 } break;
3014 case Color: {
3015 QWidget *tab = nullptr;
3016 switch (page.tab) {
3017 case GeneralColor:
3018 tab = m_colorSettings->m_page->General;
3019 break;
3020 case DisplayTab:
3021 tab = m_colorSettings->m_page->Display;
3022 break;
3023 case SoftProofing:
3024 tab = m_colorSettings->m_page->SoftProofing;
3025 break;
3026 }
3027 m_colorSettings->m_page->tabWidget->setCurrentWidget(tab);
3028 } break;
3029 case Performance: {
3030 QWidget *tab = nullptr;
3031 switch (page.tab) {
3032 case GeneralPerformance:
3033 tab = m_performanceSettings->General;
3034 break;
3035 case Advanced:
3036 tab = m_performanceSettings->Advanced;
3037 break;
3038 case AnimationCache:
3039 tab = m_performanceSettings->AnimationCache;
3040 break;
3041 case InstantPreview:
3042 tab = m_performanceSettings->InstantPreview;
3043 break;
3044 }
3045 m_performanceSettings->tabWidget->setCurrentWidget(tab);
3046 } break;
3047 case Display: {
3048 QWidget *tab = nullptr;
3049 switch (page.tab) {
3050 case CanvasAcceleration:
3051 tab = m_displaySettings->CanvasAcceleration;
3052 break;
3053 case HDR:
3054 tab = m_displaySettings->HDR;
3055 break;
3056 case CanvasDecoration:
3057 tab = m_displaySettings->CanvasDecoration;
3058 break;
3060 tab = m_displaySettings->Miscellaneous;
3061 break;
3062 }
3063 m_displaySettings->tabWidget->setCurrentWidget(tab);
3064 } break;
3065
3066 default:
3067 break;
3068 }
3069}
3070
3071bool KisDlgPreferences::editPreferences(std::optional<PageDesc>page)
3072{
3073 connect(this->buttonBox(), SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotButtonClicked(QAbstractButton*)));
3074
3075 if (page.has_value()) {
3076 PageDesc page_val = page.value();
3077 setCurrentPage(getPage(page_val.page));
3078 switchTab(page_val);
3079 }
3080
3081 int retval = exec();
3082 Q_UNUSED(retval);
3083
3084 if (!m_cancelClicked) {
3085 // General settings
3086 KisConfig cfg(false);
3087 KisImageConfig cfgImage(false);
3088
3091 cfg.setSeparateEraserCursor(m_general->m_chkSeparateEraserCursor->isChecked());
3102
3105 cfg.setForceAlwaysFullSizedOutline(!m_general->m_changeBrushOutline->isChecked());
3107 cfg.setForceAlwaysFullSizedEraserOutline(!m_general->m_changeEraserBrushOutline->isChecked());
3111
3112 KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
3113 group.writeEntry("DontUseNativeFileDialog", !m_general->m_chkNativeFileDialog->isChecked());
3114
3115 cfgImage.setMaxBrushSize(m_general->intMaxBrushSize->value());
3116 cfg.setIgnoreHighFunctionKeys(m_general->chkIgnoreHighFunctionKeys->isChecked());
3117
3118 cfg.writeEntry<bool>("use_custom_system_font", m_general->chkUseCustomFont->isChecked());
3119 if (m_general->chkUseCustomFont->isChecked()) {
3120 cfg.writeEntry<QString>("custom_system_font", m_general->cmbCustomFont->currentFont().family());
3121 cfg.writeEntry<int>("custom_font_size", m_general->intFontSize->value());
3122 }
3123 else {
3124 cfg.writeEntry<QString>("custom_system_font", "");
3125 cfg.writeEntry<int>("custom_font_size", -1);
3126 }
3127
3128 cfg.writeEntry<int>("mdi_viewmode", m_general->mdiMode());
3129 cfg.setMDIBackgroundColor(m_general->m_mdiColor->color().toXML());
3130 cfg.setMDIBackgroundImage(m_general->m_backgroundimage->text());
3131 cfg.writeEntry<int>("mdi_rubberband", m_general->m_chkRubberBand->isChecked());
3133 cfg.writeEntry("autosavefileshidden", m_general->chkHideAutosaveFiles->isChecked());
3134
3135 cfg.setBackupFile(m_general->m_backupFileCheckBox->isChecked());
3136 cfg.writeEntry("backupfilelocation", m_general->cmbBackupFileLocation->currentIndex());
3137 cfg.writeEntry("backupfilesuffix", m_general->txtBackupFileSuffix->text());
3138 cfg.writeEntry("numberofbackupfiles", m_general->intNumBackupFiles->value());
3139
3140
3148
3149 const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
3150 QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
3151 kritarc.setValue("EnableHiDPI", m_general->m_chkHiDPI->isChecked());
3152#if defined(Q_OS_WIN) && defined(HAVE_HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY)
3153 kritarc.setValue("EnableHiDPIFractionalScaling", m_general->m_chkHiDPIFractionalScaling->isChecked());
3154#endif
3155 kritarc.setValue("LogUsage", m_general->chkUsageLogging->isChecked());
3156
3158
3159 cfg.writeEntry<bool>("useCreamyAlphaDarken", (bool)!m_general->cmbFlowMode->currentIndex());
3160 cfg.writeEntry<bool>("useSubtractiveBlendingForCmykColorSpaces", (bool)!m_general->cmbCmykBlendingMode->currentIndex());
3161
3168
3170
3172 cfg.setTouchPainting(KisConfig::TouchPainting(m_general->cmbTouchPainting->currentIndex()));
3173 cfg.writeEntry("useTouchPressureSensitivity", m_general->chkTouchPressureSensitivity->isChecked());
3174 cfg.setActivateTransformToolAfterPaste(m_general->chkEnableTransformToolAfterPaste->isChecked());
3175 cfg.setZoomHorizontal(m_general->chkZoomHorizontally->isChecked());
3176 cfg.setSelectionActionBar(m_general->chkEnableSelectionActionBar->isChecked());
3177
3181 cfg.setCumulativeUndoRedo(m_general->chkCumulativeUndo->isChecked());
3183
3184 // Animation..
3188
3189#ifdef Q_OS_ANDROID
3190 QFileInfo fi(m_general->m_resourceFolderSelector->currentData(Qt::UserRole).value<QString>());
3191#else
3192 QFileInfo fi(m_general->m_urlResourceFolder->fileName());
3193#endif
3194 if (fi.isWritable()) {
3196 }
3197
3201
3202 // Color settings
3210 }
3211 else {
3212 for (int i = 0; i < QApplication::screens().count(); ++i) {
3213 cfg.setMonitorProfile(i, m_colorSettings->m_monitorProfileWidgets[i]->currentUnsqueezedText());
3214 }
3215 }
3216 cfg.setUseDefaultColorSpace(m_colorSettings->m_page->useDefColorSpace->isChecked());
3217 if (cfg.useDefaultColorSpace())
3218 {
3219 KoID currentWorkingColorSpace = m_colorSettings->m_page->cmbWorkingColorSpace->currentItem();
3220 cfg.setWorkingColorSpace(currentWorkingColorSpace.id());
3221 cfg.defColorModel(KoColorSpaceRegistry::instance()->colorSpaceColorModelId(currentWorkingColorSpace.id()).id());
3223 }
3224
3225 cfg.writeEntry("ExrDefaultColorProfile", m_colorSettings->m_page->cmbColorProfileForEXR->currentText());
3226
3227 cfgImage.setDefaultProofingConfig(*m_colorSettings->m_page->wdgProofingOptions->currentProofingConfig());
3228 cfg.setUseBlackPointCompensation(m_colorSettings->m_page->chkBlackpoint->isChecked());
3229 cfg.setAllowLCMSOptimization(m_colorSettings->m_page->chkAllowLCMSOptimization->isChecked());
3230 cfg.setForcePaletteColors(m_colorSettings->m_page->chkForcePaletteColor->isChecked());
3232 cfg.setRenderIntent(m_colorSettings->m_page->cmbMonitorIntent->currentIndex());
3233
3234 // Tablet settings
3235 cfg.setPressureTabletCurve( m_tabletSettings->m_page->pressureCurve->curve().toString() );
3237 m_tabletSettings->m_page->chkUseRightMiddleClickWorkaround->isChecked());
3238
3239#if defined Q_OS_WIN && (defined QT5_HAS_WINTAB_SWITCH || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
3240 cfg.setUseWin8PointerInput(m_tabletSettings->m_page->radioWin8PointerInput->isChecked());
3241
3242# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
3243 // Qt6 supports switching the tablet API on the fly
3244 using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
3245 if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) {
3246 nativeWindowsApp->setWinTabEnabled(!cfg.useWin8PointerInput());
3247 }
3248# endif
3249#endif
3250 cfg.writeEntry<bool>("useTimestampsForBrushSpeed", m_tabletSettings->m_page->chkUseTimestampsForBrushSpeed->isChecked());
3251
3252#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_PAGE_UP_DOWN
3253 cfg.setUsePageUpDownMouseButtonEmulationWorkaround(
3254 m_tabletSettings->m_page->chkUsePageUpDownMouseButtonEmulationWorkaround->isChecked());
3255#endif
3256
3257#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
3258 cfg.setUseHighFunctionKeyMouseButtonEmulationWorkaround(
3259 m_tabletSettings->m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->isChecked());
3260#endif
3261
3262#if KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
3263 cfg.setUseIgnoreHistoricTabletEventsWorkaround(
3264 m_tabletSettings->m_page->chkUseIgnoreHistoricTabletEventsWorkaround->isChecked());
3265#endif
3266
3267#ifdef Q_OS_ANDROID
3269 cfg.setHideTouchAndStylusCursorsWorkaround(
3270 m_tabletSettings->m_page->chkHideTouchAndStylusCursorsWorkaround->isChecked());
3271 }
3272#endif
3273
3274 cfg.writeEntry<int>("maxAllowedSpeedValue", m_tabletSettings->m_page->intMaxAllowedBrushSpeed->value());
3275 cfg.writeEntry<int>("speedValueSmoothing", m_tabletSettings->m_page->intBrushSpeedSmoothing->value());
3276 // the angle is saved in clockwise direction to be consistent with Drawing Angle, so negate
3277 cfg.writeEntry<int>("tiltDirectionOffset", -m_tabletSettings->m_page->tiltDirectionOffsetAngle->angle());
3278
3280
3281 if (!cfg.useOpenGL() && m_displaySettings->grpOpenGL->isChecked())
3282 cfg.setCanvasState("TRY_OPENGL");
3283
3284 if (m_displaySettings->grpOpenGL->isChecked()) {
3286 m_displaySettings->cmbPreferredRenderer->itemData(
3287 m_displaySettings->cmbPreferredRenderer->currentIndex()).toInt());
3289 } else {
3291 }
3292
3293 if (KisOpenGL::xcbGlProviderProtocol().has_value()) {
3294 cfg.setPreferXcbEglProvider(m_displaySettings->cmbPreferredXcbGlApi->currentData().value<KisOpenGL::XcbGLProviderProtocol>() == KisOpenGL::XCB_EGL);
3295 }
3296
3297 cfg.setUseOpenGLTextureBuffer(m_displaySettings->chkUseTextureBuffer->isChecked());
3298 cfg.setOpenGLFilteringMode(m_displaySettings->cmbFilterMode->currentIndex());
3299 cfg.setRootSurfaceFormat(&kritarc, indexToFormat(m_displaySettings->cmbPreferedRootSurfaceFormat->currentIndex()));
3300 cfg.setAssistantsDrawMode(indexToAssistantDrawMode(m_displaySettings->cmbAssistantsDrawMode->currentIndex()));
3301
3302 cfg.setCheckSize(m_displaySettings->intCheckSize->value());
3303 cfg.setScrollingCheckers(m_displaySettings->chkMoving->isChecked());
3304 cfg.setCheckersColor1(m_displaySettings->colorChecks1->color().toQColor());
3305 cfg.setCheckersColor2(m_displaySettings->colorChecks2->color().toQColor());
3306 cfg.setCanvasBorderColor(m_displaySettings->canvasBorder->color().toQColor());
3307 cfg.setHideScrollbars(m_displaySettings->hideScrollbars->isChecked());
3308 KoColor c = m_displaySettings->btnSelectionOverlayColor->color();
3309 c.setOpacity(m_displaySettings->sldSelectionOverlayOpacity->value());
3311 cfgImage.setSelectionOutlineOpacity(m_displaySettings->sldSelectionOutlineOpacity->value());
3312 cfg.setAntialiasCurves(m_displaySettings->chkCurveAntialiasing->isChecked());
3313 cfg.setAntialiasSelectionOutline(m_displaySettings->chkSelectionOutlineAntialiasing->isChecked());
3314 cfg.setShowSingleChannelAsColor(m_displaySettings->chkChannelsAsColor->isChecked());
3315 cfg.setHidePopups(m_displaySettings->chkHidePopups->isChecked());
3316
3317 cfg.setHideDockersFullscreen(m_fullscreenSettings->chkDockers->checkState());
3318 cfg.setHideMenuFullscreen(m_fullscreenSettings->chkMenu->checkState());
3319 cfg.setHideScrollbarsFullscreen(m_fullscreenSettings->chkScrollbars->checkState());
3320 cfg.setHideStatusbarFullscreen(m_fullscreenSettings->chkStatusbar->checkState());
3321 cfg.setHideTitlebarFullscreen(m_fullscreenSettings->chkTitlebar->checkState());
3322 cfg.setHideToolbarFullscreen(m_fullscreenSettings->chkToolbar->checkState());
3323
3324 cfg.setCursorMainColor(m_general->cursorColorButton->color().toQColor());
3325 cfg.setEraserCursorMainColor(m_general->eraserCursorColorButton->color().toQColor());
3326 cfg.setPixelGridColor(m_displaySettings->pixelGridColorButton->color().toQColor());
3327 cfg.setPixelGridDrawingThreshold(m_displaySettings->pixelGridDrawingThresholdBox->value() / 100);
3328
3331
3333 cfg.writeEntry("forcedDpiForQtFontBugWorkaround", m_general->forcedFontDpi());
3334 }
3335
3336 return !m_cancelClicked;
3337}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
float value(const T *src, size_t ch)
qreal u
QList< QString > QStringList
const KoID AlphaColorModelID("A", ki18n("Alpha mask"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
Q_GUI_EXPORT int qt_defaultDpi()
void toggleUseDefaultColorSpace(bool useDefColorSpace)
QList< QLabel * > m_monitorProfileLabels
QPointer< KisCIETongueWidget > m_preferredSpaceGraphic
QButtonGroup m_pasteBehaviourGroup
QPointer< QCheckBox > m_chkEnableCanvasColorSpaceManagement
QPointer< KisSqueezedComboBox > m_canvasSurfaceBitDepth
QScopedPointer< KisProofingConfigModel > m_proofModel
QPointer< KisSqueezedComboBox > m_canvasSurfaceColorSpace
QList< KisSqueezedComboBox * > m_monitorProfileWidgets
void refillMonitorProfiles(const KoID &s)
QButtonGroup m_preferredSpaceGraphicMode
ColorSettingsTab(QWidget *parent=0, const char *name=0)
WdgColorSettings * m_page
QScopedPointer< KisScreenMigrationTracker > m_screenMigrationTracker
DisplaySettingsTab(QWidget *parent=0, const char *name=0)
void slotUseOpenGLToggled(bool isChecked)
void slotPreferredSurfaceFormatChanged(int index)
FullscreenSettingsTab(QWidget *parent)
QString splashScreenImage() const
KisConfig::SessionOnStartup sessionOnStartup() const
bool kineticScrollingHiddenScrollbars()
bool saveSessionOnQuit() const
void showAdvancedCumulativeUndoSettings()
int colorSamplerPreviewCircleDiameter() const
bool autoZoomTimelineToPlaybackRange()
static void setButtonGroupEnabled(const QButtonGroup &buttonGroup, bool value)
void colorSamplePreviewThicknessChanged(qreal value)
QString m_splashScreenImage
KisConfig::ColorSamplerPreviewStyle colorSamplerPreviewStyle() const
void colorSamplePreviewOutlineEnabledChanged(int value)
void colorSamplePreviewStyleChanged(int index)
qreal colorSamplerZoomPreviewScale() const
bool colorSamplerPreviewCircleExtraCirclesEnabled() const
bool convertToImageColorspaceOnImport()
QButtonGroup m_pasteFormatGroup
OutlineStyle eraserOutlineStyle()
static KisConfig::ColorSamplerPreviewStyle getColorSamplerPreviewStyleValue(const QComboBox *cmb)
int kineticScrollingSensitivity()
void colorSamplePreviewSizeChanged(int value)
void slotChangeSplashScreen()
KisCumulativeUndoData m_cumulativeUndoData
void updateTouchPressureSensitivityEnabled(int)
bool showOutlineWhilePainting()
CursorStyle eraserCursorStyle()
static void setColorSamplerPreviewStyleItems(QComboBox *cmb)
KisConfig::IconsInMenu iconsInMenu() const
KisConfig::ColorSamplerPreviewCirclePosition colorSamplerPreviewCirclePosition() const
static void setColorSamplerPreviewStyleIndexByValue(QComboBox *cmb, KisConfig::ColorSamplerPreviewStyle style)
void enableSubWindowOptions(int)
bool colorSamplerPreviewCircleOutlineEnabled() const
bool colorSamplerZoomPreviewEnabled() const
void slotUpdateCurrentSplashScreenTitle()
OutlineStyle outlineStyle()
bool showEraserOutlineWhilePainting()
CursorStyle cursorStyle()
qreal colorSamplerPreviewCircleThickness() const
GeneralTab(QWidget *parent=0, const char *name=0)
virtual KisPreferenceSet * createPreferenceSet()=0
static KisActionRegistry * instance()
The KisActionsSnapshot class.
void connectBackwardInt(QObject *sender, const char *signal, QObject *receiver, const char *method)
void connectForwardInt(QObject *sender, const char *signal, QObject *receiver, const char *method)
@ FlipOptionsMode_MenuButton
The flip options are shown as a menu accessible via a options button.
void setCumulativeUndoData(KisCumulativeUndoData value)
ColorSamplerPreviewCirclePosition colorSamplerPreviewCirclePosition(bool defaultValue=false) const
bool backupFile(bool defaultValue=false) const
void setAntialiasCurves(bool v) const
void setSwitchSelectionCtrlAlt(bool value)
bool antialiasSelectionOutline(bool defaultValue=false) const
void setColorSamplerZoomPreviewScale(qreal scale)
void setZoomSteps(int steps)
@ ASSISTANTS_DRAW_MODE_PIXMAP_CACHE
Definition kis_config.h:879
@ ASSISTANTS_DRAW_MODE_DIRECT
Definition kis_config.h:878
@ ASSISTANTS_DRAW_MODE_LARGE_PIXMAP_CACHE
Definition kis_config.h:880
int zoomSteps(bool defaultValue=false) const
void setHideDockersFullscreen(const bool value) const
static CanvasSurfaceBitDepthMode canvasSurfaceBitDepthMode(QSettings *settings, bool defaultValue=false)
void setAdaptivePlaybackRange(bool value)
void setEnableCanvasSurfaceColorSpaceManagement(bool value)
bool colorSamplerPreviewCircleOutlineEnabled(bool defaultValue=false) const
void setPasteFormat(qint32 format)
QColor checkersColor2(bool defaultValue=false) const
void setColorSamplerPreviewCircleOutlineEnabled(bool enabled)
void setUseRightMiddleTabletButtonWorkaround(bool value)
void setCheckersColor1(const QColor &v) const
void setHidePopups(bool hidePopups)
void setMDIBackgroundColor(const QString &v) const
QString pressureTabletCurve(bool defaultValue=false) const
void setUndoStackLimit(int limit) const
bool hideScrollbars(bool defaultValue=false) const
int openGLFilteringMode(bool defaultValue=false) const
void setUseZip64(bool value)
bool showSingleChannelAsColor(bool defaultValue=false) const
void setHideToolbarFullscreen(const bool value) const
void setCanvasState(const QString &state) const
int kineticScrollingSensitivity(bool defaultValue=false) const
bool convertToImageColorspaceOnImport(bool defaultValue=false) const
int zoomMarginSize(bool defaultValue=false) const
void setAutoZoomTimelineToPlaybackRange(bool value)
bool showRootLayer(bool defaultValue=false) const
qint32 pasteFormat(bool defaultValue) const
void setEnableBrushSpeedLogging(bool value) const
void setExportMimeType(const QString &defaultExportMimeType)
void setUseWin8PointerInput(bool value)
qreal getPixelGridDrawingThreshold(bool defaultValue=false) const
bool switchSelectionCtrlAlt(bool defaultValue=false) const
void writeEntry(const QString &name, const T &value)
Definition kis_config.h:904
void setRenamePastedLayers(bool value)
QColor checkersColor1(bool defaultValue=false) const
void setHideScrollbars(bool value) const
bool allowLCMSOptimization(bool defaultValue=false) const
static void setCanvasSurfaceBitDepthMode(QSettings *settings, CanvasSurfaceBitDepthMode value)
void setIgnoreHighFunctionKeys(bool value)
bool activateTransformToolAfterPaste(bool defaultValue=false) const
void setNewCursorStyle(CursorStyle style)
bool hideDockersFullscreen(bool defaultValue=false) const
void setEraserCursorStyle(CursorStyle style)
bool compressKra(bool defaultValue=false) const
static bool preferXcbEglProvider(const QSettings *settings, bool defaultValue=false)
bool disableVectorOptimizations(bool defaultValue=false) const
void setCursorMainColor(const QColor &v) const
void setColorSamplerPreviewCircleThickness(qreal thickness)
void setCanvasSurfaceColorSpaceManagementMode(CanvasSurfaceMode value)
void setCumulativeUndoRedo(bool value)
void setConvertToImageColorspaceOnImport(bool value)
void setPixelGridColor(const QColor &v) const
void setToolOptionsInDocker(bool inDocker)
void setForceAlwaysFullSizedOutline(bool value) const
void setLongPressEnabled(bool value)
SessionOnStartup sessionOnStartup(bool defaultValue=false) const
void setForcePaletteColors(bool forcePaletteColors)
void setHideTitlebarFullscreen(const bool value) const
bool enableOpenGLFramerateLogging(bool defaultValue=false) const
QColor getPixelGridColor(bool defaultValue=false) const
bool useDefaultColorSpace(bool defaultvalue=false) const
bool hideMenuFullscreen(bool defaultValue=false) const
QString getMDIBackgroundColor(bool defaultValue=false) const
void setUseDefaultColorSpace(bool value) const
void setDefaultColorDepth(const QString &depth) const
bool hideScrollbarsFullscreen(bool defaultValue=false) const
TouchPainting touchPainting(bool defaultValue=false) const
void setSeparateEraserCursor(bool value) const
qint32 monitorRenderIntent(bool defaultValue=false) const
void setActivateTransformToolAfterPaste(bool value)
int kineticScrollingGesture(bool defaultValue=false) const
bool useZip64(bool defaultValue=false) const
bool calculateAnimationCacheInBackground(bool defaultValue=false) const
int favoritePresets(bool defaultValue=false) const
bool zoomHorizontal(bool defaultValue=false) const
QString getMDIBackgroundImage(bool defaultValue=false) const
void setAssistantsDrawMode(AssistantsDrawMode value)
CanvasSurfaceMode canvasSurfaceColorSpaceManagementMode(bool defaultValue=false) const
bool hideToolbarFullscreen(bool defaultValue=false) const
bool showCanvasMessages(bool defaultValue=false) const
bool useWin8PointerInput(bool defaultValue=false) const
bool useOpenGLTextureBuffer(bool defaultValue=false) const
void setCalculateAnimationCacheInBackground(bool value)
void setColorSamplerPreviewCircleExtraCirclesEnabled(bool enabled)
void setAutoSaveInterval(int seconds) const
void setShowSingleChannelAsColor(bool asColor)
void setTrimFramesImport(bool trim)
bool forcePaletteColors(bool defaultValue=false) const
bool colorSamplerZoomPreviewEnabled(bool defaultValue=false) const
void setAllowLCMSOptimization(bool allowLCMSOptimization)
void setColorSamplerPreviewCircleDiameter(int style)
void setRenderIntent(qint32 monitorRenderIntent) const
void setFavoritePresets(const int value)
void setEraserOutlineStyle(OutlineStyle style)
void setShowOutlineWhilePainting(bool showOutlineWhilePainting) const
RootSurfaceFormat rootSurfaceFormat(bool defaultValue=false) const
QColor canvasBorderColor(bool defaultValue=false) const
int colorSamplerPreviewCircleDiameter(bool defaultValue=false) const
QString exportMimeType(bool defaultValue) const
void setScrollingCheckers(bool scrollCheckers) const
const QString getScreenStringIdentfier(int screenNo) const
void setBackupFile(bool backupFile) const
void logImportantSettings() const
Log the most interesting settings to the usage log.
Definition kis_config.cc:76
IconsInMenu iconsInMenu(bool defaultValue=false) const
CursorStyle newCursorStyle(bool defaultValue=false) const
bool useCumulativeUndoRedo(bool defaultValue=false) const
void setCheckSize(qint32 checkSize) const
CursorStyle eraserCursorStyle(bool defaultValue=false) const
void setKineticScrollingGesture(int kineticScroll)
void setPreferXcbEglProvider(bool value)
void setPixelGridDrawingThreshold(qreal v) const
void setCanvasBorderColor(const QColor &color) const
QString monitorProfile(int screen) const
get the profile the user has selected for the given screen
@ TOUCH_PAINTING_DISABLED
Definition kis_config.h:50
void setShowCanvasMessages(bool show)
qint32 checkSize(bool defaultValue=false) const
void setWorkingColorSpace(const QString &workingColorSpace) const
void setColorSamplerPreviewCirclePosition(ColorSamplerPreviewCirclePosition position)
KisCumulativeUndoData cumulativeUndoData(bool defaultValue=false) const
QString splashScreenImage(bool defaultValue=false) const
void setMonitorProfile(int screen, const QString &monitorProfile) const
OutlineStyle newOutlineStyle(bool defaultValue=false) const
bool forceAlwaysFullSizedOutline(bool defaultValue=false) const
ColorSamplerPreviewStyle
Definition kis_config.h:138
void setPressureTabletCurve(const QString &curveString) const
qreal colorSamplerPreviewCircleThickness(bool defaultValue=false) const
QString workingColorSpace(bool defaultValue=false) const
void setEnableOpenGLFramerateLogging(bool value) const
bool renamePastedLayers(bool defaultValue=false) const
void setNewOutlineStyle(OutlineStyle style)
void setCheckersColor2(const QColor &v) const
void setShowRootLayer(bool showRootLayer) const
void setColorSamplerZoomPreviewEnabled(bool enabled)
OutlineStyle eraserOutlineStyle(bool defaultValue=false) const
void setUseBlackPointCompensation(bool useBlackPointCompensation) const
bool kineticScrollingEnabled(bool defaultValue=false) const
void setSplashScreenImage(const QString &value)
void setUseOpenGLTextureBuffer(bool useBuffer)
void setTrimKra(bool trim)
void setIconsInMenu(IconsInMenu value)
ColorSamplerPreviewCirclePosition
Definition kis_config.h:168
bool hideTitlebarFullscreen(bool defaultValue=false) const
bool useRightMiddleTabletButtonWorkaround(bool defaultValue=false) const
bool longPressEnabled(bool defaultValue=false) const
void setColorSamplerPreviewStyle(ColorSamplerPreviewStyle style)
bool hidePopups(bool defaultValue=false) const
bool enableCanvasSurfaceColorSpaceManagement(bool defaultValue=false) const
void setRootSurfaceFormat(RootSurfaceFormat value)
bool autoPinLayersToTimeline(bool defaultValue=false) const
bool toolOptionsInDocker(bool defaultValue=false) const
void setOpenGLFilteringMode(int filteringMode)
void setKineticScrollingHideScrollbars(bool scrollbar)
void setAntialiasSelectionOutline(bool v) const
bool trimKra(bool defaultValue=false) const
bool enableBrushSpeedLogging(bool defaultValue=false) const
bool forceAlwaysFullSizedEraserOutline(bool defaultValue=false) const
T readEntry(const QString &name, const T &defaultValue=T())
Definition kis_config.h:914
int autoSaveInterval(bool defaultValue=false) const
QString defColorModel(bool defaultValue=false) const
void setDisableVectorOptimizations(bool value)
void setHideStatusbarFullscreen(const bool value) const
void setCompressKra(bool compress)
void setTouchPainting(TouchPainting value) const
bool showOutlineWhilePainting(bool defaultValue=false) const
void setShowEraserOutlineWhilePainting(bool showEraserOutlineWhilePainting) const
void setHideMenuFullscreen(const bool value) const
bool autoZoomTimelineToPlaybackRange(bool defaultValue=false) const
bool scrollCheckers(bool defaultValue=false) const
CanvasSurfaceBitDepthMode
Definition kis_config.h:214
void setZoomMarginSize(int zoomMarginSize)
bool hideStatusbarFullscreen(bool defaultValue=false) const
bool colorSamplerPreviewCircleExtraCirclesEnabled(bool defaultValue=false) const
void setZoomHorizontal(bool value)
bool kineticScrollingHiddenScrollbars(bool defaultValue=false) const
bool useOpenGL(bool defaultValue=false) const
bool trimFramesImport(bool defaultValue=false) const
void setForceAlwaysFullSizedEraserOutline(bool value) const
bool selectionActionBar(bool defaultValue=false) const
int undoStackLimit(bool defaultValue=false) const
bool useBlackPointCompensation(bool defaultValue=false) const
bool saveSessionOnQuit(bool defaultValue) const
ColorSamplerPreviewStyle colorSamplerPreviewStyle(bool defaultValue=false) const
void setMDIBackgroundImage(const QString &fileName) const
QColor getCursorMainColor(bool defaultValue=false) const
void setSelectionActionBar(bool value)
qint32 pasteBehaviour(bool defaultValue=false) const
AssistantsDrawMode assistantsDrawMode(bool defaultValue=false) const
bool separateEraserCursor(bool defaultValue=false) const
void setEraserCursorMainColor(const QColor &v) const
void setSaveSessionOnQuit(bool value)
bool disableAVXOptimizations(bool defaultValue=false) const
bool showEraserOutlineWhilePainting(bool defaultValue=false) const
void setPasteBehaviour(qint32 behaviour) const
void setSessionOnStartup(SessionOnStartup value)
void setHideScrollbarsFullscreen(const bool value) const
void setAutoPinLayersToTimeline(bool value)
QColor getEraserCursorMainColor(bool defaultValue=false) const
qreal colorSamplerZoomPreviewScale(bool defaultValue=false) const
bool antialiasCurves(bool defaultValue=false) const
void setKineticScrollingSensitivity(int sensitivity)
bool ignoreHighFunctionKeys(bool defaultValue=false) const
void setDisableAVXOptimizations(bool value)
bool adaptivePlaybackRange(bool defaultValue=false) const
void setKineticScrollingEnabled(bool enabled)
std::pair< KoColorConversionTransformation::Intent, KoColorConversionTransformation::ConversionFlags > Options
KisCumulativeUndoData cumulativeUndoData() const
KoConfigAuthorPage * m_authorPage
PerformanceTab * m_performanceSettings
ColorSettingsTab * m_colorSettings
PopupPaletteTab * m_popupPaletteSettings
KPageWidgetItem * getPage(Page page_enum)
KisInputConfigurationPage * m_inputConfiguration
FullscreenSettingsTab * m_fullscreenSettings
ShortcutSettingsTab * m_shortcutSettings
TabletSettingsTab * m_tabletSettings
bool editPreferences(std::optional< PageDesc > page)
QList< KPageWidgetItem * > m_pages
DisplaySettingsTab * m_displaySettings
void slotButtonClicked(QAbstractButton *button)
KisDlgPreferences(QWidget *parent=0, const char *name=0)
void switchTab(PageDesc tab)
void showEvent(QShowEvent *event) override
void setEnableProgressReporting(bool value)
void setUseAnimationCacheRegionOfInterest(bool value)
bool useAnimationCacheFrameSizeLimit(bool defaultValue=false) const
void setAnimationCacheFrameSizeLimit(int value)
void setFrameRenderingClones(int value)
int animationCacheFrameSizeLimit(bool defaultValue=false) const
KisProofingConfigurationSP defaultProofingconfiguration(bool requestDefault=false)
void setMaxNumberOfThreads(int value)
bool useAnimationCacheRegionOfInterest(bool defaultValue=false) const
int frameRenderingClones(bool defaultValue=false) const
void setDetectFpsLimit(bool value)
void setFpsLimit(int value)
QString swapDir(bool requestDefault=false)
int maxNumberOfThreads(bool defaultValue=false) const
qreal memoryPoolLimitPercent(bool requestDefault=false) const
void setEnablePerfLog(bool value)
bool detectFpsLimit(bool defaultValue=false) const
bool enableProgressReporting(bool requestDefault=false) const
void setUseAnimationCacheFrameSizeLimit(bool value)
int fpsLimit(bool defaultValue=false) const
void setSelectionOutlineOpacity(qreal value)
int maxSwapSize(bool requestDefault=false) const
void setUseOnDiskAnimationCacheSwapping(bool value)
qreal animationCacheRegionOfInterestMargin(bool defaultValue=false) const
void setFrameRenderingTimeout(int value)
void setMaxSwapSize(int value)
qreal memoryHardLimitPercent(bool requestDefault=false) const
void setMemorySoftLimitPercent(qreal value)
void setSwapDir(const QString &swapDir)
void setSelectionOverlayMaskColor(const QColor &color)
qreal selectionOutlineOpacity(bool defaultValue=false) const
void setRenameDuplicatedLayers(bool value)
static int totalRAM()
int frameRenderingTimeout(bool defaultValue=false) const
bool enablePerfLog(bool requestDefault=false) const
void setMaxBrushSize(int value)
void setRenameMergedLayers(bool value)
void setDefaultProofingConfig(const KisProofingConfiguration &config)
QColor selectionOverlayMaskColor(bool defaultValue=false) const
qreal memorySoftLimitPercent(bool requestDefault=false) const
void setMemoryHardLimitPercent(qreal value)
bool useOnDiskAnimationCacheSwapping(bool defaultValue=false) const
void setMemoryPoolLimitPercent(qreal value)
void setAnimationCacheRegionOfInterestMargin(qreal value)
static QStringList supportedMimeTypes(Direction direction)
A Configuration Dialog Page to configure the canvas input.
A container for a set of QAction objects.
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
QList< QAction * > actions() const
virtual KisKActionCollection * actionCollection() const
Main window for Krita.
static QString descriptionForMimeType(const QString &mimeType)
Find the user-readable description for the given mimetype.
static KisOpenGLModeProber * instance()
QSurfaceFormat surfaceformatInUse() const
static OpenGLRenderer getCurrentOpenGLRenderer()
static OpenGLRenderers getSupportedOpenGLRenderers()
@ RendererSoftware
Definition kis_opengl.h:45
@ RendererDesktopGL
Definition kis_opengl.h:43
@ RendererOpenGLES
Definition kis_opengl.h:44
static QStringList getOpenGLWarnings()
static bool supportsLoD()
static OpenGLRenderer getUserPreferredOpenGLRendererConfig()
static OpenGLRenderer getQtPreferredOpenGLRenderer()
XcbGLProviderProtocol
Definition kis_opengl.h:63
static std::optional< XcbGLProviderProtocol > xcbGlProviderProtocol()
static void setUserPreferredOpenGLRendererConfig(OpenGLRenderer renderer)
static KisPart * instance()
Definition KisPart.cpp:131
KisMainWindow * currentMainwindow() const
Definition KisPart.cpp:458
static KisPlatformPluginInterfaceFactory * instance()
static KisPreferenceSetRegistry * instance()
virtual QIcon icon()=0
virtual QString header()=0
virtual void loadPreferences()=0
virtual QString name()=0
The KisProofingConfigModel class.
static const QString resourceLocationKey
std::optional< KisSurfaceColorimetry::SurfaceDescription > currentSurfaceDescription() const
ScreenInfo infoForScreen(QScreen *screen) const
void sigScreenChanged(QScreen *screen)
void addCollection(KisKActionCollection *, const QString &title=QString())
static Source getAvailableSource(const QString &key)
static KisSurfaceColorSpaceWrapper fromQtColorSpace(const QColorSpace &colorSpace)
static KoColorSpaceEngineRegistry * instance()
static KoColor fromXML(const QDomElement &elt, const QString &channelDepthId)
Definition KoColor.cpp:350
void setColor(const quint8 *data, const KoColorSpace *colorSpace=0)
Definition KoColor.cpp:186
void setOpacity(quint8 alpha)
Definition KoColor.cpp:333
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
Definition KoColor.cpp:213
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198
static const Colorimetry DCIP3
static const Colorimetry BT2020
static const Colorimetry BT709
static const Colorimetry DisplayP3
static const Colorimetry AdobeRGB
const T value(const QString &id) const
T get(const QString &id) const
QList< QString > keys() const
Definition KoID.h:30
QString id() const
Definition KoID.cpp:63
static bool tabletInputReceived()
static void getAllUserResourceFoldersLocationsForWindowsStore(QString &standardLocation, QString &privateLocation)
getAllAppDataLocationsForWindowsStore Use this to get both private and general appdata folders which ...
static QString getAppDataLocation()
static QString saveLocation(const QString &type, const QString &suffix=QString(), bool create=true)
void load(bool requestDefault)
PerformanceTab(QWidget *parent=0, const char *name=0)
QScopedPointer< KisFrameRateLimitModel > m_frameRateModel
void slotThreadsLimitChanged(int value)
QVector< SliderAndSpinBoxSync * > m_syncs
void slotFrameClonesLimitChanged(int value)
PopupPaletteTab(QWidget *parent=0, const char *name=0)
void slotSelectorTypeChanged(int index)
WdgShortcutSettings * m_page
QScopedPointer< KisActionsSnapshot > m_snapshot
ShortcutSettingsTab(QWidget *parent=0, const char *name=0)
WdgTabletSettings * m_page
TabletSettingsTab(QWidget *parent=0, const char *name=0)
bool eventFilter(QObject *, QEvent *event) override
UnscrollableComboBox(QObject *parent)
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
int getTotalRAM()
QString shortNameOfDisplay(int index)
Q_GUI_EXPORT int qt_defaultDpi()
QIcon addDisabledStatesToIcon(const QIcon &_icon, const QSize &size)
OutlineStyle
Definition kis_global.h:53
CursorStyle
Definition kis_global.h:62
#define koIcon(name)
Use these macros for icons without any issues.
Definition kis_icon.h:25
QString button(const QWheelEvent &ev)
bool canHideTouchAndStylusCursors()
QIcon loadIcon(const QString &name)
void setText(QSpinBox *spinBox, const QStringView textTemplate)
void install(QSpinBox *spinBox, std::function< QString(int)> messageFn)
void connectControl(KisCompositeOpListWidget *widget, QObject *source, const char *property)
void connectControlState(QSpinBox *spinBox, QObject *source, const char *readStateProperty, const char *writeProperty)
static const QStringList allowedColorHistorySortingValues({"none", "hsv"})
State validate(QString &line, int &) const override
BackupSuffixValidator(QObject *parent)
const QStringList invalidCharacters
void linkActivated(const QString &link)
virtual bool isSuitableForDisplay() const =0
virtual const KoColorProfile * addProfile(const QString &filename)=0
QString colorSpaceId(const QString &colorModelId, const QString &colorDepthId) const
static KoColorSpaceRegistry * instance()
KoID colorSpaceColorDepthId(const QString &_colorSpaceId) const
QString defaultProfileForColorSpace(const QString &colorSpaceId) const
KoID colorSpaceColorModelId(const QString &_colorSpaceId) const
QList< KoID > listKeys() const
State validate(QString &line, int &) const override
WritableLocationValidator(QObject *parent)