~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to kcontrol/randr/randr.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-27 12:09:48 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20080527120948-dottsyd5rcwhzd36
Tags: 4:4.0.80-1ubuntu1
* Merge with Debian
 - remove 97_fix_target_link_libraries.diff
 - Add replaces/conflicts on -kde4 packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2002,2003 Hamish Rodda <rodda@kde.org>
3
 
 *
4
 
 *  This program is free software; you can redistribute it and/or modify
5
 
 *  it under the terms of the GNU General Public License as published by
6
 
 *  the Free Software Foundation; either version 2 of the License, or
7
 
 *  (at your option) any later version.
8
 
 *
9
 
 *  This program is distributed in the hope that it will be useful,
10
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *  GNU General Public License for more details.
13
 
 *
14
 
 *  You should have received a copy of the GNU General Public License
15
 
 *  along with this program; if not, write to the Free Software
16
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
 
 */
18
 
 
19
 
#ifndef __RANDR_H__
20
 
#define __RANDR_H__
21
 
 
22
 
#include <qobject.h>
23
 
#include <qstringlist.h>
24
 
#include <qptrlist.h>
25
 
 
26
 
#include <kcmodule.h>
27
 
#include <kconfig.h>
28
 
 
29
 
class KTimerDialog;
30
 
class RandRScreenPrivate;
31
 
 
32
 
class RandRScreen : public QObject
33
 
{
34
 
        Q_OBJECT
35
 
 
36
 
public:
37
 
        enum orientations {
38
 
                Rotate0                 = 0x1,
39
 
                Rotate90                = 0x2,
40
 
                Rotate180               = 0x4,
41
 
                Rotate270               = 0x8,
42
 
                RotateMask              = 15,
43
 
                RotationCount   = 4,
44
 
                ReflectX                = 0x10,
45
 
                ReflectY                = 0x20,
46
 
                ReflectMask             = 48,
47
 
                OrientationMask = 63,
48
 
                OrientationCount = 6
49
 
        };
50
 
 
51
 
        RandRScreen(int screenIndex);
52
 
        ~RandRScreen();
53
 
 
54
 
        void            loadSettings();
55
 
        void            setOriginal();
56
 
 
57
 
        bool            applyProposed();
58
 
 
59
 
        /**
60
 
         * @returns false if the user did not confirm in time, or cancelled, or the change failed
61
 
         */
62
 
        bool            applyProposedAndConfirm();
63
 
 
64
 
public slots:
65
 
        bool            confirm();
66
 
 
67
 
public:
68
 
        QString         changedMessage() const;
69
 
 
70
 
        bool            changedFromOriginal() const;
71
 
        void            proposeOriginal();
72
 
 
73
 
        bool            proposedChanged() const;
74
 
 
75
 
        static QString  rotationName(int rotation, bool pastTense = false, bool capitalised = true);
76
 
        QPixmap         rotationIcon(int rotation) const;
77
 
        QString                 currentRotationDescription() const;
78
 
 
79
 
        int                             rotationIndexToDegree(int rotation) const;
80
 
        int                             rotationDegreeToIndex(int degree) const;
81
 
 
82
 
        /**
83
 
         * Refresh rate functions.
84
 
         */
85
 
        QStringList refreshRates(int size) const;
86
 
 
87
 
        QString         refreshRateDirectDescription(int rate) const;
88
 
        QString         refreshRateIndirectDescription(int size, int index) const;
89
 
        QString         refreshRateDescription(int size, int index) const;
90
 
 
91
 
        int                     currentRefreshRate() const;
92
 
        QString         currentRefreshRateDescription() const;
93
 
 
94
 
        // Refresh rate hz <==> index conversion
95
 
        int                     refreshRateHzToIndex(int size, int hz) const;
96
 
        int                     refreshRateIndexToHz(int size, int index) const;
97
 
 
98
 
        /**
99
 
         * Screen size functions.
100
 
         */
101
 
        int                             numSizes() const;
102
 
        const QSize&    pixelSize(int index) const;
103
 
        const QSize&    mmSize(int index) const;
104
 
        int                             pixelCount(int index) const;
105
 
 
106
 
        /**
107
 
         * Retrieve the index of a screen size with a specified pixel size.
108
 
         *
109
 
         * @param pixelSize dimensions of the screen in pixels
110
 
         * @returns the index of the requested screen size
111
 
         */
112
 
        int                             sizeIndex(QSize pixelSize) const;
113
 
 
114
 
        int                     rotations() const;
115
 
 
116
 
        /**
117
 
         * Current setting functions.
118
 
         */
119
 
        int                     currentPixelWidth() const;
120
 
        int                     currentPixelHeight() const;
121
 
        int                     currentMMWidth() const;
122
 
        int                     currentMMHeight() const;
123
 
 
124
 
        int                     currentRotation() const;
125
 
        int                     currentSize() const;
126
 
 
127
 
        /**
128
 
         * Proposed setting functions.
129
 
         */
130
 
        int                     proposedSize() const;
131
 
        bool            proposeSize(int newSize);
132
 
 
133
 
        int                     proposedRotation() const;
134
 
        void            proposeRotation(int newRotation);
135
 
 
136
 
        int                     proposedRefreshRate() const;
137
 
        /**
138
 
         * Propose a refresh rate.
139
 
         * Please note that you must propose the target size first for this to work.
140
 
         *
141
 
         * @param index the index of the refresh rate (not a refresh rate in hz!)
142
 
         * @returns true if successful, false otherwise.
143
 
         */
144
 
        bool            proposeRefreshRate(int index);
145
 
 
146
 
        /**
147
 
         * Configuration functions.
148
 
         */
149
 
        void            load(KConfig& config);
150
 
        void            save(KConfig& config) const;
151
 
 
152
 
private:
153
 
        RandRScreenPrivate*     d;
154
 
 
155
 
        int                     m_screen;
156
 
 
157
 
        QValueList<QSize>       m_pixelSizes;
158
 
        QValueList<QSize>       m_mmSizes;
159
 
        int                                     m_rotations;
160
 
 
161
 
        int                     m_originalRotation;
162
 
        int                     m_originalSize;
163
 
        int                     m_originalRefreshRate;
164
 
 
165
 
        int                     m_currentRotation;
166
 
        int                     m_currentSize;
167
 
        int                     m_currentRefreshRate;
168
 
 
169
 
        int                     m_proposedRotation;
170
 
        int                     m_proposedSize;
171
 
        int                     m_proposedRefreshRate;
172
 
 
173
 
        KTimerDialog*   m_shownDialog;
174
 
 
175
 
private slots:
176
 
        void            desktopResized();
177
 
        void            shownDialogDestroyed();
178
 
};
179
 
 
180
 
