2
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
3
* Copyright (c) 2002,2003 Hamish Rodda <rodda@kde.org>
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.
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.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#include <KIconLoader>
23
bool RandR::has_1_2 = false;
24
bool RandR::has_1_3 = false;
25
Time RandR::timestamp = 0;
27
QString RandR::rotationName(int rotation, bool pastTense, bool capitalised)
32
return i18n("No Rotation");
34
return i18n("Left (90 degrees)");
36
return i18n("Upside-Down (180 degrees)");
38
return i18n("Right (270 degrees)");
40
return i18n("Mirror Horizontally");
42
return i18n("Mirror Vertically");
44
return i18n("Unknown Orientation");
49
return i18n("Not Rotated");
51
return i18n("Rotated 90 Degrees Counterclockwise");
53
return i18n("Rotated 180 Degrees Counterclockwise");
55
return i18n("Rotated 270 Degrees Counterclockwise");
57
if (rotation & RR_Reflect_X)
58
if (rotation & RR_Reflect_Y)
60
return i18n("Mirrored Horizontally And Vertically");
62
return i18n("mirrored horizontally and vertically");
65
return i18n("Mirrored Horizontally");
67
return i18n("mirrored horizontally");
68
else if (rotation & RR_Reflect_Y)
70
return i18n("Mirrored Vertically");
72
return i18n("mirrored vertically");
75
return i18n("Unknown Orientation");
77
return i18n("unknown orientation");
81
QPixmap RandR::rotationIcon(int rotation, int currentRotation)
83
// Adjust icons for current screen orientation
84
if (!(currentRotation & RR_Rotate_0) && rotation & (RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)) {
85
int currentAngle = currentRotation & (RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270);
86
switch (currentAngle) {
99
if (rotation > RR_Rotate_270) {
106
return SmallIcon("go-up");
108
return SmallIcon("go-previous");
110
return SmallIcon("go-down");
112
return SmallIcon("go-next");
116
return SmallIcon("process-stop");
120
bool RandR::confirm(const QRect &rect)
123
// FIXME remember to put the dialog on the right screen
125
KTimerDialog acceptDialog(15000, KTimerDialog::CountDown,
126
0, "mainKTimerDialog", true,
127
i18n("Confirm Display Setting Change"),
128
KTimerDialog::Ok|KTimerDialog::Cancel,
129
KTimerDialog::Cancel);
131
acceptDialog.setButtonGuiItem(KDialog::Ok, KGuiItem(i18n("&Accept Configuration"), "dialog-ok"));
132
acceptDialog.setButtonGuiItem(KDialog::Cancel, KGuiItem(i18n("&Revert to Previous Configuration"), "dialog-cancel"));
134
QLabel *label = new QLabel(i18n("Your screen configuration has been "
135
"changed to the requested settings. Please indicate whether you wish to keep "
136
"this configuration. In 15 seconds the display will revert to your previous "
137
"settings."), &acceptDialog);
138
label->setWordWrap( true );
139
acceptDialog.setMainWidget(label);
141
//FIXME: this should be changed to use the rect instead of centerOnScreen
142
//KDialog::centerOnScreen(&acceptDialog, m_screen);
144
return acceptDialog.exec();
147
SizeList RandR::sortSizes(const SizeList &sizes)
149
int *sizeSort = new int[sizes.count()];
150
int numSizes = sizes.count();
154
foreach(const QSize &size, sizes)
155
sizeSort[i++] = size.width() * size.height();
157
for (int j = 0; j < numSizes; j++)
159
int highest = -1, highestIndex = -1;
161
for (int i = 0; i < numSizes; i++)
163
if (sizeSort[i] && sizeSort[i] > highest)
165
highest = sizeSort[i];
169
sizeSort[highestIndex] = -1;
170
Q_ASSERT(highestIndex != -1);
172
sorted.append(sizes[highestIndex]);