File indexing completed on 2025-01-26 04:08:07

0001 /*
0002  *  preferencesdlg.h - part of KImageShop^WKrita
0003  *
0004  *  SPDX-FileCopyrightText: 1999 Michael Koch <koch@kde.org>
0005  *  SPDX-FileCopyrightText: 2003-2011 Boudewijn Rempt <boud@valdyas.org>
0006  *
0007  *  SPDX-License-Identifier: GPL-2.0-or-later
0008  */
0009 
0010 #ifndef _KIS_DLG_PREFERENCES_H_
0011 #define _KIS_DLG_PREFERENCES_H_
0012 
0013 #include <QWidget>
0014 #include <QButtonGroup>
0015 #include <QMap>
0016 #include <QString>
0017 
0018 #include <kpagedialog.h>
0019 #include <kis_config.h>
0020 
0021 #include "kis_global.h"
0022 #include <KisSqueezedComboBox.h>
0023 
0024 #include "ui_wdggeneralsettings.h"
0025 #include "ui_wdgdisplaysettings.h"
0026 #include "ui_wdgcolorsettings.h"
0027 #include "ui_wdgtabletsettings.h"
0028 #include "ui_wdgperformancesettings.h"
0029 #include "ui_wdgfullscreensettings.h"
0030 #include "ui_WdgPopupPaletteSettings.h"
0031 #include "KisShortcutsDialog.h"
0032 #include "KisCumulativeUndoData.h"
0033 
0034 class KoID;
0035 class KisInputConfigurationPage;
0036 class KoConfigAuthorPage;
0037 
0038 /**
0039  *  "General"-tab for preferences dialog
0040  */
0041 
0042 class WdgGeneralSettings : public QWidget, public Ui::WdgGeneralSettings
0043 {
0044     Q_OBJECT
0045 
0046 public:
0047     WdgGeneralSettings(QWidget *parent, const char *name) : QWidget(parent) {
0048         setObjectName(name);
0049         setupUi(this);
0050         formLayout_13->takeRow(chkShowRootLayer);
0051         chkShowRootLayer->setVisible(false);
0052     }
0053 };
0054 
0055 class GeneralTab : public WdgGeneralSettings
0056 {
0057     Q_OBJECT
0058 
0059 public:
0060 
0061     GeneralTab(QWidget *parent = 0, const char *name = 0);
0062 
0063     CursorStyle cursorStyle();
0064     OutlineStyle outlineStyle();
0065     CursorStyle eraserCursorStyle();
0066     OutlineStyle eraserOutlineStyle();
0067 
0068     KisConfig::SessionOnStartup sessionOnStartup() const;
0069     bool saveSessionOnQuit() const;
0070 
0071     bool showRootLayer();
0072     int autoSaveInterval();
0073     void setDefault();
0074     int undoStackSize();
0075     bool showOutlineWhilePainting();
0076     bool showEraserOutlineWhilePainting();
0077 
0078     int mdiMode();
0079     bool showCanvasMessages();
0080     bool compressKra();
0081     bool trimKra();
0082     bool trimFramesImport();
0083     bool useZip64();
0084     bool toolOptionsInDocker();
0085     int zoomSteps();
0086     bool kineticScrollingEnabled();
0087     int kineticScrollingGesture();
0088     int kineticScrollingSensitivity();
0089     bool kineticScrollingHiddenScrollbars();
0090     int zoomMarginSize();
0091     bool switchSelectionCtrlAlt();
0092     bool convertToImageColorspaceOnImport();
0093     bool autopinLayersToTimeline();
0094     bool adaptivePlaybackRange();
0095     bool renameMergedLayers();
0096     bool renamePastedLayers();
0097 
0098     int forcedFontDpi();
0099 
0100 private Q_SLOTS:
0101     void getBackgroundImage();
0102     void clearBackgroundImage();
0103     void checkResourcePath();
0104     void enableSubWindowOptions(int);
0105     void showAdvancedCumulativeUndoSettings();
0106 
0107 public:
0108     QButtonGroup m_pasteFormatGroup;
0109     KisCumulativeUndoData m_cumulativeUndoData;
0110 };
0111 
0112 
0113 
0114 /**
0115  *  "Shortcuts" tab for preferences dialog
0116  */
0117 
0118 class WdgShortcutSettings : public KisShortcutsDialog
0119 {
0120     Q_OBJECT
0121 
0122 public:
0123     WdgShortcutSettings(QWidget *parent)
0124         : KisShortcutsDialog(KisShortcutsEditor::AllActions,
0125                              KisShortcutsEditor::LetterShortcutsAllowed,
0126                              parent)
0127     { }
0128 };
0129 
0130 class KisActionsSnapshot;
0131 
0132 class ShortcutSettingsTab : public QWidget
0133 {
0134     Q_OBJECT
0135 
0136 public:
0137 
0138     ShortcutSettingsTab(QWidget *parent = 0, const char *name = 0);
0139     ~ShortcutSettingsTab() override;
0140 
0141 public:
0142     void setDefault();
0143     WdgShortcutSettings  *m_page;
0144     QScopedPointer<KisActionsSnapshot> m_snapshot;
0145 
0146 public Q_SLOTS:
0147     void saveChanges();
0148     void cancelChanges();
0149 };
0150 
0151 
0152 
0153 /**
0154  *  "Color" tab for preferences dialog
0155  */
0156 
0157 class WdgColorSettings : public QWidget, public Ui::WdgColorSettings
0158 {
0159     Q_OBJECT
0160 
0161 public:
0162     WdgColorSettings(QWidget *parent) : QWidget(parent) {
0163         setupUi(this);
0164     }
0165 };
0166 
0167 class ColorSettingsTab : public QWidget
0168 {
0169     Q_OBJECT
0170 
0171 public:
0172 
0173     ColorSettingsTab(QWidget *parent = 0, const char  *name = 0);
0174 
0175 private Q_SLOTS:
0176 
0177     void refillMonitorProfiles(const KoID & s);
0178     void installProfile();
0179     void toggleAllowMonitorProfileSelection(bool useSystemProfile);
0180     void toggleUseDefaultColorSpace(bool useDefColorSpace);
0181 
0182 public:
0183     void setDefault();
0184     WdgColorSettings  *m_page;
0185     QButtonGroup m_pasteBehaviourGroup;
0186     QList<QLabel*> m_monitorProfileLabels;
0187     QList<KisSqueezedComboBox*> m_monitorProfileWidgets;
0188 };
0189 
0190 //=======================
0191 
0192 class WdgTabletSettings : public QWidget, public Ui::WdgTabletSettings {
0193 
0194     Q_OBJECT
0195 
0196 public:
0197     WdgTabletSettings(QWidget *parent) : QWidget(parent) {
0198         setupUi(this);
0199     }
0200 
0201 };
0202 
0203 class TabletSettingsTab : public QWidget {
0204     Q_OBJECT
0205 public:
0206     TabletSettingsTab(QWidget *parent = 0, const char  *name = 0);
0207 
0208 private Q_SLOTS:
0209     void slotTabletTest();
0210     void slotResolutionSettings();
0211 
0212 public:
0213     void setDefault();
0214     WdgTabletSettings  *m_page;
0215 
0216 
0217 };
0218 
0219 //=======================
0220 
0221 /**
0222   * "Performance"-tab for preferences dialog
0223  */
0224 
0225 class SliderAndSpinBoxSync;
0226 
0227 class WdgPerformanceSettings : public QWidget, public Ui::WdgPerformanceSettings
0228 {
0229     Q_OBJECT
0230 
0231 public:
0232     WdgPerformanceSettings(QWidget *parent, const char *name) : QWidget(parent) {
0233         setObjectName(name); setupUi(this);
0234     }
0235 };
0236 
0237 class PerformanceTab : public WdgPerformanceSettings
0238 {
0239     Q_OBJECT
0240 
0241 public:
0242     PerformanceTab(QWidget *parent = 0, const char *name = 0);
0243 
0244     ~PerformanceTab() override;
0245 
0246     void load(bool requestDefault);
0247     void save();
0248 
0249 private Q_SLOTS:
0250     void slotThreadsLimitChanged(int value);
0251     void slotFrameClonesLimitChanged(int value);
0252 
0253 private:
0254     int realTilesRAM();
0255 
0256 private:
0257     QVector<SliderAndSpinBoxSync*> m_syncs;
0258     int m_lastUsedThreadsLimit;
0259     int m_lastUsedClonesLimit;
0260 };
0261 
0262 //=======================
0263 
0264 class WdgDisplaySettings : public QWidget, public Ui::WdgDisplaySettings
0265 {
0266     Q_OBJECT
0267 
0268 public:
0269     WdgDisplaySettings(QWidget *parent, const char *name) : QWidget(parent) {
0270         setObjectName(name); setupUi(this);
0271     }
0272 };
0273 
0274 /**
0275  *  Display settings tab for preferences dialog
0276  */
0277 
0278 
0279 class DisplaySettingsTab : public WdgDisplaySettings
0280 {
0281     Q_OBJECT
0282 
0283 public:
0284     DisplaySettingsTab(QWidget *parent = 0, const char *name = 0);
0285 
0286 public:
0287     void setDefault();
0288 protected Q_SLOTS:
0289     void slotUseOpenGLToggled(bool isChecked);
0290     void slotPreferredSurfaceFormatChanged(int index);
0291 
0292 public:
0293 };
0294 
0295 //=======================
0296 
0297 /**
0298  *  Full screen settings tab for preferences dialog
0299  */
0300 
0301 class WdgFullscreenSettingsBase : public QWidget, public Ui::WdgFullscreenSettings
0302 {
0303     Q_OBJECT
0304 
0305 public:
0306     WdgFullscreenSettingsBase(QWidget *parent) : QWidget(parent) {
0307         setupUi(this);
0308     }
0309 };
0310 
0311 class FullscreenSettingsTab : public WdgFullscreenSettingsBase
0312 {
0313     Q_OBJECT
0314 public:
0315     FullscreenSettingsTab(QWidget *parent);
0316 public:
0317     void setDefault();
0318 };
0319 
0320 //=======================
0321 
0322 /**
0323   * "Pop-up Palette"-tab for preferences dialog
0324  */
0325 
0326 class WdgPopupPaletteSettingsBase : public QWidget, public Ui::WdgPopupPaletteSettings
0327 {
0328     Q_OBJECT
0329 
0330 public:
0331     WdgPopupPaletteSettingsBase(QWidget *parent, const char *name) : QWidget(parent) {
0332         setObjectName(name); setupUi(this);
0333     }
0334 };
0335 
0336 class PopupPaletteTab : public WdgPopupPaletteSettingsBase
0337 {
0338     Q_OBJECT
0339 
0340 public:
0341     PopupPaletteTab(QWidget *parent = 0, const char *name = 0);
0342 
0343     void load();
0344     void save();
0345     void setDefault();
0346 };
0347 
0348 //=======================
0349 
0350 
0351 /**
0352  *  Preferences dialog of KImageShop^WKrayon^WKrita
0353  */
0354 class KisDlgPreferences : public KPageDialog
0355 {
0356     Q_OBJECT
0357 
0358 public:
0359 
0360     KisDlgPreferences(QWidget *parent = 0, const char *name = 0);
0361     ~KisDlgPreferences() override;
0362 
0363     bool editPreferences();
0364 
0365     void showEvent(QShowEvent *event) override;
0366 
0367 private:
0368 
0369     GeneralTab *m_general;
0370     ShortcutSettingsTab  *m_shortcutSettings;
0371     ColorSettingsTab *m_colorSettings;
0372     PerformanceTab *m_performanceSettings;
0373     DisplaySettingsTab  *m_displaySettings;
0374     TabletSettingsTab *m_tabletSettings;
0375     FullscreenSettingsTab *m_fullscreenSettings;
0376     KisInputConfigurationPage *m_inputConfiguration;
0377     PopupPaletteTab *m_popupPaletteSettings;
0378     KoConfigAuthorPage *m_authorPage;
0379 
0380     QList<KPageWidgetItem*> m_pages;
0381 
0382 private Q_SLOTS:
0383 
0384     void slotButtonClicked(QAbstractButton *button);
0385     void slotDefault();
0386 
0387 private:
0388 
0389     bool m_cancelClicked {false};
0390 };
0391 
0392 #endif