typedef QPtrList<RandRScreen> ScreenList;
181
 
 
182
 
class RandRDisplay
183
 
{
184
 
public:
185
 
        RandRDisplay();
186
 
 
187
 
        bool                    isValid() const;
188
 
        const QString&  errorCode() const;
189
 
        const QString&  version() const;
190
 
 
191
 
        int             eventBase() const;
192
 
        int             screenChangeNotifyEvent() const;
193
 
        int             errorBase() const;
194
 
 
195
 
        int             screenIndexOfWidget(QWidget* widget);
196
 
 
197
 
        int                             numScreens() const;
198
 
        RandRScreen*    screen(int index);
199
 
 
200
 
        void                    setCurrentScreen(int index);
201
 
        int                             currentScreenIndex() const;
202
 
        RandRScreen*    currentScreen();
203
 
 
204
 
        void    refresh();
205
 
 
206
 
        /**
207
 
         * Loads saved settings.
208
 
         *
209
 
         * @param config the KConfig object to load from
210
 
         * @param loadScreens whether to call RandRScreen::load() for each screen
211
 
         * @retuns true if the settings should be applied on KDE startup.
212
 
         */
213
 
        bool    loadDisplay(KConfig& config, bool loadScreens = true);
214
 
        void    saveDisplay(KConfig& config, bool applyOnStartup, bool syncTrayApp);
215
 
 
216
 
        static bool             applyOnStartup(KConfig& config);
217
 
        static bool             syncTrayApp(KConfig& config);
218
 
 
219
 
        void    applyProposed(bool confirm = true);
220
 
 
221
 
private:
222
 
        int                             m_numScreens;
223
 
        int                             m_currentScreenIndex;
224
 
        RandRScreen*    m_currentScreen;
225
 
        ScreenList              m_screens;
226
 
 
227
 
        bool                    m_valid;
228
 
        QString                 m_errorCode;
229
 
        QString                 m_version;
230
 
 
231
 
        int                             m_eventBase;
232
 
        int                             m_errorBase;
233
 
};
234
 
 
235
 
#endif