ColorSchemeEditor.h 2.9 KB
Newer Older
1
/*
2
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301  USA.
*/

#ifndef COLORSCHEMEEDITOR_H
#define COLORSCHEMEEDITOR_H

// Qt
24
#include <QWidget>
25

26
// KDE
Laurent Montel's avatar
Laurent Montel committed
27
#include <QDialog>
28

29
#include "konsolecolorscheme_export.h"
30

31 32
class QTableWidgetItem;

Kurt Hindenburg's avatar
Kurt Hindenburg committed
33
namespace Ui {
Kurt Hindenburg's avatar
Kurt Hindenburg committed
34
class ColorSchemeEditor;
35
}
36

Kurt Hindenburg's avatar
Kurt Hindenburg committed
37
namespace Konsole {
38 39 40 41
class ColorScheme;

/**
 * A dialog for editing color schemes.
42
 *
Jekyll Wu's avatar
Jekyll Wu committed
43
 * After creation, the dialog can be initialized with the settings
44 45 46 47
 * of a color scheme using the setup() method.
 *
 * The dialog creates a copy of the supplied color scheme to which
 * any changes made are applied.  The modified color scheme
Jekyll Wu's avatar
Jekyll Wu committed
48
 * can be retrieved using the colorScheme() method.
49 50
 *
 * When changes are made the colorsChanged() signal is emitted.
51
 */
52
class KONSOLECOLORSCHEME_EXPORT ColorSchemeEditor : public QDialog
53
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
54
    Q_OBJECT
55 56

public:
Kurt Hindenburg's avatar
Kurt Hindenburg committed
57
    /** Constructs a new color scheme editor with the specified parent. */
58
    explicit ColorSchemeEditor(QWidget *parent = nullptr);
59
    ~ColorSchemeEditor() override;
60

Kurt Hindenburg's avatar
Kurt Hindenburg committed
61
    /** Initializes the dialog with the properties of the specified color scheme. */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
62
    void setup(const ColorScheme *scheme, bool isNewScheme);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
63
    /** Returns the modified color scheme. */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
64
    ColorScheme &colorScheme() const;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
65
    bool isNewScheme() const;
66

67
Q_SIGNALS:
Kurt Hindenburg's avatar
Kurt Hindenburg committed
68
    /** Emitted when the colors in the color scheme change. */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
69
    void colorsChanged(ColorScheme *scheme);
70
    /** Used to send back colorscheme changes into the profile edited */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
71
    void colorSchemeSaveRequested(const ColorScheme &scheme, bool isNewScheme);
72

73
public Q_SLOTS:
74
    /** Sets the text displayed in the description edit field. */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
75
    void setDescription(const QString &description);
76

77
private Q_SLOTS:
Kurt Hindenburg's avatar
Kurt Hindenburg committed
78
    void setTransparencyPercentLabel(int percent);
79
    void setBlur(bool blur);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
80
    void setRandomizedBackgroundColor(bool randomized);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
81 82
    void editColorItem(QTableWidgetItem *item);
    void wallpaperPathChanged(const QString &path);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
83
    void selectWallpaper();
84 85
    /** Triggered by apply/ok buttons */
    void saveColorScheme();
86 87

private:
88 89
    Q_DISABLE_COPY(ColorSchemeEditor)

Kurt Hindenburg's avatar
Kurt Hindenburg committed
90
    void setupColorTable(const ColorScheme *table);
91

Kurt Hindenburg's avatar
Kurt Hindenburg committed
92
    bool _isNewScheme;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
93 94
    Ui::ColorSchemeEditor *_ui;
    ColorScheme *_colors;
95
};
Stephan Binner's avatar
Stephan Binner committed
96
}
97

98
#endif // COLORSCHEMEEDITOR_H