File indexing completed on 2024-04-28 05:50:38

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef COLORSCHEMEEDITOR_H
0008 #define COLORSCHEMEEDITOR_H
0009 
0010 // Qt
0011 #include <QWidget>
0012 
0013 // KDE
0014 #include <QDialog>
0015 
0016 class QTableWidgetItem;
0017 
0018 namespace Ui
0019 {
0020 class ColorSchemeEditor;
0021 }
0022 
0023 namespace Konsole
0024 {
0025 class ColorScheme;
0026 
0027 /**
0028  * A dialog for editing color schemes.
0029  *
0030  * After creation, the dialog can be initialized with the settings
0031  * of a color scheme using the setup() method.
0032  *
0033  * The dialog creates a copy of the supplied color scheme to which
0034  * any changes made are applied.  The modified color scheme
0035  * can be retrieved using the colorScheme() method.
0036  *
0037  * When changes are made the colorsChanged() signal is emitted.
0038  */
0039 class ColorSchemeEditor : public QDialog
0040 {
0041     Q_OBJECT
0042 
0043 public:
0044     /** Constructs a new color scheme editor with the specified parent. */
0045     explicit ColorSchemeEditor(bool supportsTransparentWindows, QWidget *parent = nullptr);
0046     ~ColorSchemeEditor() override;
0047 
0048     /** Initializes the dialog with the properties of the specified color scheme. */
0049     void setup(const std::shared_ptr<const ColorScheme> &scheme, bool isNewScheme);
0050     /** Returns the modified color scheme. */
0051     ColorScheme &colorScheme() const;
0052     bool isNewScheme() const;
0053 
0054 Q_SIGNALS:
0055     /** Emitted when the colors in the color scheme change. */
0056     void colorsChanged(std::shared_ptr<ColorScheme> scheme);
0057     /** Used to send back colorscheme changes into the profile edited */
0058     void colorSchemeSaveRequested(const ColorScheme &scheme, bool isNewScheme);
0059 
0060 public Q_SLOTS:
0061     /** Sets the text displayed in the description edit field. */
0062     void setDescription(const QString &description);
0063 
0064 private Q_SLOTS:
0065     void setTransparencyPercentLabel(int percent);
0066     void setBlur(bool blur);
0067     void setRandomizedBackgroundColor(bool randomized);
0068     void editColorItem(QTableWidgetItem *item);
0069     void setWallpaperOpacity(int percent);
0070     void wallpaperPathChanged(const QString &path);
0071     void scalingTypeChanged(int styleIndex);
0072     void flipTypeChanged(int flipTypeIndex);
0073     void horizontalAnchorChanged(int pos);
0074     void verticalAnchorChanged(int pos);
0075     void selectWallpaper();
0076     /** Triggered by apply/ok buttons */
0077     void saveColorScheme();
0078 
0079 private:
0080     Q_DISABLE_COPY(ColorSchemeEditor)
0081 
0082     void setupColorTable(const std::shared_ptr<ColorScheme> &table);
0083     void enableWallpaperSettings(bool enable);
0084 
0085     bool _isNewScheme;
0086     Ui::ColorSchemeEditor *_ui;
0087     std::shared_ptr<ColorScheme> _colors;
0088 };
0089 }
0090 
0091 #endif // COLORSCHEMEEDITOR_H