~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kcontrol/colors/colorscm.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* KDE Display color scheme setup module
 
2
 * Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
 
3
 * Copyright (C) 2007 Jeremy Whiting <jpwhiting@kde.org>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; see the file COPYING.  If not, write to
 
17
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#ifndef __COLORSCM_H__
 
22
#define __COLORSCM_H__
 
23
 
 
24
#include <KCModule>
 
25
#include <KColorScheme>
 
26
#include <KPushButton>
 
27
 
 
28
#include "ui_colorsettings.h"
 
29
 
 
30
class QStackedWidget;
 
31
class QListWidgetItem;
 
32
 
 
33
/**
 
34
 * The Desktop/Colors tab in kcontrol.
 
35
 */
 
36
class KColorCm : public KCModule, public Ui::colorSettings
 
37
{
 
38
    Q_OBJECT
 
39
 
 
40
public:
 
41
    KColorCm(QWidget *parent, const QVariantList &);
 
42
    ~KColorCm();
 
43
 
 
44
public Q_SLOTS:
 
45
 
 
46
    /// load the settings from the config
 
47
    virtual void load();
 
48
 
 
49
    /// save the current settings
 
50
    virtual void save();
 
51
 
 
52
    /// sets the configuration to sensible default values.
 
53
    virtual void defaults();
 
54
 
 
55
private slots:
 
56
 
 
57
    /** set the colortable color buttons up according to the current colorset */
 
58
    void updateColorTable();
 
59
 
 
60
    /** slot called when color on a KColorButton changes */
 
61
    void colorChanged( const QColor &newColor );
 
62
 
 
63
    /** slot called when any varies button is clicked */
 
64
    void variesClicked();
 
65
 
 
66
    /** slot called when the schemeList selection changes */
 
67
    void loadScheme(QListWidgetItem *currentItem, QListWidgetItem *previousItem);
 
68
 
 
69
    /** reselect the previously selected scheme in schemeList without loading it */
 
70
    void selectPreviousSchemeAgain();
 
71
 
 
72
    /** slot called when the remove button is clicked*/
 
73
    void on_schemeRemoveButton_clicked();
 
74
 
 
75
    /** slot called when the save button is clicked */
 
76
    void on_schemeSaveButton_clicked();
 
77
 
 
78
    /** slot called when the import button is clicked */
 
79
    void on_schemeImportButton_clicked();
 
80
 
 
81
    /** slot called when the get new schemes button is clicked */
 
82
    void on_schemeKnsButton_clicked();
 
83
    
 
84
    /** slot called when the upload scheme button is clicked */
 
85
    void on_schemeKnsUploadButton_clicked();
 
86
 
 
87
    /** null slot to emit changed(true) */
 
88
    void emitChanged();
 
89
 
 
90
    // options slots
 
91
    void on_contrastSlider_valueChanged(int value);
 
92
    void on_shadeSortedColumn_stateChanged(int state);
 
93
    void on_inactiveSelectionEffect_stateChanged(int state);
 
94
    void on_useInactiveEffects_stateChanged(int state);
 
95
 
 
96
    // effects page slots
 
97
    void on_inactiveIntensityBox_currentIndexChanged(int index);
 
98
    void on_inactiveIntensitySlider_valueChanged(int value);
 
99
    void on_inactiveColorBox_currentIndexChanged(int index);
 
100
    void on_inactiveColorSlider_valueChanged(int value);
 
101
    void on_inactiveColorButton_changed(const QColor & color);
 
102
    void on_inactiveContrastBox_currentIndexChanged(int index);
 
103
    void on_inactiveContrastSlider_valueChanged(int value);
 
104
 
 
105
    void on_disabledIntensityBox_currentIndexChanged(int index);
 
106
    void on_disabledIntensitySlider_valueChanged(int value);
 
107
    void on_disabledColorBox_currentIndexChanged(int index);
 
108
    void on_disabledColorSlider_valueChanged(int value);
 
109
    void on_disabledColorButton_changed(const QColor & color);
 
110
    void on_disabledContrastBox_currentIndexChanged(int index);
 
111
    void on_disabledContrastSlider_valueChanged(int value);
 
112
 
 
113
private:
 
114
    class WindecoColors {
 
115
        public:
 
116
            enum Role {
 
117
                ActiveForeground = 0,
 
118
                ActiveBackground = 1,
 
119
                InactiveForeground = 2,
 
120
                InactiveBackground = 3,
 
121
                ActiveBlend = 4,
 
122
                InactiveBlend = 5
 
123
            };
 
124
 
 
125
            WindecoColors() {}
 
126
            WindecoColors(const KSharedConfigPtr&);
 
127
            virtual ~WindecoColors() {}
 
128
 
 
129
            void load(const KSharedConfigPtr&);
 
130
            QColor color(Role) const;
 
131
        private:
 
132
            QColor m_colors[6];
 
133
    };
 
134
 
 
135
    /** create a preview of a color scheme */
 
136
    static QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
 
137
 
 
138
    /** load options from global */
 
139
    void loadOptions();
 
140
 
 
141
    /** load from global */
 
142
    void loadInternal(bool loadOptions);
 
143
 
 
144
    /** load a scheme from a config file at a given path */
 
145
    void loadScheme(KSharedConfigPtr config);
 
146
 
 
147
    /** populate the schemeList with color schemes found on the system */
 
148
    void populateSchemeList();
 
149
 
 
150
    /** update m_colorSchemes contents from the values in m_config */
 
151
    void updateColorSchemes();
 
152
 
 
153
    /** update the effects page from the values in m_config */
 
154
    void updateEffectsPage();
 
155
 
 
156
    /** update all preview panes from the values in m_config */
 
157
    void updatePreviews();
 
158
 
 
159
    /** setup the colortable with its buttons and labels */
 
160
    void setupColorTable();
 
161
 
 
162
    /** helper to create color entries */
 
163
    void createColorEntry(const QString &text,
 
164
                          const QString &key,
 
165
                          QList<KColorButton *> &list,
 
166
                          int index);
 
167
 
 
168
    /** copy color entries from color schemes into m_config */
 
169
    void updateFromColorSchemes();
 
170
 
 
171
    /** copy effects page entries from controls into m_config */
 
172
    void updateFromEffectsPage();
 
173
 
 
174
    /** copy options from controls into m_config */
 
175
    void updateFromOptions();
 
176
 
 
177
    void changeColor(int row, const QColor &newColor);
 
178
 
 
179
    /** get the groupKey for the given colorSet */
 
180
    static QString colorSetGroupKey(int colorSet);
 
181
 
 
182
    /** save the current scheme with the given name
 
183
     @param name name to save the scheme as
 
184
     */
 
185
    void saveScheme(const QString &name);
 
186
 
 
187
    void setCommonForeground(KColorScheme::ForegroundRole role,
 
188
                             int stackIndex,
 
189
                             int buttonIndex);
 
190
    void setCommonDecoration(KColorScheme::DecorationRole role,
 
191
                             int stackIndex,
 
192
                             int buttonIndex);
 
193
 
 
194
    QList<KColorButton *> m_backgroundButtons;
 
195
    QList<KColorButton *> m_foregroundButtons;
 
196
    QList<KColorButton *> m_decorationButtons;
 
197
    QList<KColorButton *> m_commonColorButtons;
 
198
    QList<QStackedWidget *> m_stackedWidgets;
 
199
    QStringList m_colorKeys;
 
200
 
 
201
    QList<KColorScheme> m_colorSchemes;
 
202
    WindecoColors m_wmColors;
 
203
    QString m_currentColorScheme;
 
204
 
 
205
    KSharedConfigPtr m_config;
 
206
 
 
207
    bool m_disableUpdates;
 
208
    bool m_loadedSchemeHasUnsavedChanges;
 
209
    // don't (re)load the scheme, only select it in schemeList
 
210
    bool m_dontLoadSelectedScheme;
 
211
 
 
212
    // the item previously selected in schemeList
 
213
    QListWidgetItem *m_previousSchemeItem;
 
214
};
 
215
 
 
216
#endif