2
* Copyright (c) 2002,2003 Hamish Rodda <rodda@kde.org>
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.
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.
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.
23
#include <qstringlist.h>
30
class RandRScreenPrivate;
32
class RandRScreen : public QObject
51
RandRScreen(int screenIndex);
60
* @returns false if the user did not confirm in time, or cancelled, or the change failed
62
bool applyProposedAndConfirm();
68
QString changedMessage() const;
70
bool changedFromOriginal() const;
71
void proposeOriginal();
73
bool proposedChanged() const;
75
static QString rotationName(int rotation, bool pastTense = false, bool capitalised = true);
76
QPixmap rotationIcon(int rotation) const;
77
QString currentRotationDescription() const;
79
int rotationIndexToDegree(int rotation) const;
80
int rotationDegreeToIndex(int degree) const;
83
* Refresh rate functions.
85
QStringList refreshRates(int size) const;
87
QString refreshRateDirectDescription(int rate) const;
88
QString refreshRateIndirectDescription(int size, int index) const;
89
QString refreshRateDescription(int size, int index) const;
91
int currentRefreshRate() const;
92
QString currentRefreshRateDescription() const;
94
// Refresh rate hz <==> index conversion
95
int refreshRateHzToIndex(int size, int hz) const;
96
int refreshRateIndexToHz(int size, int index) const;
99
* Screen size functions.
101
int numSizes() const;
102
const QSize& pixelSize(int index) const;
103
const QSize& mmSize(int index) const;
104
int pixelCount(int index) const;
107
* Retrieve the index of a screen size with a specified pixel size.
109
* @param pixelSize dimensions of the screen in pixels
110
* @returns the index of the requested screen size
112
int sizeIndex(QSize pixelSize) const;
114
int rotations() const;
117
* Current setting functions.
119
int currentPixelWidth() const;
120
int currentPixelHeight() const;
121
int currentMMWidth() const;
122
int currentMMHeight() const;
124
int currentRotation() const;
125
int currentSize() const;
128
* Proposed setting functions.
130
int proposedSize() const;
131
bool proposeSize(int newSize);
133
int proposedRotation() const;
134
void proposeRotation(int newRotation);
136
int proposedRefreshRate() const;
138
* Propose a refresh rate.
139
* Please note that you must propose the target size first for this to work.
141
* @param index the index of the refresh rate (not a refresh rate in hz!)
142
* @returns true if successful, false otherwise.
144
bool proposeRefreshRate(int index);
147
* Configuration functions.
149
void load(KConfig& config);
150
void save(KConfig& config) const;
153
RandRScreenPrivate* d;
157
QValueList<QSize> m_pixelSizes;
158
QValueList<QSize> m_mmSizes;
161
int m_originalRotation;
163
int m_originalRefreshRate;
165
int m_currentRotation;
167
int m_currentRefreshRate;
169
int m_proposedRotation;
171
int m_proposedRefreshRate;
173
KTimerDialog* m_shownDialog;
176
void desktopResized();
177
void shownDialogDestroyed();
180
typedef QPtrList<RandRScreen> ScreenList;
187
bool isValid() const;
188
const QString& errorCode() const;
189
const QString& version() const;
191
int eventBase() const;
192
int screenChangeNotifyEvent() const;
193
int errorBase() const;
195
int screenIndexOfWidget(QWidget* widget);
197
int numScreens() const;
198
RandRScreen* screen(int index);
200
void setCurrentScreen(int index);
201
int currentScreenIndex() const;
202
RandRScreen* currentScreen();
207
* Loads saved settings.
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.
213
bool loadDisplay(KConfig& config, bool loadScreens = true);
214
void saveDisplay(KConfig& config, bool applyOnStartup, bool syncTrayApp);
216
static bool applyOnStartup(KConfig& config);
217
static bool syncTrayApp(KConfig& config);
219
void applyProposed(bool confirm = true);
223
int m_currentScreenIndex;
224
RandRScreen* m_currentScreen;
225
ScreenList m_screens;