Improved code for tderandr rotation string to allow translation in tdebase. This relates to issue #96.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit ce064fcb01)
r14.0.x
Michele Calgaro 4 years ago
parent cafb5a55ba
commit fe712166fb
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -610,17 +610,16 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::loadDisplayConfiguration(TQString p
int KRandrSimpleAPI::getHardwareRotationFlags(SingleScreenData* screendata) {
int rotationFlags = 0;
TQString rotationDesired = *screendata->rotations.at(screendata->current_rotation_index);
if (rotationDesired == ROTATION_0_DEGREES_STRING) {
if (screendata->current_rotation_index == ROTATION_0_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate0;
}
else if (rotationDesired == ROTATION_90_DEGREES_STRING) {
else if (screendata->current_rotation_index == ROTATION_90_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate90;
}
else if (rotationDesired == ROTATION_180_DEGREES_STRING) {
else if (screendata->current_rotation_index == ROTATION_180_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate180;
}
else if (rotationDesired == ROTATION_270_DEGREES_STRING) {
else if (screendata->current_rotation_index == ROTATION_270_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate270;
}
if (screendata->has_x_flip) {
@ -667,10 +666,10 @@ bool KRandrSimpleAPI::applyDisplayConfiguration(TQPtrList<SingleScreenData> scre
command.append(TQString(" --pos %1x%2").arg(screendata->absolute_x_position).arg(screendata->absolute_y_position));
command.append(TQString(" --refresh %1").arg(atoi((*screendata->refresh_rates.at(screendata->current_refresh_rate_index)).ascii())));
command.append(TQString(" --gamma %1:%2:%3").arg(screendata->gamma_red).arg(screendata->gamma_green).arg(screendata->gamma_blue));
if (screendata->current_rotation_index == 0) command.append(" --rotate ").append("normal");
if (screendata->current_rotation_index == 1) command.append(" --rotate ").append("left");
if (screendata->current_rotation_index == 2) command.append(" --rotate ").append("inverted");
if (screendata->current_rotation_index == 3) command.append(" --rotate ").append("right");
if (screendata->current_rotation_index == ROTATION_0_DEGREES_INDEX) command.append(" --rotate ").append("normal");
if (screendata->current_rotation_index == ROTATION_90_DEGREES_INDEX) command.append(" --rotate ").append("left");
if (screendata->current_rotation_index == ROTATION_180_DEGREES_INDEX) command.append(" --rotate ").append("inverted");
if (screendata->current_rotation_index == ROTATION_270_DEGREES_INDEX) command.append(" --rotate ").append("right");
if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 0)) command.append(" --reflect ").append("normal");
if ((screendata->has_x_flip == 1) && (screendata->has_y_flip == 0)) command.append(" --reflect ").append("x");
if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 1)) command.append(" --reflect ").append("y");
@ -1308,30 +1307,30 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
// RandRScreen::ReflectX
// RandRScreen::ReflectY
screendata->rotations.append(i18n(ROTATION_0_DEGREES_STRING));
screendata->rotations.append(i18n(ROTATION_90_DEGREES_STRING));
screendata->rotations.append(i18n(ROTATION_180_DEGREES_STRING));
screendata->rotations.append(i18n(ROTATION_270_DEGREES_STRING));
screendata->rotations.append(i18n("0 degrees"));
screendata->rotations.append(i18n("90 degrees"));
screendata->rotations.append(i18n("180 degrees"));
screendata->rotations.append(i18n("270 degrees"));
screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0);
if (screendata->supports_transformations) {
screendata->current_orientation_mask = cur_screen->proposedRotation();
switch (screendata->current_orientation_mask & RandRScreen::RotateMask) {
case RandRScreen::Rotate0:
screendata->current_rotation_index = 0;
screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
break;
case RandRScreen::Rotate90:
screendata->current_rotation_index = 1;
screendata->current_rotation_index = ROTATION_90_DEGREES_INDEX;
break;
case RandRScreen::Rotate180:
screendata->current_rotation_index = 2;
screendata->current_rotation_index = ROTATION_180_DEGREES_INDEX;
break;
case RandRScreen::Rotate270:
screendata->current_rotation_index = 3;
screendata->current_rotation_index = ROTATION_270_DEGREES_INDEX;
break;
default:
// Shouldn't hit this one
Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask);
screendata->current_rotation_index = 0;
screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
break;
}
screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX);
@ -1340,7 +1339,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
else {
screendata->has_x_flip = false;
screendata->has_y_flip = false;
screendata->current_rotation_index = 0;
screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
}
// Determine if this display is primary and/or extended
@ -1413,7 +1412,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
screendata->gamma_green = 2.2;
screendata->gamma_blue = 2.2;
screendata->current_rotation_index = 0;
screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
screendata->current_orientation_mask = 0;
screendata->has_x_flip = false;
screendata->has_y_flip = false;
@ -1455,7 +1454,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
screendata->gamma_green = 2.2;
screendata->gamma_blue = 2.2;
screendata->current_rotation_index = 0;
screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
screendata->current_orientation_mask = 0;
screendata->has_x_flip = false;
screendata->has_y_flip = false;

@ -35,11 +35,6 @@
#include <ksimpleconfig.h>
#include <tdelibs_export.h>
#define ROTATION_0_DEGREES_STRING "0 degrees"
#define ROTATION_90_DEGREES_STRING "90 degrees"
#define ROTATION_180_DEGREES_STRING "180 degrees"
#define ROTATION_270_DEGREES_STRING "270 degrees"
/**
* Simple API covering most of the uses of libtderandr.
*

@ -63,7 +63,7 @@ SingleScreenData::SingleScreenData()
gamma_green = 0.0;
gamma_blue = 0.0;
current_rotation_index = 0;
current_rotation_index = ROTATION_0_DEGREES_INDEX;
current_orientation_mask = 0;
has_x_flip = false;
has_y_flip = false;

@ -26,6 +26,11 @@
#include <tdecmodule.h>
#include <tdeconfig.h>
#define ROTATION_0_DEGREES_INDEX 0
#define ROTATION_90_DEGREES_INDEX 1
#define ROTATION_180_DEGREES_INDEX 2
#define ROTATION_270_DEGREES_INDEX 3
class KTimerDialog;
class RandRScreenPrivate;

Loading…
Cancel
Save